From 9bef28bfe9c6e01222351acc7adf2c2f478672f7 Mon Sep 17 00:00:00 2001 From: early Date: Sat, 27 Jul 2024 23:47:42 -0600 Subject: [PATCH] Update readme, move examples to cmd/run-mast-examples --- README.md | 37 +++++++++++++++- about/main.go | 42 ------------------- .../run-mast-examples}/ex01-pages/example.go | 2 +- .../run-mast-examples}/ex01-pages/page.html | 0 .../run-mast-examples}/ex02-parts/example.go | 2 +- .../run-mast-examples}/ex02-parts/page.html | 0 .../ex02-parts/section.html | 0 .../run-mast-examples}/ex03-slots/example.go | 2 +- .../run-mast-examples}/ex03-slots/page.html | 0 .../ex03-slots/section.html | 0 .../ex04-templates/example.go | 2 +- .../ex04-templates/page.html | 0 .../run-mast-examples}/ex06-data/example.go | 2 +- .../ex06-data/message-printer.html | 0 .../run-mast-examples}/ex06-data/page.html | 0 .../run-mast-examples}/index.html | 0 {examples => cmd/run-mast-examples}/main.go | 10 ++--- .../run-mast-examples}/parts/example-nav.html | 0 .../run-mast-examples}/parts/parts.go | 0 examples/go.mod | 9 ---- examples/go.sum | 2 - 21 files changed, 46 insertions(+), 64 deletions(-) delete mode 100644 about/main.go rename {examples => cmd/run-mast-examples}/ex01-pages/example.go (73%) rename {examples => cmd/run-mast-examples}/ex01-pages/page.html (100%) rename {examples => cmd/run-mast-examples}/ex02-parts/example.go (84%) rename {examples => cmd/run-mast-examples}/ex02-parts/page.html (100%) rename {examples => cmd/run-mast-examples}/ex02-parts/section.html (100%) rename {examples => cmd/run-mast-examples}/ex03-slots/example.go (84%) rename {examples => cmd/run-mast-examples}/ex03-slots/page.html (100%) rename {examples => cmd/run-mast-examples}/ex03-slots/section.html (100%) rename {examples => cmd/run-mast-examples}/ex04-templates/example.go (90%) rename {examples => cmd/run-mast-examples}/ex04-templates/page.html (100%) rename {examples => cmd/run-mast-examples}/ex06-data/example.go (93%) rename {examples => cmd/run-mast-examples}/ex06-data/message-printer.html (100%) rename {examples => cmd/run-mast-examples}/ex06-data/page.html (100%) rename {examples => cmd/run-mast-examples}/index.html (100%) rename {examples => cmd/run-mast-examples}/main.go (57%) rename {examples => cmd/run-mast-examples}/parts/example-nav.html (100%) rename {examples => cmd/run-mast-examples}/parts/parts.go (100%) delete mode 100644 examples/go.mod delete mode 100644 examples/go.sum diff --git a/README.md b/README.md index 037b63f..085c5fb 100644 --- a/README.md +++ b/README.md @@ -1 +1,36 @@ -# Make a Site Today (Mast) Web Engine \ No newline at end of file +# Make a Site Today (Mast) Web Engine + +The Mast engine builds on Go's templating with reusable parts in the style of +the Web Components standard. It aims to be usable for anything from static HTML +websites to complex applications with a mix of server and client-side behavior. + +## Install + +```sh +go get git.earlybird.gay/mast-engine@latest +``` + +## Usage + +Currently, the `examples` folder contains a site going through concepts by +example. You can walk through these examples yourself by installing them as +an executable: + +```sh +go install git.earlybird.gay/mast-engine/cmd/run-mast-examples@latest +run-mast-examples +``` + +## License + +> This section is not legally binding, please read the license text for +> specifics! + +The Mast Web Engine is licensed under the LGPL (GNU Lesser General Public +License). This license affects how you can run, modify, and distribute +mast-engine. In short: + +- If you modify mast-engine, you have to publish your modifications under the + GPL or LGPL. +- If you use mast-engine without modifying it, you're in the clear. +- Building a website using mast-engine does not count as modifying mast-engine. diff --git a/about/main.go b/about/main.go deleted file mode 100644 index 8f712b7..0000000 --- a/about/main.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2024 early (LGPL) -package main - -import ( - "html/template" - "net/http" - - "git.earlybird.gay/mast-engine/page" - "git.earlybird.gay/mast-engine/part" - "git.earlybird.gay/mast-engine/render" -) - -func mkList(args ...string) template.HTML { - out := template.HTML("") - return out -} - -var testPage = page.New("test-page", "example-page.html", - page.Includes(testPart), - page.OnLoad(func(data render.Data) error { - data.Set("message", "hello from test-page!") - return nil - }), - page.Pretty(" "), -) -var testPart = part.New("test-part", "example-part.html", - part.Funcs(template.FuncMap{ - "mkList": mkList, - }), - part.OnLoad(func(data render.Data) error { - data.Set("message", "hello from test-part!") - return nil - }), -) - -func main() { - http.ListenAndServe("0.0.0.0:3000", testPage) -} diff --git a/examples/ex01-pages/example.go b/cmd/run-mast-examples/ex01-pages/example.go similarity index 73% rename from examples/ex01-pages/example.go rename to cmd/run-mast-examples/ex01-pages/example.go index e6dcd89..1978a2e 100644 --- a/examples/ex01-pages/example.go +++ b/cmd/run-mast-examples/ex01-pages/example.go @@ -2,7 +2,7 @@ package ex01 import ( - "git.earlybird.gay/mast-engine/examples/parts" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/parts" "git.earlybird.gay/mast-engine/page" ) diff --git a/examples/ex01-pages/page.html b/cmd/run-mast-examples/ex01-pages/page.html similarity index 100% rename from examples/ex01-pages/page.html rename to cmd/run-mast-examples/ex01-pages/page.html diff --git a/examples/ex02-parts/example.go b/cmd/run-mast-examples/ex02-parts/example.go similarity index 84% rename from examples/ex02-parts/example.go rename to cmd/run-mast-examples/ex02-parts/example.go index 6ce8aed..8226eff 100644 --- a/examples/ex02-parts/example.go +++ b/cmd/run-mast-examples/ex02-parts/example.go @@ -2,7 +2,7 @@ package ex02 import ( - "git.earlybird.gay/mast-engine/examples/parts" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/parts" "git.earlybird.gay/mast-engine/page" "git.earlybird.gay/mast-engine/part" ) diff --git a/examples/ex02-parts/page.html b/cmd/run-mast-examples/ex02-parts/page.html similarity index 100% rename from examples/ex02-parts/page.html rename to cmd/run-mast-examples/ex02-parts/page.html diff --git a/examples/ex02-parts/section.html b/cmd/run-mast-examples/ex02-parts/section.html similarity index 100% rename from examples/ex02-parts/section.html rename to cmd/run-mast-examples/ex02-parts/section.html diff --git a/examples/ex03-slots/example.go b/cmd/run-mast-examples/ex03-slots/example.go similarity index 84% rename from examples/ex03-slots/example.go rename to cmd/run-mast-examples/ex03-slots/example.go index 0f8f065..687cdea 100644 --- a/examples/ex03-slots/example.go +++ b/cmd/run-mast-examples/ex03-slots/example.go @@ -2,7 +2,7 @@ package ex03 import ( - "git.earlybird.gay/mast-engine/examples/parts" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/parts" "git.earlybird.gay/mast-engine/page" "git.earlybird.gay/mast-engine/part" ) diff --git a/examples/ex03-slots/page.html b/cmd/run-mast-examples/ex03-slots/page.html similarity index 100% rename from examples/ex03-slots/page.html rename to cmd/run-mast-examples/ex03-slots/page.html diff --git a/examples/ex03-slots/section.html b/cmd/run-mast-examples/ex03-slots/section.html similarity index 100% rename from examples/ex03-slots/section.html rename to cmd/run-mast-examples/ex03-slots/section.html diff --git a/examples/ex04-templates/example.go b/cmd/run-mast-examples/ex04-templates/example.go similarity index 90% rename from examples/ex04-templates/example.go rename to cmd/run-mast-examples/ex04-templates/example.go index 9a20ed2..ca12658 100644 --- a/examples/ex04-templates/example.go +++ b/cmd/run-mast-examples/ex04-templates/example.go @@ -4,7 +4,7 @@ package ex04 import ( "text/template" - "git.earlybird.gay/mast-engine/examples/parts" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/parts" "git.earlybird.gay/mast-engine/page" "git.earlybird.gay/mast-engine/render" ) diff --git a/examples/ex04-templates/page.html b/cmd/run-mast-examples/ex04-templates/page.html similarity index 100% rename from examples/ex04-templates/page.html rename to cmd/run-mast-examples/ex04-templates/page.html diff --git a/examples/ex06-data/example.go b/cmd/run-mast-examples/ex06-data/example.go similarity index 93% rename from examples/ex06-data/example.go rename to cmd/run-mast-examples/ex06-data/example.go index 688d14a..d85da0f 100644 --- a/examples/ex06-data/example.go +++ b/cmd/run-mast-examples/ex06-data/example.go @@ -5,7 +5,7 @@ import ( "errors" "strings" - "git.earlybird.gay/mast-engine/examples/parts" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/parts" "git.earlybird.gay/mast-engine/page" "git.earlybird.gay/mast-engine/part" "git.earlybird.gay/mast-engine/render" diff --git a/examples/ex06-data/message-printer.html b/cmd/run-mast-examples/ex06-data/message-printer.html similarity index 100% rename from examples/ex06-data/message-printer.html rename to cmd/run-mast-examples/ex06-data/message-printer.html diff --git a/examples/ex06-data/page.html b/cmd/run-mast-examples/ex06-data/page.html similarity index 100% rename from examples/ex06-data/page.html rename to cmd/run-mast-examples/ex06-data/page.html diff --git a/examples/index.html b/cmd/run-mast-examples/index.html similarity index 100% rename from examples/index.html rename to cmd/run-mast-examples/index.html diff --git a/examples/main.go b/cmd/run-mast-examples/main.go similarity index 57% rename from examples/main.go rename to cmd/run-mast-examples/main.go index 90ab549..ee62a19 100644 --- a/examples/main.go +++ b/cmd/run-mast-examples/main.go @@ -4,11 +4,11 @@ package main import ( "net/http" - "git.earlybird.gay/mast-engine/examples/ex01-pages" - "git.earlybird.gay/mast-engine/examples/ex02-parts" - "git.earlybird.gay/mast-engine/examples/ex03-slots" - "git.earlybird.gay/mast-engine/examples/ex04-templates" - "git.earlybird.gay/mast-engine/examples/ex06-data" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/ex01-pages" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/ex02-parts" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/ex03-slots" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/ex04-templates" + "git.earlybird.gay/mast-engine/cmd/run-mast-examples/ex06-data" "git.earlybird.gay/mast-engine/page" ) diff --git a/examples/parts/example-nav.html b/cmd/run-mast-examples/parts/example-nav.html similarity index 100% rename from examples/parts/example-nav.html rename to cmd/run-mast-examples/parts/example-nav.html diff --git a/examples/parts/parts.go b/cmd/run-mast-examples/parts/parts.go similarity index 100% rename from examples/parts/parts.go rename to cmd/run-mast-examples/parts/parts.go diff --git a/examples/go.mod b/examples/go.mod deleted file mode 100644 index 49086b2..0000000 --- a/examples/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module git.earlybird.gay/mast-engine/examples - -go 1.22.4 - -require git.earlybird.gay/mast-engine v0.0.0 - -require golang.org/x/net v0.27.0 // indirect - -replace git.earlybird.gay/mast-engine => .. diff --git a/examples/go.sum b/examples/go.sum deleted file mode 100644 index 7566714..0000000 --- a/examples/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -- 2.39.5