Populating template variables in Play Framework applications

January 3rd 2011

Using interceptors to simplify code

I’ve just finished my first, supersimple project using Play Framework and Google App Engine, and I’ve been looking over my work to figure out what I’ve learned might come in handy in my next project or to other programmers.

The template for the new site, a simple code-snippet blog, is similar to the one for this blog, complete with the “fat footer” 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 @With and @Before annotations provide this functionality.

Loading...
Read More… Read More…

Yahoo Query Language: The HTML Table

November 12th 2010

The Web is My API

I recently applied for a new job at the Brown University Library–successfully, as it turned out. As part of the application/interview, I lost a week’s worth of sleep completing a presentation assignment regarding the Library’s Named Collections 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’s blog and Brown’s overall web presence.

One of the main tools I used in building this was Yahoo Query Language, in particular the “html” table. YQL, accodring to Yahoo, “is an expressive SQL-like language that lets you query, filter, and join data across Web services.” The simplest way to use it is to go to the YQL Console, enter a query, and copy the provided REST query link into the code where you’ll be using this data.

Loading...
Read More… Read More…

The New AdamTBradley.com

November 8th 2010

With notes on moving from Textpattern to Symphony

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 Swearer Center for Public Service at Brown University).

I plan to use this blog as kind of a review site for new technologies/software products I’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 Play Framework, web services, and Google App Engine. (Historically, I’ve enjoyed creating new blogs much more than actually writing in them. I’ll be writing in this one and I Really Mean It This Time.)

Loading...
Read More… Read More…

Connecting Twitter (or StatusNet) to iChat (or Adium) with Python

June 27th 2010

Sharing status updates with IM buddies

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’s a Pidgin plugin that takes care of this for me.)

The best way to run this is from cron something like this in your crontab to poll Twitter and update Adium/iChat every 15 minutes:

Loading...
Read More… Read More…

Parsing the Twitter API's XML with XSLT

May 1st 2010

Another Symphony CMS Utility

This is just a simple Twitter XML to XHTML parser I wrote for a site I’m developing with Symphony CMS.
Note that it relies on the date format converter I posted earlier.

There’s likely a much more efficient way to do what I’m doing here, but as I’m relatively new to XSLT, I haven’t found it yet.

Loading...
Read More… Read More…

Date format conversion in XSLT

April 18th 2010

Translating RFC 822 dates to ISO 8601

This is a utility I wrote for a new site I’m developing with Symphony
It’s useful for translating dates from RSS feeds into ISO date values usable by the EXSLT date functions.

Note that this relies on the EXSLT str:tokenize() function.

Loading...
Read More… Read More…

XSLT: Formatting nested groups of items

April 17th 2009

I’m in the process of builidng my first site using the Symphony CMS.

Symphony uses XSLT 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 XSLT well enough to write a single template without turning to The Google dozens of times for answers to newbie questions.

Loading...
Read More… Read More…

Mixing GET variables and segment-based addressing in CodeIgniter

February 19th 2009

“Since CodeIgniter does not utilize GET strings, there is no reason to allow” GET variables, the CodeIgniter User Guide informs us.

Unfortunately, occasionally there is a reason to use those variables—in my case, an in-house authentication program interfered with POST requests made by Javascripts—and it’s not entirely obvious how to make them available in your CodeIgniter app. The Guide seems to suggest enabling query strings, but while that gives you access to the $_GET array, it also cripples your existing URLs—using “query strings” essentially means choosing controllers and methods to execute using GET variables exclusively, what I usually see called “messy URLs.”

Loading...
Read More… Read More…