I’m releasing a preview version of my Google plugin for Blosxom 2.0. We’ve all seen blog entries with a little “G” or “Google” that when clicked execute a search at Google for something related to the blog topic. I’ve seen those that strictly took the article title and used all those words in the query, but I wanted more control. So in my plugin I inspect the first line of the blog entry body, and if it starts with “KW:” (user-configurable) then the rest of that line is taken as keywords. These keywords are joined with “+” signs and tacked onto a configurable Google search query URL. For example, if the first line of the body (obviously after the title) looked like this:
KW: fox news channel
then the resulting URL (assuming no config changes) would look like this
http://www.google.com/search?q=fox+news+channel
and would show up in the story as “| Google”.
The look of the link is also user-configurable. You can see from all of my entries that I use a pipe, then the word “Google” but you can use whatever you want. In order to get the link, just include $google::google
in your story.html
and that’s it.
There’s also a setting that will make the link open in a new window or not.
What license are people using for this type of stuff? I read through the Blosxom license but I couldn’t tell if it was one of the “well known” licenses or not. I think I lean towards LGPL, but the alphabet soup of licenses is somewhat hard to get through. Do I even need to license this?
This is a 0.1 release with very little in the way of docs other than this entry and the sparse comments in the code. Get it here
If you use this plugin, please let me know. If you have suggestions/comments/complaints send me an email.
Update!
Thanks to the rapid suggestions of Todd Larason I’ve made some changes to the plugin to make it better. Here’s what I did:
- Set the $google::google variable to an empty string each time in case you have an entry with no keywords so the existing variable value won’t carry over between stories.
- Converted my user configurable string variables to use qq{} instead of quotes for ease of quoting HTML.
- Added (back in) a variable called $link_end that can contain whatever you want to go after the closing tag. So if you enclose your links in tags, you’d put the closer here.
- Added support for keyword strings hidden in HTML comments. This way you can hide your keywords so that if you still have a non-Googleized Blosxom, your keywords line won’t show up in your story text.
The new version is available here and the old version from here just in case I messed something up!
Again, please let me know of anything else!