-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
65 lines (54 loc) · 1.84 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
task default: 'test'
MAPS_YAML = '_data/maps.yml'
desc 'Upsert markers by fetching map data'
task :upsert_markers do
YAML.unsafe_load_file(MAPS_YAML, symbolize_names: true).each do |map|
ruby "upsert_markers.rb #{map[:id]}"
end
end
desc 'Generate geojson by loading YAML data'
task :upsert_geojson do
YAML.unsafe_load_file(MAPS_YAML, symbolize_names: true).each do |map|
ruby "upsert_geojson.rb #{map[:id]}"
end
end
desc 'Build pages with GeoJSON compaction'
task build_pages: [:clean_pages] do
YAML.unsafe_load_file(MAPS_YAML, symbolize_names: true).each do |map|
ruby "build_page.rb #{map[:id]}"
end
puts ''
end
desc 'Clean pages generated by build_pages task'
task :clean_pages do
# Delete _posts/*.md files
Dir.glob('_posts/*.md').each { |file| File.delete(file) && puts("Deleted: #{file}") }
# Delete if draft files found
YAML.unsafe_load_file(MAPS_YAML, symbolize_names: true).each do |map|
draft_file = "./#{map[:id]}.md"
File.delete(draft_file) && puts("Deleted: #{draft_file} [DRAFT]") if File.exist? draft_file
end
system 'JEKYLL_END=production bundle exec jekyll clean'
end
# cf. GitHub - gjtorikian/html-proofer
# https://github.com/gjtorikian/html-proofer
require 'html-proofer'
desc 'Test static pages by HTML Proofer'
task test: [:build] do
options = {
checks: ['Links', 'Images', 'Scripts', 'OpenGraph', 'Favicon'],
allow_hash_href: true,
disable_external: true,
enforce_https: true,
#ignore_status_codes: [0, 500, 999],
}
HTMLProofer.check_directory('_site', options).run
end
desc 'Build static pages by Jekyll'
task build: [:clean] do
system 'JEKYLL_END=production bundle exec jekyll build' unless ENV['SKIP_BUILD'] == 'true'
end
desc 'Clean static pages by Jekyll'
task :clean do
system 'JEKYLL_END=production bundle exec jekyll clean' unless ENV['SKIP_BUILD'] == 'true'
end