- loading...
Sentences with links
I have suggested I’d release 0.9 many times on Google Groups.
You see sentences like this in many many blogs. I have empathy for the authors who diligently markup each word with a different URL, but it is a wonderful way to describe and hyperlink in a meaningful way.
In the above fabricated, never-before-published quote, all the links are from a Google Groups search. So I knew I’d want to auto-generate it, because the mere thought of manual labour drives me to automation.
This resulted in the new sentence_with_links gem (I like bundling small chunks of code in new gems instead of stand alone library files so that the README file and test cases are encapsulated with the library code).
Installation
> gem install sentence_with_links
Usage
That is, String now has a with_links method, that generates the HTML as above. What if there are more links than words in the sentence? See the “Jessica Simpson” image search example below.
Mashup with Google Groups
For the above demonstration, let’s use our handy Hpricot parser to scrape the GoogleGroups search results, and .
Mashup with Google Images using JSON API
Demo: There are many Jessica Simpson images on Google
(also here, here, here, here, here, here, here, here, here, here, here, and here).
Note how the with_links function handles more links than sentence words? It appends a multitude of ‘here’ links. If you can think of more pleasurable alternatives, let me know. Either way, we don’t want to miss out on any important Jessica Simpson images. They are all there.
Instead of HTML, let’s parse some JSON returned by Google’s alter-ego search interface SearchMash, which provides a JSON API.
First, get the JSON Ruby parser:
gem install json
Then slap it all together…
And there you have it, sentences with links, the lazy Ruby way.
RailsRally 2007 and GemsOnRails
In the past there has been RailsDay, but now the locals of Brazil are running a week-long competition – RailsRally.
The organiser, Ronie Uliana, There are some interesting rules for others who might want to run a RailsRally for people outside of Brazil:
- Teams of any size – you just have to figure out how you’re going to split the prizes!
- Competition runs for 7 days
- To prevent you pre-writing your application, there will be a theme for all applications, announced at the start of the competition.
- No external gems allowed. I thought this was a harsh limitation, but Ronie said they will support the native-compiled gems like Hpricot and RMagik, and other gems could be frozen into your application code base with Gems on Rails [summary below].
Gems on Rails
This Rails plugin allows you to freeze or link a gem into your rails source (inspired by Rick Olsen’s gems plugin)
Install:
To install the plugin:
> gem install gemsonrails > cd rails-app-folder > gemsonrails
Usage:
rake gems:freeze GEM=gem_to_freeze rake gems:link GEM=gem_to_link rake gems:unfreeze GEM=gem_to_unfreeze_or_unlink
The gems are loaded into vendor/gems and are loaded automatically. Any rake task files from the gems are also automatically loaded via your root Rakefile (that is, if you type rake -T from your application path the rake files in your gems are included; very nifty)
.
This plugin is experimental, and will invoke an init.rb file in the root of the gem if it has one, else it just adds the gem into the LOAD_PATH, and you’ll need to require it as per normal.
If the target gem doesn’t have an init.rb, you can create one in the vendor/gems/<gem-name>/ folder to do any preloading you’d like; instead of doing it in environment.rb.
This plugin was written by moi, and is used in a production environment, but still proceed with caution and ping me with any quirks or features.
Railsconf and Me
Dear Dr Nic Williams,
Thank you for registering for RailsConf 2007 happening on May 17 – May 20, 2007.
Conference Sessions Plus Tutorials Day
Tutorial
Title: Scaling a Rails Application from the Bottom Up
Date: 05/17/2007
Time: 8:30am to 12:00pmTutorial
Title: Harnessing Capistrano
Date: 05/17/2007
Time: 1:30pm to 5:00pm
Now, who’s organising the late-night RejectConf?
RadRails Templates Cheat Sheets
Now that RadRails is blessed with 100s of templates/snippets the challenge is now knowing what is available. Several people have had a crack at this: XSL conversions of the template XML into HTML, and Ruby scripts to convert the XML into text.
The nicest, most completest solution (that is, it is awesome and yet I didn’t have to do anything) is by Aran Donohue.
Cheat Sheets
- RHTML on radrailstemplates.com or on cheat.errtheblog.com
- Ruby on radrailstemplates.com or on hcheat.errtheblog.com
Rapid Updates
Aran now wields a rake field to update these two wiki sites whenever the templates/snippets change. Sweet cheating goodness.
Sneak a peek
Cop a glimpse at Aran’s cheating via Subversion:
http://arandonohue.com/svn/projects/EclipseCheatSheetMaker/
Prayer to the God of Cheating
Amen.




