-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
101 lines (80 loc) · 3.34 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Y∆V
===
yav is a Golang "live" static blog. Content is kept in memory for fast delivery
and checked against disk to grab updates to the site. It was aimed to be for
personal use but decided to open source it for all.
Template functionality is provided by Go's html/template and sprig. Check out
the documentation of both packages:
* https://golang.org/pkg/text/template/
* http://masterminds.github.io/sprig/
By default it will try to use HTTPS so a certificate and key should be supplied.
Plain HTTP is also available by disabling HTTPS via "-use-https=false".
You can specify all configuration settings in a YAML file as seen in the file
"config.yml.example" and using the `-config` flag.
Use "-help" for all the program flags.
Build
=====
$ cd src/ && go build -o ../yav
File tree
=========
There are 2 directories that are really important for this program to work:
* site/: all markdown files and extra files to be served.
* template/: template files used to render the pages.
Without them yav will fail miserably. Example files exist on those directories
to see it working.
HTTP
=====
Headers can be added via the argument `-header`. Multiple can be added by
passing more than one:
-header 'server: yav' -header 'x-download-options: noopen'
On HTTP errors:
^^^^^^^^^^^^^^^
Templates can also be used as a response to 404 and 500 server
errors (these two so far) and can be specified using the `-tpl-error` flag.
For example: if the template file `template/error.html` wants to be used then it
should be passed as `-tpl-error error.html`. In this case the template variables
`.content` will hold the error string and `.code` the Status code.
Markdown
========
Front Matter
^^^^^^^^^^^^
Taken from Jekyll. This way functionality can be extended and variables can be
passed to the template directly from the markdown files.
yav front matter variables:
* `template` (string): *required* dictates which template to use.
* `render` (bool): display the markdown content rendered to HTML or plain.
Template variables can be also passed from the markdown's front matter.
Templates
=========
Variables
^^^^^^^^^
Fixed variables are:
* `url` (url.URL): requests URL data.
* `query` (url.Values): URL's query parameters (HTTP GET).
* `template` (string): template name.
* `content` (string): HTML rendered content from markdown.
It is possible to add more variables to be used by templates via `-config` and
a yaml file.
Reloading templates
^^^^^^^^^^^^^^^^^^^
In case that a template was modified while the service is running a full reload
of the templates can be triggered by sending a SIGUSR1 signal to the process.
Bare in mind that new template files will also be loaded in the process.
Template functions
^^^^^^^^^^^^^^^^^^
Some extra functions were added to yav besides the mentioned previously.
* `readFile (string)`: read file in path. Returns: []byte.
* `dirLs (string)`: directory listing. Returns: string.
* `fromTplExt (string)`: converts from template to markdown extension.
Returns: string.
* `toTplExt (string)`: converts from markdown to template extension. Returns:
string.
* `getFM (string)`: get front matter variables from template. Returns:
map[string]interface{}.
* `getSiteMap ()`: get sitemap in JSON format. Returns: string
Requirements
============
* https://github.com/Masterminds/sprig
Issues
======
A lot. Please open a ticket.