|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
About...
www.flickr.com
This is a Flickr badge showing public photos from joeyGibson. Make your own badge here.
Previous Entries
Categories
Search
Blosxom Plugins
|
Sun, Mar 02 2003
User-Agent Based Content Inclusion Plugin
I've just released a new Blosxom
plugin called UAInclude
that allows you to include specific content in the <head>
section of a page, based on the User-Agent of the user's browser. This
came about because when I added Todd's nice Categories
plugin. My pages looked great with Moz or other sane browsers, but they
looked like crap with IE. The reason for the
difference is that IE and Moz render various styles differently, and
my painstaking design was suffering because of it. Todd offered a
solution, but while it made the pages look better under IE, they
didn't look as good under Moz.
Thus, I wrote this plugin. It's driven by a hash of regexes that map to (possibly non-existent) files relative to $blosxom::datadir. Each of these regexes are compared
against the User-Agent from the current user's browser to decide which
content to include. A variable called
$uainclude::included_content is exposed and should be
added inside the <head> section in your
head.html flavour file. This variable will contain the
text of the matching file, or will be empty if the matching file
doesn't exist. (An example of when this would be useful is for a
browser like Lynx which is a
text-only browser; it will ignore styles, so why send them?) If
nothing matches, there's a default that will be served up, to account
for all the browsers that I don't know about.
This may not be useful to anyone but me, but I wanted to make it available. Get it here and let me know if it's useful to you or you have suggestions for improvements. UAInclude could certainly be generalized to support more than just head-related stuff, but I didn't feel like thinking about it that much. If there are requests for that, I'll think about it some more. [/tech/blosxom] # | Google | | |
|||||||||||||||||||||||||||||||||||||||||||||||||||
| Make free, make free your spirit. Sing the song of life. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Copyright © 1998 - 2008 Joey Gibson | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||