tag cloud explanation

So what is a tag cloud ?

I have tagged each of my flog posts with one or more keywords.
So if the post was discussing my recovery from a power cut then I might tag it with +[powercut] +[ups] +[gentoo] +[grub] +[fix].
Each tag then is a link to my tag page which shows all the posts that have the same tag. In this example I can click on [powercut] and see that I have been affected by a few power cuts recently.
I have then collected all the tagging information, setting the tags that are used most to be more visible than those only used once or twice and that is the tag cloud you see below.

How does the tagging work ?

When I create a flog post I add tags that are simply words I think describe the posts content, these are saved along with an overall post description in individual XML files.
So if I add a new tag [powercut], a new powercut.xml file is created with a very simple structure.
Each time I create a new flog post it must be uploaded to the server and I have a ftp script that does this. What I have added though is an additional step which is to check for any new (or updated) .xml files and upload them as well.
Now the clever bit, the tags.html file reads the .xml file in via JavaScript and displays the links.

OK, how does the tag cloud work ?

The tag cloud is created in two steps, first all the .xml tag files are collected and examined (details below) and secondly the results are displayed in the browser.
This uses the same JavaScript technology as the tags.html file to read in an .xml file and then display it a web browser.

Collecting .xml files and building the required results

find . -name "*.xml" -exec wc -l {} \; | grep -v tagcloud_data.xml | cut -f1 -d' ' | sort -n | uniq > tag.div the find command finds all the .xml files and for each one executes the wc (word count) command (-l returns the line count), a quick grep excludes of the tag cloud collated data. This is in turn cleaned with cut (return first field using space as the delimiter) piped through a numerical sort and then all duplicates removed. This list of numbers is stored in the file tag.div
From this file we get the total number of possible(current) values and divide it by the number of different tag cloud levels. There is some jiggery pokery here to test for whole numbers and then each possible number is assigned its level in an array.
Finally for each tag .xml file an entry is made in the xml file tagcloud_data.xml denoting its level in the cloud.

The JavaScript file is free for anyone to use and abuse as they see fit ! The shell script is available on demand, it's not pretty.

loading results, please wait loading animateloading animateloading animate
Less tags

email

root

flog archives


Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk
In fact I'm not responsible for anything ever, so there!

[Pay4Foss banner long]