public SiteMapUrl(string urlLocation, changefreq changeFreq, decimal priority) { _loc = urlLocation; _lastmod = DateTime.MinValue; _changefreq = changeFreq; _changeFrequencySpecified = true; _priority = priority; }
public url(string locIn, DateTime lastmodIn, changefreq freqIn, Decimal priorityIn) { loc = locIn; lastmod = lastmodIn; changefreq = freqIn; changefreqSpecified = true; priority = priorityIn; prioritySpecified = true; }
public void Load(ISiteMapOptionKeys settingKeys) { StoreSettingCollection settings = Token.Instance.Store.Settings; _CompressedSiteMapFileName = settings.GetValueByKey(settingKeys.CompressedSiteMapFileName); _SiteMapDataPath = settings.GetValueByKey(settingKeys.SiteMapDataPath); _SiteMapFileName = settings.GetValueByKey(settingKeys.SiteMapFileName); _IncludeProducts = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeProducts), true); _IncludeCategories = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeCategories), true); _IncludeWebpages = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeWebpages), true); _OverwriteCompressedFile = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteCompressedFile), true); _OverwriteSiteMapFile = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteSiteMapFile), true); _DefaultChangeFrequency = (changefreq)AlwaysConvert.ToEnum(typeof(changefreq), settings.GetValueByKey(settingKeys.DefaultChangeFrequency), changefreq.weekly); _DefaultUrlPriority = AlwaysConvert.ToDecimal(settings.GetValueByKey(settingKeys.DefaultUrlPriority), 0.5M); IsDirty = false; }
public urlset GetGoogleSiteMap() { urlset root = new urlset(); root.url = new urlCollection(); //Default first... url basePage = new url(dasBlogSettings.GetBaseUrl(), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(basePage); //Archives next... url archivePage = new url(dasBlogSettings.RelativeToRoot("archives"), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(archivePage); //All Pages EntryCollection entryCache = dataService.GetEntries(false); foreach (Entry e in entryCache) { if (e.IsPublic) { //Start with a RARE change freq...newer posts are more likely to change more often. // The older a post, the less likely it is to change... changefreq freq = changefreq.daily; //new stuff? if (e.CreatedLocalTime < DateTime.Now.AddMonths(-9)) { freq = changefreq.yearly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-30)) { freq = changefreq.monthly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-7)) { freq = changefreq.weekly; } if (e.CreatedLocalTime > DateTime.Now.AddDays(-2)) { freq = changefreq.hourly; } //Add comments pages, since comments have indexable content... // Only add comments if we aren't showing comments on permalink pages already if (dasBlogSettings.SiteConfiguration.ShowCommentsWhenViewingEntry == false) { url commentPage = new url(dasBlogSettings.GetCommentViewUrl(e.CompressedTitle), e.CreatedLocalTime, freq, 0.7M); root.url.Add(commentPage); } //then add permalinks url permaPage = new url(dasBlogSettings.RelativeToRoot(dasBlogSettings.GetPermaTitle(e.CompressedTitle)), e.CreatedLocalTime, freq, 0.9M); root.url.Add(permaPage); } } //All Categories CategoryCacheEntryCollection catCache = dataService.GetCategories(); foreach (CategoryCacheEntry cce in catCache) { if (cce.IsPublic) { url catPage = new url(dasBlogSettings.GetCategoryViewUrl(cce.Name), DateTime.Now, changefreq.weekly, 0.6M); root.url.Add(catPage); } } return(root); }
public void ProcessRequest(HttpContext context) { try { //Cache the sitemap for 12 hours... string CacheKey = "GoogleSiteMap"; DataCache cache = CacheFactory.GetCache(); urlset root = cache[CacheKey] as urlset; if (root == null) //we'll have to build it... { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); SiteConfig siteConfig = SiteConfig.GetSiteConfig(); root = new urlset(); root.url = new urlCollection(); //Default first... url basePage = new url(SiteUtilities.GetBaseUrl(siteConfig), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(basePage); url defaultPage = new url(SiteUtilities.GetStartPageUrl(siteConfig), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(defaultPage); //Archives next... url archivePage = new url(SiteUtilities.RelativeToRoot(siteConfig, "archives.aspx"), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(archivePage); //All Pages EntryCollection entryCache = dataService.GetEntries(false); foreach (Entry e in entryCache) { if (e.IsPublic) { //Start with a RARE change freq...newer posts are more likely to change more often. // The older a post, the less likely it is to change... changefreq freq = changefreq.daily; //new stuff? if (e.CreatedLocalTime < DateTime.Now.AddMonths(-9)) { freq = changefreq.yearly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-30)) { freq = changefreq.monthly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-7)) { freq = changefreq.weekly; } if (e.CreatedLocalTime > DateTime.Now.AddDays(-2)) { freq = changefreq.hourly; } //Add comments pages, since comments have indexable content... // Only add comments if we aren't showing comments on permalink pages already if (siteConfig.ShowCommentsWhenViewingEntry == false) { url commentPage = new url(SiteUtilities.GetCommentViewUrl(siteConfig, e.EntryId), e.CreatedLocalTime, freq, 0.7M); root.url.Add(commentPage); } //then add permalinks url permaPage = new url(SiteUtilities.GetPermaLinkUrl(siteConfig, (ITitledEntry)e), e.CreatedLocalTime, freq, 0.9M); root.url.Add(permaPage); } } //All Categories CategoryCacheEntryCollection catCache = dataService.GetCategories(); foreach (CategoryCacheEntry cce in catCache) { if (cce.IsPublic) { url catPage = new url(SiteUtilities.GetCategoryViewUrl(siteConfig, cce.Name), DateTime.Now, changefreq.weekly, 0.6M); root.url.Add(catPage); } } cache.Insert(CacheKey, root, DateTime.Now.AddHours(12)); } XmlSerializer x = new XmlSerializer(typeof(urlset)); x.Serialize(context.Response.OutputStream, root); context.Response.ContentType = "text/xml"; } catch (Exception exc) { ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, exc); } }