Bug fixes and support for Gemtext markup
git-svn-id: file:///srv/svn/repo/aya/trunk@94 cec141ff-132a-4243-88a5-ce187bd62f94
This commit is contained in:
27
README.md
27
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 '</channel>' >> $AYA_OUTDIR/blog/rss.xml
|
||||
echo '</rss>' >> $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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
30
cmd/aya/gemini.go
Normal file
30
cmd/aya/gemini.go
Normal file
@@ -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)
|
||||
}
|
||||
11
cmd/aya/gemini_stub.go
Normal file
11
cmd/aya/gemini_stub.go
Normal file
@@ -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")
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
1
go.mod
1
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
|
||||
|
||||
2
go.sum
2
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=
|
||||
|
||||
4
usage.go
4
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")
|
||||
|
||||
Reference in New Issue
Block a user