Tags Plugin, first version
Several things have become clear writing this plugin.
- Some sort of method to standardize tags will be helpful.
Did I use "plugin" or "plugins" last time?
- Getting tags working and getting tags complete are
different tasks. I have tags working now,
complete will include non-ASCII tags working
(currently they display, but won't search) and more
advanced searching like TAG or TAG,
TAG and TAG, TAG without TAG, and
no tags at all. Even if the automatically
generated links won't include that, I'll want those
searches for my own use.
- The limits of the default interpolation become more
obvious. I can set a a string to be included, but I can't
have a template that includes a loop over an array, to
e.g. have the top twenty tags listed in desktop view but
only five in mobile view.
I don't plan to fix interpolation any time soon, but the other two I can
see in my near future. I will probably
code up a post composer of some sort to help standardize tags. With that
I can foresee also making the post composer do preliminary HTML
formatting from a simple markup language, and hooking the composer up to
a cellphone friendly CGI page.
Fixing the tags plugin to move beyond "MVP" — minimum viable
product — particularly for non-ASCII tags will also be a
relatively high priority. Right now tags can be (roughly)
/^[a-zA-Z0-9_-]+$/, with the caveat that I block leading
hyphens (will probably want that available for tag negation searches)
and I allow whitespace in tags, but map that to
(underscore) for searches, so there will be no way to distinguish
But here it is:
First off tags for any post are saved in a file with the same name but a
different (configurable) extension. One tag per line. Lines starting
# are comments. Leading and trailing whitespace
removed, and internal whitespace is normalized to a single space.
It creates a interpolation variable for a configurable number of top
tags, I'm going to be using that instead of the old categories. (And I
used the categories and subcategories to seed the tags on all the old
posts.) It also creates a tags variable for interpolation just before
each story is processed. Both of those make the tags shown into
I've named it starting with "aaa" because I want it to have access to
%others lists before any
filter() edits them. This way I can build a complete list of
unfiltered tags. This also means that tag search filters happen with a
very high priority, which isn't as necessary. Just running that any time
before pagination kicks in would have been fine.
With this plugin, I'm retiring my use
breadcrumbs plugins. That's leaving
me pretty close to 100% plugins I wrote