2020-09-29 20:42:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "text/template"
|
|
|
|
|
|
|
|
// Default templates
|
|
|
|
|
|
|
|
const atom_xml = `<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
|
|
<title>{{ .Title }}</title>
|
2020-09-30 01:30:50 +00:00
|
|
|
<link href="{{ .URL }}"/>
|
|
|
|
<link rel="self" href="{{ .URL }}{{ .Path }}"/>
|
2020-09-30 04:27:59 +00:00
|
|
|
<updated>{{ .Updated.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
2020-09-30 01:30:50 +00:00
|
|
|
<id>{{ .URL }}{{ .Path }}</id>
|
|
|
|
{{- $url := .URL -}}
|
|
|
|
{{- range .Entries }}
|
2020-09-29 20:42:27 +00:00
|
|
|
<entry>
|
|
|
|
<title>{{ .Title }}</title>
|
2020-09-30 01:30:50 +00:00
|
|
|
<link href="{{ $url }}{{ .Permalink }}"/>
|
|
|
|
<id>{{ $url }}{{ .Permalink }}</id>
|
2020-09-29 20:42:27 +00:00
|
|
|
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
2020-09-30 01:30:50 +00:00
|
|
|
<content src="{{ $url }}{{ .Permalink }}" type="text/gemini"></content>
|
2020-09-29 20:42:27 +00:00
|
|
|
</entry>
|
2020-09-30 01:30:50 +00:00
|
|
|
{{ end -}}
|
2020-09-29 20:42:27 +00:00
|
|
|
</feed>`
|
|
|
|
|
|
|
|
const index_gmi = `# Index of {{ .Permalink }}
|
|
|
|
|
2020-09-30 01:30:50 +00:00
|
|
|
{{ range .Dirs }}=> {{ .Permalink }}
|
|
|
|
{{ end -}}
|
2020-09-29 20:42:27 +00:00
|
|
|
{{ range .Pages }}=> {{ .Permalink }}
|
2020-09-30 01:30:50 +00:00
|
|
|
{{ end -}}`
|
2020-09-29 20:42:27 +00:00
|
|
|
|
|
|
|
const page_gmi = `# {{ .Title }}
|
|
|
|
|
|
|
|
{{ .Content }}`
|
|
|
|
|
|
|
|
var (
|
|
|
|
atomTmpl = template.Must(template.New("atom.xml").Parse(atom_xml))
|
|
|
|
indexTmpl = template.Must(template.New("index.gmi").Parse(index_gmi))
|
|
|
|
pageTmpl = template.Must(template.New("page.gmi").Parse(page_gmi))
|
|
|
|
)
|