Esempio 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,
                              ILoggerFactory loggerFactory,
                              IYamlIndexer yamlIndexer)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

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

            // get the path to the content directory so the yaml headers can be indexed as metadata
            var contentPath = string.Format("{0}\\posts\\", env.WebRootPath);

            yamlIndexer.IndexContentFiles(contentPath);
        }
Esempio n. 2
0
 public FeedController(IMarkdownContentLoader markdownLoader,
                       IYamlIndexer indexer,
                       IOptions <DownrOptions> options)
 {
     _markdownLoader = markdownLoader;
     _indexer        = indexer;
     _options        = options.Value;
 }
Esempio n. 3
0
 public ContentRefreshWorker(ILogger <ContentRefreshWorker> logger,
                             IYamlIndexer yamlIndexer,
                             IOptions <DownrOptions> config)
 {
     this.config      = config.Value;
     this.yamlIndexer = yamlIndexer;
     this.logger      = logger;
 }
Esempio n. 4
0
        public static void UseWebServerFileSystemStorage(
            this DownrContentProviderConfigurator configurator)
        {
            IYamlIndexer yamlIndexer = (IYamlIndexer)
                                       configurator.Builder.ApplicationServices.GetService(typeof(IYamlIndexer));

            yamlIndexer.IndexContentFiles();
        }
Esempio n. 5
0
 public PostsController(
     IYamlIndexer indexer,
     IOptions <DownrOptions> options
     )
     : base(indexer)
 {
     _options = options.Value;
 }
Esempio n. 6
0
        public static void UseAzureStorage(
            this DownrContentProviderConfigurator configurator)
        {
            IYamlIndexer yamlIndexer = (IYamlIndexer)
                                       configurator.Builder.ApplicationServices.GetService(typeof(IYamlIndexer));

            IOptions <AzureStorageConfiguration> config = (IOptions <AzureStorageConfiguration>)
                                                          configurator.Builder.ApplicationServices.GetService(typeof(IOptions <AzureStorageConfiguration>));

            yamlIndexer.IndexContentFiles();
        }
Esempio 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,
                              ILoggerFactory loggerFactory,
                              IYamlIndexer yamlIndexer)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseResponseCompression();
            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse =
                    _ => _.Context.Response.Headers[HeaderNames.CacheControl] =
                        "public,max-age=604800"
            });

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

            // get the path to the content directory so the yaml headers can be indexed as metadata
            if (string.IsNullOrWhiteSpace(env.WebRootPath))
            {
                env.WebRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot");
            }
            var contentPath = Path.Combine(env.WebRootPath, "posts");

            yamlIndexer.IndexContentFiles(contentPath);
        }
Esempio n. 8
0
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              IOptions <DownrOptions> downrOptions,
                              IYamlIndexer yamlIndexer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebAssemblyDebugging();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseBlazorFrameworkFiles();
            app.UseStaticFiles();
            app.UseResponseCompression();
            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse = _ => _.Context.Response.Headers[HeaderNames.CacheControl] = "public,max-age=604800"
            });
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
                endpoints.MapFallbackToFile("index.html");
                endpoints.MapControllerRoute(
                    name: "blog-feed-rss",
                    pattern: "/feed/rss",
                    defaults: new { controller = "Feed", Action = "Rss" }
                    );
            });

            app.UseDownr()
            //.UseAzureStorage(); // use azure blob storage
            .UseWebServerFileSystemStorage();    // use local web server storage
        }
Esempio n. 9
0
 public PostService(IYamlIndexer indexer, IOptions <DownrOptions> downrOptions)
 {
     _downrOptions = downrOptions.Value;
     _indexer      = indexer;
 }
Esempio n. 10
0
 public CategoryController(IYamlIndexer indexer) : base(indexer)
 {
 }
Esempio n. 11
0
 public TagCloudViewComponent(IYamlIndexer indexer)
 {
     _indexer = indexer;
 }
Esempio n. 12
0
 public HomeController(IYamlIndexer indexer)
 {
     _indexer = indexer;
 }
Esempio n. 13
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,
                              IYamlIndexer yamlIndexer,
                              IOptions <DownrOptions> downrOptions)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseResponseCompression();
            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse =
                    _ => _.Context.Response.Headers[HeaderNames.CacheControl] =
                        "public,max-age=604800"
            });

            var stem = downrOptions.Value.Stem.StripLeading("/");

            if (!string.IsNullOrEmpty(stem) && !stem.EndsWith("/"))
            {
                stem += "/";
            }

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "blog-root",
                    template: stem,
                    defaults: new { controller = "Posts", Action = "Index" }
                    );
                routes.MapRoute(
                    name: "blog-post",
                    template: stem + "posts/{slug}",
                    defaults: new { controller = "Posts", Action = "Post" }
                    );
                routes.MapRoute(
                    name: "blog-categories",
                    template: stem + "category/{name}",
                    defaults: new { controller = "Category", Action = "Index" }
                    );
                routes.MapRoute(
                    name: "blog-feed-rss",
                    template: stem + "feed/rss",
                    defaults: new { controller = "Feed", Action = "Rss" }
                    );
            });

            var logger = loggerFactory.CreateLogger <Startup>();

            logger.LogInformation("Options.Title: '{0}'", downrOptions.Value.Title);
            logger.LogInformation("Options.RooUrl: '{0}'", downrOptions.Value.RootUrl);
            logger.LogInformation("Options.Stem: '{0}' ({1})", downrOptions.Value.Stem, stem);

            // get the path to the content directory so the yaml headers can be indexed as metadata
            if (string.IsNullOrWhiteSpace(env.WebRootPath))
            {
                env.WebRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot");
                logger.LogInformation("Set WebRootPath to '{0}'", env.WebRootPath);
            }
            var contentPath = Path.Combine(env.WebRootPath, "posts");

            yamlIndexer.IndexContentFiles(contentPath);
        }
Esempio n. 14
0
 public PostsController(IYamlIndexer indexer) : base(indexer)
 {
 }
Esempio n. 15
0
 public BaseController(IYamlIndexer indexer)
 {
     _indexer = indexer;
 }
Esempio n. 16
0
 public PostService(IYamlIndexer indexer)
 {
     _indexer = indexer;
 }
Esempio n. 17
0
 public PostsController(PostService postService, IOptions <DownrOptions> options, IYamlIndexer yamlIndexer)
 {
     _yamlIndexer = yamlIndexer;
     _postService = postService;
     _options     = options.Value;
 }
Esempio n. 18
0
 public FeedController(IMarkdownContentLoader markdownLoader,
                       IYamlIndexer indexer)
 {
     _markdownLoader = markdownLoader;
     _indexer        = indexer;
 }