changes
This commit is contained in:
parent
c667ce43b8
commit
1fbb94e9a2
13 changed files with 1171 additions and 1150 deletions
6
BeefManaged.toml
Normal file
6
BeefManaged.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
FileVersion = 1
|
||||
Version = ""
|
||||
GitURL = "https://code.booklordofthe.dev/Booklordofthedings/Aven"
|
||||
GitTag = ""
|
||||
GitHash = "c987948d019ca245b0ad1a65a31f8efc38701989"
|
||||
Setup = true
|
|
@ -8,6 +8,17 @@ using Aven.HTML;
|
|||
class Index : Page
|
||||
{
|
||||
|
||||
public override void LoadPageContents()
|
||||
{
|
||||
this.AddElement(
|
||||
Div("Content aisjdoasjiodashuihnsduijhnuisdhfsd",
|
||||
H1("Hello from Aven"),
|
||||
Raw("Aven is a website generation library, that can be used from"), A("Beef")..SetValue("href", "https://Beeflang.org"), Raw("to generate reuseable html."), Br(),
|
||||
Raw("By being integrated into a programming language you can freely write your own templating and generation logic"), Br()
|
||||
)..SetValue("style", "padding: 15px;")
|
||||
);
|
||||
}
|
||||
|
||||
public this() : base()
|
||||
{
|
||||
Title = scope $"Aven - {Aven.Version}";
|
||||
|
@ -18,14 +29,6 @@ class Index : Page
|
|||
}
|
||||
""");
|
||||
|
||||
this.AddElement(
|
||||
Div("",
|
||||
H1("Hello from Aven"),
|
||||
Raw("Aven is a website generation library, that can be used from"), A("Beef")..SetValue("href", "https://Beeflang.org"), Raw("to generate reuseable html."), Br(),
|
||||
Raw("By being integrated into a programming language you can freely write your own templating and generation logic"), Br()
|
||||
)..SetValue("style", "padding: 15px;")
|
||||
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
}
|
|
@ -8,10 +8,9 @@ class Program
|
|||
{
|
||||
public static void Main()
|
||||
{
|
||||
Builder b = scope .();
|
||||
b.OutputDirectory = "../output/";
|
||||
b.[Friend]_Pages.Add(new .("Index.html"),new Example_Website.Index());
|
||||
b.Build();
|
||||
|
||||
Aven aven = scope .();
|
||||
aven.Pages.Add(scope Example_Website.Index());
|
||||
aven.OutputDirectory = "../output/";
|
||||
aven.Build();
|
||||
}
|
||||
}
|
6
src/.gitignore
vendored
6
src/.gitignore
vendored
|
@ -1,6 +0,0 @@
|
|||
# ---> Beef
|
||||
output/
|
||||
build/
|
||||
recovery/
|
||||
BeefSpace_User.toml
|
||||
|
88
src/Aven.bf
88
src/Aven.bf
|
@ -1,8 +1,94 @@
|
|||
namespace Aven;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
|
||||
class Aven
|
||||
{
|
||||
public static readonly String Version = "0.1.0";
|
||||
private static readonly Logger _defaultLogger = new .() ~ delete _;
|
||||
private static readonly Builder _defaultBuilder = new .() ~ delete _;
|
||||
|
||||
public static readonly String Version = "0.5.0";
|
||||
|
||||
private Dictionary<String, String> _dirs = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||
private Dictionary<String, String> _files = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||
|
||||
|
||||
public List<Page> Pages = new .(10) ~ delete _;
|
||||
public Logger Log = _defaultLogger;
|
||||
public Builder Builder = _defaultBuilder;
|
||||
public String OutputDirectory = null;
|
||||
|
||||
///Copy a directory to the output directory
|
||||
public Result<void> IncludeDirInOutput(StringView dir, StringView outdir)
|
||||
{
|
||||
if(!Directory.Exists(dir))
|
||||
return .Err;
|
||||
_dirs.Add(new .(dir), new .(outdir));
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
///Copy a file to the output directory
|
||||
public Result<void> IncludeFileInOutput(StringView dir, StringView outdir)
|
||||
{
|
||||
if(!File.Exists(dir))
|
||||
return .Err;
|
||||
_files.Add(new .(dir), new .(outdir));
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
///Builds the website
|
||||
public void Build()
|
||||
{
|
||||
Log.Info(scope $"Starting Aven {Version}");
|
||||
Log.Info("Start building");
|
||||
|
||||
if(!EnsureOutputExists())
|
||||
return;
|
||||
|
||||
Builder.Build(this);
|
||||
|
||||
Log.Info("Successfully build");
|
||||
}
|
||||
|
||||
///Writes a file to the location specified by output
|
||||
private Result<void> WriteToOutput(StringView file, StringView data)
|
||||
{
|
||||
String outdir = scope .();
|
||||
if (Path.GetDirectoryPath(scope $"{OutputDirectory}/{file}", outdir) case .Ok)
|
||||
{
|
||||
if (Directory.CreateDirectory(outdir) case .Ok)
|
||||
{
|
||||
if(File.WriteAllText(scope $"{OutputDirectory}/{file}", data) case .Ok)
|
||||
{
|
||||
Log.Info(scope $"Wrote file to {OutputDirectory}/{file}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.Error(scope $"Attempt to write to {OutputDirectory}/{file} failed");
|
||||
return .Err;
|
||||
}
|
||||
|
||||
private bool EnsureOutputExists()
|
||||
{
|
||||
if(OutputDirectory == null)
|
||||
{
|
||||
Log.Error("No output directory is has been set");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Directory.Exists(OutputDirectory))
|
||||
return true;
|
||||
|
||||
if(Directory.CreateDirectory(OutputDirectory) case .Err)
|
||||
{
|
||||
Log.Error("Unable to create output directoy");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.Info("Output directory has been created");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
namespace Aven;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
|
||||
/**
|
||||
The builder is the core object for the page generation
|
||||
it houses most of the configuration object and it acts
|
||||
as a storage for all of the other pages.
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
private Dictionary<String, Page> _Pages = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||
private List<String> _InputDirectories = new .() ~ DeleteContainerAndItems!(_);
|
||||
|
||||
private String _OutputDirectory = new .("") ~ delete _;
|
||||
public StringView OutputDirectory
|
||||
{
|
||||
get => _OutputDirectory;
|
||||
set
|
||||
{
|
||||
_OutputDirectory.Clear();
|
||||
_OutputDirectory.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
///Copies over a folder into the output directory
|
||||
public void AddFolder(StringView folder) => _InputDirectories.Add(new .(folder));
|
||||
public void AddPage(StringView name, Page page)
|
||||
{
|
||||
if(!_Pages.ContainsKeyAlt<StringView>(name))
|
||||
{
|
||||
_Pages.Add(new .(name), page);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates all of the website files and writes them to the output location
|
||||
*/
|
||||
public void Build()
|
||||
{
|
||||
|
||||
Log.Info("Starting build");
|
||||
|
||||
//First validate everything, so that we dont do a bunch of work for nothing
|
||||
if(_OutputDirectory == String.Empty)
|
||||
{
|
||||
Log.Error("No output directory specified. Cannot build");
|
||||
return;
|
||||
}
|
||||
|
||||
for(var entry in _Pages)
|
||||
{
|
||||
Log.Debug(scope $"Attempting to build: {_OutputDirectory}{entry.key}");
|
||||
var output = entry.value.Build(.. scope .());
|
||||
if(WriteFile(scope $"{_OutputDirectory}{entry.key}", output) case .Ok)
|
||||
Log.Info(scope $"Sucessfully build page: {entry.key}");
|
||||
else
|
||||
Log.Error("Unable to build page");
|
||||
}
|
||||
|
||||
Log.Debug("Copying over directories");
|
||||
for(var i in _InputDirectories)
|
||||
Directory.Copy(i, _OutputDirectory).IgnoreError();
|
||||
}
|
||||
private Result<void> WriteFile(StringView target, StringView toWrite)
|
||||
{
|
||||
|
||||
var targetDir = target.Substring(0, target.LastIndexOf('/'));
|
||||
if(!Directory.Exists(targetDir))
|
||||
{
|
||||
Log.Debug(scope $"Target directory does not exist, attempting to create: {targetDir}");
|
||||
if(Directory.CreateDirectory(targetDir) case .Err)
|
||||
{
|
||||
Log.Debug("Unable to create target directory");
|
||||
return .Err;
|
||||
}
|
||||
}
|
||||
|
||||
if(File.WriteAllText(target, toWrite) case .Err)
|
||||
{
|
||||
Log.Debug("Unable to write file");
|
||||
return .Err;
|
||||
}
|
||||
return .Ok;
|
||||
}
|
||||
}
|
917
src/HTML.bf
Normal file
917
src/HTML.bf
Normal file
|
@ -0,0 +1,917 @@
|
|||
namespace Aven.HTML;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
class HTML
|
||||
{
|
||||
static public implicit operator HTML (StringView v) => Raw(v);
|
||||
|
||||
private String _Name = new .("") ~ delete _;
|
||||
private String _Body = new .("") ~ delete _;
|
||||
private String _Id = new .("") ~ delete _;
|
||||
private HashSet<String> _Classes = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<HTML> _Children = new .() ~ DeleteContainerAndItems!(_);
|
||||
private bool _SelfClosing = false; //makes an object <name />
|
||||
private Dictionary<String, String> _Values = new .() ~ DeleteDictionaryAndKeysAndValues!(_); //Most of these values should come from fields
|
||||
//This is just used to allow arbitrary values for stuff ive missed
|
||||
|
||||
|
||||
public StringView Name
|
||||
{
|
||||
get => _Name;
|
||||
set
|
||||
{
|
||||
_Name.Clear();
|
||||
_Name.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
public StringView Body
|
||||
{
|
||||
get => _Body;
|
||||
set
|
||||
{
|
||||
_Body.Clear();
|
||||
_Body.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
public StringView Id
|
||||
{
|
||||
get => _Id;
|
||||
set
|
||||
{
|
||||
_Id.Clear();
|
||||
_Id.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
public this(params Span<HTML> children)
|
||||
{
|
||||
for (var i in children)
|
||||
_Children.Add(i);
|
||||
}
|
||||
|
||||
public void SetValue(StringView key, StringView value)
|
||||
{
|
||||
if (_Values.ContainsKeyAlt<StringView>(key))
|
||||
_Values[scope .(key)]..Clear().Append(value);
|
||||
else
|
||||
_Values.Add(new .(key), new .(value));
|
||||
}
|
||||
|
||||
public void AddClass(StringView clas) => _Classes.Add(new .(clas));
|
||||
|
||||
public void RemoveClass(StringView clas) => _Classes.Remove(scope .(clas));
|
||||
|
||||
public void Build(String buffer)
|
||||
{
|
||||
if (_SelfClosing && _Name != "")
|
||||
{
|
||||
buffer.Append(scope $"<{Name} {CalculateValues(.. scope .())} />");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (Name != "")
|
||||
buffer.Append(scope $"<{Name} {CalculateValues(.. scope .())}>\n");
|
||||
|
||||
if (_Body != .Empty)
|
||||
buffer.Append(_Body);
|
||||
|
||||
for (var i in _Children)
|
||||
i.Build(buffer);
|
||||
|
||||
if (Name != "")
|
||||
buffer.Append(scope $"</{Name}>\n");
|
||||
}
|
||||
|
||||
private void CalculateValues(String buffer)
|
||||
{
|
||||
if(_Id != .Empty)
|
||||
buffer.Append(scope $"id=\"{_Id}\"");
|
||||
|
||||
if(_Classes.Count > 0)
|
||||
{
|
||||
buffer.Append("class=\"");
|
||||
for(var i in _Classes)
|
||||
buffer.Append(scope $"{i} ");
|
||||
buffer.Append("\" ");
|
||||
}
|
||||
|
||||
for(var i in _Values)
|
||||
{
|
||||
buffer.Append(scope $"{i.key}=\"{i.value}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
public static HTML Raw(StringView body = "")
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_Body.Append(body);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Empty(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(children: params children);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Custom(StringView name, params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .(name);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static HTML Collapseable(HTML summary, params Span<HTML> details)
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.Name = .("details");
|
||||
|
||||
var sum = new HTML(children: summary);
|
||||
sum.Name = .("summary");
|
||||
toReturn.[Friend]_Children.Add(sum);
|
||||
for(var i in details)
|
||||
toReturn.[Friend]_Children.Add(i);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Adress(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("adress");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Article(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("article");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Aside(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("aside");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Footer(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("footer");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Header(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("header");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static HTML H1(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("h1");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H2(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("h2");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H3(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("h3");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H4(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("h4");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H5(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("h5");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H6(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("h6");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML HGroup(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("hgroup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Main(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("main");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Nav(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("nav");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Section(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("section");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Search(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("search");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML BlockQuote(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("blockquote");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dd(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("dd");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Div(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("div");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dl(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("dl");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dt(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("dt");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Figcaption(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("figcaption");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Figure(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("figure");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Hr()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("hr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Li(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("li");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Menu(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("menu");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ol(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("ol");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML P(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("p");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Pre(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("pre");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ul(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("ul");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML A(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("a");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Abbr(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("abbr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML B(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("b");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Bdi(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("bdi");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Bdo(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("bdo");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Br()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("br");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Cite(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("cite");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Code(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("code");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Data(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("data");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dfn(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("dfn");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Em(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("em");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML I(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("i");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Kdb(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("kdb");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Mark(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("mark");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Q(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("q");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Rp(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("rp");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Rt(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("rt");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ruby(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("ruby");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML S(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("s");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Samp(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("samp");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Small(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("small");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Span(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("span");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Strong(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("strong");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Sub(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("sub");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Sup(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("sup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Time(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("time");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML U(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("u");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Var(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("var");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Wbr()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("wbr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Area()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("area");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Audio(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("audio");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Img(StringView src = "", int64 width = -1, int64 height = -1, StringView alt = "")
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
if(src != "") toReturn.SetValue("src", src);
|
||||
if(alt != "") toReturn.SetValue("alt", alt);
|
||||
if(width > 0) toReturn.SetValue("width", width.ToString(.. scope .()));
|
||||
if(height > 0) toReturn.SetValue("height", height.ToString(.. scope .()));
|
||||
toReturn.Name = .("img");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Map(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("map");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Track()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("track");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Video(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("video");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Embed()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("embed");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Fencedframe(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("fencedframe");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML IFrame(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("iframe");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Object(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("object");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Picture(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("picture");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Portal(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("portal");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Source()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("source");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Svg(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("svg");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Math(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("math");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Canvas(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("canvas");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML NoScript(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("noscript");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Script(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("script");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Del(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("del");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ins(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("ins");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Caption(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("caption");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Col()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("col");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Colgroup(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("colgroup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Table(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("table");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML TBody(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("tbody");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Td(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("td");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML TFoot(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("tfoot");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Th(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("th");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML THead(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("thead");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Tr(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("tr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Button(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("button");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Datalist(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("datalist");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Fieldset(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("fieldset");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Form(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("form");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Input()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("input");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Label(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("label");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Legend(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("legend");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Meter(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("meter");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Optgroup(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("optgroup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Option(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("option");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Output(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("output");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Progress(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("progress");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Select(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("select");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Textarea(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML( params children);
|
||||
toReturn.Name = .("textarea");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Details(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("details");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dialog(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("dialog");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Summary(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML( params children);
|
||||
toReturn.Name = .("summary");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Slot(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("slot");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Template(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(params children);
|
||||
toReturn.Name = .("template");
|
||||
return toReturn;
|
||||
}
|
||||
}
|
914
src/HTML/HTML.bf
914
src/HTML/HTML.bf
|
@ -1,914 +0,0 @@
|
|||
namespace Aven.HTML;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
class HTML
|
||||
{
|
||||
private String _Name = new .("") ~ delete _;
|
||||
private String _Body = new .("") ~ delete _;
|
||||
private String _Id = new .("") ~ delete _;
|
||||
private HashSet<String> _Classes = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<HTML> _Children = new .() ~ DeleteContainerAndItems!(_);
|
||||
private bool _SelfClosing = false; //makes an object <name />
|
||||
private Dictionary<String, String> _Values = new .() ~ DeleteDictionaryAndKeysAndValues!(_); //Most of these values should come from fields
|
||||
//This is just used to allow arbitrary values for stuff ive missed
|
||||
|
||||
public StringView Name
|
||||
{
|
||||
get => _Name;
|
||||
set
|
||||
{
|
||||
_Name.Clear();
|
||||
_Name.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
public StringView Body
|
||||
{
|
||||
get => _Body;
|
||||
set
|
||||
{
|
||||
_Body.Clear();
|
||||
_Body.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
public StringView Id
|
||||
{
|
||||
get => _Id;
|
||||
set
|
||||
{
|
||||
_Id.Clear();
|
||||
_Id.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
public this(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
_Body.Append(body);
|
||||
for (var i in children)
|
||||
_Children.Add(i);
|
||||
}
|
||||
|
||||
public void SetValue(StringView key, StringView value)
|
||||
{
|
||||
if (_Values.ContainsKeyAlt<StringView>(key))
|
||||
_Values[scope .(key)]..Clear().Append(value);
|
||||
else
|
||||
_Values.Add(new .(key), new .(value));
|
||||
}
|
||||
|
||||
public void AddClass(StringView clas) => _Classes.Add(new .(clas));
|
||||
|
||||
public void RemoveClass(StringView clas) => _Classes.Remove(scope .(clas));
|
||||
|
||||
public void Build(String buffer)
|
||||
{
|
||||
if (_SelfClosing && _Name != "")
|
||||
{
|
||||
buffer.Append(scope $"<{Name} {CalculateValues(.. scope .())} />");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (Name != "")
|
||||
buffer.Append(scope $"<{Name} {CalculateValues(.. scope .())}>\n");
|
||||
|
||||
if (_Body != .Empty)
|
||||
buffer.Append(_Body);
|
||||
|
||||
for (var i in _Children)
|
||||
i.Build(buffer);
|
||||
|
||||
if (Name != "")
|
||||
buffer.Append(scope $"</{Name}>\n");
|
||||
}
|
||||
|
||||
private void CalculateValues(String buffer)
|
||||
{
|
||||
if(_Id != .Empty)
|
||||
buffer.Append(scope $"id=\"{_Id}\"");
|
||||
|
||||
if(_Classes.Count > 0)
|
||||
{
|
||||
buffer.Append("class=\"");
|
||||
for(var i in _Classes)
|
||||
buffer.Append(scope $"{i} ");
|
||||
buffer.Append("\" ");
|
||||
}
|
||||
|
||||
for(var i in _Values)
|
||||
{
|
||||
buffer.Append(scope $"{i.key}=\"{i.value}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
public static HTML Raw(StringView body = "")
|
||||
{
|
||||
var toReturn = new HTML(body);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Empty(params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(children: params children);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Custom(StringView name, StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .(name);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static HTML Collapseable(HTML summary, params Span<HTML> details)
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.Name = .("details");
|
||||
|
||||
var sum = new HTML(children: summary);
|
||||
sum.Name = .("summary");
|
||||
toReturn.[Friend]_Children.Add(sum);
|
||||
for(var i in details)
|
||||
toReturn.[Friend]_Children.Add(i);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Adress(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("adress");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Article(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("article");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Aside(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("aside");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Footer(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("footer");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Header(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("header");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
public static HTML H1(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("h1");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H2(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("h2");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H3(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("h3");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H4(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("h4");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H5(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("h5");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML H6(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("h6");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML HGroup(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("hgroup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Main(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("main");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Nav(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("nav");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Section(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("section");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Search(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("search");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML BlockQuote(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("blockquote");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dd(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("dd");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Div(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("div");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dl(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("dl");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dt(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("dt");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Figcaption(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("figcaption");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Figure(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("figure");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Hr()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("hr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Li(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("li");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Menu(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("menu");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ol(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("ol");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML P(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("p");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Pre(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("pre");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ul(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("ul");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML A(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("a");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Abbr(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("abbr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML B(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("b");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Bdi(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("bdi");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Bdo(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("bdo");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Br()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("br");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Cite(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("cite");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Code(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("code");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Data(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("data");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dfn(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("dfn");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Em(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("em");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML I(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("i");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Kdb(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("kdb");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Mark(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("mark");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Q(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("q");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Rp(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("rp");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Rt(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("rt");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ruby(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("ruby");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML S(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("s");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Samp(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("samp");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Small(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("small");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Span(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("span");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Strong(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("strong");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Sub(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("sub");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Sup(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("sup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Time(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("time");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML U(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("u");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Var(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("var");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Wbr()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("wbr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Area()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("area");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Audio(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("audio");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Img(StringView src = "", int64 width = -1, int64 height = -1, StringView alt = "")
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
if(src != "") toReturn.SetValue("src", src);
|
||||
if(alt != "") toReturn.SetValue("alt", alt);
|
||||
if(width > 0) toReturn.SetValue("width", width.ToString(.. scope .()));
|
||||
if(height > 0) toReturn.SetValue("height", height.ToString(.. scope .()));
|
||||
toReturn.Name = .("img");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Map(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("map");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Track()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("track");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Video(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("video");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Embed()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("embed");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Fencedframe(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("fencedframe");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML IFrame(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("iframe");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Object(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("object");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Picture(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("picture");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Portal(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("portal");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Source()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("source");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Svg(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("svg");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Math(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("math");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Canvas(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("canvas");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML NoScript(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("noscript");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Script(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("script");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Del(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("del");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Ins(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("ins");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Caption(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("caption");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Col()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("col");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Colgroup(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("colgroup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Table(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("table");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML TBody(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("tbody");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Td(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("td");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML TFoot(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("tfoot");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Th(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("th");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML THead(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("thead");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Tr(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("tr");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Button(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("button");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Datalist(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("datalist");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Fieldset(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("fieldset");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Form(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("form");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Input()
|
||||
{
|
||||
var toReturn = new HTML();
|
||||
toReturn.[Friend]_SelfClosing = true;
|
||||
toReturn.Name = .("input");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Label(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("label");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Legend(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("legend");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Meter(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("meter");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Optgroup(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("optgroup");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Option(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("option");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Output(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("output");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Progress(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("progress");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Select(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("select");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Textarea(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("textarea");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Details(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("details");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Dialog(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("dialog");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Summary(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("summary");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Slot(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("slot");
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static HTML Template(StringView body = "", params Span<HTML> children)
|
||||
{
|
||||
var toReturn = new HTML(body, params children);
|
||||
toReturn.Name = .("template");
|
||||
return toReturn;
|
||||
}
|
||||
}
|
23
src/Internal/Builder.bf
Normal file
23
src/Internal/Builder.bf
Normal file
|
@ -0,0 +1,23 @@
|
|||
namespace Aven;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
|
||||
class Builder
|
||||
{
|
||||
public void Build(Aven aven)
|
||||
{
|
||||
aven.Log.Debug("Default Builder");
|
||||
|
||||
String output = new .(1000);
|
||||
defer delete output;
|
||||
|
||||
for(var page in aven.Pages)
|
||||
{
|
||||
page.Build(output);
|
||||
if(aven.[Friend]WriteToOutput(page.GetPageFileOutput(), output) case .Err)
|
||||
aven.Log.Warn("Page has not been written");
|
||||
}
|
||||
}
|
||||
}
|
41
src/Internal/Logger.bf
Normal file
41
src/Internal/Logger.bf
Normal file
|
@ -0,0 +1,41 @@
|
|||
namespace Aven;
|
||||
|
||||
using System;
|
||||
|
||||
class Logger
|
||||
{
|
||||
public enum LogLevel
|
||||
{
|
||||
Debug,
|
||||
Info,
|
||||
Warn,
|
||||
Error
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public LogLevel CurrentLogLevel = .Debug;
|
||||
#else
|
||||
public LogLevel CurrentLogLevel = .Info;
|
||||
#endif
|
||||
|
||||
///Log a message
|
||||
public virtual void Log(LogLevel logLevel, StringView message)
|
||||
{
|
||||
switch(logLevel)
|
||||
{
|
||||
case .Debug:
|
||||
Console.WriteLine(scope $"[Aven][Debug]: {message}");
|
||||
case .Info:
|
||||
Console.WriteLine(scope $"[Aven][Info]: {message}");
|
||||
case .Warn:
|
||||
Console.WriteLine(scope $"[Aven][Warn]: {message}");
|
||||
case .Error:
|
||||
Console.WriteLine(scope $"[Aven][Error]: {message}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Debug(StringView message) => Log(.Debug, message);
|
||||
public void Info(StringView message) => Log(.Info, message);
|
||||
public void Warn(StringView message) => Log(.Warn, message);
|
||||
public void Error(StringView message) => Log(.Error, message);
|
||||
}
|
73
src/Internal/Page.bf
Normal file
73
src/Internal/Page.bf
Normal file
|
@ -0,0 +1,73 @@
|
|||
namespace Aven;
|
||||
using Aven.HTML;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
/**
|
||||
An instance of this class represents a single .html website
|
||||
*/
|
||||
abstract class Page
|
||||
{
|
||||
private String _title = new .("") ~ delete _;
|
||||
private List<HTML> _elements = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<String> _scripts = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<String> _inlineStyle = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<String> _styles = new .() ~ DeleteContainerAndItems!(_);
|
||||
|
||||
public virtual StringView GetPageFileOutput() => "Index.html";
|
||||
|
||||
public void AddElement(params Span<HTML> elmt)
|
||||
{
|
||||
for(var i in elmt)
|
||||
_elements.Add(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Build(String buffer)
|
||||
{
|
||||
LoadPageContents();
|
||||
buffer.Append(scope $"""
|
||||
<!Doctype HTML>
|
||||
<!-- Made with Quill version 0.1 -->
|
||||
<html>
|
||||
<head>
|
||||
<title>{Title}</title>
|
||||
{BuildStyles(.. scope .())}
|
||||
{BuildScripts(.. scope .())}
|
||||
</head>
|
||||
<body>
|
||||
{BuildElements(.. scope .())}
|
||||
</body>
|
||||
</html>
|
||||
""");
|
||||
}
|
||||
|
||||
private void BuildElements(String buffer)
|
||||
{
|
||||
for(var i in _elements)
|
||||
{
|
||||
i.Build(buffer);
|
||||
buffer.Append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildStyles(String buffer)
|
||||
{
|
||||
for(var i in _styles)
|
||||
buffer.Append(scope $"<link rel=\"stylesheet\" href=\"{i}\" />\n");
|
||||
for(var i in _inlineStyle)
|
||||
buffer.Append(scope $"""
|
||||
<style>
|
||||
{i}
|
||||
</style>
|
||||
""");
|
||||
}
|
||||
|
||||
private void BuildScripts(String buffer)
|
||||
{
|
||||
for(var i in _scripts)
|
||||
buffer.Append(scope $"<script src=\"{i}\"></script>\n");
|
||||
}
|
||||
}
|
59
src/Log.bf
59
src/Log.bf
|
@ -1,59 +0,0 @@
|
|||
namespace Aven;
|
||||
|
||||
using System;
|
||||
|
||||
/*
|
||||
A very basic logging implementation, future implementations can use this interface but be better
|
||||
*/
|
||||
class Log
|
||||
{
|
||||
public enum LogLevel
|
||||
{
|
||||
Trace,
|
||||
Debug,
|
||||
Info,
|
||||
Warn,
|
||||
Error
|
||||
}
|
||||
|
||||
public static LogLevel LogLevel
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = .Debug;
|
||||
|
||||
public static void Trace(StringView message)
|
||||
{
|
||||
Console.ForegroundColor = .Cyan;
|
||||
Console.WriteLine(scope $"[Trace]:{message}");
|
||||
Console.ForegroundColor = .White;
|
||||
}
|
||||
|
||||
public static void Debug(StringView message)
|
||||
{
|
||||
Console.ForegroundColor = .Yellow;
|
||||
Console.WriteLine(scope $"[Debug]:{message}");
|
||||
Console.ForegroundColor = .White;
|
||||
}
|
||||
|
||||
public static void Info(StringView message)
|
||||
{
|
||||
Console.ForegroundColor = .Green;
|
||||
Console.WriteLine(scope $"[Info]:{message}");
|
||||
Console.ForegroundColor = .White;
|
||||
}
|
||||
|
||||
public static void Error(StringView message)
|
||||
{
|
||||
Console.ForegroundColor = .DarkYellow;
|
||||
Console.WriteLine(scope $"[Error]:{message}");
|
||||
Console.ForegroundColor = .White;
|
||||
}
|
||||
|
||||
public static void Fatal(StringView message)
|
||||
{
|
||||
Console.ForegroundColor = .Red;
|
||||
Console.WriteLine(scope $"[Fatal]:{message}");
|
||||
Console.ForegroundColor = .White;
|
||||
}
|
||||
}
|
76
src/Page.bf
76
src/Page.bf
|
@ -1,96 +1,36 @@
|
|||
namespace Aven;
|
||||
using Aven.HTML;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
/**
|
||||
An instance of this class represents a single .html website
|
||||
*/
|
||||
abstract class Page
|
||||
extension Page
|
||||
{
|
||||
private String _Title = new .("") ~ delete _;
|
||||
private List<HTML> _Elements = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<String> _Scripts = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<String> _InlineStyle = new .() ~ DeleteContainerAndItems!(_);
|
||||
private List<String> _Styles = new .() ~ DeleteContainerAndItems!(_);
|
||||
|
||||
|
||||
public StringView Title
|
||||
{
|
||||
get => _Title;
|
||||
get => _title;
|
||||
set
|
||||
{
|
||||
_Title.Clear();
|
||||
_Title.Append(value);
|
||||
_title.Clear();
|
||||
_title.Append(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddElement(params Span<HTML> elmt)
|
||||
{
|
||||
for(var i in elmt)
|
||||
_Elements.Add(i);
|
||||
}
|
||||
|
||||
public void AddScripts(params Span<StringView> scripts)
|
||||
{
|
||||
for(var i in scripts)
|
||||
_Scripts.Add(new .(i));
|
||||
_scripts.Add(new .(i));
|
||||
}
|
||||
|
||||
public void AddStyles(params Span<StringView> styles)
|
||||
{
|
||||
for(var i in styles)
|
||||
_Styles.Add(new .(i));
|
||||
_styles.Add(new .(i));
|
||||
}
|
||||
|
||||
public void AddInlineStyle(StringView style)
|
||||
{
|
||||
_InlineStyle.Add(new .(style));
|
||||
_inlineStyle.Add(new .(style));
|
||||
}
|
||||
|
||||
public void Build(String buffer)
|
||||
{
|
||||
buffer.Append(scope $"""
|
||||
<!Doctype HTML>
|
||||
<!-- Made with Quill version 0.1 -->
|
||||
<html>
|
||||
<head>
|
||||
<title>{Title}</title>
|
||||
{BuildStyles(.. scope .())}
|
||||
{BuildScripts(.. scope .())}
|
||||
</head>
|
||||
<body>
|
||||
{BuildElements(.. scope .())}
|
||||
</body>
|
||||
</html>
|
||||
""");
|
||||
}
|
||||
public abstract void LoadPageContents();
|
||||
|
||||
private void BuildElements(String buffer)
|
||||
{
|
||||
for(var i in _Elements)
|
||||
{
|
||||
i.Build(buffer);
|
||||
buffer.Append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildStyles(String buffer)
|
||||
{
|
||||
for(var i in _Styles)
|
||||
buffer.Append(scope $"<link rel=\"stylesheet\" href=\"{i}\" />\n");
|
||||
for(var i in _InlineStyle)
|
||||
buffer.Append(scope $"""
|
||||
<style>
|
||||
{i}
|
||||
</style>
|
||||
""");
|
||||
}
|
||||
|
||||
private void BuildScripts(String buffer)
|
||||
{
|
||||
for(var i in _Scripts)
|
||||
buffer.Append(scope $"<script src=\"{i}\"></script>\n");
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue