a work on process

Viewing posts tagged: Web Services

Jumping On

19 February 2007 (5:28 pm)

By James Stewart
Filed under: Uncategorized
Tagged:

Bandwagon logo

Bandwagon is a soon-to-be-launched service to help people back up their itunes libraries. It provides online services (and it looks like tools) to manage and store the backups.

They’re also offering free accounts to bloggers linking to their site, and I’d really like to try the service, so here’s my post.

I’m a little sceptical that it’ll be practical to do online backups of our main itunes library, seeing as how it’s just steamed past 175GB and our DSL connection isn’t at the high end. But I’d love to be proven wrong…

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

Input formats and content types in Rails 1.2

3 February 2007 (2:54 pm)

By James Stewart
Filed under: Notes
Tagged: , , , ,

One feature of recent releases of Rails I hadn’t spotted before is the ability to define your own parameter parsing based on content type. I’m working on an application that will employ a RESTful API and that I hope will take its input in either standard http parameters, microformatted HTML, XML or JSON.

I don’t really want to have to write custom code within the controllers to interpret the input based on content type, so I started looking for how rails parses XML input and came across the following in the actionpack changelog:

    # Assign a new param parser to a new content type
    ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| 
      node = REXML::Document.new(post) 
     { node.root.name => node.root }
    end
 
    # Assign the default XmlSimple to a new content type
    ActionController::Base.param_parsers['application/backpack+xml'] = :xml_simple

Looking at the actual source code it appears it’s actually being implemented slightly differently, with the Mime::Type object being used as the key, rather than the text content type. Since the json content type is already defined (with a reference to the object in Mime::JSON), JSON can (usually) be parsed as YAML, and the :yaml symbol is a shortcut to a YAML parser, handling it transparently is almost as simple as adding:

ActionController::Base.param_parsers[Mime::JSON] = :yaml

or if we wanted to be a bit more explicit:

ActionController::Base.param_parsers[Mime::JSON] = Proc.new do |data| 
	YAML::load(data) 
end

to environment.rb. Building these APIs is even easier than I’d thought!

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

Bus routes on Rails

25 September 2006 (5:51 pm)

By James Stewart
Filed under: Notes
Tagged: , , , , , , ,

Following on from my previous entry about scraping bus route data from The Rapid’s website, and to begin to demonstrate the possibilities it opens up, I’ve set up a simple web service to provide route and stop data. It’s based on the new REST style from Edge Rails, and routes are scoped by city to allow for future expansion. To get data on Route 1, GET:

http://projects.jystewart.net/buses/cities/1/routes/1

To get a list of the stops within 1.5 miles of a given longitude and latitude, GET:

http://projects.jystewart.net/buses/cities/1/stops/?longitude=X&latitude=Y&distance=1.5

Using Edge Rails, setting up the application was remarkably simple. Three models, three controllers, appropriate use of respond_to blocks, and the right entries in config/routes.rb:

map.resources :cities do |cities| 
  cities.resources :stops
  cities.resources :routes
end

This was the first time I’ve used nested routes so it took a few minutes to work out the correct syntax for the link_to calls. When using nested routes like those above, you must declare first the ID of the city and then the ID of the stop or route, eg:

< %= link_to 'My Route', route_url(city, route) %>

I’m not making any guarantees about the long term availability of the service, but if anyone wants to make use of it, let me know and we can probably work something out. I’ll probably be making use of it myself.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

Embedding PHP with Smart Pill

15 August 2006 (8:03 am)

By James Stewart
Filed under: Announcements
Tagged: , , ,

It’s always an interesting challenge to take a system you are familiar with and try to use it in an entirely new way or context. That’s what I’ve been getting with PHP of late. As more and more of my web development work moves to Rails, I’ve had the chance to work on PHP embedded within Filemaker Pro as I’ve tested and explored Scodigo’s new Smart Pill plugin.

For those of us used to programming in full-fledged languages, writing scripts and functions in filemaker can be quite a challenge. Writing and debugging all that recursive code is a time-consuming process, and communicating with external processes isn’t really worth the work without plugins. Smart Pill changes all that, by opening up the entire PHP (5.1.4, including many extensions) engine for use within Filemaker.

I can’t imagine the plugin is going to tempt many web developers over to Filemaker, but for those who are integrating with existing filemaker systems or who need an office database system but want to be able to make use of web services or any of the other functionality PHP allows this could be a huge improvement.

You can see a screencast of the plugin in action, including a number of examples I worked on, over at the Filemaker Magazine site.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

Exploring Greenbelt with Last.FM

11 February 2006 (5:52 pm)

By James Stewart
Filed under: Announcements, Commentary
Tagged:

My particular focus this year as a member of the Greenbelt web team is on finding ways to better integrate festival related content with the wider web, and then working out how to use the festival’s website as a hub for all of that information. It started out with the collage that we built using flickr photos, del.icio.us links, and blog entries around the festival last year, and the next step (the first longer term one) is integration with last.fm.

The integration is pretty simple. We have a Greenbelt group set up on last.fm that we’re encouraging festivalgoers to join. That immediately brings with it all sorts of benefits, like discussion boards, journals, and a custom radio station, but we’re then making use of last.fm’s web services to suck the listening information into the Greenbelt database once a week and produce our own chart page.

By pulling the data into our own database we’re able to do some matching between the artists festivalgoers have been listening to, and the artists in our database. As we build that database out with new bookings, and old archived information that information will get richer and peoples’ listening habits will become not only a way to learn more about the community, but a gateway into our collective history.

There are some kinks to work out. Too many of us keep listening to artists with non-latin characters in their names, and it took me a while to get round to ensure that was being handled nicely. And we probably need a fallback so that if last.fm haven’t updated their charts by a given time, we check again, and provide people a way to access alternative charts. But it’s yet another demonstration of how easy it is to make one site richer using another’s metadata.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 
« Previous PageNext Page »