<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>AdamTBradley.com</title>
    <link>http://www.adamtbradley.com</link>
    <description>AdamTBradley.com Feed</description>
    <language>en-us</language>
    <generator>Symphony (build )</generator>
    <atom:link href="http://www.adamtbradley.com/rss/" rel="self" type="application/rss+xml"/>
    <item>
      <title>Populating template variables in Play Framework applications</title>
      <link>http://www.adamtbradley.com/articles/populating-template-variables-in-play-framework-applications/</link>
      <pubDate>Mon, 03 Jan 2011 08:15 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/populating-template-variables-in-play-framework-applications/</guid>
      <description>&lt;p&gt;I&amp;#8217;ve just finished my first, supersimple project using &lt;a href="http://www.playframework.org/"&gt;Play Framework&lt;/a&gt; and &lt;a href="http://appengine.google.com"&gt;Google App Engine&lt;/a&gt;, and I&amp;#8217;ve been looking over my work to figure out what I&amp;#8217;ve learned might come in handy in my next project or to other programmers.&lt;/p&gt;

&lt;p&gt;The template for the new site, a simple code-snippet blog, is similar to the one for this blog, complete with the &amp;#8220;&lt;a href="#footer"&gt;fat footer&lt;/a&gt;&amp;#8221; including feeds from multiple sources. Since the code to populate the variables that provide this data to the template has to run before every page load for almost every controller, it makes sense to put it into a single location that can be run automatically. The &lt;code&gt;@With&lt;/code&gt; and &lt;code&gt;@Before&lt;/code&gt; annotations provide this functionality.&lt;/p&gt;

&lt;p&gt;First, we define a controller that contains the setup code. The &lt;code&gt;@Before&lt;/code&gt; annotation tells Play! to run the function it&amp;#8217;s applied to before any action in this controller. (There are also &lt;code&gt;@After&lt;/code&gt; and &lt;code&gt;@Finally&lt;/code&gt; &amp;#8220;&lt;a href="http://www.playframework.org/documentation/1.1/controllers#interceptions"&gt;interceptions&lt;/a&gt;&amp;#8221;.)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
public class Template_Setup extends Controller {
    @Before
    public static void Footer_Setup() {
        ...
        renderArgs.put("somedata", somedata);
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Second, we use the &lt;code&gt;@With&lt;/code&gt; annotation on each controller that needs our setup. This effectively allows the class to extend more than one parent class (If you&amp;#8217;ve ever used Play&amp;#8217;s built-in Secure module, you&amp;#8217;re already familiar with &lt;code&gt;@With&lt;/code&gt;).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
@With(Template_Setup.class)
public class SomeController extends Controller {
...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With that done, any time an action in our &lt;code&gt;SomeController&lt;/code&gt; controller is called, the &lt;code&gt;Template_Setup.Footer_Setup()&lt;/code&gt; function will be run first, ensuring that our templates receive the data needed to generate the page.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Yahoo Query Language: The HTML Table</title>
      <link>http://www.adamtbradley.com/articles/yahoo-query-language-the-html-table/</link>
      <pubDate>Fri, 12 Nov 2010 07:46 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/yahoo-query-language-the-html-table/</guid>
      <description>&lt;p&gt;I recently applied for a new job at the &lt;a href="http://library.brown.edu"&gt;Brown University Library&lt;/a&gt;&amp;#8211;successfully, as it turned out. As part of the application/interview, I lost a week&amp;#8217;s worth of sleep completing a presentation assignment regarding the Library&amp;#8217;s &lt;a href="http://library.brown.edu/collatoz/"&gt;Named Collections&lt;/a&gt; website. My response to this assignment was a website that combined the content from this site with other sources of information on campus, including the Library&amp;#8217;s blog and Brown&amp;#8217;s overall web presence.&lt;/p&gt;

&lt;p&gt;One of the main tools I used in building this was &lt;a href="http://developer.yahoo.com/yql/"&gt;Yahoo Query Language&lt;/a&gt;, in particular the &amp;#8220;html&amp;#8221; table.  YQL, accodring to Yahoo, &amp;#8220;is an expressive SQL-like language that lets you query, filter, and join data across Web services.&amp;#8221; The simplest way to use it is to go to the &lt;a href="http://developer.yahoo.com/yql/console"&gt;YQL Console&lt;/a&gt;, enter a query, and copy the provided REST query link into the code where you&amp;#8217;ll be using this data.&lt;/p&gt;

&lt;p&gt;YQL&amp;#8217;s html table allows you to query a specific web page, and optionally apply an XPath query, and returns the result as well-formed XML or JSON. For example, the query &lt;a href="http://y.ahoo.it/nboROTVh"&gt;&lt;code&gt;select * from html where url="http://library.brown.edu/collatoz/"&lt;/code&gt;&lt;/a&gt; will return a version of our page (by default, we get only the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; element and its descendants) ready for just about any processor we want to use.&lt;/p&gt;

&lt;p&gt;But pulling the entire body from the page gives us a lot of boilerplate information (header and footer info, sitewide navigation, etc.) that we&amp;#8217;re not interested in here. So let&amp;#8217;s add an XPath query to give us just collection titles and links: &lt;a href="http://y.ahoo.it/7j45jvEK"&gt;&lt;code&gt;select * from html where url="http://library.brown.edu/collatoz/"; and xpath="//li[@class='bodytext']/a[@class='main']"&lt;/code&gt;&lt;/a&gt;. We can expand this query, though, to give us more of what we want from the page. This XPath query will give us the collection links, in addition to the list of &amp;#8220;subject groups&amp;#8221; (from the list on the right side of the original page) and the in-page navigation links&amp;#8211;which gives us a list of all letters that start the name of at least one collection: &lt;a href="http://y.ahoo.it/vpsh0svO"&gt;&lt;code&gt;//li[@class='bodytext']/a[@class='main']|//a[starts-with(@href, 'cluster.php')]|//span[@class='bodytextSmallBold']/a&lt;/code&gt;&lt;/a&gt;&amp;#8211;&lt;a href="http://tinyurl.com/3yedkag"&gt;this link&lt;/a&gt; will give you the XML version of this query&amp;#8217;s results, ready to be parsed using SimpleXML, XSLT, or whatever (You can also get the results &lt;a href="http://tinyurl.com/35y3pua"&gt;in JSON format&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For my project, I used XSLT to translate output from YQL and several other sources, including the RSS feed of the &lt;a href="http://blogs.brown.edu/libnews/"&gt;Library&amp;#8217;s news blog&lt;/a&gt;, into XHTML with RDFa markup. I&amp;#8217;m looking forward to finding other uses for Yahoo&amp;#8217;s technology.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The New AdamTBradley.com</title>
      <link>http://www.adamtbradley.com/articles/the-new-adamtbradleycom/</link>
      <pubDate>Mon, 08 Nov 2010 07:56 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/the-new-adamtbradleycom/</guid>
      <description>&lt;p&gt;Welcome to the new version of adamtbradley.com. This is the first new project I started using Symphony CMS, but not the first I finished (that would be the new website for the &lt;a href="http://swearercenter.brown.edu"&gt;Swearer Center for Public Service at Brown University&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;I plan to use this blog as kind of a review site for new technologies/software products I&amp;#8217;ve encountered in the course of my work and spare-time experimentation. In the forseeable future, that will probably include things like Symphony, Django and Python, PHP frameworks, the &lt;a href="http://playframework.org/"&gt;Play Framework&lt;/a&gt;, web services, and Google App Engine.  (Historically, I&amp;#8217;ve enjoyed creating new blogs much more than actually writing in them. I&amp;#8217;ll be writing in this one and I Really Mean It This Time.)&lt;/p&gt;

&lt;p&gt;Symphony is a major shift from Textpattern, the system I used for my last several websites and now my second-favorite CMS. Many of the major differences between Textpattern and Symphony are tracable to Symphony&amp;#8217;s use of XSLT as a template language: Since Symphony can natively process any XML, it can act as a simple REST web service client. This means that Symphony can do many things on its own that require a plug-in in Textpattern&amp;#8211;the five feeds pulled into my &lt;a href="#footer"&gt;footer&lt;/a&gt;, for example, are all handled without a single extension; in Textpattern I would have needed five plugins to populate these (&lt;code&gt;bit_rss&lt;/code&gt; for the RSS feed from LibraryThing, my own &lt;code&gt;atb_twitter&lt;/code&gt; for the Twitter feed, and a few plugins that may or may not already exist to load, cache, and parse the XML from GitHub, Flickr, and Delicious).&lt;/p&gt;

&lt;p&gt;The other major feature Symphony has that Textpattern lacks is its support for custom content types, or &amp;#8220;Sections&amp;#8221; in Symphony parlance. Textpattern&amp;#8217;s equivalents of Symphony&amp;#8217;s sections would be articles, links, images, files, and comments; in Symphony, these are user-created collections of fields. For example, my Comment section has six fields: Text Inputs for Author, Email and Website (the Email field is a special type created by an extension&amp;#8211;it generates an MD5 hash so I can pull &lt;a href="http://gravatar.com/"&gt;Gravatars&lt;/a&gt;, a date field, a Textarea for the actual comment body, and a &amp;#8220;Select Box Link&amp;#8221; (effectively a specialized foreign key field) providing a link to the comment&amp;#8217;s article.&lt;/p&gt;

&lt;p&gt;Overall, I&amp;#8217;m impressed enough with Symphony that it&amp;#8217;s likely to become my default choice for setting up new websites in a LAMP environment&amp;#8211;it&amp;#8217;s adaptable, and once you&amp;#8217;re used to it, easy enough to use. The documentation isn&amp;#8217;t as complete as I&amp;#8217;d like, and much of what I&amp;#8217;ve learned about writing extensions for it has been gleaned from reading the source code, both of Symphony&amp;#8217;s core, and of other people&amp;#8217;s extensions, but the forums are still a very helpful resource (This is essentially where Textpattern was four or five years ago, when I started using it).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Connecting Twitter (or StatusNet) to iChat (or Adium) with Python</title>
      <link>http://www.adamtbradley.com/articles/connecting-twitter-or-statusnet-to-ichat-or-adium-with-python/</link>
      <pubDate>Sun, 27 Jun 2010 11:59 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/connecting-twitter-or-statusnet-to-ichat-or-adium-with-python/</guid>
      <description>&lt;p&gt;This is just a simple Python script I wrote to update my IM status with the IM programs on my Mac. (On my Windows and Linux machines, there&amp;#8217;s a Pidgin plugin that takes care of this for me.)&lt;/p&gt;

&lt;p&gt;The best way to run this is from &lt;a href="http://www.macosxhints.com/article.php?story=2001020700163714;"&gt;cron&lt;/a&gt; something like this in your &lt;code&gt;crontab&lt;/code&gt; to poll Twitter and update Adium/iChat every 15 minutes:&lt;/p&gt;

&lt;pre&gt;0,15,30,45 * * * * python /Scripts/twit.py&lt;/pre&gt;

&lt;p&gt;And here is the thoroughly-commented script itself:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Put your Twitter screen name here.
twit = &amp;#39;daydreamlab&amp;#39;
&lt;/code&gt;
&lt;code&gt;from appscript import *
from xml.dom.minidom import parse
from urllib2 import urlopen
&lt;/code&gt;
&lt;code&gt;#Grab the XML feed from the Twitter API.
tweetXML = urlopen(&amp;#39;http://twitter.com/statuses/user_timeline/&amp;#39;+twit+&amp;#39;.xml?count=1&amp;#39;)
&lt;/code&gt;
&lt;code&gt;# If you use identi.ca, use this instead:
#tweetXML = urlopen(&amp;#39;http://identi.ca/api/statuses/user_timeline/&amp;#39;+twit+&amp;#39;.xml?count=1&amp;#39;)
&lt;/code&gt;
&lt;code&gt;#Grab the text of the newest entry.
newestTweet = parse(tweetXML).getElementsByTagName(&amp;#39;text&amp;#39;).item(0).firstChild.data
&lt;/code&gt;
&lt;code&gt;#Tell iChat to update its status message. (Comment this line out if you don&amp;#39;t use iChat.)
app(&amp;#39;iChat&amp;#39;).status_message.set(newestTweet)
&lt;/code&gt;
&lt;code&gt;#Tell Adium to update its status message for each account. 
#(Uncomment these lines if you use Adium.)
#for account in app(&amp;#39;Adium&amp;#39;).account.get():
#        account.status_message.set(newestTweet)
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>XSLT: Formatting nested groups of items</title>
      <link>http://www.adamtbradley.com/articles/xslt-formatting-nested-groups-of-items/</link>
      <pubDate>Fri, 17 Apr 2009 09:01 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/xslt-formatting-nested-groups-of-items/</guid>
      <description>&lt;p&gt;I’m in the process of builidng my first site using &lt;a href="http://symphony21.com/"&gt;the Symphony CMS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Symphony uses &lt;a href="http://en.wikipedia.org/wiki/XSLT"&gt;&lt;span class="caps"&gt;XSLT&lt;/span&gt;&lt;/a&gt; as its template language. In theory, this should make it more flexible than core Textpattern, with its limited number of built-in tags (Although the huge number of plugins available for Textpattern definitely means Txp is still capable of holding its own). That is, if I actually knew &lt;span class="caps"&gt;XSLT&lt;/span&gt; well enough to
write a single template without turning to The Google dozens of times for
answers to newbie questions.&lt;/p&gt;

&lt;p&gt;For the site in question, I need to display a list of categories
as a set of song lyrics, divided into verses of four lines each. In
this first version, I’d decided I wanted the song divided
into columns of four verses each. I’ve changed my mind on
this design decision, but rather than let the &lt;del&gt;headache&lt;/del&gt;
experience go to waste, I’ve decided the code might interest
other, still-newer-than-me newbies. It demonstrates how to build
nested lists in &lt;span class="caps"&gt;XSLT&lt;/span&gt;, which is much less
intuitive than in a procedural language like &lt;span class="caps"&gt;PHP&lt;/span&gt; (or Textpattern Tags with a plugin like &lt;a href="http://thresholdstate.com/software/3707/zemnth"&gt;zem_nth&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Your first impulse, if you’re used to &lt;span class="caps"&gt;PHP&lt;/span&gt;, is to do something like this to group
blocks of items together:&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
&amp;lt;p&amp;gt;
&amp;lt;xsl:template match="data/posts"&amp;gt;
        &amp;lt;xsl:if test="position() mod 4 = 1"&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&amp;lt;/xsl:if&amp;gt;
        &amp;lt;xsl:apply-templates /&amp;gt;
&amp;lt;/xsl:template&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;That &lt;em&gt;so&lt;/em&gt; doesn’t work.&lt;/p&gt;

&lt;p&gt;The problem is, it’s not valid &lt;span class="caps"&gt;XML&lt;/span&gt;—the parser will see an
&lt;code&gt;xsl:if&lt;/code&gt; tag matched with a closing &lt;code&gt;p&lt;/code&gt; tag
and scold you (Symphony won’t even let you save a template
with this markup in it—it fails the first test the &lt;span class="caps"&gt;CMS&lt;/span&gt; subjects it to).&lt;/p&gt;

&lt;p&gt;To handle nested groups, you have to do something like this
(I’m using the &lt;a href="http://www.blueprintcss.org/"&gt;Blueprint&lt;/a&gt; &lt;span class="caps"&gt;CSS&lt;/span&gt; framework, thus the &lt;code&gt;div&lt;/code&gt;s with
class &lt;code&gt;"span-8"&lt;/code&gt;):&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
&amp;lt;xsl:template match="/data/categorylist"&amp;gt;
        &amp;lt;!-- For every sixteenth item in the list: --&amp;gt;
        &amp;lt;xsl:for-each select="entry[position() mod 16 = 1]"&amp;gt;
&lt;/code&gt;
 &lt;code&gt;
         &amp;lt;!--Process this item and the next 16, putting them inside a div --&amp;gt;
                &amp;lt;div class="lyrics span-8"&amp;gt;
                &amp;lt;xsl:for-each select=".|following-sibling::entry[position() &amp;amp;lt; 16]"&amp;gt;
                        &amp;lt;!-- With every fourth item in this block of 16: --&amp;gt;
                        &amp;lt;xsl:if test="position() mod 4 = 1"&amp;gt;
                        &amp;lt;!-- Wrap the current item and the next four in a p --&amp;gt;
                        &amp;lt;p&amp;gt;
                                &amp;lt;xsl:apply-templates select=".|following-sibling::entry[position() &amp;amp;lt; 4]"/&amp;gt;
                        &amp;lt;/p&amp;gt;
                        &amp;lt;/xsl:if&amp;gt;
                &amp;lt;/xsl:for-each&amp;gt;
                &amp;lt;/div&amp;gt;
&lt;/code&gt;
 &lt;code&gt;
 &amp;lt;/xsl:for-each&amp;gt;
&amp;lt;/xsl:template&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;As the comments explain, you have to grab every &lt;em&gt;nth&lt;/em&gt;
item, then apply your templates to that item plus the following
&lt;em&gt;n-1,&lt;/em&gt; or, in XPath,
&lt;code&gt;.|following-sibling::entry[position() &amp;amp;lt; 16]&lt;/code&gt;
(’.’ means the current item in the list being
processed; ‘|’ means “and”).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Date format conversion in XSLT</title>
      <link>http://www.adamtbradley.com/articles/date-format-conversion-in-xslt/</link>
      <pubDate>Sun, 18 Apr 2010 14:06 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/date-format-conversion-in-xslt/</guid>
      <description>&lt;p&gt;This is a utility I wrote for a new site I’m developing
with &lt;a href="http://symphony-cms.com/;"&gt;Symphony&lt;/a&gt;&lt;br/&gt;
It’s useful for translating dates from &lt;span class="caps"&gt;RSS&lt;/span&gt; feeds into &lt;span class="caps"&gt;ISO&lt;/span&gt;
date values usable by the &lt;a href="http://exslt.org/date/"&gt;&lt;span class="caps"&gt;EXSLT&lt;/span&gt; date functions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note that this relies on the &lt;a href="http://exslt.org/str/functions/tokenize/index.html"&gt;&lt;span class="caps"&gt;EXSLT&lt;/span&gt; str:tokenize() function&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:str="http://exslt.org/strings"&amp;gt;
&lt;/code&gt;
&lt;code&gt;
&amp;lt;xsl:template name="rfc-to-iso"&amp;gt;
&amp;lt;xsl:param name="input-date" /&amp;gt;
&lt;/code&gt;
&lt;code&gt;
&amp;lt;!-- Read parts of the date into variables, reading backwards from the end,
     so we don't have to worry about the optional weekday --&amp;gt;
&amp;lt;xsl:variable name="year" select="str:tokenize($input-date, ' ')[last()]" /&amp;gt;
&amp;lt;xsl:variable name="tz" select="str:tokenize($input-date, ' ')[last()-1]" /&amp;gt;
&amp;lt;xsl:variable name="time" select="str:tokenize($input-date, ' ')[last()-2]" /&amp;gt;
&amp;lt;xsl:variable name="day" select="str:tokenize($input-date, ' ')[last()-3]" /&amp;gt;
&amp;lt;xsl:variable name="month" select="str:tokenize($input-date, ' ')[last()-4]" /&amp;gt;
&lt;/code&gt;
&lt;code&gt;
&amp;lt;xsl:value-of select="$year" /&amp;gt;-&amp;lt;xsl:choose&amp;gt;
&amp;lt;!-- Translate month into a two-digit number --&amp;gt;
&amp;lt;xsl:when test="$month = 'Jan'"&amp;gt;01&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Feb'"&amp;gt;02&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Mar'"&amp;gt;03&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Apr'"&amp;gt;04&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'May'"&amp;gt;05&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Jun'"&amp;gt;06&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Jul'"&amp;gt;07&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Aug'"&amp;gt;08&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Sep'"&amp;gt;09&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Oct'"&amp;gt;10&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Nov'"&amp;gt;11&amp;lt;/xsl:when&amp;gt;
&amp;lt;xsl:when test="$month = 'Dec'"&amp;gt;12&amp;lt;/xsl:when&amp;gt;
&amp;lt;/xsl:choose&amp;gt;-&amp;lt;xsl:value-of select="$day" /&amp;gt;T&amp;lt;xsl:value-of select="$time" /&amp;gt;&amp;lt;xsl:if test="$tz = '+0000'"&amp;gt;Z&amp;lt;/xsl:if&amp;gt;&amp;lt;xsl:if test="$tz != '+0000'"&amp;gt;&amp;lt;xsl:value-of select="$tz" /&amp;gt;&amp;lt;/xsl:if&amp;gt;
&lt;/code&gt;
&lt;code&gt;
&amp;lt;/xsl:template&amp;gt;
&lt;/code&gt;
&lt;code&gt;
&amp;lt;/xsl:stylesheet&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Parsing the Twitter API's XML with XSLT</title>
      <link>http://www.adamtbradley.com/articles/parsing-the-twitter-apis-xml-with-xslt/</link>
      <pubDate>Sat, 01 May 2010 00:00 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/parsing-the-twitter-apis-xml-with-xslt/</guid>
      <description>&lt;p&gt;This is just a simple Twitter &lt;span class="caps"&gt;XML&lt;/span&gt; to &lt;span class="caps"&gt;XHTML&lt;/span&gt; parser I wrote for a site I&amp;#8217;m developing with &lt;a href="http://symphonycms.com/"&gt;Symphony &lt;span class="caps"&gt;CMS&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
Note that it relies on the &lt;a href="http://www.adamtbradley.com/journal/date-format-conversion-in-xslt"&gt;date format converter&lt;/a&gt; I posted earlier.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s likely a much more efficient way to do what I&amp;#8217;m doing here, but as I&amp;#8217;m relatively new to &lt;span class="caps"&gt;XSLT&lt;/span&gt;, I haven&amp;#8217;t found it yet.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&amp;amp;quot;1.0&amp;amp;quot; encoding=&amp;amp;quot;UTF-8&amp;amp;quot;?&amp;gt;
&amp;lt;xsl:stylesheet version=&amp;amp;quot;1.0&amp;amp;quot;
    xmlns:xsl=&amp;amp;quot;http://www.w3.org/1999/XSL/Transform&amp;amp;quot;
    xmlns:str=&amp;amp;quot;http://exslt.org/strings&amp;amp;quot; 
    xmlns:date=&amp;amp;quot;http://exslt.org/dates-and-times&amp;amp;quot;
    extension-element-prefixes=&amp;amp;quot;str&amp;amp;quot;&amp;gt;
&lt;/code&gt;
&lt;code&gt;&amp;lt;xsl:import href=&amp;amp;quot;../utilities/rfc-to-iso-dates.xsl&amp;amp;quot; /&amp;gt;
&lt;/code&gt;
&lt;code&gt;&amp;lt;xsl:template match=&amp;amp;quot;//statuses/status&amp;amp;quot;&amp;gt;
    &amp;lt;li class=&amp;amp;quot;tweet&amp;amp;quot;&amp;gt;
    &amp;lt;!--make date display prettier--&amp;gt;
    &amp;lt;xsl:variable name=&amp;amp;quot;now&amp;amp;quot; select=&amp;amp;quot;date:date-time()&amp;amp;quot; /&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;xsl:variable name=&amp;amp;quot;tweetdate&amp;amp;quot;&amp;gt;
        &amp;lt;xsl:call-template name=&amp;amp;quot;rfc-to-iso&amp;amp;quot;&amp;gt;
        &amp;lt;xsl:with-param name=&amp;amp;quot;input-date&amp;amp;quot; select=&amp;amp;quot;created_at&amp;amp;quot; /&amp;gt;
        &amp;lt;/xsl:call-template&amp;gt;
    &amp;lt;/xsl:variable&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;xsl:variable name=&amp;amp;quot;datediff&amp;amp;quot; select=&amp;amp;quot;date:difference($tweetdate, $now)&amp;amp;quot; /&amp;gt;
    &amp;lt;xsl:variable name=&amp;amp;quot;secsdiff&amp;amp;quot; select=&amp;amp;quot;date:seconds($datediff)&amp;amp;quot; /&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;span class=&amp;amp;quot;date&amp;amp;quot;&amp;gt;
        &amp;lt;xsl:choose&amp;gt;
            &amp;lt;xsl:when test=&amp;amp;quot;$secsdiff &amp;lt; 60&amp;amp;quot;&amp;gt;
            &amp;lt;xsl:value-of select=&amp;amp;quot;$secsdiff&amp;amp;quot;/&amp;gt; seconds ago&amp;lt;/xsl:when&amp;gt;
&lt;/code&gt;
&lt;code&gt;            &amp;lt;xsl:when test=&amp;amp;quot;$secsdiff &amp;lt; 3600&amp;amp;quot;&amp;gt;
            &amp;lt;xsl:value-of select=&amp;amp;quot;round($secsdiff div 60)&amp;amp;quot; /&amp;gt; minutes ago&amp;lt;/xsl:when&amp;gt;
&lt;/code&gt;
&lt;code&gt;            &amp;lt;xsl:when test=&amp;amp;quot;$secsdiff &amp;lt; 86400&amp;amp;quot;&amp;gt;
            about &amp;lt;xsl:value-of select=&amp;amp;quot;round($secsdiff div 3600)&amp;amp;quot; /&amp;gt; hours ago&amp;lt;/xsl:when&amp;gt;
&lt;/code&gt;
&lt;code&gt;            &amp;lt;xsl:otherwise&amp;gt;
            &amp;lt;xsl:value-of select=&amp;amp;quot;concat(date:day-in-month($tweetdate), &amp;#39;. &amp;#39;, date:month-name($tweetdate))&amp;amp;quot; /&amp;gt;&amp;lt;/xsl:otherwise&amp;gt;
        &amp;lt;/xsl:choose&amp;gt;:
    &amp;lt;/span&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;!-- Is this a reply? Add an &amp;amp;quot;(in reply to whoever)&amp;amp;quot; link. --&amp;gt;
    &amp;lt;xsl:if test=&amp;amp;quot;in_reply_to_status_id != &amp;#39;&amp;#39;&amp;amp;quot;&amp;gt;
        &amp;lt;a class=&amp;amp;quot;responselink&amp;amp;quot; href=&amp;amp;quot;http://twitter.com/{in_reply_to_screen_name}/status/{in_reply_to_status_id}&amp;amp;quot;&amp;gt;(in reply to &amp;lt;xsl:value-of select=&amp;amp;quot;in_reply_to_screen_name&amp;amp;quot; /&amp;gt;)&amp;lt;/a&amp;gt;
        &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;
    &amp;lt;/xsl:if&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;!-- Parse the text word-by-word --&amp;gt;
    &amp;lt;xsl:for-each select=&amp;amp;quot;str:tokenize(normalize-space(text), &amp;#39; &amp;#39;)&amp;amp;quot;&amp;gt;
&lt;/code&gt;
&lt;code&gt;        &amp;lt;xsl:choose&amp;gt;
&lt;/code&gt;
&lt;code&gt;        &amp;lt;!-- @reference. Make this a link to the referenced user&amp;#39;s Twitter page. --&amp;gt;
        &amp;lt;xsl:when test=&amp;amp;quot;starts-with(., &amp;#39;@&amp;#39;)&amp;amp;quot;&amp;gt;
            &amp;lt;a&amp;gt;
                &amp;lt;xsl:attribute name=&amp;amp;quot;href&amp;amp;quot;&amp;gt;
                &amp;lt;xsl:value-of select=&amp;amp;quot;concat(&amp;#39;http://twitter.com/&amp;#39;, substring(.,2))&amp;amp;quot; /&amp;gt;
                &amp;lt;/xsl:attribute&amp;gt;
                &amp;lt;xsl:value-of select=&amp;amp;quot;.&amp;amp;quot; /&amp;gt;
            &amp;lt;/a&amp;gt; 
        &amp;lt;/xsl:when&amp;gt;
&lt;/code&gt;
&lt;code&gt;        &amp;lt;!-- Hashtag. Link to a Twitter search for this tag. --&amp;gt;
        &amp;lt;xsl:when test=&amp;amp;quot;starts-with(., &amp;#39;#&amp;#39;)&amp;amp;quot;&amp;gt;
            &amp;lt;a&amp;gt;
                &amp;lt;xsl:attribute name=&amp;amp;quot;href&amp;amp;quot;&amp;gt;&amp;lt;xsl:value-of select=&amp;amp;quot;concat(&amp;#39;http://search.twitter.com/search?result_type=recent&amp;amp;q=%23&amp;#39;, substring(., 2))&amp;amp;quot; /&amp;gt;
                &amp;lt;/xsl:attribute&amp;gt;
                &amp;lt;xsl:value-of select=&amp;amp;quot;.&amp;amp;quot; /&amp;gt;
            &amp;lt;/a&amp;gt; 
        &amp;lt;/xsl:when&amp;gt;
&lt;/code&gt;
&lt;code&gt;        &amp;lt;!-- Web URL. Turn it into a link. --&amp;gt;
        &amp;lt;xsl:when test=&amp;amp;quot;starts-with(., &amp;#39;http:&amp;#39;)&amp;amp;quot;&amp;gt;
            &amp;lt;a href=&amp;amp;quot;{.}&amp;amp;quot;&amp;gt;&amp;lt;xsl:value-of select=&amp;amp;quot;.&amp;amp;quot; /&amp;gt;&amp;lt;/a&amp;gt; 
        &amp;lt;/xsl:when&amp;gt;
&lt;/code&gt;
&lt;code&gt;        &amp;lt;!-- Just a word. --&amp;gt;
        &amp;lt;xsl:otherwise&amp;gt;
            &amp;lt;xsl:value-of select=&amp;amp;quot;.&amp;amp;quot; /&amp;gt; 
        &amp;lt;/xsl:otherwise&amp;gt;
&lt;/code&gt;
&lt;code&gt;        &amp;lt;/xsl:choose&amp;gt;
&lt;/code&gt;
&lt;code&gt;        &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;/xsl:for-each&amp;gt;
&lt;/code&gt;
&lt;code&gt;    &amp;lt;/li&amp;gt;
&lt;/code&gt;
&lt;code&gt;&amp;lt;/xsl:template&amp;gt;
&lt;/code&gt;
&lt;code&gt;&amp;lt;/xsl:stylesheet&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Mixing GET variables and segment-based addressing in CodeIgniter</title>
      <link>http://www.adamtbradley.com/articles/mixing-get-variables-and-segment-based-addressing-in-codeigniter/</link>
      <pubDate>Thu, 19 Feb 2009 00:00 -0500</pubDate>
      <guid>http://www.adamtbradley.com/articles/mixing-get-variables-and-segment-based-addressing-in-codeigniter/</guid>
      <description>&lt;p&gt;&amp;#8220;Since CodeIgniter does not utilize &lt;span class="caps"&gt;GET&lt;/span&gt; strings, there is no reason to allow&amp;#8221; &lt;span class="caps"&gt;GET&lt;/span&gt; variables, the CodeIgniter User Guide &lt;a href="http://codeigniter.com/user_guide/libraries/input.html"&gt;informs us&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unfortunately, occasionally there &lt;em&gt;is&lt;/em&gt; a reason to use those variables&amp;#8212;in my case, an in-house authentication program interfered with &lt;span class="caps"&gt;POST&lt;/span&gt; requests made by Javascripts&amp;#8212;and it&amp;#8217;s not entirely obvious how to make them available in your CodeIgniter app.  The Guide seems to suggest &lt;a href="http://codeigniter.com/user_guide/general/urls.html"&gt;enabling query strings&lt;/a&gt;, but while that gives you access to the &lt;code&gt;$_GET&lt;/code&gt; array, it also cripples your existing &lt;span class="caps"&gt;URL&lt;/span&gt;s&amp;#8212;using &amp;#8220;query strings&amp;#8221; essentially means choosing controllers and methods to execute using &lt;span class="caps"&gt;GET&lt;/span&gt; variables exclusively, what I usually see called &amp;#8220;messy &lt;span class="caps"&gt;URL&lt;/span&gt;s.&amp;#8221;&lt;/p&gt;

&lt;p&gt;The solution is (relatively) simple, but not immediately obvious.  I found the solution in &lt;a href="http://codeigniter.com/forums/viewthread/47309/P15/#239306"&gt;this forum post&lt;/a&gt; (hopefully it&amp;#8217;ll be more visible here).  Add these settings to your applications &lt;code&gt;config.php&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$config[&amp;#39;uri_protocol&amp;#39;] = &amp;amp;quot;PATH_INFO&amp;amp;quot;; 
$config[&amp;#39;enable_query_strings&amp;#39;] = TRUE;
$config[&amp;#39;permitted_uri_chars&amp;#39;] = &amp;#39;a-z 0-9~%.:_-?=+&amp;amp;;&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This should give you an app that uses &lt;span class="caps"&gt;URI&lt;/span&gt; segments to map requests to controllers, but can also pull an occasional argument out of the &lt;code&gt;$_GET&lt;/code&gt; superglobal, using the more-or-less generic, universal &lt;code&gt;.htaccess&lt;/code&gt; settings I &amp;#8220;borrowed&amp;#8221; from Textpattern:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;IfModule mod_rewrite.c&amp;gt;
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
&amp;lt;/IfModule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
  </channel>
</rss>

