Skip to content

lubiedo/yav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Y∆V is a Golang "live" static blog

Topics

Resources

License

Stars

Watchers

Forks

Languages