This commit is contained in:
qwsdcvghyu89
2025-09-27 13:37:40 +10:00
parent db9bdecea6
commit 13c6fbaf5f
23 changed files with 45 additions and 1295 deletions
-5
View File
@@ -23,9 +23,4 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Abstract\" />
<Folder Include="Closed Concrete\" />
</ItemGroup>
</Project> </Project>
+8
View File
@@ -0,0 +1,8 @@
using aeqw89.DataKeys;
namespace Beam.Models;
public class RelationTypes {
public static DataKey<object> LinkTable => new DataKey<object>("rel:toc");
public static DataKey<object> ArticleData => new DataKey<object>("rel:articleData");
}
+27
View File
@@ -0,0 +1,27 @@
using aeqw89.DataKeys;
using aeqw89.PersistentData;
using Beam.Abstractions;
namespace Beam.Models;
public class ResourceDefinition {
public required DataKey<ResourceDefinition> Key { get; init; }
public required MetaData Meta { get; init; }
/// <summary>Map of element name to extraction config. Keys must match ^[A-Za-z0-9_-]+$</summary>
public required Table<IDataProvider> Elements { get; init; }
/// <summary>Minimum 1 item; polymorphic segments discriminated by "type".</summary>
public required ILinkBuilder Url { get; init; }
/// <summary>Keys must match ^[A-Za-z0-9_-]+$</summary>
public required Table<ResourceRelation> 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; }
}
}
+8
View File
@@ -0,0 +1,8 @@
using aeqw89.DataKeys;
namespace Beam.Models;
public class ResourceRelation {
public required DataKey<ResourceDefinition> Key { get; init; }
public required DataKey<object> RelationType { get; init; }
}
@@ -1,42 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="HtmlBook.cs.obsolete" />
<Compile Include="HtmlBookTemplates.cs.obsolete" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="aeqw89.DataKeys" Version="2.0.1" />
<PackageReference Include="aeqw89.PersistentData" Version="1.3.3" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
<PackageReference Include="OpenAI" Version="2.1.0" />
<PackageReference Include="Spectre.Console" Version="0.49.2-preview.0.70" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Beam.Dynamic\Beam.Dynamic.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
<ProjectReference Include="..\Beam.Exports\Beam.Exports.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
<ProjectReference Include="..\Beam.Fluent\Beam.Fluent.csproj" />
<ProjectReference Include="..\Beam.Models\Beam.Models.csproj" />
<ProjectReference Include="..\Beam.Playwright\Beam.Playwright.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
<ProjectReference Include="..\Beam.Stealth\Beam.Stealth.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
<ProjectReference Include="..\Beam\Beam.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
</ItemGroup>
</Project>
-30
View File
@@ -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";
// }
//}
-132
View File
@@ -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<File> ContentPage => new DataKey<File>("content_page");
// public static DataKey<File> NoContentPage => new DataKey<File>("no_content_page");
// public static DataKey<File> TitlePage => new DataKey<File>("title_page");
// public static DataKey<File> StylesPage => new DataKey<File>("styles_page");
// }
// public List<Tracked<IDocument>> Documents { get; set; }
// public IReadOnlyList<string> Pages => _Pages;
// private List<string> _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<IDocument>? 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<IDocument>(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<string> 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<string, string> table) {
// ArgumentNullException.ThrowIfNull(template);
// ArgumentNullException.ThrowIfNull(table);
// foreach (var kvp in table) {
// template = template.Replace(kvp.Key, kvp.Value);
// }
// return template;
// }
// private Dictionary<string, string> GetDocumentTable(IDocument doc, bool keepPlaceholders = false) {
// var table = new Dictionary<string, string>() {
// { "{" + nameof(doc.Filename) + "}", doc.Filename },
// { "{Content}", doc.ToString() }
// };
// return SolvePlaceholders(table, keepPlaceholders);
// }
// private Dictionary<string, string> GetArticleDataTable(IDocument doc, ArticleData ad, bool keepPlaceholders = false) {
// var table = new Dictionary<string, string>() {
// { "{" + 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<string, string> SolvePlaceholders(Dictionary<string, string> table, bool keepPlaceholders) {
// if (keepPlaceholders)
// return table.Select(
// (x) => new KeyValuePair<string, string>(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();
// }
// }
//}
@@ -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; }
}
}
@@ -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<Func<WebResourceBuilder>> _builders;
//
//
// private record class WebResourceBuilder(string ResourceKey) {
// private Func<Template> _template;
// private Func<IReadOnlyDictionary<DataKey<DataBindings>, DataBindings>> _bindings;
// private string _name;
// private string _description;
// private Uri _domain;
//
// }
//
// private record class ResourceDictionaryRegistrar(
// string SiteKey,
// string FriendlyName,
// IEnumerable<WebResource> Resources,
// IReadOnlyDictionary<string, Template> Templates,
// IReadOnlyDictionary<string, DataBindings> Bindings) : IResourceDictionaryRegistrar {
//
// private Dictionary<string, ImmutableState> _states;
//
// public IResourceDictionaryRegistrar AddInitialState(string key, ImmutableState state) {
// _states[key] = state;
// return this;
// }
//
// public void Register(BeamDataContext sdd) {
// foreach (var resource in Resources)
// sdd.Resources.TryAdd(resource.Key, resource);
// // foreach (var template in Templates)
// // sdd.Templates.TryAdd(new DataKey<WebResource>(template.Key), template.Value);
// foreach (var binding in Bindings)
// sdd.Bindings.TryAdd(new DataKey<DataBindings>(binding.Key), binding.Value);
// foreach (var state in _states)
// sdd.InitialStates.TryAdd(new DataKey<ImmutableState>(state.Key), state.Value);
//
// sdd.ResourceDictionaries.TryAdd(new DataKey<ResourceDictionary>(SiteKey), new ResourceDictionary() {
// Key = new DataKey<ResourceDictionary>(SiteKey),
// FriendlyName = FriendlyName,
// InitialStates =
// });
// }
// }
// }
//
// public interface IResourceDictionaryRegistrar {
// public IResourceDictionaryRegistrar AddInitialState(string key, ImmutableState state);
// public void Register(BeamDataContext sdd);
// }
//
// public interface IBindingsBuilder {
// public IBindingsBuilder AddBinding(DataBindings bindings);
// public IBindingsBuilder AddBinding(Action<DataBindings> configure);
// public IReadOnlyDictionary<DataKey<DataBindings>, DataBindings> Build();
// }
//
// public interface IResourceDictionaryBuilder {
// public IResourceDictionaryBuilder AddResource(Func<ITemplateBuilderStage, IWebResourceBuilderStage> configure);
// public IResourceDictionaryBuilder WithResources(Func<ITemplateBuilderStage, IWebResourceBuilderStage>[] configure);
// public IResourceDictionaryBuilder WithFriendlyName(string friendlyName);
// public IResourceDictionaryRegistrar Then();
// }
//
// public interface IWebResourceBuilderStage {
// public IWebResourceBuilderStage WithName(string name); // Stage 3
// public IWebResourceBuilderStage WithDescription(string description); // Stage 3
// public IWebResourceBuilderStage WithDomain(Uri domain); // Stage 3
// public WebResource Build();
// }
//
// public interface IBindingBuilderStage {
// public IWebResourceBuilderStage WithBindings(Action<IBindingsBuilder> configure);
// public IWebResourceBuilderStage WithBindings(IReadOnlyDictionary<DataKey<DataBindings>, DataBindings> bindings);
// }
//
// public interface ITemplateBuilderStage {
// public IBindingBuilderStage WithTemplate(Action<ITemplateBuilder> configure);
// public IBindingBuilderStage WithTemplate(Template template);
// }
//
// public interface ITemplateBuilder {
// public ITemplateBuilder WithFactory(StateChangerFactory factory);
// public ITemplateBuilder WithUrlBuilder(LinkBuilder builder);
// public ITemplateBuilder WithUrlBuilder(Action<LinkBuilder> configure);
// public Template Build();
// }
//
// }
-520
View File
@@ -1,520 +0,0 @@
//
//
// using aeqw89.DataKeys;
// using Beam.Dynamic;
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Runtime.CompilerServices;
// using System.Text;
// using System.Threading.Tasks;
// using Beam.Data;
// using Beam.Fluent;
// using Beam.Models;
// using Beam.Models.Public_Concrete;
//
// namespace Beam.Temporary.Cli {
//
// public static class NovelStatics {
// //public static void Define_LightNovelWorld_Novel_TheLegendaryMechanic(SharedDataDictionary sdd) {
// // var lnwAggregator = new DataKey<WebResource>("aeqw89:document:aggregators:light_novel_world");
// // var lnwAuxiliary = new DataKey<WebResource>("aeqw89:document:auxillaries:light_novel_world");
// // var novel = new TextResource() {
// // Key = new DataKey<TextResource>("novels:the_legendary_mechanic"),
// // AssociatedSource = lnwAggregator,
// // AssociatedMetaSource = lnwAuxiliary,
// // TemplateInitialData = ["the-legendary-mechanic-245", "1"],
// // MetaTemplateInitialData = ["the-legendary-mechanic"]
// // };
// // sdd.Novels.TryAdd(novel.Key, novel);
//
// // sdd.AggregatorNovels.TryAdd(lnwAggregator, [novel.Key]);
// //}
//
// //public static void Define_LightNovelWorl_Novel_IAloneLevelUp(SharedDataDictionary sdd) {
// // var lnwAggregator = new DataKey("light_novel_world").ToAggregator().As<WebResource>();
// // var lnwAuxiliary = new DataKey("light_novel_world").ToAuxiliary().As<WebResource>();
// // var novel = new TextResource() {
// // Key = new DataKey<TextResource>("novels:i_alone_level_up"),
// // AssociatedSource = lnwAggregator,
// // AssociatedMetaSource = lnwAuxiliary,
// // TemplateInitialData = ["i-alone-level-up-236", "1"],
// // MetaTemplateInitialData = ["i-alone-level-up-solo-leveling-05122225"]
// // };
//
// // sdd.Novels.TryAdd(novel.Key, novel);
//
// // sdd.AggregatorNovels.TryAdd(lnwAggregator, [novel.Key]);
// //}
//
// //// -----------------------------------------------------------------------------
// //// Helper: same as in the WoDuShu file
// //private static (DataKey<T>, DataKey<T>) CreateKeyPair<T>(
// // string pref1, string pref2, string common, string @namespace) {
// // return (
// // new DataKey<T>($"{pref1}:{common}").WithNamespace(@namespace),
// // new DataKey<T>($"{pref2}:{common}").WithNamespace(@namespace)
// // );
// //}
//
// // -----------------------------------------------------------------------------
// // 1) Site-wide definition YeBiQuge (m.yebiquge.com)
// public static void Define_YeBiQuge(BeamDataContext sdd) {
// // ---------- keys ----------
// var yb = new DataKey<WebResource>("aeqw89:yebiquge");
//
// var bindings = new DataKey<DataBindings>($"aeqw89:yebiquge:{nameof(IDocument).ToLower()}:bindings");
// var bindings_info = new DataKey<DataBindings>($"aeqw89:yebiquge:{nameof(ArticleData).ToLower()}:bindings");
// var bindings_toc = new DataKey<DataBindings>($"aeqw89:yebiquge:{nameof(TableOfContentsData).ToLower()}:bindings");
//
// // ---------- web resources ----------
// var aggregator = new WebResource(yb.InsertEnd(nameof(IDocument).ToLower())) {
// Name = "YeBiQuge Chapters",
// Description = "Chapter pages (mobile)",
// Domain = "https://m.yebiquge.com",
// Bindings = bindings
// };
//
// var bookInfo = new WebResource(yb.InsertEnd(nameof(ArticleData).ToLower())) {
// Name = "YeBiQuge Book Info",
// Description = "Book information / latest updates page",
// Domain = "https://m.yebiquge.com",
// Bindings = bindings_info
// };
//
// var tocPage = new WebResource(yb.InsertEnd(nameof(TableOfContentsData).ToLower())) {
// Name = "YeBiQuge TOC",
// Description = "Full chapter list (index*.html)",
// Domain = "https://m.yebiquge.com",
// Bindings = bindings_toc
// };
//
// sdd.Resources.TryAdd(aggregator.Key, aggregator);
// sdd.Resources.TryAdd(bookInfo.Key, bookInfo);
// sdd.Resources.TryAdd(tocPage.Key, tocPage);
//
// // ---------- URL templates ----------
// // 1-a) Chapter page /{catId}/{bookId}/{chapterId}.html
// sdd.Templates.TryAdd(aggregator.Key, new() {
// Factory = new(StateChangerFactory.LastAsNumber),
// Builder = new LinkBuilder("m.yebiquge.com")
// .WithSegments("", "", "") // /<cat>/<book>/<chap>
// .WithParameters(0, "")
// .WithParameters(1, "")
// .WithParameters(2, (".html", Position.After)) // chapId.html
// });
//
// // 1-b) Book-info page /{catId}/{bookId}/
// sdd.Templates.TryAdd(bookInfo.Key, new() {
// Factory = new(StateChangerFactory.Constant),
// Builder = new LinkBuilder("m.yebiquge.com")
// .WithSegments("", "") // /<cat>/<book>/
// .WithParameters(0, "")
// .WithParameters(1, "")
// });
//
// // 1-c) TOC page /{catId}/{bookId}/index.html (first page)
// sdd.Templates.TryAdd(tocPage.Key, new() {
// Factory = new(StateChangerFactory.Constant),
// Builder = new LinkBuilder("m.yebiquge.com")
// .WithSegments("", "", "index.html") // /<cat>/<book>/index.html
// .WithParameters(0, "")
// .WithParameters(1, "")
// });
//
// // ---------- bindings ----------
// // ── chapter page ────────────────────────────────────────────────
// sdd.Bindings.Add(bindings, new() {
// Title = new ContentsDataProvider {
// Content = new Binding { XPath = "//*[@id='nr_title']" }
// },
// Content = new ParagraphedContentDataProvider {
// Content = new Binding { XPath = "//*[@id='chaptercontent']" }
// },
// });
//
// // ── book-info page ──────────────────────────────────────────────
// sdd.Bindings.Add(bindings_info, new() {
// Title = new ContentsDataProvider {
// Content = new Binding { XPath = "//div[@class='book_info']//dt[@class='name']" }
// },
// Authors = new ContentsArrayDataProvider {
// Content = new Binding {
// XPath = "//div[@class='book_info']//span[contains(text(),'作者')]"
// }
// },
// Description = new ParagraphedContentDataProvider {
// Content = new Binding { XPath = "//div[@class='book_about']/dl/dd" }
// }
// });
//
// // ── TOC page ────────────────────────────────────────────────────
// sdd.Bindings.Add(bindings_toc, new() {
// PagesDropDown = new DropDownDataProvider {
// Content = new Binding { XPath = "//div[@class='fenye']//select" },
// RelativeTo = tocPage.Domain
// },
// TableOfContents = new AnchorCollectionDataProvider {
// Content = new Binding { XPath = "//div[@class='book_last']/dl" },
// RelativeTo = tocPage.Domain
// }
// });
// }
//
// // -----------------------------------------------------------------------------
// // 2) Concrete novel 《诡秘之主》 / Lord of the Mysteries
// public static void Define_YeBiQuge_LordOfMysteries(BeamDataContext sdd) {
// var yb = new DataKey<WebResource>("aeqw89:yebiquge:novels:lord_of_the_mysteries");
// var ybAgg = yb.InsertEnd(nameof(IDocument).ToLower());
// var ybInfo = yb.InsertEnd(nameof(ArticleData).ToLower());
// var ybToc = yb.InsertEnd(nameof(TableOfContentsData).ToLower());
//
// var novel = new ResourceDictionary {
// Key = yb.To<ResourceDictionary>(),
// FriendlyName = "Lord of the Mysteries",
// Resources = {
// { nameof(IDocument) , ybAgg }, // chapters
// { nameof(ArticleData) , ybInfo }, // book info
// { nameof(TableOfContentsData), ybToc } // full TOC
// },
//
// // catId = 2 , bookId = 2958 , sample chapterId = 8699808
// InitialStates = new Dictionary<DataKey<WebResource>, ImmutableState> {
// { ybAgg, new ImmutableState(["2","2958","8699808"]) },
// { ybInfo, new ImmutableState(["2","2958"]) },
// { ybToc, new ImmutableState(["2","2958"]) },
// }
// };
//
// sdd.ResourceDictionaries.TryAdd(novel.Key, novel);
// sdd.AggregatorNovels.TryAdd(ybAgg, [novel.Key]);
// }
//
//
// // -----------------------------------------------------------------------------
// // 1) Site-wide definition KuaiShu5 (www.kuaishu5.com)
// public static void Define_KuaiShu5(BeamDataContext sdd) {
// // ---------- keys ----------
// var ks = new DataKey<WebResource>("aeqw89:kuaishu5");
//
// var bindings_chapter = new DataKey<DataBindings>($"aeqw89:kuaishu5:{nameof(IDocument).ToLower()}:bindings");
// var bindings_info = new DataKey<DataBindings>($"aeqw89:kuaishu5:{nameof(ArticleData).ToLower()}:bindings");
// var bindings_toc = new DataKey<DataBindings>($"aeqw89:kuaishu5:{nameof(TableOfContentsData).ToLower()}:bindings");
//
// // ---------- web resources ----------
// var chapters = new WebResource(ks.InsertEnd(nameof(IDocument).ToLower())) {
// Name = "KuaiShu5 Chapters",
// Description = "Chapter pages",
// Domain = "https://www.kuaishu5.com",
// Bindings = bindings_chapter
// };
//
// var bookInfo = new WebResource(ks.InsertEnd(nameof(ArticleData).ToLower())) {
// Name = "KuaiShu5 Book Info",
// Description = "Book information / landing page",
// Domain = "https://www.kuaishu5.com",
// Bindings = bindings_info
// };
//
// var tocPage = new WebResource(ks.InsertEnd(nameof(TableOfContentsData).ToLower())) {
// Name = "KuaiShu5 TOC",
// Description = "Full chapter list (index page)",
// Domain = "https://www.kuaishu5.com",
// Bindings = bindings_toc
// };
//
// sdd.Resources.TryAdd(chapters.Key, chapters);
// sdd.Resources.TryAdd(bookInfo.Key, bookInfo);
// sdd.Resources.TryAdd(tocPage.Key, tocPage);
//
// // ---------- URL templates ----------
// // 1-a) Chapter page /b{bookId}/{chapterId}.html
// sdd.Templates.TryAdd(chapters.Key, new() {
// Factory = new(StateChangerFactory.LastAsNumber),
// Builder = new LinkBuilder("www.kuaishu5.com")
// .WithSegments("", "") // /<seg0>/<seg1>
// .WithParameters(0, ("b", Position.Before)) // seg0: b{bookId}
// .WithParameters(1, (".html", Position.After)) // seg1: {chapterId}.html
// });
//
// // 1-b) Book-info page /b{bookId}/
// sdd.Templates.TryAdd(bookInfo.Key, new() {
// Factory = new(StateChangerFactory.Constant),
// Builder = new LinkBuilder("www.kuaishu5.com")
// .WithSegments("") // /<seg0>
// .WithParameters(0, ("b", Position.Before)) // seg0: b{bookId}
// });
//
// // 1-c) TOC page /b{bookId}/ (same as book-info)
// sdd.Templates.TryAdd(tocPage.Key, new() {
// Factory = new(StateChangerFactory.Constant),
// Builder = new LinkBuilder("www.kuaishu5.com")
// .WithSegments("") // /<seg0>
// .WithParameters(0, ("b", Position.Before)) // seg0: b{bookId}
// });
//
// // ---------- bindings ----------
// // ── chapter page ────────────────────────────────────────────────
// sdd.Bindings.Add(bindings_chapter, new() {
// Title = new ContentsDataProvider {
// Content = new Binding { XPath = "//h1[@class='bookname']" }
// },
// Content = new ParagraphedContentDataProvider {
// Content = new Binding { XPath = "//*[@id='booktxt']" }
// }
// });
//
// // ── book-info page ──────────────────────────────────────────────
// sdd.Bindings.Add(bindings_info, new() {
// Title = new ContentsDataProvider {
// Content = new Binding { XPath = "//*[@id='info']/h1" }
// },
// Authors = new ContentsArrayDataProvider {
// Content = new Binding {
// XPath = "//*[@id='info']//p[contains(text(),'作者')]/a"
// }
// },
// Description = new ParagraphedContentDataProvider {
// Content = new Binding { XPath = "//*[@id='intro']" }
// }
// });
//
// // ── TOC page ────────────────────────────────────────────────────
// sdd.Bindings.Add(bindings_toc, new() {
// PagesDropDown = new DropDownDataProvider {
// Content = new Binding { XPath = "//*[@id='indexselect']" },
// RelativeTo = tocPage.Domain
// },
// TableOfContents = new AnchorCollectionDataProvider {
// Content = new Binding { XPath = "//*[@id='content_1']" },
// RelativeTo = tocPage.Domain
// }
// });
// }
//
// // -----------------------------------------------------------------------------
// // 2) Concrete novel 《诡秘之主》 / Lord of the Mysteries
// public static void Define_KuaiShu5_LordOfMysteries(BeamDataContext sdd) {
// var ks = new DataKey<WebResource>("aeqw89:kuaishu5");
// var ksChapters = ks.InsertEnd(nameof(IDocument).ToLower());
// var ksInfo = ks.InsertEnd(nameof(ArticleData).ToLower());
// var ksToc = ks.InsertEnd(nameof(TableOfContentsData).ToLower());
//
// var novel = new ResourceDictionary {
// Key = new DataKey<ResourceDictionary>("kuaishu5:novels:lord_of_the_mysteries"),
// FriendlyName = "Lord of the Mysteries",
// Resources =
// {
// { nameof(IDocument) , ksChapters },
// { nameof(ArticleData) , ksInfo },
// { nameof(TableOfContentsData), ksToc }
// }
// };
//
// // bookId = 122722 , sample chapterId = 288372
// sdd.InitialStates = new Dictionary<DataKey<ImmutableState>, ImmutableState>
// {
// { ksChapters.To<ImmutableState>(), new ImmutableState(["122722", "288372"]) },
// { ksInfo .To<ImmutableState>(), new ImmutableState(["122722"]) },
// { ksToc .To<ImmutableState>(), new ImmutableState(["122722"]) }
// };
//
// sdd.ResourceDictionaries.TryAdd(novel.Key, novel);
// sdd.AggregatorNovels.TryAdd(ksChapters, [novel.Key]);
// }
// //public static void Define_WoDuShu_HouseOfHorrors(BeamDataDictionary sdd) {
// // var (wdsAgg, wdsAux) = CreateKeyPair<WebResource>("aggregators", "auxillaries", "wodushu", "aeqw89:document");
// // var novel = new ResourceDictionary() {
// // Key = new DataKey<ResourceDictionary>("novels:house_of_horrors"),
// // FriendlyName = "My House Of Horrors",
// // AssociatedSource = wdsAgg,
// // AssociatedMetaSource = wdsAux,
// // TemplateInitialData = new ImmutableState(["24349", "2896325"]),
// // MetaTemplateInitialData = new ImmutableState(["24349"])
// // };
//
// // sdd.ResourceDictionaries.TryAdd(novel.Key, novel);
//
// // sdd.AggregatorNovels.TryAdd(wdsAgg, [novel.Key]);
// //}
//
// private static (DataKey<T>, DataKey<T>) CreateKeyPair<T>(string pref1, string pref2, string common, string @namespace) {
// return (
// new DataKey<T>(pref1 + ":" + common).InsertStart(@namespace),
// new DataKey<T>(pref2 + ":" + common).InsertStart(@namespace)
// );
// }
//
// //public static void Define_WoDuShu(BeamDataDictionary sdd) {
// // var (wdsAgg, wdsAux) = CreateKeyPair<WebResource>("aggregators", "auxillaries", "wodushu", "aeqw89:document");
// // var bindings = new DataKey<DataBindings>("aeqw89:bindings:wodushu");
// // var aggregator = new WebResource(wdsAgg) {
// // Name = "WoDuShu.com",
// // Description = "A Chinese novel aggregator site",
// // Domain = "https://wodushu.com",
// // Bindings = bindings
// // };
// // var auxiliary = new WebResource(wdsAux) {
// // Name = "WoDuShu.com",
// // Description = "A Chinese novel aggregator site",
// // Domain = "https://wodushu.com",
// // Bindings = bindings.WithSuffix("_aux")
// // };
//
// // sdd.Templates.TryAdd(wdsAgg, new() {
// // Factory = new(StateChangerFactory.LastAsNumber),
// // Builder = new SourceLinkBuilder("www.wodushu.com")
// // .WithSegments("read", "", "")
// // .WithParameters(1, "")
// // .WithParameters(2, (".html", Position.After))
// // });
// // sdd.Templates.TryAdd(wdsAux, new() {
// // Factory = new(StateChangerFactory.Constant),
// // Builder = new SourceLinkBuilder("www.wodushu.com")
// // .WithSegments("book", "")
// // .WithParameters(1, "")
// // });
//
// // sdd.Resources.TryAdd(wdsAgg, aggregator);
// // sdd.Auxillaries.TryAdd(wdsAux, auxiliary);
//
// // var binding_agg = new DataKey<DataBindings>("aeqw89:bindings:wodushu");
// // var binding_aux = new DataKey<DataBindings>("aeqw89:bindings:wodushu_aux");
//
// // sdd.Bindings.Add(binding_agg, new() {
// // Title = new ContentsDataProvider() {
// // Content = new Binding() {
// // XPath = "/html/body/div[4]/div/div/div[2]/h1"
// // }
// // },
//
// // Content = new ParagraphedContentDataProvider() {
// // Content = new Binding() {
// // XPath = "//*[@id=\"content\"]"
// // }
// // },
// // });
//
// // sdd.Bindings.Add(binding_aux, new() {
// // Title = new ContentsDataProvider() {
// // Content = new Binding() {
// // XPath = "/html/body/div[3]/div[1]/div/div/div[2]/div[1]/h1"
// // }
// // },
// // Authors = new ContentsArrayDataProvider() {
// // Content = new Binding() {
// // XPath = "/html/body/div[3]/div[1]/div/div/div[2]/div[1]/div/p[1]/a"
// // }
// // },
// // Description = new ParagraphedContentDataProvider() {
// // Content = new Binding() {
// // XPath = "/html/body/div[3]/div[1]/div/div/div[2]/div[2]"
// // }
// // },
// // });
// //}
//
// //public static void Define_NovelFull(SharedDataDictionary sdd) {
// // var docNamespace = "aeqw89:document";
// // var nfAgg = new DataKey<WebResource>("aggregators:novel_full").WithNamespace(docNamespace);
// // var nfAux = new DataKey<WebResource>("auxillaries:novel_full").WithNamespace(docNamespace);
// // var nfBindings = new DataKey<DataBindings>("aeqw89:bindings:light_novel_world");
// // var aggregator = new WebResource(nfAgg) {
// // Name = "Novel Full",
// // Description = "A novel aggregator site",
// // Domain = "https://novelfull.net",
// // Bindings = nfBindings
// // };
// // var auxiliary = new WebResource(nfAux) {
// // Name = "Novel Full",
// // Description = "A novel aggregator site",
// // Domain = "https://novelfull.net",
// // Bindings = nfBindings.WithSuffix("_aux")
// // };
//
// // sdd.Templates.TryAdd(nfAux, new(StateChangerFactory.LastAsNumberPrefixed));
//
// // sdd.Aggregators.TryAdd(nfAgg, aggregator);
// // sdd.Auxillaries.TryAdd(nfAux, auxiliary);
//
// // var binding_agg = new DataKey<DataBindings>("aeqw89:bindings:be")
//
// //}
//
// //public static void Define_LightNovelWorld(SharedDataDictionary sdd) {
// // var lnwAggregator = new DataKey<WebResource>("aeqw89:document:aggregators:light_novel_world");
// // var lnwAuxiliary = new DataKey<WebResource>("aeqw89:document:auxillaries:light_novel_world");
// // const string lnwBindingsA = "aeqw89:bindings:light_novel_world";
// // var aggregator = new WebResource(lnwAggregator) {
// // Name = "Light Novel World",
// // Description = "A novel aggregator site maintained by NetherClaw",
// // Domain = "https://www.lightnovelworld.co",
// // Bindings = new DataKey<DataBindings>(lnwBindingsA)
// // };
// // const string lnwBindingsB = "aeqw89:bindings:light_novel_world_aux";
// // var auxiliary = new WebResource(lnwAuxiliary) {
// // Name = "Light Novel World",
// // Description = "A novel aggregator site maintained by NetherClaw",
// // Domain = "https://www.lightnovelworld.co",
// // Bindings = new DataKey<DataBindings>(lnwBindingsB)
// // };
//
// // sdd.Templates.TryAdd(lnwAuxiliary, new() {
// // Template = "https://www.lightnovelworld.co/novel/{0}",
// // IndexOfChapterIndex = -1
// // });
// // sdd.Templates.TryAdd(lnwAggregator, new() {
// // Template = "https://www.lightnovelworld.co/novel/{0}/chapter-{1}",
// // IndexOfChapterIndex = 1
// // });
//
// // sdd.Aggregators.TryAdd(aggregator.Key, aggregator);
// // sdd.Auxillaries.TryAdd(auxiliary.Key, auxiliary);
//
// // var lnwBindings = new DataKey<DataBindings>(lnwBindingsA);
// // var lnwBindingsAux = new DataKey<DataBindings>(lnwBindingsB);
// // sdd.Bindings.TryAdd(lnwBindings, new DataBindings() {
// // Title = new Binding("aeqw89:binding:light_novel_world:title") {
// // XPath = "/html/body/main/article/section/div[1]/h1/span[2]",
// // Type = BindingType.Single
// // },
// // Content = new("aeqw89:binding:light_novel_world:content") {
// // Provider = new ParagraphedContentDataProvider() {
// // Content = new Binding() {
// // XPath = "//*[@id=\"chapter-container\"]"
// // }
// // },
// // Type = BindingType.UseProvider
// // },
// // });
// // sdd.Bindings.TryAdd(lnwBindingsAux, new DataBindings() {
// // Title = new("aeqw89:binding:light_novel_world_aux:title") {
// // XPath = "/html/body/main/article/header/div[2]/div[2]/div[1]/h1",
// // Type = BindingType.Single
// // },
// // Authors = new("aeqw89:binding:light_novel_world_aux:authors") {
// // XPath = "/html/body/main/article/header/div[2]/div[2]/div[1]/div[1]/a",
// // Type = BindingType.Single
// // },
// // Description = new("aeqw89:binding:light_novel_world_aux:description") {
// // Provider = new ParagraphedContentDataProvider() {
// // Content = new() {
// // XPath = "/html/body/main/article/div/section/div[1]/div"
// // }
// // },
// // Type = BindingType.UseProvider
// // },
// // Tags = new("aeqw89:binding:light_novel_world_aux:tags") {
// // Provider = new ListContentDataProvider() {
// // Content = new() {
// // XPath = "/html/body/main/article/header/div[2]/div[2]/div[3]/ul"
// // }
// // },
// // Type = BindingType.UseProvider
// // }
// // });
// //}
//
//
// }
// }
-230
View File
@@ -1,230 +0,0 @@
// using aeqw89.PersistentData;
// using aeqw89.DataKeys;
// using Beam.Dynamic;
// using HtmlAgilityPack;
// using Microsoft.Extensions.DependencyInjection;
// using Microsoft.Extensions.Logging;
// using System.Text.Json;
// using System.Text.Json.Serialization;
// using System.Text.Json.Serialization.Metadata;
// using Beam.Temporary.Cli.Templates.Classic;
// using Beam.Exports;
// using System.Diagnostics;
// using Beam.Models;
// using Beam.Models.Public_Concrete;
// using Beam.Stealth;
namespace Beam.Temporary.Cli {
internal class Program {
//
// public static JsonSerializerOptions ConversionOptions { get; internal set; } = new();
//
// public static BeamDataContext BeamData { get; set; } = [];
//
// public static IArchitecture Architecture = IArchitecture.Default;
//
// const string BeamDataPath = "data/.dat";
static async Task Main(string[] args) {
// ConversionOptions.Converters.AddPersistentDataRequiredConverters();
// ConversionOptions.WriteIndented = true;
//
// var web = new HtmlWeb();
//
// var lf = LoggerFactory.Create((x) => x
// .AddConsole()
// .SetMinimumLevel(LogLevel.Trace)
// );
//
// ILogger logger = lf
// .CreateLogger("Program");
//
// await using var sharedContext = await DataDictionaryContext<BeamDataContext>.Create(
// BeamDataPath,
// false,
// DataKind.Shared,
// logger,
// ConversionOptions
// );
//
// BeamData = sharedContext.Data;
//
// BeamData.Clear();
// NovelStatics.Define_YeBiQuge(BeamData);
// NovelStatics.Define_YeBiQuge_LordOfMysteries(BeamData);
// NovelStatics.Define_KuaiShu5(BeamData);
// NovelStatics.Define_KuaiShu5_LordOfMysteries(BeamData);
// ClassicTemplates.Register(BeamData);
//
// await sharedContext.ForceSave();
// BeamData = sharedContext.Data; // need to refresh instance after forced save!
//
// CancellationTokenSource cts = new();
//
// using var config = StealthConfig.Create(true, null, TimeSpan.FromMinutes(2), Browser.Chrome, lf.CreateLogger<StealthConfig>());
// var unit = new StealthUnitPageDownloader<HtmlDocument>(new(), config, (x) => {
// return Task.CompletedTask;
// }, x => Task.FromResult(x));
//
// var (success, result) = await unit.TryDownload([new("https://duckduckgo.com/?t=ffab&q=C%23+stealth+headless+browser&ia=web", 0)], default);
// if (success)
// logger?.LogInformation("Success! Downloaded '{}'", result?.DocumentNode.Name);
// else
// logger?.LogError("Failed to download!");
//
// Console.WriteLine(result?.DocumentNode.OuterHtml);
//
// //var novelResDict = new DataKey<ResourceDictionary>("kuaishu5:novels:lord_of_the_mysteries");
//
// //var metadata2 = await DownloadBuilder<HtmlDocument, TableOfContentsData>.FromResource(novelResDict, nameof(TableOfContentsData), BeamData)
// // .WithLink()
// // .WithTransformer(CommonTransformers.TableOfContentsTransformer)
// // .Configure((x) => x
// // .WithDownloadLogger(logger)
// // .WithRetryReporter(new Progress<RetryReport>())
// // .WithTimeOut(TimeSpan.FromSeconds(15)))
// // .Build()
// // .FirstAsync();
//
// //if (metadata2.Data.PagesLinks is null || metadata2.Data.PagesLinks.Length == 0)
// // Debugger.Break();
//
// //var pageLinks = DownloadBuilder<HtmlDocument, TableOfContentsData>.FromScratch()
// // .WithLinks(metadata2.Data.PagesLinks)
// // .WithTransformer(CommonTransformers.TableOfContentsTransformer(BeamData.Bindings[BeamData.Resources[BeamData.ResourceDictionaries[novelResDict].Resources[nameof(TableOfContentsData)]].Bindings]))
// // .Configure(x => x
// // .WithDownloadLogger(logger)
// // .WithRetryReporter(new Progress<RetryReport>())
// // .WithTimeOut(TimeSpan.FromSeconds(15)))
// // .Build();
//
// //var links = (await pageLinks
// // .ToListAsync())
// // .Where(x => x?.Data?.ContentLinks is not null)
// // .SelectMany(x => x.Data.ContentLinks!)
// // .DistinctBy(x => x.Link.AbsoluteUri);
//
// //var downloader = DownloadBuilder<HtmlDocument, StringDocument>.FromScratch()
// // .WithLinks(links)
// // .WithTransformer(CommonTransformers.DocumentTransformer(BeamData.Bindings[BeamData.Resources[BeamData.ResourceDictionaries[novelResDict].Resources[nameof(IDocument)]].Bindings]))
// // .Configure(x => x
// // .WithDownloadLogger(logger)
// // .WithRetryReporter(new Progress<RetryReport>(x => logger?.LogWarning("Retrying download {} for the {} time", x.Link, x.TryNumber)))
// // .WithTimeOut(TimeSpan.FromSeconds(15)))
// // .WithParallelism(4)
// // .UseFragments()
// // .Build();
//
// //HashSet<Ordered<StringDocument>> downloaded = [];
// //try {
// // await foreach (var download in downloader) {
// // logger?.LogInformation("Downloaded chapter with order={}", download.Order);
// // try {
// // downloaded.Add(download);
// // } catch (Exception e) {
// // logger?.LogError(e, "Unknown error occurred");
// // }
// // }
// //} catch (Exception e) {
// // logger?.LogError(e, "Uncaught error detected!");
// //} finally {
// // logger?.LogInformation("Done with loop, downloaded {}", downloaded.Count);
// // try {
// // string serialized = JsonSerializer.Serialize(downloaded.Select(x => new { x.Order, x.Data.Content, x.Data.MetaData }).ToArray(), ConversionOptions);
// // System.IO.File.WriteAllText("lordOfTheMysteries.json", serialized);
// // } catch (Exception e) {
// // logger?.LogInformation(e, "Failed to serialize chapters");
// // }
// //}
//
// //var downloader2 = DownloadBuilder<HtmlDocument, IDocument>.FromText(novel, BeamData)
// // .WithRange(1..5)
// // .WithLinkGenerator()
// // .WithTransformer((x) => CommonTransformers.DocumentTransformer(x, metadata2.Data))
// // .Configure((x) => x
// // .WithDownloadLogger(logger)
// // .WithDownloadReporter(new Progress<DownloadReport>((x) => logger.LogInformation(x.ToString())))
// // .WithTimeOut(TimeSpan.FromSeconds(15))
// // )
// // .Build();
//
//
//
// //List<Task<Ordered<IDocument>>> translationTasks = [];
// //List<Ordered<IDocument>> documents = [];
//
// //await foreach (var download in downloader2.Take(10)) {
// // if (!download.Data.MetaData.TryGetValue(Architecture.ChapterKey, out var meta))
// // continue;
// // if (meta is not ArticleData articleMetaData)
// // continue;
// // if (!download.Data.MetaData.TryGetValue(Architecture.BookKey, out var bookmeta))
// // continue;
// // if (meta is not ArticleData bookMetaData)
// // continue;
// // //Console.WriteLine($"Title: {data.Name}");
// // //Console.WriteLine($"Description: {data.Description}");
// // //Console.WriteLine($"Categories: {data.Categories.Aggregate((x, y) => $"{x}; {y}")}");
// // //Console.WriteLine($"Authors: {data.Authors.Aggregate((x,y) => $"{x}; {y}")}");
// // Console.WriteLine($"Chapter title: {articleMetaData.Name}");
// // Console.WriteLine($"Book title: {bookMetaData.Name}");
// // //Console.WriteLine($"Content: {download}");
//
// // //translationTasks.Add(Task.Run(async () => {
// // // logger.LogInformation("Beginning translation {} task for {}", download.Order, articleMetaData.Name);
// // // var ret = new Ordered<IDocument>(await QuickAndDirtyJanitor.TranslateAsync(download.Data), download.Order);
// // // logger.LogInformation("Finished translation {} task for {}", download.Order, articleMetaData.Name);
// // // return ret;
// // //}));
// //}
//
// //documents = (await Task.WhenAll(translationTasks)).ToList();
//
// //string testDir = Path.Combine("txt", Path.GetRandomFileName());
// //Directory.CreateDirectory(testDir);
//
// //int len = documents.MaxBy((x) => x.Order)?.Order ?? -1;
// //foreach (var document in documents.OrderBy((x) => x.Order)) {
// // document.Data.MetaData.TryGetValue(Architecture.ChapterKey, out var chapterMetaData);
// // Dictionary<string, string> linkButtons = new();
// // if (document.Order != 0)
// // linkButtons.Add("Previous", $"{document.Order - 1}.html");
// // if (document.Order != len)
// // linkButtons.Add("Next", $"{document.Order + 1}.html");
// // new HtmlExporter(document.Data, chapterMetaData as ArticleData, linkButtons).Write(Path.Combine(testDir, $"{document.Order}.html"));
// //}
//
// Console.ReadKey();
//
// //foreach (var download in documents.OrderBy((x) => x.Order)) {
// // if (download.Data.TryGetTaggedMetaData<ArticleData>(Architecture.ChapterKey, out var meta))
// // Console.WriteLine($"{download.Order}:{meta.Name}");
// //}
//
// //string[] templates = new DataKey<File>[] {
// // HtmlBook.Keys.ContentPage,
// // HtmlBook.Keys.NoContentPage,
// // HtmlBook.Keys.TitlePage,
// // HtmlBook.Keys.StylesPage,
// //}.Select(
// // (x) => BeamData.Files.ReadToString(x.WithNamespace("aeqw89:files:templates:classic"))
// //).ToArray();
//
// //HtmlBook book = new(
// // bookname: Path.Combine(Path.GetRandomFileName(), "I Alone Level Up"),
// // new CssData(),
// // new ArticleData(),
// // new HtmlBookTemplates() {
// // ContentPageTemplate = templates[0],
// // NoContentTemplate = templates[1],
// // TitlePageTemplate = templates[2],
// // CssTemplate = templates[3],
// // },
// // documents: documents.Select((x) => x.Data).ToList()
// //);
//
// //book.Update();
// //Console.WriteLine("One variable!");
}
}
}
@@ -1,10 +0,0 @@
{
"profiles": {
"Beam.Temporary.Cli": {
"commandName": "Project",
"environmentVariables": {
"OPEN_AI_KEY": "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"
}
}
}
}
@@ -1,26 +0,0 @@
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;
// using System.Threading.Tasks;
// using Beam.Models;
// using OpenAI;
// using OpenAI.Chat;
//
// namespace Beam.Temporary.Cli {
// public class QuickAndDirtyJanitor {
// static OpenAIClient client;
//
// static QuickAndDirtyJanitor() {
// var key = Environment.GetEnvironmentVariable("OPEN_AI_KEY");
// client = new OpenAIClient(key);
// }
//
// public static async Task<IDocument> TranslateAsync(IDocument document) {
// var chatCompletion = await client.GetChatClient("gpt-4.1").CompleteChatAsync(
// ChatMessage.CreateSystemMessage("Translate the following text into english. If any part of the text has no direct English translation, you may choose to leave it as is. In either case, make sure to leave footnotes for any difficult to translate words. You must translate the whole text and output only your translation and footnotes. No other comments are necessary."),
// ChatMessage.CreateUserMessage("From UNKNOWN to ENGLISH.\n" + document.ToString()));
// return new StringDocument(document.Filename, chatCompletion.Value.Content.DefaultIfEmpty().Select((x) => x?.Text).Aggregate((x,y) => $"{x}{y}"));
// }
// }
// }
-15
View File
@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beam.Temporary.Cli {
public static class StringExtensions {
public static string Aggregate(this IEnumerable<string> str, string separator) {
if (!str.Any())
return string.Empty;
return str.Aggregate((x, y) => $"{x}{separator}{y}");
}
}
}
@@ -1,30 +0,0 @@
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;
// using System.Threading.Tasks;
//
// namespace Beam.Temporary.Cli.Templates.Classic {
// internal class ClassicTemplates {
// public static void Register(BeamDataDictionary sdd) {
// sdd.Files.TryAdd(
// new("aeqw89:files:templates:classic:content_page"),
// new("C:\\Users\\qwsdc\\source\\repos\\Beam\\Beam.Temporary.Cli\\Templates\\Classic\\Content.template.html", "htmlpage", "templates"));
// sdd.Files.TryAdd(
// new("aeqw89:files:templates:classic:title_page"),
// new("C:\\Users\\qwsdc\\source\\repos\\Beam\\Beam.Temporary.Cli\\Templates\\Classic\\Title.template.html", "htmlpage", "templates"));
// sdd.Files.TryAdd(
// new("aeqw89:files:templates:classic:styles_page"),
// new("C:\\Users\\qwsdc\\source\\repos\\Beam\\Beam.Temporary.Cli\\Templates\\Classic\\Styles.template.css", "styles", "templates"));
// sdd.Files.TryAdd(
// new("aeqw89:files:templates:classic:no_content_page"),
// new("C:\\Users\\qwsdc\\source\\repos\\Beam\\Beam.Temporary.Cli\\Templates\\Classic\\NoContent.template.html", "htmlpage", "templates"));
// }
// }
//
// internal static class DictionaryOfFileExtensions {
// public static string ReadToString<T>(this Dictionary<T, File> dict, T key) where T: notnull {
// return System.IO.File.ReadAllText(dict[key].Path);
// }
// }
// }
@@ -1,27 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{Name}</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>{Name}</h1>
<p><em>{Description}</em></p>
<div>
<span><strong>Authors:</strong> {Authors}</span> |
<span><strong>Language:</strong> {Language}</span> |
<span><strong>Categories:</strong> {Categories}</span> |
<span><strong>Version:</strong> {Version}</span>
</div>
</header>
<article>
{Content}
</article>
<div class="navigation">
<button id="prev">Previous</button>
<button id="next">Next</button>
</div>
</body>
</html>
@@ -1,15 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404 - Not Found</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="error-container">
<h1>404 - Content Not Found</h1>
<p>The file <strong>{Filename}</strong> was not found.</p>
<p>{Content}</p>
</div>
</body>
</html>
@@ -1,60 +0,0 @@
/* styles.css */
/* Placeholders:
{PrimaryColor}, {SecondaryColor}, {TertiaryColor}, {ButtonColor},
{ForegroundColor}, {ContentFont}, {ContentFontSize}, {TitleFont}, {TitleFontSize}
*/
body {
font-family: {ContentFont};
font-size: {ContentFontSize};
background-color: {PrimaryColor};
color: {ForegroundColor};
margin: 0;
padding: 20px;
}
header {
background-color: {SecondaryColor};
padding: 20px;
text-align: center;
}
header h1 {
font-family: {TitleFont};
font-size: {TitleFontSize};
margin: 0;
}
header p {
font-style: italic;
margin: 5px 0;
}
section, article, nav {
background: {TertiaryColor};
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
margin: 20px auto;
max-width: 800px;
}
.navigation {
display: flex;
justify-content: space-between;
max-width: 800px;
margin: 20px auto;
}
button {
background-color: {ButtonColor};
color: {ForegroundColor};
border: none;
padding: 10px 20px;
cursor: pointer;
font-size: {ContentFontSize};
border-radius: 4px;
}
nav h2 {
margin-top: 0;
}
@@ -1,26 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{Name}</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>{Name}</h1>
<p><em>{Description}</em></p>
</header>
<section>
<div><strong>Authors:</strong> {Authors}</div>
<div><strong>Language:</strong> {Language}</div>
<div><strong>Categories:</strong> {Categories}</div>
<div><strong>Version:</strong> {Version}</div>
</section>
<nav>
<h2>Table of Contents</h2>
<ul>
{TOC} <!-- Expected to be a list of items (e.g. <li>Chapter 1</li>, etc.) -->
</ul>
</nav>
</body>
</html>
-6
View File
@@ -5,8 +5,6 @@ VisualStudioVersion = 17.12.35506.116
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beam", "Beam\Beam.csproj", "{3BC9A070-85B0-405D-A6F8-D0AEEE625B81}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beam", "Beam\Beam.csproj", "{3BC9A070-85B0-405D-A6F8-D0AEEE625B81}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beam.Temporary.Cli", "Beam.Temporary.Cli\Beam.Temporary.Cli.csproj", "{8F650BBA-3800-4B5E-A6FF-9057633601EE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beam.Dynamic", "Beam.Dynamic\Beam.Dynamic.csproj", "{DDEABE82-096C-4799-87F1-56F494D35FAA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beam.Dynamic", "Beam.Dynamic\Beam.Dynamic.csproj", "{DDEABE82-096C-4799-87F1-56F494D35FAA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beam.Exports", "Beam.Exports\Beam.Exports.csproj", "{7C0ADBC0-44D4-48F8-901B-9C93F1B1FFDC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beam.Exports", "Beam.Exports\Beam.Exports.csproj", "{7C0ADBC0-44D4-48F8-901B-9C93F1B1FFDC}"
@@ -43,10 +41,6 @@ Global
{3BC9A070-85B0-405D-A6F8-D0AEEE625B81}.Debug|Any CPU.Build.0 = Debug|Any CPU {3BC9A070-85B0-405D-A6F8-D0AEEE625B81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BC9A070-85B0-405D-A6F8-D0AEEE625B81}.Release|Any CPU.ActiveCfg = Release|Any CPU {3BC9A070-85B0-405D-A6F8-D0AEEE625B81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BC9A070-85B0-405D-A6F8-D0AEEE625B81}.Release|Any CPU.Build.0 = Release|Any CPU {3BC9A070-85B0-405D-A6F8-D0AEEE625B81}.Release|Any CPU.Build.0 = Release|Any CPU
{8F650BBA-3800-4B5E-A6FF-9057633601EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F650BBA-3800-4B5E-A6FF-9057633601EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F650BBA-3800-4B5E-A6FF-9057633601EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F650BBA-3800-4B5E-A6FF-9057633601EE}.Release|Any CPU.Build.0 = Release|Any CPU
{DDEABE82-096C-4799-87F1-56F494D35FAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DDEABE82-096C-4799-87F1-56F494D35FAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDEABE82-096C-4799-87F1-56F494D35FAA}.Debug|Any CPU.Build.0 = Debug|Any CPU {DDEABE82-096C-4799-87F1-56F494D35FAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDEABE82-096C-4799-87F1-56F494D35FAA}.Release|Any CPU.ActiveCfg = Release|Any CPU {DDEABE82-096C-4799-87F1-56F494D35FAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+1 -1
View File
@@ -7,7 +7,7 @@
<Title>Beam</Title> <Title>Beam</Title>
<Authors>aeqw89</Authors> <Authors>aeqw89</Authors>
<Company>qwsdcvghyu</Company> <Company>qwsdcvghyu</Company>
<Version>2.1.4</Version> <Version>2.1.6</Version>
<Description>A library for downloading internet resources</Description> <Description>A library for downloading internet resources</Description>
<PackageProjectUrl>https://github.com/qwsdcvghyu89/Beam</PackageProjectUrl> <PackageProjectUrl>https://github.com/qwsdcvghyu89/Beam</PackageProjectUrl>
<RepositoryUrl>https://github.com/qwsdcvghyu89/Beam</RepositoryUrl> <RepositoryUrl>https://github.com/qwsdcvghyu89/Beam</RepositoryUrl>