Introducing "gadgets" and "demo generator"
Published 11/15/2008 – Programming – 0 comments
I started learning DOM scripting and how to work with JSON about a year ago. More recently I’ve been learning object-oriented JavaScript, and have enjoyed learning the Prototype framework for its similarities to Ruby. For these reasons, I started creating runnable mini apps that demonstrate what I’m learning, and serve as code samples for others to read.
I started managing directories of static files in the “public” directory of my main site, to host these mini apps, but I really wanted a separate app. With dynamic script tags, calling web services is easy, since it doesn’t require server side code, but I wanted to have the option of returning data from the server for these apps as well. The separate app still needed to be deployable (Capistrano) and “hostable” (apache virtual host plus Phusion Passenger), be written in Ruby, and have an MVC design. Last week I started playing around with Merb “very-flat” apps and Sinatra for these reasons, and decided to go with Sinatra. When I was working on getting things set up, I realized I wanted a way to show which mini apps are new, or the updates I’ve made to existing ones, so parsing a repository commit log seemed like a good way to do that. As I started thinking about what should go on the landing page, I realized that most of the data I wanted was already available as metadata from the project repository. I wanted to host this on github, so I used hpricot to parse both XML from the official GitHub API and scrape HTML off the repo page, to get the metadata I needed.
I settled on the name “gadgets” for these mini apps, and “demo generator” for the Sinatra app, which basically parses the commit feed, scrapes repository metadata, and builds a list of directories where the gadgets live. I realized I could make this configurable for others to use as well. By supplying a user, project, and branch value, demo generator can generate a landing page for your github project too. I’m not sure if anyone else will actually use this, but the capability is there. I thought this was kind of an interesting use of Sinatra, a dynamic page for some simple client-side apps, which could optionally return data from a database or filesystem, is written in Ruby, and is an MVC design.
- Check out “gadgets” and “demo generator” on github
- Demo generator landing page at http://gadgets.webandy.com/
0 comments