Almost every Rails app I’ve worked on has had some kind of blog component. Not only are blogs an easy way to keep your site updated, but it also brings in search engine traffic. One of the best ways to get your blog indexed fairly quickly is by using ping services such as Technorati. These services come by after you ping them and read your RSS feed, indexing your content and ultimately getting your site out in front of a lot of people.
Luckily Rails comes with a built in XMLRPC client, so adding in ping functionality to your app is dead easy. Below is a snippet I use regularly. You can change out the listed services to include any of these ping services. I choose Technorati and Google first, and add in any others that might be more specific to the type of site I’m developing.
def xmlrpc_ping
services = ["http://rpc.technorati.com/rpc/ping","http://blogsearch.google.com/ping/RPC2"]
services.each{|service|
begin
server = XMLRPC::Client.new2(service)
server.call2('weblogUpdates.ping',"My Blog",'http://www.myblog.com')
rescue => detail
logger.info("ping failed for server #{service} (#{detail})")
end
}
end
You may choose to set your ping service list and ping parameters in your environment file. Or, set it to pull from a database so you or your client can edit them through a browser.
PING_SERVICES = ["http://rpc.technorati.com/rpc/ping","http://blogsearch.google.com/ping/RPC2"]
PING_BLOG_NAME = 'My Blog'
PING_BLOG_URL = 'http://www.myblog.com'
Then rewrite the method:
def xmlrpc_ping
PING_SERVICES.each{|service|
begin
server = XMLRPC::Client.new2(service)
server.call2('weblogUpdates.ping',PING_BLOG_NAME,PING_BLOG_URL)
rescue => detail
logger.info("ping failed for server #{service} (#{detail})")
end
}
end
Almost a year after launch, I’ve finally started developing version 2.0 of Unthirsty, a happy hour finder using Google Maps.
Since launching Unthirsty, I haven’t done much in way of improving it. I think of it as a way to let it sit and mature, which it has wonderfully. Both Jason Glaspey (my partner in crime) and I have discovered a few things that could be improved, both from regular use and from user feedback. But we’ve also come up with a laundry list of new features we want to add. Overall, the most exciting thing about the new and improved Unthirsty will be developing it with Ruby on Rails.
The most exciting thing about the new and improved Unthirsty will be developing it with Ruby on Rails, which I’ve come to know and love in the past 6 months while working on a few projects both freelance clients and my new employer, Instrument Marketing. Finally taking the dive and learning Ruby has been great, and working in the Rails framework has been a great experience. Creating Unthirsty 2.0 in Rails is going to make the daunting list of new features much easier to tackle. If I continued using PHP I would probably never get it done.
A few things that Ruby and Rails will dramatically help with will be:
- Keeping track of data relationships
- After creating the class relationship map, I counted at least 16 different relationships between entities in the application. Keeping track of all relationships and validations in PHP would have been a nightmare.
- Geocoding
- I’ve discovered a Ruby gem Graticule, that works with pretty much all the major geocoding services, to geocode addresses into coordinates. It also has methods to calculate distance, and even a SQL query generator that will find locations within a radius of a given point. Although Unthirsty has all this functionality currently, having this completely abstracted in another library is going to make life so much easier.
- AJAX Interface to data
- I’ve gained a lot more Javascript experience since I initially worked on Unthirsty, including tons of time into working with Prototype. With Rails Prototype helpers, grabbing data and plotting it on the map from the Unthirsty database will be a lot simpler. Outputting data will be a snap since ActiveRecord objects can be converted to JSON with one method. Currently Unthirsty data comes out and is processed by Javascript in a really convoluted way that is hard to maintain.
There will be a ton of exciting new features and improvements coming with this new version of Unthirsty, but we do know that we’re doing something right already. The trick is to keep that rhythm going. I think we’ll be able to.