Ukulele Web Autogenerated Pages

To autogenerate pages for UkuleleWeb, it is often enough to use a simple shell script that executes periodically and restart UkuleleWeb after autogeneration.

Example

1. Create the shell script

The shell script could for example be named periodic-wiki.sh and generate lists of other pages.

#!/bin/sh

cd /path/to/wiki

generate() {
	for b in $*; do
		echo "* ${b}"
	done

	echo
	echo "Autogenerated by the WikiPeriodicJob on" `date -I`
}

generate *Book > ListOfBooks
generate *Recipe > ListOfRecipes
generate ListOf* > ListOfLists

# Restart the wiki - not the nicest way to do that, but it does the job.
killall ukuleleweb

🐞 Having to restart UkuleleWeb is currently a weak point - UkuleleWeb caches the pages in RAM and does otherwise not know that it should invalidate the cache. (I should fix that and make that possible without restart.)

This can in principle be avoided by submitting the resulting pages through a POST request (same as the page editor is sending). Going through POST requests is slightly more cumbersome to write and can interact poorly with user authentication in reverse proxies.

2. Test the shell script

Run the shell script to make sure it generates the desired pages.

3. Register the execution in cron

Register the periodic execution for the wiki user as a periodic job.

On a classic UNIX system that can be registered by the UkuleleWeb user using crontab -e:

20 * * * * /intra/bin/periodic-wiki.sh

💡 Make sure that the periodic script is always executing as the same user which is also running the UkuleleWeb process. This avoids conflicts when the page files are owned by different users.