Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/_plugins_dev/sitemap-fake.rb
1677 views
1
module Jekyll
2
module Generators
3
# Fake sitemap generator.
4
class SitemapGenerator2 < Generator
5
safe true
6
7
def generate(site)
8
result = '<?xml version="1.0" encoding="UTF-8"?>'
9
result += '<!-- This sitemap has FAKE modification dates intentionally, that step is slow. -->'
10
result += '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' \
11
'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ' \
12
'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ' \
13
'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
14
15
16
subset_pages = site.pages
17
.reject { |t| t.path =~ /ipynb$/ || t.path =~ /api\/ga4gh\/trs\/v2/}
18
.reject { |t| t.data.fetch('layout', 'page') =~ /external/}
19
.reject { |t| t.data.fetch('hands_on', '') == 'external'}
20
21
subset_pages.each do |t|
22
result += "<url><loc>#{site.config['url'] + site.config['baseurl'] + t.url}</loc>" \
23
'<lastmod>2016-06-30T18:00:00-07:00</lastmod></url>'
24
end
25
result += '</urlset>'
26
27
page2 = PageWithoutAFile.new(site, '', '.', 'sitemap.xml')
28
page2.content = result
29
site.pages << page2
30
end
31
end
32
end
33
end
34
35