diff --git a/core/std.lua b/core/std.lua index 82b7844..71456ad 100644 --- a/core/std.lua +++ b/core/std.lua @@ -186,46 +186,6 @@ function M.site_authors() return {} end --- Join array with separator -function M.join(arr, sep) - arr = arr or {} - sep = sep or ", " - local result = {} - for _, v in ipairs(arr) do - table.insert(result, tostring(v)) - end - return table.concat(result, sep) -end - --- Trim whitespace -function M.trim(str) - str = tostring(str or "") - return str:match("^%s*(.-)%s*$") -end - --- Table HTML generator -function M.table(headers, rows) - headers = headers or {} - rows = rows or {} - - local html = "" - for _, header in ipairs(headers) do - html = html .. "" - end - html = html .. "" - - for _, row in ipairs(rows) do - html = html .. "" - for _, cell in ipairs(row) do - html = html .. "" - end - html = html .. "" - end - - html = html .. "
" .. tostring(header) .. "
" .. tostring(cell) .. "
" - return html -end - function M.highlight(str) return '' .. (str or "") .. "" end diff --git a/index.html b/index.html new file mode 100644 index 0000000..1b413cc --- /dev/null +++ b/index.html @@ -0,0 +1,500 @@ + + + + + + Documentation Title + + + +
+
+

Documentation

+

Fes: A lightweight, static, and opinionated microframework.

+
+ + + +
+

Introduction

+

Fes, or Free Easy Site, is a microframework used for small static sites. It is not designed for complex web applications and that is why it is good. Yes, I hate modern web and that is the reason this exists.

+
+ +
+

Installation

+
git clone https://git.vxserver.dev/fSD/fes
+
cd fes
+
go install fes
+
+ +
+

Usage

+

Typical workflows and examples.

+ +
+ +
+

Cli Reference

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescription
--helpDisplay help information
--no-colorDisable color output
-p <port>Set the server port
new <project>Create a new projet called <project>
docOpen this documention page
run <project>Run the projet called <project>
+
+ +
+

Reference

+ All std functions have binding for the site and can be used like so: site:h1("Hello, World!"), where site is the site object. +

Builtin

+ + + + + + + + + + + + + + + + + +
NameDescription
fes()Generate a site object
:custom()Add a custom string to the site body
+

Std

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescription
std.fes_version()Get the current version of fes.
std.site_version()Get the current version of the site, defined in Fes.toml.
std.site_name()Get the current name of the site, defined in Fes.toml.
std.site_title()Get the current name of the site, defined in Fes.toml.
std.site_authors()Get a table of the authors of the site, defined in Fes.toml.
std.joinGet a table of the authors of the site, defined in Fes.toml.
std.a(link: string, str: string)Returns an anchor tag.
std.ha(link: string, str: string)Returns an anchor tag with sytiling to make it hidden.
std.external(link: string, str: string)Returns an anchor tag that opens up in a new tab.
std.note(str: string)Returns a note object.
std.muted(str: string)Returns a muted object.
std.callout(str: string)Returns a callout object.
std.h1(str: string)Returns a header level 1 object.
std.h2(str: string)Returns a header level 2 object.
std.h3(str: string)Returns a header level 3 object.
std.h4(str: string)Returns a header level 4 object.
std.h5(str: string)Returns a header level 5 object.
std.h6(str: string)Returns a header level 6 object.
std.p(str: string)Returns a paragraph object.
std.pre(str: string)Returns preformated text.
std.code(str: string)Returns a codeblock.
std.ul(items: {...strings})Generates an unordered list from a table of strings.
std.ol(items: {...strings})Generates an ordered list from a table of strings.
std.tl(items: {...strings})Generates a table from a table of strings.
std.blockquote(str: string)Returns a blockquote.
std.hr()Returns a horizonal rule.
std.img(src: string, alt: string)Returns an image at location source with given alternative text.
std.strong(str: string)Returns bolded text.
std.em(str: string)Returns italicized text.
std.br()Returns a break.
std.div(content: string, class: string)Returns a div of class class with content of content.
std.spa(content: string, class: string)Returns a span of class class with content of content.
std.escape(str: string)Returns an html escaped string.
std.highlight(str: string)Returns highlighted text.
std.banner(str: string)Returns a banner that is attached to the top of the site.
std.center(str: string)Returns centered text.
std.nav(link: string, str: string)Returns a speical navigation link, used for in-site traversal.
std.rl(r: string, l: string)Right and light alight content.
+

Symbol

+ + + + + + + + + + + + + + + + + + + +
NameSymbol
symbol.copyright©
Registered Trademark®
Trademark
+

Util

+ + + + + + + + + + + + + + + + +
NameDescription
util.cc(tbl: {...strings})Concatenate a table of strings into a single string.
util.copyright(link: string, holder: string)Used when setting the website copyright holder.
+

Dkjson

+ This is a third party object and is best documented here + + + + + + + + + + + + + + + + +
NameDescription
dkjson.encode(obj: {...any})Serilize a Lua table into JSON.
dkjson.decode(obj: {...any})Deserilize JSON into a Lua table.
+
+ + +
+ + diff --git a/main.go b/main.go index 952dc4e..c3f75b3 100644 --- a/main.go +++ b/main.go @@ -18,10 +18,14 @@ import ( //go:embed core/* var core embed.FS +//go:embed index.html +var documentation string + func init() { config.Port = flag.Int("p", 3000, "Set the server port") config.Color = flag.Bool("no-color", false, "Disable color output") config.Core = core + config.Doc = documentation } func main() { diff --git a/src/config/config.go b/src/config/config.go index e564136..2e9ea17 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -6,6 +6,7 @@ import ( ) var Core embed.FS +var Doc string var Port *int var Color *bool diff --git a/src/doc/doc.go b/src/doc/doc.go index a48d46f..7d000e1 100644 --- a/src/doc/doc.go +++ b/src/doc/doc.go @@ -1,6 +1,7 @@ package doc import ( + "fes/src/config" "fmt" "os" "path/filepath" @@ -12,12 +13,8 @@ func Open() error { fmt.Println("Opening documentation in browser") tmpFile := filepath.Join(os.TempDir(), "doc.html") - content := `
-This feature is not implemented yet. It will be once the doc site
-is up and running, for now read through the core/ files and examples.
-
` - if err := os.WriteFile(tmpFile, []byte(content), 0644); err != nil { + if err := os.WriteFile(tmpFile, []byte(config.Doc), 0644); err != nil { return err }