Skip to content

Commit 229a037

Browse files
committed
First attempt at sitemaps
1 parent 0253f58 commit 229a037

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ gem 'serrano', '~> 1.0'
4343
# simple_form 5.3.0 introduced a bug that prevents custom inputs from being
4444
# loaded (see https://github.com/heartcombo/simple_form/issues/1824)
4545
gem 'simple_form', '~> 5.2.0'
46+
gem 'sitemap_generator'
4647
gem 'strain-code', '~> 0.3'
4748
# Turbolinks makes navigating your web application faster.
4849
# Read more: https://github.com/turbolinks/turbolinks

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ GEM
386386
simple_form (5.2.0)
387387
actionpack (>= 5.2)
388388
activemodel (>= 5.2)
389+
sitemap_generator (6.3.0)
390+
builder (~> 3.0)
389391
spring (2.1.1)
390392
spring-watcher-listen (2.0.1)
391393
listen (>= 2.7, < 4.0)
@@ -501,6 +503,7 @@ DEPENDENCIES
501503
selenium-webdriver
502504
serrano (~> 1.0)
503505
simple_form (~> 5.2.0)
506+
sitemap_generator
504507
spring
505508
spring-watcher-listen (~> 2.0.0)
506509
strain-code (~> 0.3)

config/sitemap.rb

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
SitemapGenerator::Sitemap.default_host = 'https://registry.seqco.de'
2+
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'
3+
4+
# Top-level pages
5+
SitemapGenerator::Sitemap.create do
6+
extend HelpTopics
7+
add root_path, changefreq: :daily, priority: 1.0
8+
9+
# Pages
10+
add page_api_path, changefreq: :monthly, priority: 0.4
11+
add page_about_path, changefreq: :weekly, priority: 0.8
12+
add page_committee_path, changefreq: :monthly, priority: 0.6
13+
add page_news_path, changefreq: :monthly, priority: 0.6
14+
add page_prize_path, changefreq: :monthly, priority: 0.4
15+
add page_publications_path, changefreq: :monthly, priority: 0.4
16+
add page_seqcode_path, changefreq: :monthly, priority: 0.8
17+
18+
# Help
19+
add help_index_path, changefreq: :weekly, priority: 0.8
20+
help_topics.each do |_cat, topics|
21+
topics.each do |topic, _data|
22+
add help_path(topic: topic), changefreq: :monthly, priority: 0.8
23+
end
24+
end
25+
26+
# User registration
27+
add '/sign_up', changefreq: :monthly, priority: 0.5
28+
add '/login', changefreq: :monthly, priority: 0.5
29+
30+
# Indexes
31+
add name_type_genomes_path, changefreq: :weekly, priority: 0.6
32+
add names_path, changefreq: :daily, priority: 0.8
33+
add submitted_names_path, changefreq: :daily, priority: 0.8
34+
add endorsed_names_path, changefreq: :daily, priority: 0.8
35+
add strains_path, changefreq: :daily, priority: 0.6
36+
add registers_path, changefreq: :weekly, priority: 0.8
37+
add authors_path, changefreq: :daily, priority: 0.4
38+
add journals_path, changefreq: :monthly, priority: 0.4
39+
add publications_path, changefreq: :daily, priority: 0.4
40+
add subjects_path, changefreq: :monthly, priority: 0.2
41+
add search_path, changefreq: :monthly, priority: 0.2
42+
end
43+
44+
# Names
45+
SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:names)
46+
SitemapGenerator::Sitemap.create do
47+
Name.all_public.find_each do |name|
48+
add name_path(name), lastmod: name.updated_at,
49+
changefreq: :weekly, priority: 0.6
50+
# TODO:
51+
# - add wiki
52+
# - add network
53+
end
54+
end
55+
56+
# Genomes
57+
SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:genomes)
58+
SitemapGenerator::Sitemap.create do
59+
Genome.all_public.find_each do |genome|
60+
add genome_path(genome), lastmod: genome.updated_at,
61+
changefreq: :weekly, priority: 0.4
62+
# TODO:
63+
# - add sample_map
64+
end
65+
end
66+
67+
# Strains
68+
SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:strains)
69+
SitemapGenerator::Sitemap.create do
70+
Strain.find_each do |strain|
71+
add strain_path(strain), lastmod: strain.updated_at,
72+
changefreq: :weekly, priority: 0.4
73+
end
74+
end
75+
76+
# Registers
77+
SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:registers)
78+
SitemapGenerator::Sitemap.create do
79+
Register.where(validated: true).find_each do |register|
80+
add register_path(register), lastmod: register.updated_at,
81+
changefreq: :weekly, priority: 0.6
82+
# TODO:
83+
# - add table
84+
# - add list
85+
# - add sample_map
86+
# - add tree
87+
end
88+
end
89+
90+
# TODO Add members for:
91+
# - authors
92+
# - journals
93+
# - publications
94+
# - subjects
95+

0 commit comments

Comments
 (0)