public static void Generate(Site site) { LoadData(site); //Read templates var indexTemplate = new IndexTemplate(site); //Clean web target FileManager.Clean(site.WebPath); //Copy static: Done in calling bash script FileManager.Clone(site.StaticPath, site.WebPath); //Generate news indexTemplate["site:news"] = GenerateNews(site); var pageTemplate = new PageTemplate(site); var postTemplate = new PostTemplate(site); //Generate all files GenerateIndex(indexTemplate, site); GenerateFeed(site); foreach (Page p in site.Pages) GeneratePage(site, p, pageTemplate, indexTemplate); foreach (Post p in site.Posts) GeneratePost(site, p, postTemplate, indexTemplate); GenerateNewPostPageTemplate(site); Compressor.CompressDirectoryRecursive(site.WebPath); }
static void GenerateIndex(IndexTemplate template, Site site) { var indexInstance = template.Create(site); if (site.GetPage("index") != null) return; var compactPostTemplate = new CompactPostTemplate(site); indexInstance["title"] = site.Title; indexInstance["tabs"] = GenerateTabs(site, null, null); indexInstance["contents"] = new Html(); foreach (Post p in site.Posts) { indexInstance["contents"] += compactPostTemplate.Generate(site, p); } indexInstance.Write(Path.Combine(site.WebPath, "index.html")); }
static void GeneratePost(Site site, Post p, PostTemplate postTemplate, IndexTemplate indexTemplate) { string dirPath = Path.Combine(site.WebPath, p.Path); string htmlPath = Path.Combine(dirPath, "index.html"); Directory.CreateDirectory(dirPath); if (Directory.Exists(p.SourceDir)) FileManager.Clone(p.SourceDir, dirPath); var inst = indexTemplate.Create(site); inst["title"] = p.Title; inst["tabs"] = GenerateTabs(site, null, p); inst["contents"] = postTemplate.Generate(site, p); inst.Write(htmlPath); }
static void GeneratePage(Site site, Page p, PageTemplate pageTemplate, IndexTemplate indexTemplate) { string dirPath = Path.Combine(site.WebPath, p.Path); if (p.Path == "index/") dirPath = site.WebPath; Directory.CreateDirectory(dirPath); if (Directory.Exists(p.SourceDir)) FileManager.Clone(p.SourceDir, dirPath); var indexInstance = indexTemplate.Create(site); indexInstance["title"] = p.Title; indexInstance["tabs"] = GenerateTabs(site, p, null); indexInstance["contents"] = pageTemplate.Generate(site, p); indexInstance.Write(Path.Combine(dirPath, "index.html")); }