sitemap.xml
This commit is contained in:
parent
3b7f158890
commit
740693018b
4 changed files with 28 additions and 0 deletions
10
app/controllers/sitemap_controller.rb
Normal file
10
app/controllers/sitemap_controller.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class SitemapController < ApplicationController
|
||||||
|
layout nil
|
||||||
|
|
||||||
|
def index
|
||||||
|
respond_to do |format|
|
||||||
|
format.xml { @items = Item.sitemap }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -40,6 +40,8 @@ class Item < ActiveRecord::Base
|
||||||
scope :sold_in_mall, where(:sold_in_mall => true)
|
scope :sold_in_mall, where(:sold_in_mall => true)
|
||||||
scope :not_sold_in_mall, where(:sold_in_mall => false)
|
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
|
# Not defining validations, since this app is currently read-only
|
||||||
|
|
||||||
def nc?
|
def nc?
|
||||||
|
|
14
app/views/sitemap/index.xml.haml
Normal file
14
app/views/sitemap/index.xml.haml
Normal 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
|
||||||
|
|
|
@ -41,5 +41,7 @@ OpenneoImpressItems::Application.routes.draw do |map|
|
||||||
match '/wardrobe' => 'outfits#edit', :as => :wardrobe
|
match '/wardrobe' => 'outfits#edit', :as => :wardrobe
|
||||||
|
|
||||||
match '/terms' => 'static#terms', :as => :terms
|
match '/terms' => 'static#terms', :as => :terms
|
||||||
|
|
||||||
|
match '/sitemap.xml' => 'sitemap#index', :as => :sitemap, :format => :xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue