Merge pull request #1278 from microweb10/ISSUE-1170
Create dynamic sitemap
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -29,3 +29,5 @@
|
||||
# Mac finder artifacts
|
||||
.DS_Store
|
||||
.ruby-gemset
|
||||
|
||||
public/sitemap.xml
|
||||
1
Gemfile
1
Gemfile
@@ -55,6 +55,7 @@ gem 'devise-async'
|
||||
gem 'newrelic_rpm', '~> 3.17.0.325'
|
||||
gem 'whenever', require: false
|
||||
gem 'pg_search'
|
||||
gem 'sitemap_generator'
|
||||
|
||||
gem 'ahoy_matey', '~> 1.4.2'
|
||||
gem 'groupdate', '~> 3.1.0' # group temporary data
|
||||
|
||||
@@ -381,6 +381,8 @@ GEM
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.0)
|
||||
sitemap_generator (5.2.0)
|
||||
builder (~> 3.0)
|
||||
social-share-button (0.3.1)
|
||||
coffee-rails
|
||||
sass-rails
|
||||
@@ -511,6 +513,7 @@ DEPENDENCIES
|
||||
rvm1-capistrano3
|
||||
sass-rails (~> 5.0, >= 5.0.4)
|
||||
savon
|
||||
sitemap_generator
|
||||
social-share-button
|
||||
spring
|
||||
spring-commands-rspec
|
||||
@@ -522,3 +525,6 @@ DEPENDENCIES
|
||||
unicorn (~> 5.1.0)
|
||||
web-console (= 3.3.0)
|
||||
whenever
|
||||
|
||||
BUNDLED WITH
|
||||
1.13.6
|
||||
|
||||
@@ -22,3 +22,7 @@
|
||||
every 1.minute do
|
||||
command "date > ~/cron-test.txt"
|
||||
end
|
||||
|
||||
every 1.day, at: '5:00 am' do
|
||||
rake "-s sitemap:refresh"
|
||||
end
|
||||
|
||||
36
config/sitemap.rb
Normal file
36
config/sitemap.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
# not use compression
|
||||
class SitemapGenerator::FileAdapter
|
||||
def gzip(stream, data); stream.write(data); stream.close end
|
||||
end
|
||||
SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:sitemap, extension: '.xml')
|
||||
|
||||
# default host
|
||||
SitemapGenerator::Sitemap.default_host = Setting["url"]
|
||||
|
||||
# sitemap generator
|
||||
SitemapGenerator::Sitemap.create do
|
||||
pages = Dir.entries(File.join(Rails.root,"app","views","pages"))
|
||||
pages.each do |page|
|
||||
page_name = page.split(".").first
|
||||
add page_name if page_name.present?
|
||||
end
|
||||
|
||||
add "help_translate"
|
||||
|
||||
add debates_path, priority: 0.7, changefreq: "daily"
|
||||
Debate.find_each do |debate|
|
||||
add debate_path(debate), lastmod: debate.updated_at
|
||||
end
|
||||
|
||||
add proposals_path, priority: 0.7, changefreq: "daily"
|
||||
Proposal.find_each do |proposal|
|
||||
add proposal_path(proposal), lastmod: proposal.updated_at
|
||||
end
|
||||
|
||||
add proposal_ballots_path
|
||||
|
||||
add spending_proposals_path, priority: 0.7, changefreq: "daily"
|
||||
SpendingProposal.find_each do |spending_proposal|
|
||||
add spending_proposal_path(spending_proposal), lastmod: spending_proposal.updated_at
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user