// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApi api)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();

                // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
                // specifying the Swagger JSON endpoint.
                app.UseSwaggerUI(options =>
                {
                    options.SwaggerEndpoint("/swagger/v1/swagger.json", "PiranhaCMS API V1");
                });
            }

            App.Init(api);

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

            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.BlogArchive))
                                  .AddType(typeof(Models.StandardPage))
                                  .AddType(typeof(Models.TeaserPage))
                                  .Build()
                                  .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.BlogPost))
                                  .Build()
                                  .DeleteOrphans();
            var siteTypeBuilder = new Piranha.AttributeBuilder.SiteTypeBuilder(api)
                                  .AddType(typeof(Models.StandardSite))
                                  .Build()
                                  .DeleteOrphans();

            /**
             *
             * Test another culture in the UI
             *
             * var cultureInfo = new System.Globalization.CultureInfo("en-US");
             * System.Globalization.CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
             * System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
             */

            // Register middleware
            app.UseStaticFiles();
            app.UsePiranha();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UsePiranhaIdentity();
            app.UsePiranhaManager();
            app.UsePiranhaTinyMCE();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapPiranhaManager();
            });

            Seed.RunAsync(api).GetAwaiter().GetResult();
        }
示例#2
0
文件: Startup.cs 项目: MrAnh3011/TVS
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApi api)
        {
            app.UseResponseCompression();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();

                // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
                // specifying the Swagger JSON endpoint.
                app.UseSwaggerUI(options =>
                {
                    options.SwaggerEndpoint("/swagger/v1/swagger.json", "PiranhaCMS API V1");
                });
            }

            App.Init(api);

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


            // Build content types
            var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
                                  .AddType(typeof(Models.TeaserPage))
                                  .AddType(typeof(Models.RelationPage))
                                  .AddType(typeof(Models.ContactPage))
                                  .AddType(typeof(Models.IntroPage))
                                  .AddType(typeof(Models.ServicesPage))
                                  .AddType(typeof(Models.InvestbankPage))
                                  .AddType(typeof(Models.AgencyPage))
                                  .AddType(typeof(Models.NewsPage))
                                  .AddType(typeof(Models.RequestOpenAccPage))
                                  .AddType(typeof(Models.RecruitPage))
                                  .AddType(typeof(Models.LoginPage))
                                  .AddType(typeof(Models.RegisterPage))
                                  .AddType(typeof(Models.SearchPage))
                                  .AddType(typeof(Models.ForgotPassword))
                                  .AddType(typeof(Models.AnalyzePage))
                                  .AddType(typeof(Models.OtherServicesPage))
                                  .Build()
                                  .DeleteOrphans();
            var postTypeBuilder = new Piranha.AttributeBuilder.PostTypeBuilder(api)
                                  .AddType(typeof(Models.NewsPost))
                                  .Build()
                                  .DeleteOrphans();
            var siteTypeBuilder = new Piranha.AttributeBuilder.SiteTypeBuilder(api)
                                  .AddType(typeof(Models.StandardSite))
                                  .Build()
                                  .DeleteOrphans();

            /**
             *
             * Test another culture in the UI
             *
             * var cultureInfo = new System.Globalization.CultureInfo("en-US");
             * System.Globalization.CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
             * System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
             */

            // Register middleware
            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse = ctx =>
                {
                    var headers          = ctx.Context.Response.GetTypedHeaders();
                    headers.CacheControl = new CacheControlHeaderValue
                    {
                        Public = true,
                        MaxAge = TimeSpan.FromDays(3)
                    };
                }
            });
            app.UsePiranha();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UsePiranhaIdentity();
            app.UsePiranhaManager();
            app.UsePiranhaSummernote();
            app.UsePiranhaTinyMCE();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapPiranhaManager();
            });

            app.UseRewriter(new RewriteOptions()
                            .AddIISUrlRewrite(env.ContentRootFileProvider, "RedirectToWwwRule.xml")
                            .AddRedirectToHttps()
                            );
            Seed.RunAsync(api).GetAwaiter().GetResult();
        }