Ejemplo n.º 1
0
 public CachedFeedService(IConfigSettings configSettings, IRootPathProvider rootPathProvider)
 {
     this.rootPathProvider = rootPathProvider;
     cacheMinutes = configSettings.GetAppSetting<int>("cacheminutes");
     nancyCategories = configSettings.GetAppSetting("nancycategories")
         .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
 }
Ejemplo n.º 2
0
 public CachedFeedService(IConfigSettings configSettings, IRootPathProvider rootPathProvider)
 {
     this.rootPathProvider = rootPathProvider;
     cacheMinutes          = configSettings.GetAppSetting <int>("cacheminutes");
     nancyCategories       = configSettings.GetAppSetting("nancycategories")
                             .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
 }
Ejemplo n.º 3
0
        public HomeModule(IPostService postService, IFeedService feedService, IConfigSettings configSettings)
        {
            Get["/"] = _ =>
            {
                int currentPage;
                int pageSize;

                if (!int.TryParse(Request.Query.currentpage.ToString(), out currentPage))
                {
                    currentPage = 1;
                }

                if (!int.TryParse(Request.Query.pagesize.ToString(), out pageSize))
                {
                    pageSize = 10;
                }

                var viewmodel = postService.GetViewModel(pageSize, currentPage);

                return(View["index", viewmodel]);
            };

            Get["/{title}"] = parameters =>
            {
                var post = feedService.GetItem(parameters.title);
                if (post == null)
                {
                    return(View["404"].WithStatusCode(404));
                }

                return(View["post", post]);
            };

            Get["/about"] = _ =>
            {
                var model = configSettings.GetAppSetting("nancycategories")
                            .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                ViewBag.NancyCategories = string.Join(" or ", model);

                return(View["about"]);
            };

            Get["/rss"] = x => Response.AsRSS(feedService.GetItems(), "Nancy Blog", "http://blog.nancyfx.org/", "rss");
        }
Ejemplo n.º 4
0
        public HomeModule(IPostService postService, IFeedService feedService, IConfigSettings configSettings)
        {
            Get["/"] = _ =>
            {
                int currentPage;
                int pageSize;

                if (!int.TryParse(Request.Query.currentpage.ToString(), out currentPage))
                {
                    currentPage = 1;
                }

                if (!int.TryParse(Request.Query.pagesize.ToString(), out pageSize))
                {
                    pageSize = 10;
                }

                var viewmodel = postService.GetViewModel(pageSize, currentPage);

                return View["index", viewmodel];
            };

            Get["/{title}"] = parameters =>
            {
                var post = feedService.GetItem(parameters.title);
                if (post == null)
                {
                    return View["404"];
                }

                return View["post", post];
            };

            Get["/about"] = _ =>
            {
                var model = configSettings.GetAppSetting("nancycategories")
                    .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                ViewBag.NancyCategories = string.Join(" or ", model);

                return View["about"];
            };

            Get["/rss"] = x => Response.AsRSS(feedService.GetItems(), "Nancy Blog", "http://blog.nancyfx.org/", "feed.xml");
        }
Ejemplo n.º 5
0
 public CachedFeedService(IFeedService feedService, IConfigSettings configManager)
 {
     this.feedService = feedService;
     cacheMinutes     = configManager.GetAppSetting <int>("cacheminutes");
 }
Ejemplo n.º 6
0
 public CachedFeedService(IFeedService feedService, IConfigSettings configManager)
 {
     this.feedService = feedService;
     cacheMinutes = configManager.GetAppSetting<int>("cacheminutes");
 }