sitemap.xml

This commit is contained in:
Emi Matchu 2011-05-20 20:49:48 -04:00
parent 3b7f158890
commit 740693018b
4 changed files with 28 additions and 0 deletions

View file

@ -0,0 +1,10 @@
class SitemapController < ApplicationController
layout nil
def index
respond_to do |format|
format.xml { @items = Item.sitemap }
end
end
end

View file

@ -40,6 +40,8 @@ class Item < ActiveRecord::Base
scope :sold_in_mall, where(:sold_in_mall => true)
scope :not_sold_in_mall, where(:sold_in_mall => false)
scope :sitemap, select([:id, :name]).order(:id).limit(49999)
# Not defining validations, since this app is currently read-only
def nc?

View file

@ -0,0 +1,14 @@
!!! XML
%urlset{:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9"}
- for item in @items
%url
%loc http://#{request.host_with_port}#{url_for(item)}
%changefreq monthly
%priority 0.5
-# Homepage
%url
%loc= root_url
%changefreq monthly
%priority 1.0

View file

@ -41,5 +41,7 @@ OpenneoImpressItems::Application.routes.draw do |map|
match '/wardrobe' => 'outfits#edit', :as => :wardrobe
match '/terms' => 'static#terms', :as => :terms
match '/sitemap.xml' => 'sitemap#index', :as => :sitemap, :format => :xml
end