//using aeqw89.DataKeys; //using System; //using System.Collections.Generic; //using System.Linq; //using System.Text; //using System.Threading.Tasks; //namespace Beam.Temporary.Cli { // internal class HtmlBook : Document { // public class Keys { // public static DataKey ContentPage => new DataKey("content_page"); // public static DataKey NoContentPage => new DataKey("no_content_page"); // public static DataKey TitlePage => new DataKey("title_page"); // public static DataKey StylesPage => new DataKey("styles_page"); // } // public List> Documents { get; set; } // public IReadOnlyList Pages => _Pages; // private List _Pages { get; set; } = []; // private const string EMTPY_PAGE = "EMPTY"; // public CssData CssData { get; } // public ArticleData BookData { get; set; } // public HtmlBookTemplates Templates { get; set; } // public HtmlBook(string bookname, CssData cssData, ArticleData bookData, HtmlBookTemplates templates, List? documents = null, Encoding? encoding = null) // : base(bookname, encoding) { // Documents = []; // CssData = cssData; // BookData = bookData; // Templates = templates; // if (documents is not null) // Documents = documents.Select((x) => new Tracked(x)).ToList(); // } // public void Update(bool ignoreDirty = false) { // if (!Directory.Exists(Filename)) // Directory.CreateDirectory(Filename); // //System.IO.File.WriteAllLines(Path.Combine(Filename, "styles.css"), Format()) // List newpages = []; // if (Pages.Count < Documents.Count) // _Pages.AddRange(Enumerable.Repeat(EMTPY_PAGE, Documents.Count - Pages.Count)); // foreach (var (doc, page) in Documents.Zip(Pages)) { // if (!doc.IsDirty) // newpages.Add(page); // else if (doc.TrackedObject.MetaData.Count == 0) // newpages.Add(PlainPage(doc.TrackedObject)); // else if (doc.TrackedObject.MetaData.TryGetValue(Program.Architecture.ChapterKey, out var meta) && meta is ArticleData articleData) // newpages.Add(ArticlePage(doc.TrackedObject, articleData)); // else { // Console.WriteLine("Unhandlable Metadata detected!"); // newpages.Add(PlainPage(doc.TrackedObject)); // } // System.IO.File.WriteAllText(Path.Combine(Filename, Path.GetRandomFileName() + ".html"), newpages[^1]); // doc.IsDirty = false; // } // _Pages = newpages; // } // public void UpdateCss() { // } // public void UpateTitle() { // } // private string Format(string template, Dictionary table) { // ArgumentNullException.ThrowIfNull(template); // ArgumentNullException.ThrowIfNull(table); // foreach (var kvp in table) { // template = template.Replace(kvp.Key, kvp.Value); // } // return template; // } // private Dictionary GetDocumentTable(IDocument doc, bool keepPlaceholders = false) { // var table = new Dictionary() { // { "{" + nameof(doc.Filename) + "}", doc.Filename }, // { "{Content}", doc.ToString() } // }; // return SolvePlaceholders(table, keepPlaceholders); // } // private Dictionary GetArticleDataTable(IDocument doc, ArticleData ad, bool keepPlaceholders = false) { // var table = new Dictionary() { // { "{" + nameof(ad.Language) + "}", ad.Language ?? "" }, // { "{" + nameof(ad.Authors) + "}", ad.Authors.Aggregate("; ")}, // { "{" + nameof(ad.Categories) + "}", ad.Categories.Aggregate("; ") }, // { "{" + nameof(ad.Version) + "}", ad.Version ?? "" }, // { "{" + nameof(ad.Description) + "}", ad.Description ?? "" }, // { "{" + nameof(ad.Name) + "}", ad.Name ?? "" }, // { "{" + nameof(doc.Filename) + "}", doc.Filename }, // { "{Content}", doc.ToString() } // }; // return SolvePlaceholders(table, keepPlaceholders); // } // private Dictionary SolvePlaceholders(Dictionary table, bool keepPlaceholders) { // if (keepPlaceholders) // return table.Select( // (x) => new KeyValuePair(x.Key, x.Value == "" ? $"{x.Key}" : x.Value)) // .ToDictionary(); // return table; // } // private string PlainPage(IDocument doc, bool keepPlaceholders = false) { // return Format(Templates.ContentPageTemplate, GetDocumentTable(doc, keepPlaceholders)); // } // private string ArticlePage(IDocument doc, ArticleData data, bool keepPlaceholders = false) { // return Format(Templates.ContentPageTemplate, GetArticleDataTable(doc, data, keepPlaceholders)); // } // public override byte[] ToBytes() { // throw new NotImplementedException(); // } // public override string ToString() { // throw new NotImplementedException(); // } // } //}