diff --git a/README.md b/README.md index c2d8c4c..86d2fb9 100644 --- a/README.md +++ b/README.md @@ -17,24 +17,19 @@ Named after [Aya Shameimaru](https://en.touhouwiki.net/wiki/Aya_Shameimaru) from Build it manually provided you have Go (>=1.17) installed: - $ go install mahou-no-mori.yakumo.dev/aya/cmd/aya@latest (1) - --- or --- - $ git clone https://git.mentality.rip/novaburst/aya + $ svn checkout https://svn.laidback.moe/repo/aya/trunk aya $ cd aya $ make # make install -(1) If you use this method, the `aya version` subcommand may print the wrong string, -but it should not be a problem unless you use it on a page. You can also disable certain features at build time, with the `-tags` switch. -Currently, these tags are available: `noamber`, `nogcss`. +Currently, these tags are available: `noamber`, `nogcss`, `nogemtext` See `go help buildconstraint` for more details. ## Ideology -Keep your texts in markdown, [amber](https://github.com/eknkc/amber), or html format right in the main directory -of your blog/site. +Keep your texts in markdown, [amber](https://github.com/eknkc/amber), [gemtext](https://git.sr.ht/~m15o/gmi2html), or html format right in the main directory of your blog/site. Keep all service files (extensions, layout pages, deployment scripts etc) in the `.aya` subdirectory. @@ -91,6 +86,22 @@ echo '' >> $AYA_OUTDIR/blog/rss.xml echo '' >> $AYA_OUTDIR/blog/rss.xml ``` +## Example of [Twtxt](https://twtxt.readthedocs.io) feed generation + +```bash +#!/bin/sh +for f in ./blog/*/*.md; do + d=$($AYA var $f date) + if [ !-z $d ]; then + timestamp=`gdate --date "$d" +%s` + title=`$AYA var $f title | tr A-Z a-z` + url=`$AYA var $f url` + descr=`$AYA var $f description` + echo $timestamp "$(gdate --date @$timestamp --iso-8601=seconds) $title ($desc) -- $url" + fi +done | sort -r -n | cut -d' ' -f2- >> $AYA_OUTDIR/twtxt.txt +``` + ## Hooks There are two special plugin names that are executed every time the build happens - `prehook` and `posthook`. You can define some global actions here like diff --git a/cmd/aya/build.go b/cmd/aya/build.go index e868d6b..23c6dc3 100644 --- a/cmd/aya/build.go +++ b/cmd/aya/build.go @@ -17,6 +17,8 @@ func build(path string, w io.Writer, vars Vars) error { return buildAmber(path, w, vars) } else if ext == ".gcss" { return buildGCSS(path, w) + } else if ext == ".gmi" { + return buildGemtext(path, w, vars) } else { return buildRaw(path, w) } diff --git a/cmd/aya/gemini.go b/cmd/aya/gemini.go new file mode 100644 index 0000000..4b1a0a2 --- /dev/null +++ b/cmd/aya/gemini.go @@ -0,0 +1,30 @@ +//go:build !nogemtext +package main + +import ( + "io" + "os" + "path/filepath" + "git.sr.ht/~m15o/gmi2html" +) + +func buildGemtext(path string, w io.Writer, vars Vars) error { + v, body, err := getVars(path, vars) + if err != nil { + return err + } + content, err := render(body, v) + if err != nil { + return err + } + v["content"] = string(gmi2html.Convert(string(content))) + if w == nil { + out, err := os.Create(filepath.Join(PUBDIR, renameExt(path, "", ".html"))) + if err != nil { + return err + } + defer out.Close() + w = out + } + return buildHTML(filepath.Join(AYADIR, v["layout"]), w, v) +} diff --git a/cmd/aya/gemini_stub.go b/cmd/aya/gemini_stub.go new file mode 100644 index 0000000..199ab4a --- /dev/null +++ b/cmd/aya/gemini_stub.go @@ -0,0 +1,11 @@ +//go:build nogemtext +package main + +import ( + "io" + "errors" +) + +func buildGemtext(path string, w io.Writer, vars Vars) error { + return errors.New("Gemtext support was disabled at build-time") +} diff --git a/cmd/aya/main.go b/cmd/aya/main.go index a067bea..9eff29f 100644 --- a/cmd/aya/main.go +++ b/cmd/aya/main.go @@ -54,7 +54,7 @@ func main() { if err != nil { log.Fatalf("\033[0;31m%s\033[0m\n", "I see, you want me to serve a non-existent directory, huh?") } else { - aya.HttpServe(fmt.Sprint(d), 8000) + aya.HttpServe(PUBDIR, 8000) } case "var": if len(args) == 0 { diff --git a/go.mod b/go.mod index 5e14e97..6a04f02 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module mahou-no-mori.yakumo.dev/aya go 1.17 require ( + git.sr.ht/~m15o/gmi2html v0.4.0 github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 github.com/russross/blackfriday/v2 v2.1.0 github.com/yosssi/gcss v0.1.0 diff --git a/go.sum b/go.sum index 10c4609..23e648d 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +git.sr.ht/~m15o/gmi2html v0.4.0 h1:WwxWgZQ26YWcdhG9fgGnGPq4zigMIVqZwYMSNY0T1oc= +git.sr.ht/~m15o/gmi2html v0.4.0/go.mod h1:z3rqGHBxMss/zQJTA5lHCm+s17JkRtu98kK3ehzC/Uk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= diff --git a/usage.go b/usage.go index 39bb434..41b5e46 100644 --- a/usage.go +++ b/usage.go @@ -7,8 +7,8 @@ import ( // This function is called by the `aya help` subcommand func PrintUsage() { fmt.Printf("aya/%v\n", PrintFullVersion()) - fmt.Println("Homepage: https://suzunaan.yakumo.dev/aya") - fmt.Println("Repository: https://svn.yakumo.dev/repo/aya") + fmt.Println("Homepage: https://projects.laidback.moe/aya") + fmt.Println("Repository: https://svn.laidback.moe/repo/aya") fmt.Println("==") fmt.Println("build [file] · (Re)build a site or a file in particular") fmt.Println("clean · Remove the generated .pub directory")