async Task BuildIndexCategory(IList <Post> data) { FSStaticBuilder.EnsureDirectoryEmpty(Paths.GetCategoryRoot(RootPath)); var(tree, map) = await CategoryTreeBuilder.BuildFromPosts(data.ToAsyncEnumerable()); Queue <CategoryTree.CategoryTreeNode> q = new Queue <CategoryTree.CategoryTreeNode>(); foreach (var v in tree.Root.Children.Values) { q.Enqueue(v); } while (q.Count > 0) { var node = q.Dequeue(); await BuildDataIdList(map[node].Select(x => x.Id).ToArray(), Paths.GetCategoryRoot(RootPath, node.Category)).ConfigureAwait(false); foreach (var v in node.Children.Values) { q.Enqueue(v); } } await using var st = FSStaticBuilder.GetFileRewriteStream(Paths.GetCategoryMetadata(RootPath)); await JsonSerializer.SerializeAsync(st, tree).ConfigureAwait(false); }
public virtual async Task Build(IList <T> data) { FSStaticBuilder.EnsureDirectoryEmpty(RootPath); FSStaticBuilder.EnsureDirectoryEmpty(Paths.GetDataRoot(RootPath)); FSStaticBuilder.EnsureDirectoryEmpty(Paths.GetConfigRoot(RootPath)); FSStaticBuilder.EnsureDirectoryEmpty(Paths.GetIndexRoot(RootPath)); await BuildData(data).ConfigureAwait(false); }
async Task BuildRouteIndex(IList <Page> data) { var gr = from x in data group x by x.Route; foreach (var g in gr) { string path = Paths.GetRouteFile(RootPath, g.Key); await using var st = FSStaticBuilder.GetFileRewriteStream(path); await JsonSerializer.SerializeAsync(st, (from p in g select p.Id).ToArray()).ConfigureAwait(false); } }
public void Setup() { RootPath = Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Guid.NewGuid().ToString()); FSStaticBuilder.EnsureDirectoryExists(RootPath); PostData = Enumerable.Range(0, Length).Select(x => Generator.GetPost()).ToArray(); LayoutData = Enumerable.Range(0, Length).Select(x => Generator.GetLayout()).ToArray(); PageData = Enumerable.Range(0, Length).Select(x => Generator.GetPage()).ToArray(); FileData = Enumerable.Range(0, Length).Select(x => Generator.GetFile()).ToArray(); Builder = new BlogBuilder(new BlogOptions(), RootPath); }
protected virtual async Task BuildData(IList <T> data) { List <TId> ids = new List <TId>(); foreach (var v in data) { var id = v.Id?.ToString() ?? throw new NullReferenceException(nameof(v.Id)); await using var st = FSStaticBuilder.GetFileRewriteStream(Paths.GetDataFile(RootPath, id)); await JsonSerializer.SerializeAsync(st, v).ConfigureAwait(false); ids.Add(v.Id); } await BuildDataIdList(ids, Paths.GetConfigRoot(RootPath)).ConfigureAwait(false); }
async Task BuildIndexKeyword(IList <Post> data) { FSStaticBuilder.EnsureDirectoryEmpty(Paths.GetKeywordRoot(RootPath)); var(collection, map) = await KeywordCollectionBuilder.BuildFromPosts(data.ToAsyncEnumerable()); foreach (var v in collection.Items) { await BuildDataIdList(map[v.OneName()].Select(x => x.Id).ToArray(), Paths.GetKeywordRoot(RootPath, v)).ConfigureAwait(false); } await using var st = FSStaticBuilder.GetFileRewriteStream(Paths.GetKeywordMetadata(RootPath)); await JsonSerializer.SerializeAsync(st, collection).ConfigureAwait(false); }
protected virtual async Task BuildDataIdList(IList <TId> dataIds, string rootPath) { { var stats = new QueryStatistic { Count = dataIds.Count }; await using var st = FSStaticBuilder.GetFileRewriteStream(Paths.GetStatisticFile(rootPath)); await JsonSerializer.SerializeAsync(st, stats).ConfigureAwait(false); } { await using var st = FSStaticBuilder.GetFileRewriteStream(Paths.GetIdListFile(rootPath)); await JsonSerializer.SerializeAsync(st, dataIds).ConfigureAwait(false); } }
public async Task Setup() { RootPath = Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "fstest"); FSStaticBuilder.EnsureDirectoryExists(RootPath); PostData = Enumerable.Range(0, 100).Select(x => Generator.GetPost()).ToArray(); LayoutData = Enumerable.Range(0, 100).Select(x => Generator.GetLayout()).ToArray(); PageData = Enumerable.Range(0, 100).Select(x => Generator.GetPage()).ToArray(); FileData = Enumerable.Range(0, 100).Select(x => Generator.GetFile()).ToArray(); BlogOptionsData = new BlogOptions(); BlogBuilder builder = new BlogBuilder(BlogOptionsData, RootPath); await builder.Build(); await builder.BuildPosts(PostData); await builder.BuildLayouts(LayoutData); await builder.BuildPages(PageData); await builder.BuildFiles(FileData); BlogService = new FileSystemBlogService(new PhysicalFileProvider(RootPath).AsFileProvider()); }
public void Cleanup() { FSStaticBuilder.EnsureDirectoryExists(RootPath, false); }
public RecordFSRepo(string rootPath) : base(rootPath) { FSStaticBuilder.EnsureDirectoryExists(rootPath); FileProvider = new PhysicalFileProvider(rootPath).AsFileProvider(); }