IMG
IMG is a simple image stream generated using mk(1).
TODO:
- HTML-escape alt text and captions.
- Limit alt text and caption sizes.
- Image file extensions should be recognized regardless of case.
- The _timestamp files are used by feed.json and index.atom but not index.hml.
- Note and link the Apple Shortcut I use to post from mobile.
- index.html should link to the readme and (at least in the header) feed.json and index.atom.
- Fix this page's css to indent ol items a bit.
Using it
One time-setup:
-
Satisfy the prerequisites.
-
Stick the mkfile in a directory your web server can get at.
-
Create files "_header" and "_footer" with whatever you like.
The header should start with something like "<html>" or
whatnot, and must end with a line containing exactly
and only the string "<!--End header-->".
The footer, similarly, must begin with a line containing
exactly and only the string "<!--Begin footer-->", and
should end the document with something like a "</html>".
Mine are very simple and you can use them as examples for both
header and footer,
but you are free to use them to implement navigation, a
sidebar, include javascript, whatever.
-
If you want to use the JSON or Atom feeds, you'll want
_atomhead and _jsonhead.
Change the strings in there to make sense for your installation.
-
Optionally, add an entry in cron to run "mk" in this directory.
In case you forget to run it yourself after making changes
or creating a new entry. I run it every 10 minutes.
To create an entry:
-
Create an image file with a recognized extension.
We recognize the extensions jpeg, jpg, gif, and png.
-
Optionally, add alt text (highly encouraged) and/or a caption.
Create a test file with the same name as the image, plus
".alt" for the alt text and ".caption" for the caption.
-
Run 'mk' (optional if you created the 'cron' entry)..
This will add any new image file names to _timestamps if
this is the first time we're seeing it, and then regenerate
"index", "index.html", "index.atom", and "feed.json", as needed.
Other notes
Prerequisites:
On Plan 9:
You'll need my datefmt and
statprograms.
On unix:
(This is expected to work but is completely untested.)
You'll need
Plan 9 from User Space
installed, and in your $path or $PATH before the normal unix tools.
You'll also need datefmt
and stat, like above.
Reserved words/patterns:
- Anything starting with an underscore ("_").
- The files "index", "index.html", "index.atom", and "feed.json"
will be updated (overwritten) by the mkfile.
- Anything other file not ending with a recognized image file
extension, .alt, or .caption should just be ignored.
Notes:
-
Unless your web server makes other arrangements, the
full contents of this directory, including the mkfile, source, and
names starting with _, will be available. That's a feature.
-
The JSON feed lacks context_text because I don't have a good way to
safely escape it yet. I'm also not sure whether that should be alt text
or captions, with or without fallback. Want to
weigh in?
-
The _timestamps file is currently used inconsistently.
The JSON and Atom feeds sorts by the entry in _timestamps,
use that for 'date_published' or 'published',
and use the file modification time for 'date_modified' or 'updated'.
The index.html sorts by file modification time and doesn't expose the
original published time.
-
plan9port support is entirely untested. I'd appreciate success/failure reports.
Inspired by the version at Texto-Plano.