Section configuring host settings such as root, and start node ids and multiple sites.
Inheritance: N2.Configuration.ContentConfigurationSectionBase
Example #1
0
 public ContentSectionTable(HostSection web, EngineSection engine, DatabaseSection database, EditSection management)
 {
     Web        = web;
     Engine     = engine;
     Database   = database;
     Management = management;
 }
 public CacheManager(IWebContext context, IPersister persister, HostSection config)
     : this(context, persister)
 {
     enabled = config.OutputCache.Enabled;
     varyByParam = config.OutputCache.VaryByParam;
     cacheProfile = config.OutputCache.CacheProfile;
     duration = config.OutputCache.Duration;
 }
 public CachingUrlParserDecorator(IUrlParser inner, IPersister persister, IWebContext webContext, CacheWrapper cache, HostSection config)
 {
     this.inner = inner;
     this.persister = persister;
     this.webContext = webContext;
     this.cache = cache;
     SlidingExpiration = config.OutputCache.SlidingExpiration ?? TimeSpan.FromMinutes(15);
 }
        public override void SetUp()
        {
            base.SetUp();

            CreateDefaultStructure();
            webContext = new FakeWebContextWrapper("http://www.n2cms.com/");
            hostSection = new HostSection {Web = new WebElement {ObserveEmptyExtension = true}};
            parser = new UrlParser(persister, webContext, new Host(webContext, startItem.ID, startItem.ID), hostSection);
        }
Example #5
0
        public CacheManager(IWebContext context, IPersister persister, HostSection config)
            : this(context, persister)
        {
            enabled = config.OutputCache.Enabled;
            varyByParam = config.OutputCache.VaryByParam;
            varyByHeader = config.OutputCache.VaryByHeader;
            cacheProfile = config.OutputCache.CacheProfile;
            duration = config.OutputCache.Duration;
			invalidationMode = config.OutputCache.InvalidateOnChangesTo;
        }
Example #6
0
        public UrlParser(IPersister persister, IWebContext webContext, IHost host, HostSection config)
        {
            if (host == null) throw new ArgumentNullException("host");

            this.persister = persister;
            this.webContext = webContext;
            this.host = host;

            ignoreExistingFiles = config.Web.IgnoreExistingFiles;
        }
Example #7
0
        public override void SetUp()
        {
            base.SetUp();

            config = new HostSection();
            config.RootID = 123;
            config.StartPageID = 234;
            ctx = new ThreadContext();
            host = new Host(ctx, config);

            root = CreateOneItem<Items.PageItem>(123, "start", null);
            start = CreateOneItem<Items.PageItem>(234, "start", null);
        }
Example #8
0
		public UrlParser(IPersister persister, IWebContext webContext, IHost host, N2.Plugin.ConnectionMonitor connections, HostSection config)
		{
			if (host == null) throw new ArgumentNullException("host");

			IsOnline = connections.IsConnected ?? true;
			connections.Online += (s, a) => IsOnline = true;
			connections.Offline += (s, a) => IsOnline = false;

			this.persister = persister;
			this.webContext = webContext;
			this.host = host;

			ignoreExistingFiles = config.Web.IgnoreExistingFiles;
		}
Example #9
0
 public static IList<Site> ExtractSites(HostSection config)
 {
     List<Site> sites = new List<Site>();
     foreach (SiteElement configElement in config.Sites)
     {
         Site s = new Site(configElement.RootID ?? config.RootID, configElement.ID, configElement.Name);
         s.Wildcards = configElement.Wildcards || config.Wildcards;
         foreach (FolderElement folder in configElement.UploadFolders)
             s.UploadFolders.Add(folder.Path);
         foreach (string key in configElement.Settings.AllKeys)
             s.Settings[key] = configElement.Settings[key].Value;
         sites.Add(s);
     }
     return sites;
 }
 public RequestPathProvider(IWebContext webContext, IUrlParser parser, IErrorNotifier errorHandler, HostSection config)
 {
     this.webContext = webContext;
     this.parser = parser;
     this.errorHandler = errorHandler;
     observeAllExtensions = config.Web.ObserveAllExtensions;
     rewriteEmptyExtension = config.Web.ObserveEmptyExtension;
     StringCollection additionalExtensions = config.Web.ObservedExtensions;
     if (additionalExtensions != null && additionalExtensions.Count > 0)
     {
         observedExtensions = new string[additionalExtensions.Count + 1];
         additionalExtensions.CopyTo(observedExtensions, 1);
     }
     observedExtensions[0] = config.Web.Extension;
     nonRewritablePaths = config.Web.Urls.NonRewritable.GetPaths(webContext);
 }
 /// <summary>Creates a new instance of the RequestLifeCycleHandler class.</summary>
 /// <param name="webContext">The web context wrapper.</param>
 /// <param name="broker"></param>
 /// <param name="installer"></param>
 /// <param name="dispatcher"></param>
 /// <param name="adapters"></param>
 /// <param name="errors"></param>
 /// <param name="editConfig"></param>
 /// <param name="hostConfig"></param>
 /// <param name="managementUrls"></param>
 public RequestLifeCycleHandler(IWebContext webContext, EventBroker broker, InstallationManager installer,
     RequestPathProvider dispatcher, IContentAdapterProvider adapters, IErrorHandler errors,
     IEditUrlManager editUrlManager, EditSection editConfig, HostSection hostConfig)
 {
     checkInstallation = editConfig.Installer.CheckInstallationStatus;
     welcomeUrl = editConfig.Installer.WelcomeUrl;
     managementUrl = editConfig.ManagementInterfaceUrl;
     rewriteMethod = hostConfig.Web.Rewrite;
     this.webContext = webContext;
     this.broker = broker;
     this.adapters = adapters;
     this.errors = errors;
     this.editUrlManager = editUrlManager;
     this.installer = installer;
     this.dispatcher = dispatcher;
 }
        public MultipleSitesInitializer(IPersister persister, IHost host, ISitesProvider sitesProvider, HostSection config, IDefinitionManager ignored)
        {
            Debug.WriteLine("MultipleSitesInitializer");

            if (config.MultipleSites && config.DynamicSites)
            {
                host.AddSites(sitesProvider.GetSites());
                persister.ItemSaved += delegate(object sender, ItemEventArgs e)
                {
                    if (e.AffectedItem is ISitesSource)
                    {
                        IList<Site> sites = Host.ExtractSites(config);
                        sites = Host.Union(sites, sitesProvider.GetSites());

                        host.ReplaceSites(host.DefaultSite, sites);
                    }
                };
            }
        }
Example #13
0
        public static IList<Site> ExtractSites(HostSection config)
        {
            List<Site> sites = new List<Site>();
            foreach (SiteElement configElement in config.Sites)
            {
                Site s = new Site(configElement.RootID ?? config.RootID, configElement.ID, configElement.Name);
                s.Wildcards = configElement.Wildcards || config.Wildcards;

                foreach (FolderElement folder in configElement.UploadFolders.AllElements)
                {
                    if (string.IsNullOrEmpty(folder.Path))
                        throw new ConfigurationErrorsException("Upload path configured for site '" + configElement.Name + "' cannot be empty.");
                    s.UploadFolders.Add(FixPath(folder.Path));
                }
                foreach (string key in configElement.Settings.AllKeys)
                    s.Settings[key] = configElement.Settings[key].Value;
                sites.Add(s);
            }
            return sites;
        }
Example #14
0
        public MultipleSitesParser(IPersister persister, IWebContext webContext, IHost host, ISitesProvider sitesProvider, HostSection config)
            : base(persister, webContext, host, config)
        {
            if (config == null) throw new ArgumentNullException("config");

            if (config.DynamicSites)
            {
                host.AddSites(sitesProvider.GetSites());
                persister.ItemSaved += delegate(object sender, ItemEventArgs e)
                {
                    if(e.AffectedItem is ISitesSource)
                    {
                        IList<Site> sites = Host.ExtractSites(config);
                        sites = Host.Union(sites, sitesProvider.GetSites());

                        host.ReplaceSites(host.DefaultSite, sites);
                    }
                };
            }
        }
        protected virtual void InitializeEnvironment(IServiceContainer container, HostSection hostConfig)
        {
            if (hostConfig != null)
            {
                Url.DefaultExtension = hostConfig.Web.Extension;
                PathData.PageQueryKey = hostConfig.Web.PageQueryKey;
                PathData.ItemQueryKey = hostConfig.Web.ItemQueryKey;
                PathData.PartQueryKey = hostConfig.Web.PartQueryKey;

                if (!hostConfig.Web.IsWeb)
                    container.AddComponentInstance("n2.webContext.notWeb", typeof(IWebContext), new ThreadContext());

                if (hostConfig.Web.Urls.EnableCaching)
                    container.AddComponent("n2.web.cachingUrlParser", typeof(IUrlParser), typeof(CachingUrlParserDecorator));

                if (hostConfig.MultipleSites)
                    container.AddComponent("n2.multipleSitesParser", typeof(IUrlParser), typeof(MultipleSitesParser));
                else
                    container.AddComponent("n2.urlParser", typeof(IUrlParser), typeof(UrlParser));
            }
        }
		public override void SetUp()
		{
			base.SetUp();

			root = CreateOneItem<PageItem>(1, "root", null);
			one = CreateOneItem<CustomExtensionItem>(2, "one", root);
			two = CreateOneItem<PageItem>(3, "two", one);
			CreateOneItem<DataItem>(4, "four", root);
			three = CreateOneItem<PageItem>(5, "three.3", root);

			webContext = new FakeWebContextWrapper();
			var hostSection = new HostSection { Web = new WebElement { Rewrite = rewriteMethod } };
			parser = new UrlParser(persister, webContext, new Host(webContext, root.ID, root.ID), new N2.Plugin.ConnectionMonitor(), hostSection);
			errorHandler = new FakeErrorHandler();
			engine = new FakeEngine();
			engine.Container.AddComponentInstance(null, typeof(IWebContext), webContext);
			engine.Container.AddComponentInstance(null, typeof(TargetingRadar), new TargetingRadar(hostSection, new DetectorBase[0]));
			adapterProvider = new ContentAdapterProvider(engine, new AppDomainTypeFinder());
			adapterProvider.Start();

			ReCreateDispatcherWithConfig(hostSection);
		}
Example #17
0
		public Host(IWebContext context, HostSection config)
		{
            this.context = context;

		    ReplaceSites(new Site(config.RootID, config.StartPageID), ExtractSites(config));
		}
        void ReCreateDispatcherWithConfig(HostSection config)
        {
            dispatcher = new RequestPathProvider(webContext, parser, errorHandler, config);

            handler = new FakeRequestLifeCycleHandler(webContext, dispatcher, adapterProvider, errorHandler,
                new ConfigurationManagerWrapper { Sections = new ConfigurationManagerWrapper.ContentSectionTable(config, null, null, new EditSection()) });
        }
 public MultipleSitesParser(IPersister persister, IWebContext webContext, IHost host, N2.Plugin.ConnectionMonitor connections, HostSection config)
     : base(persister, webContext, host, connections, config)
 {
 }
 public FakeRequestLifeCycleHandler(IWebContext webContext, InstallationManager installer, RequestPathProvider dispatcher, IContentAdapterProvider adapters, IErrorHandler errors, IEditUrlManager editUrlManager, EditSection editConfig, HostSection hostConfig)
     : base(webContext, EventBroker.Instance, installer, dispatcher, adapters, errors, editUrlManager, editConfig, hostConfig)
 {
     initialized = true;
 }
Example #21
0
 public MultipleSitesParser(IPersister persister, IWebContext webContext, IHost host, HostSection config)
     : base(persister, webContext, host, config)
 {
 }
		void ReCreateDispatcherWithConfig(HostSection config)
		{
			IPersister persister = null;
			dispatcher = new RequestPathProvider(webContext, parser, errorHandler, config, TestSupport.CreateDraftRepository(ref persister));

			handler = new FakeRequestLifeCycleHandler(webContext, dispatcher, adapterProvider, errorHandler,
				new ConfigurationManagerWrapper { Sections = new ConfigurationManagerWrapper.ContentSectionTable(config, null, null, new EditSection()) });
		}
Example #23
0
 public SafeContentRenderer(HostSection config)
 {
     encodeHtml = config.HtmlSanitize.EncodeHtml;
 }
Example #24
0
 public HtmlSanitizer(HostSection config)
 {
     encodeHtml = config.HtmlSanitize.EncodeHtml;
 }