diff --git a/Beam.Fluent/DownloadBuilder.cs b/Beam.Fluent/DownloadBuilder.cs index 1f9ea71..fcb85b6 100644 --- a/Beam.Fluent/DownloadBuilder.cs +++ b/Beam.Fluent/DownloadBuilder.cs @@ -15,7 +15,7 @@ namespace Beam.Fluent { /// public static partial class DownloadBuilder { /* ──────────────────────────── Entry points ─────────────────────────── */ - + public static ILinkStage FromResource(DataKey dict, string kind, BeamDataContext beamDataDictionary) => Create(dict, beamDataDictionary, kind); diff --git a/Beam.Models/Public Concrete/ArticleData.cs b/Beam.Models/ArticleData.cs similarity index 100% rename from Beam.Models/Public Concrete/ArticleData.cs rename to Beam.Models/ArticleData.cs diff --git a/Beam.Models/Beam.Models.csproj b/Beam.Models/Beam.Models.csproj index 18e8640..9464a24 100644 --- a/Beam.Models/Beam.Models.csproj +++ b/Beam.Models/Beam.Models.csproj @@ -23,9 +23,4 @@ - - - - - diff --git a/Beam.Models/RelationTypes.cs b/Beam.Models/RelationTypes.cs new file mode 100644 index 0000000..dd1fb11 --- /dev/null +++ b/Beam.Models/RelationTypes.cs @@ -0,0 +1,8 @@ +using aeqw89.DataKeys; + +namespace Beam.Models; + +public class RelationTypes { + public static DataKey LinkTable => new DataKey("rel:toc"); + public static DataKey ArticleData => new DataKey("rel:articleData"); +} \ No newline at end of file diff --git a/Beam.Models/ResourceDefinition.cs b/Beam.Models/ResourceDefinition.cs new file mode 100644 index 0000000..d5d3e39 --- /dev/null +++ b/Beam.Models/ResourceDefinition.cs @@ -0,0 +1,27 @@ +using aeqw89.DataKeys; +using aeqw89.PersistentData; +using Beam.Abstractions; + +namespace Beam.Models; + +public class ResourceDefinition { + public required DataKey Key { get; init; } + + public required MetaData Meta { get; init; } + + /// Map of element name to extraction config. Keys must match ^[A-Za-z0-9_-]+$ + public required Table Elements { get; init; } + + /// Minimum 1 item; polymorphic segments discriminated by "type". + public required ILinkBuilder Url { get; init; } + + /// Keys must match ^[A-Za-z0-9_-]+$ + public required Table Relations { get; init; } + + public class MetaData { + public required string Name { get; init; } + public required string Author { get; init; } + public string? Description { get; init; } + public string? ProjectUrl { get; init; } + } +} \ No newline at end of file diff --git a/Beam.Models/ResourceRelation.cs b/Beam.Models/ResourceRelation.cs new file mode 100644 index 0000000..6eb884f --- /dev/null +++ b/Beam.Models/ResourceRelation.cs @@ -0,0 +1,8 @@ +using aeqw89.DataKeys; + +namespace Beam.Models; + +public class ResourceRelation { + public required DataKey Key { get; init; } + public required DataKey RelationType { get; init; } +} \ No newline at end of file diff --git a/Beam.Temporary.Cli/Beam.Temporary.Cli.csproj b/Beam.Temporary.Cli/Beam.Temporary.Cli.csproj deleted file mode 100644 index 0a29474..0000000 --- a/Beam.Temporary.Cli/Beam.Temporary.Cli.csproj +++ /dev/null @@ -1,42 +0,0 @@ - - - - Exe - net9.0 - enable - enable - - - - - - - - - - - - - - - - - - all - - - all - - - - - all - - - all - - - all - - - \ No newline at end of file diff --git a/Beam.Temporary.Cli/CssData.cs.obsolete b/Beam.Temporary.Cli/CssData.cs.obsolete deleted file mode 100644 index 18907ac..0000000 --- a/Beam.Temporary.Cli/CssData.cs.obsolete +++ /dev/null @@ -1,30 +0,0 @@ -//namespace Beam.Temporary.Cli { -// public class CssData { -// // Primary background color (e.g., for the body) -// public string PrimaryColor { get; set; } = "#f5f5f5"; - -// // Secondary color (e.g., for header background) -// public string SecondaryColor { get; set; } = "#e0e0e0"; - -// // Tertiary color (e.g., for content sections) -// public string TertiaryColor { get; set; } = "#ffffff"; - -// // Button background color -// public string ButtonColor { get; set; } = "#007bff"; - -// // Foreground text color -// public string ForegroundColor { get; set; } = "#333333"; - -// // Font family for main content -// public string ContentFont { get; set; } = "Arial, sans-serif"; - -// // Font size for main content -// public string ContentFontSize { get; set; } = "16px"; - -// // Font family for titles -// public string TitleFont { get; set; } = "Georgia, serif"; - -// // Font size for titles -// public string TitleFontSize { get; set; } = "32px"; -// } -//} diff --git a/Beam.Temporary.Cli/HtmlBook.cs.obsolete b/Beam.Temporary.Cli/HtmlBook.cs.obsolete deleted file mode 100644 index 19e8897..0000000 --- a/Beam.Temporary.Cli/HtmlBook.cs.obsolete +++ /dev/null @@ -1,132 +0,0 @@ -//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(); -// } - -// } -//} diff --git a/Beam.Temporary.Cli/HtmlBookTemplates.cs.obsolete b/Beam.Temporary.Cli/HtmlBookTemplates.cs.obsolete deleted file mode 100644 index 932e901..0000000 --- a/Beam.Temporary.Cli/HtmlBookTemplates.cs.obsolete +++ /dev/null @@ -1,8 +0,0 @@ -namespace Beam.Temporary.Cli { - internal struct HtmlBookTemplates { - public string TitlePageTemplate { get; set; } - public string ContentPageTemplate { get; set; } - public string CssTemplate { get; set; } - public string NoContentTemplate { get; set; } - } -} diff --git a/Beam.Temporary.Cli/NovelDefinitionBuilder.cs b/Beam.Temporary.Cli/NovelDefinitionBuilder.cs deleted file mode 100644 index 90af2c0..0000000 --- a/Beam.Temporary.Cli/NovelDefinitionBuilder.cs +++ /dev/null @@ -1,111 +0,0 @@ -// using aeqw89.DataKeys; -// using Beam.Dynamic; -// using System; -// using System.Collections.Generic; -// using System.Collections.Immutable; -// using System.Collections.ObjectModel; -// using System.Linq; -// using System.Text; -// using System.Threading.Tasks; -// using Beam.Data; -// using Beam.Fluent; -// using Beam.Models; - -/* - * MAJOR TODO FIX THIS MESS - */ - -// -// namespace Beam.Temporary.Cli { -// -// public record class ResourceDictionaryBuilder(string SiteKey) { -// private List> _builders; -// -// -// private record class WebResourceBuilder(string ResourceKey) { -// private Func