I’ve completed a massive overhaul of my growlmurrdurr weblog system. It is now exactly a thousand times more nicely written, expandable, and just generally clean and happy. No longer do I have to cringe every time I want to make a change to it.
Now that it is more generic and clean and happy, after a bit of testing I’ll be releasing it upon the world on my software page. I’ll even write some documentation and stuff, explaining how to set it up. It’s nice and robust now, such that modifications to the source files shouldn’t be required just to get it up and running. Give or take a bit.
I’ve been pondering the best way to create some kind of configuration system for it. Some kind of more robust administration than it currently has, so that it could be expanded to do more in the future. Multiple author support, for example, will require some way for the administrator to create multiple author ‘accounts’ and so on. Anyways, I’m happy with the new setup. It’s up-to-date in the Subversion repository, if you’re interested in taking a look-see.
Earlier today I was searching around Google for some technical information, and was given Expert Exchange as a link. Experts Exchange has this nifty little feature, implemented as an Apache module, whereby the HTTP referer is examined for search engine footprints. When it is found that you were linked by a search engine, this Apache module named mod_suru will highlight those search terms inside the resultant web page.
“Cool,” I thought. So I went to look at mod_suru and discovered that it is only available at a relatively high cost. Certainly not a cost that I’m willing to pay for my own personal website.
import os, re, cgi
# Highlight google-ed for words!
words = None
m = re.search("google.[a-z.]+/search\\?(.*)", os.environ['HTTP_REFERER'])
googleQuery = cgi.parse_qs(m.group(1))
words = ' '.join(googleQuery['q']).split(' ')
words = filter(lambda x: x.find(":") == -1, words) # remove words like 'site:blahblah.com'
if words != None:
print "<!-- Begin magical search term highlighting. -->"
colors = ("#00eeee", "#eeee00", "#ee00ee", "#ee0000", "#00ee00", "#0000ee")
for i in range(len(words)):
print "highlightWord(%r, %r, document.documentElement);" % (words[i], colors[i])
print "<!-- End magical search term highlighting. -->"
Hopefully, it should be pretty clear how you could take this and use the same idea on your own web site, or modify my code to support more than just Google. Yay!