Skip to content

Commit

Permalink
Merge pull request seek4science#1578 from seek4science/sitemap
Browse files Browse the repository at this point in the history
Sitemaps
  • Loading branch information
fbacall authored Sep 8, 2023
2 parents 29004d2 + 4d68328 commit a74be62
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public/javascripts/i18n.js
public/javascripts/translations.js
public/stylesheets/*_cached.css
public/system/
public/sitemaps/*

public/assets/
public/assets_dev/
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ gem 'ransack'

gem 'terser', '~> 1.1', '>= 1.1.1'


# Rails 4 upgrade
gem 'activerecord-session_store'
gem 'rails-observers'
Expand Down Expand Up @@ -202,3 +203,5 @@ group :test, :development do
gem 'teaspoon'
gem 'teaspoon-mocha'
end

gem "sitemap_generator", "~> 6.3"
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
sitemap_generator (6.3.0)
builder (~> 3.0)
slop (3.6.0)
snaky_hash (2.0.0)
hashie
Expand Down Expand Up @@ -1073,6 +1075,7 @@ DEPENDENCIES
seedbank
simple-spreadsheet-extractor (~> 0.18.0)
simplecov
sitemap_generator (~> 6.3)
sprockets-rails
sqlite3 (~> 1.4)
stringio (= 3.0.1)
Expand Down
5 changes: 5 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def offset(off_hours)
runner "Seek::BioSchema::DataDump.generate_dumps"
end

# Generate a new sitemap...
every 1.day, at: '12:45 am' do
rake "-s sitemap:refresh"
end

# not safe to automatically add in a non containerised environment
if Seek::Docker.using_docker?
every 10.minutes do
Expand Down
19 changes: 19 additions & 0 deletions config/sitemap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://github.com/kjvarga/sitemap_generator#sitemapgenerator
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps"
SitemapGenerator::Sitemap.create_index = "auto"
SitemapGenerator::Sitemap.compress = false
SitemapGenerator::Sitemap.default_host = URI.parse(Seek::Config.site_base_url)

SitemapGenerator::Sitemap.create do
Seek::Util.searchable_types.each do |type|
add polymorphic_path(type), lastmod: type.maximum(:updated_at), changefreq: 'daily', priority: 0.7
end
end

Seek::Util.searchable_types.each do |type|
SitemapGenerator::Sitemap.create(filename: type.table_name, include_root: false) do
type.authorized_for('view', nil).find_all do |obj|
add polymorphic_path(obj), lastmod: obj.updated_at, changefreq: 'daily', priority: 0.7
end
end
end

0 comments on commit a74be62

Please sign in to comment.