XML Sitemap Generator for Rails
This is an approach to get the amazing XML Sitemap Generator for Wordpress to the rails world.
The plugin adds an after_save filter to the model which fires the generate_sitemap method provided by the plugin.
The sitemap is saved in the public folder as sitemap.xml and a gziped version sitemap.xml.gz.
The plugin informs Google by pinging the sitemap submit URL google provids (http://www.google.com/webmasters/tools/ping?sitemap=http://your-site.com/sitemap.xml.gz)
script/plugin install git://github.com/fsmanuel/xml_sitemap_generator.git
Modify config/sitemap_config.yml to your needs (models has to be an array)
production: domain: your-site.com models: ['user', 'content']
Include the MixinSitemap module in every model that should update the sitemap after a change:
Add a method self.find_for_sitemap to your models to restrict what will be added to the sitemap. Default is
def self.find_for_sitemap find(:all, :conditions => ["status = 1"], :order => "id") end
This project can be found on github at the following URL.
Feel free forking the project.
Arne Brachhold, who made the fantastic “Google (XML) Sitemaps Generator for WordPress” which gave me the basic idea – http://www.arnebrachhold.de
Harry Love, who wrote “Google Sitemaps with Ruby on Rails, Capistrano, and Cron” on his Blog: http://harrylove.org