Skip to content

Commit 594c124

Browse files
Add sitemap.txt (#4155)
Same data as `/sitemap.xml`, but as a flat file list of URLs - #4060 The purpose is for a simple way for an archivist to make a backup of the whole site using cURL/wget/similar means. # TODO - add URLs of CSS/JS files - add URLs of images (!!!) - add URLS of PDFs (downloads of zines, posters, etc)
1 parent aae5061 commit 594c124

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

app/views/sitemap/show.text.erb

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
<%# no indentation, so that the rendered text file is also flat %>
2+
<%# homepage %>
3+
<%= root_url %>
4+
<%# %>
5+
<%# default articles feed, for english articles %>
6+
<%= feed_url %>
7+
<%# %>
8+
<%# Atom feeds discovery page, for all languages with articles %>
9+
<%= feeds_url %>
10+
<%# %>
11+
<%# articles feed, for all languages with articles %>
12+
<% @localized_feeds.each do |locale| %>
13+
<%# Atom feed %>
14+
<%= feed_url(locale.abbreviation) %>
15+
<%# %>
16+
<%# JSON feed (https://jsonfeed.org) %>
17+
<%= json_feed_url(locale.abbreviation) %>
18+
<% end %>
19+
<%# %>
20+
<%# categories %>
21+
<%= categories_url %>
22+
<% @categories.each do |category| %>
23+
<%# category Atom feeds %>
24+
<%= category_feed_url(category.slug) %>
25+
<%# category JSON feeds %>
26+
<%= category_json_feed_url(category.slug) %>
27+
<%# category pages %>
28+
<%= category_url(category.slug) %>
29+
<% end %>
30+
<%# %>
31+
<%# static-ish pages %>
32+
<% @static_paths.each do |path| %>
33+
<%= [root_url, path].join('/') %>
34+
<% end %>
35+
<%# %>
36+
<%# article years %>
37+
<% @article_years.each do |year| %>
38+
<% lastmod = DateTime.new(year).end_of_day %>
39+
<% lastmod = @last_modified if year == Time.current.year %>
40+
<%# %>
41+
<%= article_archives_url(year: year) %>
42+
<% end %>
43+
<%# %>
44+
<%# To Change Everything (TCE) %>
45+
<%= to_change_everything_url %>
46+
<%# %>
47+
<% @to_change_everything_languages.each do |tce_language| %>
48+
<%= to_change_everything_url(lang: tce_language) %>
49+
<%= [to_change_everything_url(lang: tce_language), '/get'].join %>
50+
<% end %>
51+
<%# %>
52+
<%# articles %>
53+
<% @articles.find_each do |article| %>
54+
<% cache article do %>
55+
<%= [root_url, article.path].join %>
56+
<% end %>
57+
<% end %>
58+
<%# %>
59+
<%# language pages %>
60+
<%= languages_url %>
61+
<%# %>
62+
<% Locale.live.each do |locale| %>
63+
<%
64+
# TODO: move these URLs to routes/model/helper
65+
unicode_url = language_url locale.name.downcase.tr(' ', '-')
66+
slug_url = language_url locale.slug.to_sym
67+
english_url = language_url locale.name_in_english.downcase.tr(' ', '-')
68+
#
69+
urls = [unicode_url, slug_url, english_url].uniq
70+
%>
71+
<%# %>
72+
<% urls.each do |url| %>
73+
<%= url %>
74+
<% end %>
75+
<% end %>
76+
<%# %>
77+
<%# support %>
78+
<%= support_url %>
79+
<%# %>
80+
<%# search %>
81+
<%= search_url %>
82+
<%= advanced_search_url %>
83+
<%# %>
84+
<%# tools %>
85+
<%# books %>
86+
<%= books_url %>
87+
<%= books_extras_url(:work) %>
88+
<% @books.find_each do |book| %>
89+
<% cache book do %>
90+
<%= book_url(book.slug) %>
91+
<% end %>
92+
<% end %>
93+
<%# %>
94+
<%# logos %>
95+
<%= logos_url %>
96+
<% @logos.find_each do |logo| %>
97+
<% cache logo do %>
98+
<%= logo_url(logo.slug) %>
99+
<% end %>
100+
<% end %>
101+
<%# %>
102+
<%# posters %>
103+
<%= posters_url %>
104+
<% @posters.find_each do |poster| %>
105+
<% cache poster do %>
106+
<%= poster_url(poster.slug) %>
107+
<% end %>
108+
<% end %>
109+
<%# %>
110+
<%# stickers %>
111+
<%= stickers_url %>
112+
<% @stickers.find_each do |sticker| %>
113+
<% cache sticker do %>
114+
<%= sticker_url(sticker.slug) %>
115+
<% end %>
116+
<% end %>
117+
<%# %>
118+
<%# videos / music %>
119+
<%= music_url %>
120+
<%= videos_url %>
121+
<% @videos.find_each do |video| %>
122+
<% cache video do %>
123+
<%= video_url(video.slug) %>
124+
<% end %>
125+
<% end %>
126+
<%# %>
127+
<%# zines %>
128+
<%= zines_url %>
129+
<% @zines.find_each do |zine| %>
130+
<% cache zine do %>
131+
<%= zine_url(zine.slug) %>
132+
<% end %>
133+
<% end %>
134+
<%# %>
135+
<%# journals / issues %>
136+
<%= journals_url %>
137+
<% @journals.find_each do |journal| %>
138+
<% cache journal do %>
139+
<%= journal_url(journal.slug) %>
140+
<%# %>
141+
<% journal.issues.each do |issue| %>
142+
<% cache issue do %>
143+
<%= issue_url(slug: journal.slug, issue_number: issue.issue) %>
144+
<% end %>
145+
<% end %>
146+
<% end %>
147+
<% end %>
148+
<%# %>
149+
<%# podcasts / episodes %>
150+
<%= podcasts_url %>
151+
<% @podcasts.find_each do |podcast| %>
152+
<% cache podcast do %>
153+
<%= podcast_url(podcast.slug) %>
154+
<%# %>
155+
<% podcast.episodes.each do |episode| %>
156+
<% cache episode do %>
157+
<%= episode_url(slug: podcast.slug, episode_number: episode.episode_number) %>
158+
<%= episode_transcript_url(slug: podcast.slug, episode_number: episode.episode_number) %>
159+
<% end %>
160+
<% end %>
161+
<% end %>
162+
<% end %>

config/routes.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
require 'sidekiq/web'
22

33
Rails.application.routes.draw do
4+
# sitemaps
5+
# xml: for robots/search engines
6+
# txt: for humans/archivers
47
get 'sitemap.xml', to: 'sitemap#show', as: :sitemap
8+
get 'sitemap.txt', to: 'sitemap#show', as: :sitemap_txt
59

610
# TODO: After switching the site auth to Devise, enable this auth protected route
711
# # Sidekiq admin interface to monitor background jobs

0 commit comments

Comments
 (0)