Ejemplo n.º 1
0
        private static string GetSharedItemUrl(Item item, SiteContext site, Item parentItem, string urlFormat)
        {
            var itemUrl    = HtmlEncode(GetItemUrl(item, site));
            var parentUrl  = HtmlEncode(GetItemUrl(parentItem, site));
            var siteConfig = new SitemapManagerConfiguration(site.Name);

            parentUrl = parentUrl.EndsWith("/") ? parentUrl : parentUrl + "/";
            if (!string.IsNullOrWhiteSpace(urlFormat))
            {
                return(HtmlEncode(parentUrl + FormatItemUrl(item, urlFormat).TrimStart('/')));
            }
            else if (siteConfig.CleanupBucketPath)
            {
                var pos          = itemUrl.LastIndexOf("/", StringComparison.Ordinal) + 1;
                var itemNamePath = itemUrl.Substring(pos, itemUrl.Length - pos);
                return(HtmlEncode(parentUrl + itemNamePath));
            }
            else
            {
                var contentParentItem = SitemapManager.GetContentLocation(item);
                if (contentParentItem == null)
                {
                    return(null);
                }
                var contentParentItemUrl = HtmlEncode(GetItemUrl(contentParentItem, site));
                if (string.IsNullOrWhiteSpace(contentParentItemUrl))
                {
                    return(string.Empty);
                }
                itemUrl = itemUrl.Replace(contentParentItemUrl, string.Empty);
                return(string.IsNullOrWhiteSpace(itemUrl) ? string.Empty : HtmlEncode(parentUrl + itemUrl.Trim('/')));
            }
        }
Ejemplo n.º 2
0
        public static string GetSharedItemUrl(Item item, SiteContext site)
        {
            var parentItem = SitemapManager.GetSharedLocationParent(item);
            var itemUrl    = HtmlEncode(GetItemUrl(item, site));
            var parentUrl  = HtmlEncode(GetItemUrl(parentItem, site));

            parentUrl = parentUrl.EndsWith("/") ? parentUrl : parentUrl + "/";
            var pos          = itemUrl.LastIndexOf("/") + 1;
            var itemNamePath = itemUrl.Substring(pos, itemUrl.Length - pos);

            return(HtmlEncode(parentUrl + itemNamePath));
        }
Ejemplo n.º 3
0
        public void RefreshSitemap(object sender, EventArgs args)
        {
            var sites = SitemapManagerConfiguration.GetSiteNames();

            foreach (var site in sites)
            {
                var config         = new SitemapManagerConfiguration(site);
                var sitemapManager = new SitemapManager(config);
                sitemapManager.SubmitSitemapToSearchenginesByHttp();

                if (!config.GenerateRobotsFile)
                {
                    continue;
                }
                sitemapManager.RegisterSitemapToRobotsFile();
            }
        }
        public override void Process(HttpRequestArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (Context.Site == null || string.IsNullOrEmpty(Context.Site.RootPath.Trim())) return;
            if (Context.Page.FilePath.Length > 0) return;
            var sitemapHandler = string.IsNullOrWhiteSpace(Context.Site.Properties["sitemapHandler"])
                ? "sitemap.xml"
                : Context.Site.Properties["sitemapHandler"];
            if (!args.Url.FilePath.Contains(sitemapHandler)) return;

            // Important to return qualified XML (text/xml) for sitemaps
            args.Context.Response.ClearHeaders();
            args.Context.Response.ClearContent();
            args.Context.Response.ContentType = "text/xml";

            // Checking the HTML cache first
            var site = Context.Site;
            #if !DEBUG
            var cacheKey = "UltimateSitemapXML_" + site.Name;
            var cache = CacheManager.GetHtmlCache(site).GetHtml(cacheKey);
            if (!string.IsNullOrWhiteSpace(cache))
            {
                args.Context.Response.Write(cache);
                args.Context.Response.End();
                return;
            }
            #endif

            var content = string.Empty;
            try
            {
                var config = new SitemapManagerConfiguration(site.Name);
                var sitemapManager = new SitemapManager(config);

                content = sitemapManager.BuildSiteMapForHandler();
                args.Context.Response.Write(content);
            }
            finally
            {
            #if !DEBUG
                CacheManager.GetHtmlCache(site).SetHtml(cacheKey, content);
            #endif
                args.Context.Response.Flush();
                args.Context.Response.End();
            }
        }
Ejemplo n.º 5
0
 public void RefreshSitemap(object sender, EventArgs args)
 {
     try
     {
         var sites = SitemapManagerConfiguration.GetSiteNames();
         foreach (var site in sites)
         {
             var config         = new SitemapManagerConfiguration(site);
             var sitemapManager = new SitemapManager(config);
             sitemapManager.SubmitSitemapToSearchenginesByHttp();
             //removed because now the robots is generated when it is invoked the url with robots.txt at the end
             //if (!config.GenerateRobotsFile) continue;
             //sitemapManager.RegisterSitemapToRobotsFile();
         }
     }
     catch (Exception e)
     {
         Log.Error("Error Sitemap", e, this);
     }
 }