Esempio n. 1
0
 /// <summary>
 /// At the end of a request, we'll check if there is a flag in the request indicating to rebuild the routes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <remarks>
 /// In some cases many articulate roots might be published at one time but we only want to rebuild the routes once so we'll do it once
 /// at the end of the request.
 /// </remarks>
 private static void UmbracoApplication_PostRequestHandlerExecute(object sender, EventArgs e)
 {
     if (ApplicationContext.Current == null)
     {
         return;
     }
     if (ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem("articulate-refresh-routes") == null)
     {
         return;
     }
     //the token was found so that means one or more articulate root nodes were changed in this request, rebuild the routes.
     ArticulateRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache, UmbracoContext.Current.UrlProvider);
 }
Esempio n. 2
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //TODO: Listen to events when we need to re-map the routes when data changes!

            //map routes
            ArticulateRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache);

            ContentService.Created               += ContentService_Created;
            ContentService.Saving                += ContentService_Saving;
            ContentService.Saved                 += ContentService_Saved;
            ServerVariablesParser.Parsing        += ServerVariablesParser_Parsing;
            ContentTypeService.SavingContentType += ContentTypeService_SavingContentType;
        }
Esempio n. 3
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //list to the init event of the application base, this allows us to bind to the actual HttpApplication events
            UmbracoApplicationBase.ApplicationInit += UmbracoApplicationBase_ApplicationInit;

            //map routes
            ArticulateRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache);

            //umbraco event subscriptions
            ContentService.Created               += ContentService_Created;
            ContentService.Saving                += ContentService_Saving;
            ContentService.Saved                 += ContentService_Saved;
            ServerVariablesParser.Parsing        += ServerVariablesParser_Parsing;
            ContentTypeService.SavingContentType += ContentTypeService_SavingContentType;
            PageCacheRefresher.CacheUpdated      += PageCacheRefresher_CacheUpdated;
        }
        /// <summary>
        /// Constructor used to create a new handler for multi-tenency with domains and ids
        /// </summary>
        /// <param name="umbracoUrlProvider"></param>
        /// <param name="itemsForRoute"></param>
        public ArticulateVirtualNodeByIdRouteHandler(UrlProvider umbracoUrlProvider, IEnumerable <IPublishedContent> itemsForRoute)
        {
            foreach (var publishedContent in itemsForRoute)
            {
                var allUrls = ArticulateRoutes.GetContentUrls(umbracoUrlProvider, publishedContent);

                foreach (var url in allUrls)
                {
                    //if there is a double slash, it will have a domain
                    if (url.Contains("//"))
                    {
                        var uri = new Uri(url, UriKind.Absolute);
                        _hostsAndIds.Add(new Tuple <string, int>(uri.Host, publishedContent.Id));
                    }
                    else
                    {
                        _hostsAndIds.Add(new Tuple <string, int>(string.Empty, publishedContent.Id));
                    }
                }
                LogHelper.Debug <ArticulateVirtualNodeByIdRouteHandler>(() => $"Hosts/IDs map for node {publishedContent.Id}. Values: {DebugHostIdsCollection()}");
            }
        }
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //list to the init event of the application base, this allows us to bind to the actual HttpApplication events
            UmbracoApplicationBase.ApplicationInit += UmbracoApplicationBase_ApplicationInit;

            //map routes
            RouteTable.Routes.MapRoute(
                "ArticulateFeeds",
                "ArticulateFeeds/{action}/{id}",
                new { controller = "Feed", action = "RenderGitHubFeed", id = 0 }
                );
            ArticulateRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache, UmbracoContext.Current.UrlProvider);

            //umbraco event subscriptions
            ContentService.Created               += ContentService_Created;
            ContentService.Saving                += ContentService_Saving;
            ContentService.Saved                 += ContentService_Saved;
            ServerVariablesParser.Parsing        += ServerVariablesParser_Parsing;
            ContentTypeService.SavingContentType += ContentTypeService_SavingContentType;
            PageCacheRefresher.CacheUpdated      += PageCacheRefresher_CacheUpdated;
            DomainCacheRefresher.CacheUpdated    += DomainCacheRefresher_CacheUpdated;
        }
        public TagsOrCategoryPathRouteConstraint(UrlProvider umbracoUrlProvider, IEnumerable <IPublishedContent> itemsForRoute)
        {
            if (itemsForRoute == null)
            {
                throw new ArgumentNullException(nameof(itemsForRoute));
            }

            foreach (var node in itemsForRoute)
            {
                var allUrls = ArticulateRoutes.GetContentUrls(umbracoUrlProvider, node);

                foreach (var url in allUrls)
                {
                    //if there is a double slash, it will have a domain
                    if (url.Contains("//"))
                    {
                        var uri = new Uri(url, UriKind.Absolute);
                        _urlNames.Add(new UrlNames
                        {
                            Host            = uri.Host,
                            CategoryUrlName = node.GetPropertyValue <string>("categoriesUrlName"),
                            TagsUrlName     = node.GetPropertyValue <string>("tagsUrlName")
                        });
                    }
                    else
                    {
                        _urlNames.Add(new UrlNames
                        {
                            Host            = string.Empty,
                            CategoryUrlName = node.GetPropertyValue <string>("categoriesUrlName"),
                            TagsUrlName     = node.GetPropertyValue <string>("tagsUrlName")
                        });
                    }
                }
            }
        }