A Tag Cloud for Gensite

Andrew Stephens, Wednesday the 28th of June, 2017 in Computing

I have finally finished a long-planned but never-implemented feature of gensite, the software that builds this blog. As well as a simple chronological list of articles, you can now narrow your search using the new Tag Cloud.

A meaningless visual representation of the available tags
A meaningless visual representation of the available tags

Because sheep.horse is a completely static sitethis may change, the tag cloud is implemented in Javascript and runs completely client side. All the gensite software does is generate a JSON representation of the tag database and include it in the static page during the build. Such a scheme will probably break down after a few thousand articles but it works fine for now.

If you select more than one tag, the articles that match all of your choices appear first. Articles that match only some selected tags appear down the list and are de-emphasized slightly. I think this is a fair compromise between being a strict logical AND, which is inflexible, and an loose OR, which doesn't filter enough to be useful.

I am happy with the way the Javascript turned out. An annoying feature of other sites is that you cannot link to a arbitrary page state but I used the Javascript history api to generate canonical uris for the currently selected tags. This allows linking to specific combinations, for example all articles about science fiction films.