IMG
IMG is a simple image stream generated using mk(1).
Drop a mkfile and some images in a directory, run mk
,
and you'll get a web page, JSON feed, and Atom feed.
TODO:
- HTML-escape alt text and captions.
- The produced JSON and Atom feeds are valid,
but the images don't show up in the readers I've tested.
There's a lot of variation in how to present things; I'm researching improvements.
- Note and link the Apple Shortcut I use to post from mobile.
Using it
One time-setup:
-
Satisfy the prerequisites.
-
Stick the mkfile in a directory your web server can get at.
-
Modify the definition of BASEURL in the mkfile.
-
The first time you run 'mk' it'll create
"_header", "_footer", "_jsonhead", and "_atomhead" files.
You'll need to edit those, replacing the all-caps strings with
more sensible local values.
Keep the last line of _header, _jsonhead, and _atomhead,
and the first line of _footer, as they are.
The provided defaults are very simple,
but you are free to implement navigation, a sidebar,
include javascript, whatever.
-
The default mk target will make index.html, feed.json, and index.atom
files suitable for their normal purposes.
An "index" file (with no extension) is created and updated during operation.
The created index.html references img.css; none is provided, but
the img.css I use
should be suitable.
File names starting with an underscore are also reserved.
-
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 (regardless of case).
You can add others by editing the mkfile:\^TARG line.
-
Optionally, add alt text (highly encouraged) and/or a caption.
Create a text 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
stat programs.
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.
- Files with names matching an existing image file plus ".alt" or ".caption".
- Any other file not ending with a recognized image file
extension, .alt, or .caption should just be ignored.
- Consider "index.rss" and "index.[0-9]+.html" reserved for future use.
Notes:
-
Feeds are limited to the 20 most recently modified images.
This might add pagination in the future. Maybe.
-
Unless your web server makes other arrangements,
the full contents of this directory, including the mkfile,
files with names starting with _,
and any non-image files in there will be available. That's a feature.
-
The JSON feed probably needs to switch from content_text to content_html
and embed the relevant snippet from index.html to make feed readers display
the contents in a useful way.
-
Similarly, the Atom feed probably needs the <content> tag expanded
to include the relevant snippet from index.html to make feed readers display
the contents in a useful way.
-
plan9port support is entirely untested. I'd appreciate success/failure reports.
Inspired by the version at Texto-Plano.
Made in CN85 by Anthony.