Exemple #1
0
        private float GetPriority(PageDefinition.SiteMapPriorityEnum siteMapPriority)
        {
            if (siteMapPriority == PageDefinition.SiteMapPriorityEnum.Default)
            {
                siteMapPriority = (PageDefinition.SiteMapPriorityEnum)Manager.CurrentSite.SiteMapPriority;
                if ((int)siteMapPriority == 0)
                {
                    siteMapPriority = PageDefinition.SiteMapPriorityEnum.Medium;
                }
            }
            int   value = (int)siteMapPriority;
            float prio  = ((float)value) / 100;

            prio = (float)Math.Max(0, Math.Min(1.0, prio));
            return(prio);
        }
        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);
        }
Exemple #3
0
        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)
                                                                   );
        }
Exemple #4
0
 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);
 }