<div style="background-color: none transparent;"><a href="http://www.rsspump.com/?web_widget/rss_widget/twitter_widget" title="web widget">Twitter Widget</a></div>
   Google Sitemaps in Mephisto image


Google Sitemaps in Mephisto


Posted on Jan 31, 07 at 11:00 am. 
Google Sitemaps in Mephisto art

Well we call them Google Sitemaps, but MSN and Yahoo are also on board and have formed sitemaps.org. So I guess we just call them XML sitemaps?

The 3 search engines currently don’t support the full sitemaps protocol, which is shame, hopefully by later this year they will.

First off : Mephisto, the Ruby on Rails blogging software that powers this site.

Creating a sitemap is no trouble at all with the Mephisto sitemap plugin. Although to get it working on this blog, I had to change the following in
vendor/plugins/mephisto_google_sitemap/lib/mephisto_google_site_map.rb from:


    def lastmod(article)
      time_zone = TimeZone.new(article.site.timezone.current_period.utc_offset)
      latest_comment = article.comments_count.zero? ? nil : article.comments.calculate(:max, :updated_at)
      (latest_comment.nil? ? article.updated_at : latest_comment).strftime("%Y-%m-%dT%H:%M:%S#{time_zone.formatted_offset}")
    end

to:


    def lastmod(article)
      latest_comment = article.comments_count.zero? ? nil : article.comments.calculate(:max, :updated_at)
      (latest_comment.nil? ? article.updated_at : latest_comment).strftime("%Y-%m-%dT%H:%M:%S+00:00")
    end

Change +00:00 to what ever your timezone offset from UTC is. Hopefully this will be fixed in a later version of the sitemap plugin.

Screen Scraping in Ruby


Posted on Jan 31, 07 at 11:00 am. 
Screen Scraping in Ruby art

I’m not going to make a full post on this because over on Rubyrailways.com they have an excellent post covering the main libraries for screen scraping in ruby.

However it is a bit out of date being 7 months old, and since then 2 more excellent libraries have emerged.

Hpricot from the Ruby Superstar _why which has just been updated to version 0.5 today!

And Scrapi which is also excellent.

Even better looking URLs with permalink_fu


Posted on Jan 23, 07 at 11:00 am. 
Even better looking URLs with permalink_fu art

Extracted from Mephisto is the handy plugin called permalink_fu.
This plugin allows you to use ID-less permalinks, much like that in this blog.

I wrote earlier about how to use to_param for nicer URLs, but these are even better. The plugin automatically turns a field in your model into something that could be a permalink, by stripping out all non english and non alphanumeric letters. It then saves this in a field in your database for future use.

So, onto the HowTo:

First, install the plugin in your rails app.


./script/plugin install http://svn.techno-weenie.net/projects/plugins/permalink_fu/

Now you need to add a field to your database to store the permalink.


./script/generate migration add_permalink_to_article

In the migration we add the field called permalink.


add_column :designers, :permalink, :string

Now for the model code


class Article < ActiveRecord::Base

  1. title is the field name you want to convert to a permalink
    has_permalink :title
  2. you can also specifiy a different permalink field in your database by giving a second paramater
  3. has_permalink :title, :my_permalink_field
  1. we now add the to_param method which Rails’s routing uses
    def to_param
    permalink
    end
    end

The permalink field is only populated after the record is validated, so if you have a bunch of records already in your database you can get the permalink field to populate with


Article.find(:all).each(&:save)

If you already have lots of view code written then this is the easy way to get these routes working – in your controller :


@article = Article.find_by_permalink(params[:id])

However that doesn’t seem to pass the smell test using :id rather than :permalink, but will work fine.
To use :permalink you will have to change your routing code and your view code :


# in your route file
map.connect 'article/:permalink', :controller => 'article', :action => 'view'
# in your views when linking
link_to "View #{article.title}", {:controller => 'designer', :action => 'view', :permalink => article.permalink}
# then in your controller you can use
@article = Article.find_by_permalink(params[:permalink])

Thats all! I’m always on the lookout for SEO related Rails topics to talk about so drop me a line @ questions at this domain .com.

Next Page →



Popular Incoming Search Queries For This Topic

This Post Is Filed Under The Following Categories

Web Hosting Plans

Tags Associated with This Post


Affordable Web Hosting News Archives

    web hosting web hosting



    Top Site Listings


    Science Link Exchange
    Business Link Exchange

    Even better looking URLs with permalink_fu picture Subscribe To Affordable Web Hosting By Email
    Even better looking URLs with permalink_fu drawing Affordable Web Hosting RSS Feed
    Even better looking URLs with permalink_fu decal Affordable Web Hosting Comments Feed
    Join
    Affordable
    Web
    Hosting
    On

    Twitter