private string GetChangeFrequencyText(PageDefinition.ChangeFrequencyEnum changeFrequency) { if (changeFrequency == PageDefinition.ChangeFrequencyEnum.Default) { changeFrequency = (PageDefinition.ChangeFrequencyEnum)Manager.CurrentSite.DefaultChangeFrequency; } switch (changeFrequency) { case PageDefinition.ChangeFrequencyEnum.Always: return("always"); case PageDefinition.ChangeFrequencyEnum.Daily: return("daily"); case PageDefinition.ChangeFrequencyEnum.Hourly: return("hourly"); case PageDefinition.ChangeFrequencyEnum.Monthly: return("monthly"); case PageDefinition.ChangeFrequencyEnum.Never: return("never"); default: case PageDefinition.ChangeFrequencyEnum.Weekly: return("weekly"); case PageDefinition.ChangeFrequencyEnum.Yearly: return("yearly"); } }
private async Task AddNewsSiteMapPageAsync(PageDefinition page, string url, DateTime?dateUpdated, PageDefinition.SiteMapPriorityEnum priority, PageDefinition.ChangeFrequencyEnum changeFrequency, object obj) { BlogEntry blogEntry = (BlogEntry)obj; await AddUrlAsync(GetTempFile(), page, blogEntry, url, dateUpdated); }
private async Task AddUrlAsync(string file, PageDefinition page, string canonicalUrl, DateTime?lastMod, PageDefinition.SiteMapPriorityEnum siteMapPriority, PageDefinition.ChangeFrequencyEnum changeFrequency) { if (!PagesFound.Contains(page.PageGuid)) // keep track of pages so we don't add it as a designed page in case it was dynamic { PagesFound.Add(page.PageGuid); } canonicalUrl = Manager.CurrentSite.MakeUrl(canonicalUrl, PagePageSecurity: page.PageSecurity); if (!ValidForSiteMap(page)) { return; } string cf = GetChangeFrequencyText(changeFrequency); float prio = GetPriority(siteMapPriority); var w3clastMod = lastMod != null?string.Format(" <lastmod>{0}</lastmod>\r\n", XmlConvert.ToString((DateTime)lastMod, XmlDateTimeSerializationMode.Utc)) : ""; #if MVC6 canonicalUrl = WebUtility.HtmlEncode(canonicalUrl); #else canonicalUrl = AntiXssEncoder.XmlEncode(canonicalUrl); #endif await FileSystem.FileSystemProvider.AppendAllTextAsync(file, string.Format( " <url>\r\n" + " <loc>{0}</loc>\r\n" + "{1}" + " <changefreq>{2}</changefreq>\r\n" + " <priority>{3}</priority>\r\n" + " </url>\r\n", canonicalUrl, w3clastMod, cf, prio) ); }
private async Task AddSiteMapPageAsync(PageDefinition page, string url, DateTime?dateUpdated, PageDefinition.SiteMapPriorityEnum priority, PageDefinition.ChangeFrequencyEnum changeFrequency, object obj) { await AddUrlAsync(GetTempFile(), page, url, dateUpdated, priority, changeFrequency); }