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 static void UseWebServerFileSystemStorage(
            this DownrContentProviderConfigurator configurator)
        {
            IYamlIndexer yamlIndexer = (IYamlIndexer)
                                       configurator.Builder.ApplicationServices.GetService(typeof(IYamlIndexer));

            yamlIndexer.IndexContentFiles();
        }
Esempio n. 3
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                logger.LogInformation("Time to refresh the content...");
                await yamlIndexer.IndexContentFiles();

                await Task.Delay(TimeSpan.FromMinutes(config.AutoRefreshInterval));
            }
        }
Esempio n. 4
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. 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,
                              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. 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,
                              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. 7
0
 public ActionResult ReIndex()
 {
     _yamlIndexer.IndexContentFiles();
     return(Ok());
 }
Esempio n. 8
0
 public ActionResult ReIndex()
 {
     _yamlIndexer.IndexContentFiles();
     return(Redirect("/"));
 }