public void AndGivenStoreThatReturnsThePage() { _store = Substitute.For <IFrankenstore>(); _store .GetPageAsync("slug") .Returns(Task.FromResult(_page)); }
public void GivenStoreThatDoesNotHaveTheRequestedSlug() { _store = Substitute.For<IFrankenstore>(); _store .GetPageAsync("static-content/ghost-cat.jpg") .Returns(Task.FromResult(default(Frankenpage))); }
public void GivenStoreThatDoesNotHaveTheRequestedSlug() { _store = Substitute.For <IFrankenstore>(); _store .GetPageAsync("static-content/ghost-cat.jpg") .Returns(Task.FromResult(default(Frankenpage))); }
public void AndGivenStoreThatReturnsThePage() { _store = Substitute.For<IFrankenstore>(); _store .GetPageAsync("slug") .Returns(Task.FromResult(_page)); }
private async Task <dynamic> GetFrankenpageResponseForSlug(IFrankenstore store, string slug) { var page = await store.GetPageAsync(slug); return(page == null ? null : View["page", page]); }
private async Task<dynamic> GetFrankenpageResponseForSlug(IFrankenstore store, string slug) { var page = await store.GetPageAsync(slug); return page == null ? null : View["page", page]; }
public IndexModule(IFrankenstore store) { Get["/index", true] = async(o, token) => { var indices = await store.GetPageIndicesAsync(); return(View["pages-index", indices]); }; }
public IndexModule(IFrankenstore store) { Get["/index", true] = async (o, token) => { var indices = await store.GetPageIndicesAsync(); return View["pages-index", indices]; }; }
public CategoriesModule(IFrankenstore store) { Get["/categories", true] = async (o, token) => { var categories = await store.GetAllCategoriesAsync(); return View["categories", categories]; }; }
public CategoriesModule(IFrankenstore store) { Get["/categories", true] = async(o, token) => { var categories = await store.GetAllCategoriesAsync(); return(View["categories", categories]); }; }
public WhatLinksToModule(IFrankenstore store) { Get["/what-links-to/{slug*}", true] = async (o, token) => { var slug = (string) o.slug; var page = await store.GetPageAsync(slug); return View["tools-what-links-here", page]; }; }
public WhatLinksToModule(IFrankenstore store) { Get["/what-links-to/{slug*}", true] = async(o, token) => { var slug = (string)o.slug; var page = await store.GetPageAsync(slug); return(View["tools-what-links-here", page]); }; }
public CategoryModule( IFrankenstore store) { Get["/category/{slug*}", true] = async (o, token) => { var slug = (string) o.slug; var index = await store.GetIndexForCategory(slug); return View["category", index]; }; }
public CategoryModule( IFrankenstore store) { Get["/category/{slug*}", true] = async(o, token) => { var slug = (string)o.slug; var index = await store.GetIndexForCategory(slug); return(View["category", index]); }; }
public void GenerateFromSource( string sourcePath, IFrankenstore store) { sourcePath = Path.GetDirectoryName(sourcePath + "\\"); var pages = from filePath in EnumerateFiles(sourcePath, "*.md", "*.markdown") let fileAsMarkdown = File.ReadAllText(filePath) let slug = GetSlug(filePath, sourcePath) select BuildUpPage(slug, fileAsMarkdown); store.StoreAsync(pages); }
public PageModule( IFrankenstore store, IRootPathProvider rootPathProvider, FrankenwikiConfiguration configuration) { _rootPathProvider = rootPathProvider; _configuration = configuration; var strategies = new Func <string, Task <dynamic> >[] { slug => GetStaticResourceForSlug(slug), slug => GetFrankenpageResponseForSlug(store, slug), }; Get["/wiki", true] = async(o, token) => await GetFrankenpageResponseForSlug(store, "index"); Get["/wiki/{slug*}", true] = async(o, token) => { var slug = (string)o.slug; // TODO HACK this is to allow routes like /wiki/cat.jpg/ which without the // trailing slash will fail because of a NancyFx bug in 1.1.0: // https://github.com/NancyFx/Nancy/issues/1829 slug = slug.TrimEnd('/'); foreach (var strategy in strategies) { var result = await strategy(slug); if (result != null) { return(result); } } return((dynamic) new NotFoundResponse()); }; Get["/echo/{slug*}"] = _ => _.slug; Get["/echo2/{slug}/hi"] = _ => _.slug; }
public PageModule( IFrankenstore store, IRootPathProvider rootPathProvider, FrankenwikiConfiguration configuration) { _rootPathProvider = rootPathProvider; _configuration = configuration; var strategies = new Func<string, Task<dynamic>>[] { slug => GetStaticResourceForSlug(slug), slug => GetFrankenpageResponseForSlug(store, slug), }; Get["/wiki", true] = async (o, token) => await GetFrankenpageResponseForSlug(store, "index"); Get["/wiki/{slug*}", true] = async (o, token) => { var slug = (string) o.slug; // TODO HACK this is to allow routes like /wiki/cat.jpg/ which without the // trailing slash will fail because of a NancyFx bug in 1.1.0: // https://github.com/NancyFx/Nancy/issues/1829 slug = slug.TrimEnd('/'); foreach (var strategy in strategies) { var result = await strategy(slug); if (result != null) { return result; } } return (dynamic) new NotFoundResponse(); }; Get["/echo/{slug*}"] = _ => _.slug; Get["/echo2/{slug}/hi"] = _ => _.slug; }
public InMemoryFrankensearch(IFrankenstore store) { _store = store; }