Skip to content

Commit fcc2d9f

Browse files
committed
Full functional sitemaps
1 parent 9db3d1a commit fcc2d9f

4 files changed

Lines changed: 49 additions & 22 deletions

File tree

app/controllers/journals_controller.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ class JournalsController < ApplicationController
22
# GET /journals
33
# GET /journals.json
44
def index
5-
@journals = Publication.where.not(journal: ['', nil])
6-
.select(:journal).reorder(:journal).distinct
7-
.paginate(page: params[:page], per_page: 100)
5+
@journals =
6+
Publication.journals.paginate(page: params[:page], per_page: 100)
87
@crumbs = ['Journals']
98
end
109

app/models/publication.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ def query_crossref(query)
173173
publications
174174
end
175175

176+
def journals
177+
where.not(journal: ['', nil]).select(:journal).reorder(:journal).distinct
178+
end
179+
176180
end
177181

178182
def authors_et_al(format = :text)

config/schedule.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
rake 'wikidata:push'
1717
end
1818

19+
every 1.week do
20+
rake 'sitemap:refresh'
21+
end
22+
1923
every 1.month do
2024
runner 'ReminderMail.register_reminder'
2125
rake 'genomes:clean'

config/sitemap.rb

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
SitemapGenerator::Sitemap.default_host = 'https://registry.seqco.de'
2-
SitemapGenerator::Sitemap.sitemaps_path = '/'
32

43
SitemapGenerator::Sitemap.create do
5-
6-
# Global index
7-
# %w[pages names genomes strains registers].each do |base|
8-
# add_to_index 'sitemaps/%s.xml.gz' % base
9-
# end
10-
114
# Top-level pages
125
group(filename: :pages, sitemaps_path: 'sitemaps/') do
136
extend HelpTopics
@@ -53,9 +46,9 @@
5346
group(filename: :names, sitemaps_path: 'sitemaps/') do
5447
Name.all_public.find_each do |name|
5548
add name_path(name), lastmod: name.updated_at,
56-
changefreq: :weekly, priority: 0.6
49+
changefreq: :monthly, priority: 0.6
5750
add wiki_name_path(name), lastmod: name.updated_at,
58-
changefreq: :weekly, priority: 0.1
51+
changefreq: :monthly, priority: 0.1
5952
# TODO:
6053
# - add network
6154
end
@@ -65,7 +58,7 @@
6558
group(filename: :genomes, sitemaps_path: 'sitemaps/') do
6659
Genome.all_public.find_each do |genome|
6760
add genome_path(genome), lastmod: genome.updated_at,
68-
changefreq: :weekly, priority: 0.4
61+
changefreq: :monthly, priority: 0.4
6962
# TODO:
7063
# - add sample_map
7164
end
@@ -75,28 +68,55 @@
7568
group(filename: :strains, sitemaps_path: 'sitemaps/') do
7669
Strain.find_each do |strain|
7770
add strain_path(strain), lastmod: strain.updated_at,
78-
changefreq: :weekly, priority: 0.4
71+
changefreq: :monthly, priority: 0.4
7972
end
8073
end
8174

8275
# Registers
8376
group(filename: :registers, sitemaps_path: 'sitemaps/') do
8477
Register.where(validated: true).find_each do |register|
8578
add register_path(register), lastmod: register.updated_at,
86-
changefreq: :weekly, priority: 0.6
79+
changefreq: :monthly, priority: 0.6
80+
add table_register_path(register), lastmod: register.updated_at,
81+
changefreq: :monthly, priority: 0.2
82+
add list_register_path(register), lastmod: register.updated_at,
83+
changefreq: :monthly, priority: 0.2
8784
# TODO:
88-
# - add table
89-
# - add list
9085
# - add sample_map
9186
# - add tree
9287
end
9388
end
9489

95-
# TODO Add members for:
96-
# - authors
97-
# - journals
98-
# - publications
99-
# - subjects
90+
# Authors
91+
group(filename: :authors, sitemaps_path: 'sitemaps/') do
92+
Author.find_each do |author|
93+
add author_path(author), lastmod: author.updated_at,
94+
changefreq: :monthly, priority: 0.2
95+
end
96+
end
97+
98+
# Journals
99+
group(filename: :journals, sitemaps_path: 'sitemaps/') do
100+
Publication.journals.find_each do |journal|
101+
add journal_path(journal.journal),
102+
changefreq: :monthly, priority: 0.2
103+
end
104+
end
105+
106+
# Publications
107+
group(filename: :publications, sitemaps_path: 'sitemaps/') do
108+
Publication.find_each do |publication|
109+
add publication_path(publication), lastmod: publication.updated_at,
110+
changefreq: :monthly, priority: 0.2
111+
end
112+
end
100113

114+
# Subjects
115+
group(filename: :subjects, sitemaps_path: 'sitemaps/') do
116+
Subject.find_each do |subject|
117+
add subject_path(subject), lastmod: subject.updated_at,
118+
changefreq: :monthly, priority: 0.1
119+
end
120+
end
101121
end
102122

0 commit comments

Comments
 (0)