The Artima Developer Community
Sponsored Link

Java Buzz Forum
User-Agent Based Content Inclusion Plugin

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Joey Gibson

Posts: 71
Nickname: joeygibson
Registered: Jun, 2003

Joey Gibson is an opinionated software architect who blogs about technology, politics, music, etc.
User-Agent Based Content Inclusion Plugin Posted: Jun 26, 2003 8:19 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Joey Gibson.
Original Post: User-Agent Based Content Inclusion Plugin
Feed Title: Joey Gibson's Blog
Feed URL: http://www.jobkabob.com/index.html
Feed Description: Thoughts, musings, ramblings and rants on Java, Ruby, Python, obscure languages, politics and other exciting topics.
Latest Java Buzz Posts
Latest Java Buzz Posts by Joey Gibson
Latest Posts From Joey Gibson's Blog

Advertisement
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.

Read: User-Agent Based Content Inclusion Plugin

Topic: Python is slithering onto my radar, again Previous Topic   Next Topic Topic: BMC's four rules for meeting attendence

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use