Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApi api)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive))
                                  .AddType(typeof(Models.StandardPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();
            app.UsePiranha();
            app.UsePiranhaManager();

            app.UseMvc();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApi api)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            // app.UseCookiePolicy();

            // Initialize Piranha
            App.Init();

            // Configure cache level
            App.CacheLevel = Piranha.Cache.CacheLevel.Basic;

            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(BlogArchive))
                                  .AddType(typeof(StandardPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();
            var siteTypeBuilder = new Piranha.AttributeBuilder.SiteTypeBuilder(api)
                                  .AddType(typeof(BlogSite));

            siteTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UsePiranha();
            app.UsePiranhaManager();
            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });
        }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider services)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Initialize Piranha
            var api = services.GetService <IApi>();

            App.Init(api);

            // Add custom blocks
            App.Blocks.Register <Models.Blocks.SliderGroup>();
            App.Blocks.Register <Models.Blocks.SliderItem>();

            // Build types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive))
                                  .AddType(typeof(Models.StandardPage))
                                  .AddType(typeof(Models.TeaserPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();
            var siteTypeBuilder = new Piranha.AttributeBuilder.SiteTypeBuilder(api)
                                  .AddType(typeof(Models.StandardSite));

            siteTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UsePiranha();
            app.UsePiranhaManager();
            app.UseMvc(routes => {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });

            Seed(api);
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services, IApi api)
        {
            // Initialize Piranha
            App.Init();

            // Configure cache level
            App.CacheLevel = Piranha.Cache.CacheLevel.Basic;

            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive))
                                  .AddType(typeof(Models.StandardPage))
                                  .AddType(typeof(Models.LiveStreamsPage))
                                  .AddType(typeof(Models.ChatPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();
            var siteTypeBuilder = new Piranha.AttributeBuilder.SiteTypeBuilder(api)
                                  .AddType(typeof(Models.BlogSite));

            siteTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();
            app.UseResponseCompression();
            app.UseGlobalErrorHandler(true);
            app.UseCorrelationToken();
            app.UseRequestLogging();
            app.UsePerformanceLogging(settings.PerformaceWarningMinimumInMS);
            app.UseAuthentication();
            app.UsePiranha();
            app.UsePiranhaManager();

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });

            logger.Debug($"Service started (v{Program.GetVersion})");
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider services)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Initialize Piranha
            var api = services.GetService <IApi>();

            App.Init(api);

            // Config
            using (var config = new Config(api)) {
                config.CacheExpiresPages = 0;
            }

            // Build types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.StandardBlog))
                                  .AddType(typeof(Models.StandardPage))
                                  .AddType(typeof(Models.TeaserPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.ArticlePost));

            postTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();
            app.UsePiranhaSimpleSecurity();
            app.UsePiranha();
            app.UsePiranhaManager();
            app.UseMvc(routes => {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });

            Seed(api);
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApi api)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Initialize Piranha
            App.Init();

            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();

            // This security provider is only for development
            // purposes
            app.UsePiranhaSimpleSecurity();

            // Add the middleware needed for a blog
            app.UsePiranhaApplication();
            app.UsePiranhaAliases();
            app.UsePiranhaPosts();
            app.UsePiranhaArchives();
            app.UsePiranhaManager();

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });
        }
Ejemplo n.º 7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApi api)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Configure cache level
            // App.CacheLevel = Piranha.Cache.CacheLevel.Basic;
            App.CacheLevel = Piranha.Cache.CacheLevel.Full;

            // Custom components
            App.Blocks.Register <Models.Blocks.SeparatorBlock>();

            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive))
                                  .AddType(typeof(Models.StandardPage))
                                  .AddType(typeof(Models.TeaserPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UsePiranha();
            app.UsePiranhaManager();
            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });

            Seed.Run(api);
        }
Ejemplo n.º 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Initialize Piranha
            var api = services.GetService <IApi>();

            App.Init(api);

            // Configure cache level
            App.CacheLevel = Piranha.Cache.CacheLevel.None;

            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive))
                                  .AddType(typeof(Models.StandardPage))
                                  .AddType(typeof(Models.StartPage))
                                  .AddType(typeof(Models.ContactPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UsePiranha();
            app.UsePiranhaManager();
            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });
        }
Ejemplo n.º 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider services)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            // Initialize Piranha
            var api = services.GetService <IApi>();

            App.Init(api);

            // Configure cache level
            App.CacheLevel = Piranha.Cache.CacheLevel.None;

            // Add custom fields
            App.Fields.Register <SizedImageField>();

            // Add custom blocks
            App.Blocks.Register <SliderGroup>();
            App.Blocks.Register <SizedImageBlock>();

            // Build types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive))
                                  .AddType(typeof(Models.StandardPage))
                                  .AddType(typeof(Models.StartPage))
                                  .AddType(typeof(Models.CoolAppsPage));

            pageTypeBuilder.Build()
            .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost));

            postTypeBuilder.Build()
            .DeleteOrphans();

            // Register middleware
            app.UseAuthentication();
            app.UsePiranhaManager();
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "areaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "ClientApp";

                spa.UseSpaPrerendering(options =>
                {
                    options.BootModulePath    = $"{spa.Options.SourcePath}/dist-server/main.bundle.js";
                    options.BootModuleBuilder = env.IsDevelopment()
                        ? new AngularCliBuilder(npmScript: "build:ssr")
                        : null;

                    options.SupplyData = (context, data) =>
                    {
                        // Creates a new value called isHttpsRequest that's passed to TypeScript code
                        data["isHttpsRequest"] = context.Request.IsHttps;
                    };
                    options.ExcludeUrls = new[] { "/sockjs-node" };
                });

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });
        }