Hipster News

Hipster News is a small static site generator based on sh, redo, Git and xsltproc. It generates web pages from HTML and plain text files as a server-side Git hook – web pages and feeds are generated after each push.

Index

  1. Deployment
    1. Server
    2. Client
  2. Posting
    1. Static entries
    2. Generated entries

Deployment

Server

On the server, install redo and xsltproc, then create both a directory for your web page and a bare Git repository in a directory that is published by a web server. For example, if your web server publishes /var/www/html by default and your site is called my_site, do:

cd /var/www/html
mkdir my_site
git init --bare my_site.git

Create a file hooks/post-update in the bare repository and make it executable:

touch my_site.git/hooks/post-update
chmod a+x my_site.git/hooks/post-update

Copy the following code into that file:

#!/bin/sh
git update-server-info
PWD=$(pwd)
BARE_REPO=${PWD##*/}
WORK_TREE=${BARE_REPO%%.git}
GIT_WORK_TREE=../"$WORK_TREE" git checkout -f
cd ../"$WORK_TREE" && env GIT_DIR=../"$BARE_REPO" redo

The above code checks out repository contents into a folder and runs redo whenever the repository receives data, e.g. when you run git push on a client. git update-server-info makes it possible to clone the repository over plain HTTP.

Client

On the client, create a new git repository and populate it with the Hipster News build scripts:

git init my_site && cd my_site
wget http://news.dieweltistgarnichtso.net/bin/archives/hipster-news.tar.gz
tar -xzf hipster-news.tar.gz
git add all.do atom2html.xsl default.xml.do index.xml.do default.html.do index.html.do screen.css template xhtml_body.xsl xhtml_title.xsl xhtml_embedded_files.xsl 
git commit -m '+ Hipster News build scripts'

Add your server as a remote for the current repository. For example, if your username on the server is user, your server is called example.org and the path to the repository on your server is /var/www/html/my_site.git:

git remote add origin ssh://user@example.org/var/www/html/my_site.git

Create a file index.id containing a single line with a unique identifier – preferably a Tag URI. Create a file index.prefix containing a single line with the URL prefix for your entries' location on the web server. Commit both files and push.

For example, if your entries' will be available under http://example.org/my_site, your email address is user@example.org, the date is 2016-07-06 and your repository is called my_site, do:

echo -n tag:user@example.org,2016-07-06:my_site > index.id
echo -n http://example.org/my_site > index.prefix
git add index.id index.prefix
git commit -m '+ identifier and prefix for my site'
git push origin master

Hipster News should now generate a mostly-empty index.

Posting

An entry in Hipster News consists of two files: One file contains content (for static entries) or build instructions (for generated entries), the other file contains a unique identifier for the entry. Hipster News uses the second file to distinguish between entries and non-entries and to provide an identifier for feeds. Having files in the repository that do not represent an entry is useful when you have content embedded in entries or want to commit an entry but not publish it yet.

Static entries

To create a new static entry, create a new file in the Git repository on the client, containing UTF-8 encoded text, XHTML (you can use the template file) or TSV data. Then create a file with the same filename plus an .id suffix, containing a single line with a unique identifier. To publish, commit both files and push.

If the file contains XHTML, Hipster News uses the title element for the title of the entry – otherwise it uses the filename. Author(s) and creation/modification date(s) for entries are taken from Git.

For each file embedded in an XHTML entry, an Atom enclosure element is generated. This means you can create podcast episodes by just using HTML multimedia elements.

Generated entries

To create a new generated entry, commit an id file and a dofile with the same prefix, like example.do and example.id. This enables your entries to declare dependencies on other content. This entry, for example, depends on hipster-news.tar.gz, the archive with the build scripts it refers to.