public static IEnumerable <SiteRoute> DiscoverRoutesForSite(Site site) { var allRoutes = new List <SiteRoute>(); var pageRepository = new CmsPageRepository(); var historicalPageLocations = pageRepository.GetHistoricalPageLocations(site); foreach (var location in historicalPageLocations) { allRoutes.Add(new RedirectPageRoute { InternalRedirectPageId = location.PageId, Authority = site.UriAuthority, Priority = location.Priority, SiteId = location.SiteId, VirtualPath = new Uri(location.VirtualPath, UriKind.Relative) }); } var associatedSitemap = SitemapBuilder.BuildSitemap(site, ContentEnvironment.Live, SitemapBuilderFilters.All); if (associatedSitemap.HomePage != null) { var homePageRoute = new ContentPageRoute { Authority = site.UriAuthority, Priority = 0, SiteId = site.ContentId, PageId = site.HomepageId, VirtualPath = MakeRelativeUri(site, string.Empty), RequireSsl = associatedSitemap.HomePage.RequireSsl }; var homepageContentRoutes = DiscoverContentRoutes(associatedSitemap.HomePage, new[] { homePageRoute }); allRoutes.Add(homePageRoute); allRoutes.AddRange(homepageContentRoutes); } foreach (var childNode in associatedSitemap.ChildNodes) { allRoutes.AddRange(DiscoverPageRoutesRecursive(childNode, site)); } return(allRoutes); }
private void AppendToRouteHistory(CmsPage page) { var site = new SiteRepository().GetById(page.SiteId); var sitemap = SitemapBuilder.BuildSitemap(site, ContentEnvironment.Live, SitemapBuilderFilters.All); var previousLivePosition = sitemap.GetSitemapNode(page); if (previousLivePosition != null) { var historicalRoute = new HistoricalRoute { Priority = (int)RoutePriority.Former, VirtualPath = previousLivePosition.VirtualPath.ToString(), PageId = page.ContentId, SiteId = page.SiteId, }; Orm.Save(historicalRoute); } }