Exemplo n.º 1
0
        public SiteResourceViewModel Build(Item renderingContextItem, ID resourceLocationId, ID deviceId, string siteScriptFieldName, string pageScriptFieldName)
        {
            var model = new SiteResourceViewModel();

            if (!string.IsNullOrWhiteSpace(siteScriptFieldName))
            {
                var home = SiteContext.GetHomeItem();
                if (home != null)
                {
                    model.SiteResources = new HtmlString(home[siteScriptFieldName] ?? "");
                }
            }

            if (renderingContextItem != null)
            {
                if (!string.IsNullOrWhiteSpace(pageScriptFieldName))
                {
                    model.PageResources = new HtmlString(renderingContextItem[pageScriptFieldName] ?? "");
                }

                var theme = _themeRetriever.GetThemeFromContextItem(renderingContextItem);
                model.ThemeResources = new HtmlString(theme == null
                                                          ? ""
                                                          : _themeRetriever.GetThemeResources(theme, deviceId,
                                                                                              resourceLocationId)
                                                      );
            }

            return(model);
        }
Exemplo n.º 2
0
 public void Process(GenerateSitemapArgs args)
 {
     if (args.RootItem == null)
     {
         args.RootItem = SiteContext.GetHomeItem();
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            var requestUrl = context.Request.RawUrl;

            if (string.IsNullOrWhiteSpace(requestUrl) || !requestUrl.ToLower().EndsWith("robots.txt"))
            {
                return;
            }

            var robotsTxtContent = @"User-agent: *" + Environment.NewLine
                                   + "Disallow: /sitecore" + Environment.NewLine
                                   + "Sitemap: /sitemap.xml";

            if (Sitecore.Context.Site != null && Sitecore.Context.Database != null)
            {
                var homeNode = SiteContext.GetHomeItem();
                if (homeNode != null)
                {
                    robotsTxtContent = homeNode.Fields.GetValue(RobotsTxtGenerationFieldIDs.RobotsTxt)
                                       .Or(robotsTxtContent);
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(robotsTxtContent);
            context.Response.End();
        }
Exemplo n.º 4
0
 public static Item GetHomeItem(this RenderingContext context)
 {
     return(SiteContext.GetHomeItem());
 }