aboutsummaryrefslogtreecommitdiff

lowdown.cgi, lowdown-gemini.cgiCGI wrappers around lowdown

The lowdown.cgi program generates HTML and Gemtext documents from Markdown using lowdown(1).

  1. Install lowdown
  2. Clone this repository:
    $ git clone git://sysrq.in:/lowdown.cgi /var/www/mysite

    or add it as a submodule:

    $ git submodule add git://sysrq.in:/lowdown.cgi
    $ ln -s ./lowdown.cgi/cgi-bin cgi-bin
  3. Setup your web and/or gemini server (see ENVIRONMENT and EXAMPLES).

Options for lowdown(1).
Absolute path to a Markdown file. If unset, ‘$PATH_TRANSLATED’ is used for Gemini and ‘$DOCUMENT_ROOT$DOCUMENT_URI’ for web.

The lowdown.cgi program uses the following files if they can be found in the same directory as $MARKDOWN_FILENAME:

header.html, header.gmi
Some text to be displayed before rendered Markdown article.
footer.html, footer.gmi
Some text to be displayed after rendered Markdown article.

Use lowdown's --out-standalone option if you don't need custom header or footer.

The lowdown.cgi utility exits 0 on success, and >0 if an error occurs.

/var/www
├── cgi-bin
│   └── ...
├── blog
│   ├── footer.html -> /var/www/footer.html
│   ├── header.html
│   └── index.md
├── htdocs
│   ├── icon.png
│   └── styles.css
├── about.md
├── footer.html
├── header.html
├── index.md
└── lowdown_params

location / {
    root /var/www/htdocs;
    try_files $uri @lowdown;
}

location @lowdown {
    root /var/www;

    set $fn $document_root$document_uri;

    if (-d $fn) {
        set $fn $fn/index.md;
    }
    if (!-f $fn) {
        return 404;
    }
    include             fastcgi_params;
    fastcgi_param       MARKDOWN_FILENAME $fn;
    fastcgi_param       SCRIPT_FILENAME $document_root/cgi-bin/lowdown.cgi;
    fastcgi_pass        unix:/run/fcgiwrap.sock-1;
}

location /sitemap.xml {
    root /var/www;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME $document_root/cgi-bin/sitemap.cgi;
    fastcgi_pass    unix:/run/fcgiwrap.sock-1;
}