-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRakefile
172 lines (149 loc) · 4.13 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
require 'byebug'
require 'erb'
require 'launchy'
require 'rake/clean'
require 'squib'
# Add Rake's clean & clobber tasks
CLEAN.include('_output/*').exclude('_output/gitkeep.txt')
task default: [
:with_color,
:full,
:rulebook_figures,
:characters,
:character_backs,
:skills,
:skill_backs,
:npcs,
:events,
:crises,
:fixers,
:chits,
:items,
:trackers,
:helps,
:rules,
:rivercity
]
task :full do
ENV['SQUIB_BUILD'] ||= ''
ENV['SQUIB_BUILD'] += ',full'
end
task color: [:with_color, :default]
task :sheets do
Squib.enable_build_globally :sheets
Rake::Task['color'].invoke
end
task :with_color do
ENV['SQUIB_BUILD'] ||= ''
ENV['SQUIB_BUILD'] += ',color'
end
task :lvl1 do
ENV['SQUIB_BUILD'] ||= ''
ENV['SQUIB_BUILD'] += ',lvl1'
end
task :rulebook_figures do
ENV['SQUIB_BUILD'] ||= ''
ENV['SQUIB_BUILD'] += ',rulebook_figures'
end
# Any file in src/ can be loaded with `rake foo` if src/foo.rb exists
# The first line of the file, if it's a comment, becomes the description
Dir['src/**.rb'].each do |src_file|
comment = File.open(src_file) { |f| f.readline } # first line comment
desc comment[/^# (.+)/, 1] if comment.start_with? '# '
task_name = src_file[/src\/(.+).rb/, 1].to_sym
task task_name do
load src_file
end
end
task :data do
url = "file:///#{Dir.pwd}/data/data.xlsx"
Launchy.open(url)
end
# Typical booklet
# --page-width 5.0in
# --page-height 8.0in
# --margin-left 0.40in
# --margin-right 0.40in
# --margin-bottom 0.40in
# --margin-top 0.40in
# Small booklet
# --page-width 3.75in
# --page-height 6.25in
# --margin-left 0.45in
# --margin-right 0.45in
# --margin-bottom 0.45in
# --margin-top 0.45in
# Small Vault Box
# --page-width 6.50in
# --page-height 6.50in
# --margin-left 0.25in
# --margin-right 0.25in
# --margin-bottom 0.25in
# --margin-top 0.25in
desc 'Build the rules PDF'
task :rules do
puts "Converting markdown to html..."
load 'src/rules_wikitext.rb'
puts "Weasyprinting..."
`python3 src/weasybuild.py`
end
desc 'Build the full book PDF'
task :book do
puts "Converting markdown to html..."
load 'src/book_wikitext.rb'
puts "Weasyprinting..."
`python3 src/weasybuild_book.py`
end
task :book_pngs do
puts "Ghostscripting PDF to PNGs..."
`gs -dNOPAUSE -dBATCH -sDEVICE=png16m -r600 -dDownScaleFactor=2 -sOutputFile="_output/BOOK[%02d].png" _output/BOOK.pdf`
end
task :rules_pngs do
puts "Ghostscripting PDF to PNGs..."
# `gswin64c -dNOPAUSE -dBATCH -sDEVICE=png16m -r600 -dDownScaleFactor=2 -sOutputFile="_output/RULES-%02d.png" _output/RULES.pdf`
`gs -dNOPAUSE -dBATCH -sDEVICE=png16m -r600 -dDownScaleFactor=2 -sOutputFile="_output/RULES-%02d.png" _output/RULES.pdf`
end
desc 'Build the scenarios PDF'
task yourlastheist: ['yourlastheist:md_to_html','yourlastheist:html_to_pdf']
namespace :yourlastheist do
task :md_to_html do
load 'src/your_last_heist.rb' # convert markdown
template = 'scenarios/your-last-heist/booklet-template.html.erb'
erb = ERB.new(File.read(template))
File.open('scenarios/your-last-heist/booklet.html', 'w+') do |html|
html.write(erb.result)
end
end
task html_to_pdf: [:md_to_html] do
sh <<-EOS.gsub(/\n/, '')
wkhtmltopdf
--page-width 6.50in
--page-height 6.50in
--margin-left 0.25in
--margin-right 0.25in
--margin-bottom 0.25in
--margin-top 0.25in
--footer-right "[page] of [topage]"
--footer-left "Your Last Heist"
--footer-font-name "Archivo Narrow"
--footer-font-size "10"
scenarios/your-last-heist/booklet.html _output/your-last-heist.pdf
EOS
end
end
desc 'Build the River City scenarios PDF'
task rivercity: ['rivercity:md_to_html','rivercity:html_to_pdf']
namespace :rivercity do
task :md_to_html do
load 'src/rivercity.rb' # convert markdown
template = 'scenarios/rivercity/booklet-template.html.erb'
erb = ERB.new(File.read(template))
File.open('scenarios/rivercity/booklet.html', 'w+') do |html|
html.write(erb.result)
end
end
task html_to_pdf: [:md_to_html] do
puts "Weasyprinting..."
`python3 src/weasybuild_rivercity.py`
end
end