obf 0.9.8.32 → 0.9.8.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Sazanami-Hanazono-Mincho.ttf +0 -0
- data/lib/obf/external.rb +29 -0
- data/lib/obf/pdf.rb +138 -130
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e9c05fbc1eb76aca00e0b2bda343ed7d2309ef8350d494eee7c07b1806013e4
|
4
|
+
data.tar.gz: 0b13491784c9dae969e7cf9344f7c5d171b63ab6251a37d57ce0261ae78106da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9459a448663ae43c120ed92d1d223efa5402895665919df8ba2d1ac2c8a52276724f6b4157a71f6c1abe7fafa26029118467a1646f1f0ea2083320dc5c8fcc45
|
7
|
+
data.tar.gz: 8847fd9594814bb7789178f89584811f63c4726982307a1e4ff432cb9537e9a2beff69c684d4218a04d398116128bab6efc7e87eadc07f24a0a6d09f64aedffa
|
Binary file
|
data/lib/obf/external.rb
CHANGED
@@ -116,6 +116,8 @@ module OBF::External
|
|
116
116
|
OBF::Utils.update_current_progress(idx.to_f / button_count.to_f)
|
117
117
|
end
|
118
118
|
|
119
|
+
# board_id 1_527892 has some svg's still, not pre-rasterized versions
|
120
|
+
# 1_531854 convert-im6.q16: non-conforming drawing primitive definition `Helvetica''' @ error/draw.c/DrawImage/3265.
|
119
121
|
if to_include[:images]
|
120
122
|
hydra = OBF::Utils.hydra
|
121
123
|
grabs = []
|
@@ -129,6 +131,7 @@ module OBF::External
|
|
129
131
|
end
|
130
132
|
end
|
131
133
|
end
|
134
|
+
OBF::Utils.log(" batch-retrieving #{grabs.length} images for board #{res['name'] || res['id']}")
|
132
135
|
hydra.run
|
133
136
|
|
134
137
|
grabs.each do |grab|
|
@@ -192,6 +195,20 @@ module OBF::External
|
|
192
195
|
end
|
193
196
|
res['images'] << trim_empties(image)
|
194
197
|
end
|
198
|
+
elsif to_include[:image_urls]
|
199
|
+
images.each do |original_image|
|
200
|
+
image = {
|
201
|
+
'id' => original_image['id'],
|
202
|
+
'width' => original_image['width'],
|
203
|
+
'height' => original_image['height'],
|
204
|
+
'license' => OBF::Utils.parse_license(original_image['license']),
|
205
|
+
'url' => original_image['url'],
|
206
|
+
'data_url' => original_image['data_url'],
|
207
|
+
'content_type' => original_image['content_type']
|
208
|
+
}
|
209
|
+
res['images'] << trim_empties(image)
|
210
|
+
end
|
211
|
+
|
195
212
|
end
|
196
213
|
|
197
214
|
if to_include[:sounds]
|
@@ -225,6 +242,18 @@ module OBF::External
|
|
225
242
|
sound['path'] = zip_path
|
226
243
|
end
|
227
244
|
|
245
|
+
res['sounds'] << trim_empties(sound)
|
246
|
+
end
|
247
|
+
elsif to_include[:sound_urls]
|
248
|
+
sounds.each do |original_sound|
|
249
|
+
sound = {
|
250
|
+
'id' => original_sound['id'],
|
251
|
+
'duration' => original_sound['duration'],
|
252
|
+
'license' => OBF::Utils.parse_license(original_sound['license']),
|
253
|
+
'url' => original_sound['url'],
|
254
|
+
'data_url' => original_sound['data_url'],
|
255
|
+
'content_type' => original_sound['content_type']
|
256
|
+
}
|
228
257
|
res['sounds'] << trim_empties(sound)
|
229
258
|
end
|
230
259
|
end
|
data/lib/obf/pdf.rb
CHANGED
@@ -31,6 +31,36 @@ module OBF::PDF
|
|
31
31
|
build_pdf(obj, dest_path, zipper, opts)
|
32
32
|
return dest_path
|
33
33
|
end
|
34
|
+
|
35
|
+
def self.load_fonts(pdf, opts)
|
36
|
+
# remember: https://www.alphabet-type.com/tools/charset-checker/
|
37
|
+
pdf.font_families.update('THFahKwangBold' => {
|
38
|
+
normal: File.expand_path('../../THFahKwangBold.ttf', __FILE__)
|
39
|
+
})
|
40
|
+
pdf.font_families.update('MiedingerBook' => {
|
41
|
+
normal: File.expand_path('../../MiedingerBook.ttf', __FILE__)
|
42
|
+
})
|
43
|
+
pdf.font_families.update('Arial' => {
|
44
|
+
normal: File.expand_path('../../Arial.ttf', __FILE__)
|
45
|
+
})
|
46
|
+
pdf.font_families.update('TimesNewRoman' => {
|
47
|
+
normal: File.expand_path('../../TimesNewRoman.ttf', __FILE__)
|
48
|
+
})
|
49
|
+
# TODO: option to add more fonts
|
50
|
+
pdf.font_families.update('Sazanami-Hanazono-Mincho' => {
|
51
|
+
normal: File.expand_path('../../Sazanami-Hanazono-Mincho.ttf', __FILE__)
|
52
|
+
})
|
53
|
+
default_font = 'TimesNewRoman'
|
54
|
+
if opts['font'] && !opts['font'].match(/TimesNewRoman/) && File.exists?(opts['font'])
|
55
|
+
pdf.font_families.update('DocDefault' => {
|
56
|
+
normal: opts['font']
|
57
|
+
})
|
58
|
+
default_font = 'DocDefault'
|
59
|
+
end
|
60
|
+
pdf.fallback_fonts = ['TimesNewRoman', 'THFahKwangBold', 'MiedingerBook', 'Helvetica', 'Sazanami-Hanazono-Mincho']
|
61
|
+
pdf.font(default_font)
|
62
|
+
default_font
|
63
|
+
end
|
34
64
|
|
35
65
|
def self.build_pdf(obj, dest_path, zipper, opts={})
|
36
66
|
OBF::Utils.as_progress_percent(0, 1.0) do
|
@@ -43,33 +73,11 @@ module OBF::PDF
|
|
43
73
|
}
|
44
74
|
}
|
45
75
|
pdf = Prawn::Document.new(doc_opts)
|
46
|
-
|
47
|
-
pdf.font_families.update('THFahKwangBold' => {
|
48
|
-
normal: {font: 'THFahKwangBold', file: File.expand_path('../../THFahKwangBold.ttf', __FILE__)}
|
49
|
-
})
|
50
|
-
pdf.font_families.update('MiedingerBook' => {
|
51
|
-
normal: {font: 'MiedingerBook', file: File.expand_path('../../MiedingerBook.ttf', __FILE__)}
|
52
|
-
})
|
53
|
-
pdf.font_families.update('Arial' => {
|
54
|
-
normal: {font: 'Arial', file: File.expand_path('../../Arial.ttf', __FILE__)}
|
55
|
-
})
|
56
|
-
pdf.font_families.update('TimesNewRoman' => {
|
57
|
-
normal: {font: 'TimesNewRoman', file: File.expand_path('../../TimesNewRoman.ttf', __FILE__)}
|
58
|
-
})
|
59
|
-
default_font = 'TimesNewRoman'
|
60
|
-
if opts['font'] && !opts['font'].match(/TimesNewRoman/) && File.exists?(opts['font'])
|
61
|
-
pdf.font_families.update('DocDefault' => {
|
62
|
-
normal: {font: 'DocDefault', file: font}
|
63
|
-
})
|
64
|
-
default_font = 'DocDefault'
|
65
|
-
else
|
66
|
-
end
|
67
|
-
pdf.fallback_fonts = ['TimesNewRoman', 'THFahKwangBold', 'MiedingerBook', 'Helvetica']
|
68
|
-
pdf.font(default_font)
|
76
|
+
default_font = load_fonts(pdf, opts)
|
69
77
|
|
70
78
|
multi_render_paths = []
|
71
79
|
if obj['boards']
|
72
|
-
multi_render = obj['boards'].length > 20
|
80
|
+
multi_render = obj['boards'].length > 20 && `which gs`.length > 0
|
73
81
|
obj['backlinks'] = {}
|
74
82
|
if obj['pages']
|
75
83
|
obj['boards'].each do |board|
|
@@ -90,10 +98,10 @@ module OBF::PDF
|
|
90
98
|
OBF::Utils.as_progress_percent(pre, post) do
|
91
99
|
# if more than 20 pages, build each page individually
|
92
100
|
# and combine them afterwards
|
93
|
-
|
94
101
|
if multi_render
|
95
102
|
path = OBF::Utils.temp_path("stash-#{idx}.pdf")
|
96
103
|
pdf = Prawn::Document.new(doc_opts)
|
104
|
+
load_fonts(pdf, opts)
|
97
105
|
else
|
98
106
|
pdf.start_new_page unless idx == 0
|
99
107
|
end
|
@@ -119,7 +127,7 @@ module OBF::PDF
|
|
119
127
|
else
|
120
128
|
build_page(pdf, obj, {
|
121
129
|
'headerless' => !!opts['headerless'],
|
122
|
-
'font' =>
|
130
|
+
'font' => default_font,
|
123
131
|
'text_on_top' => !!opts['text_on_top'],
|
124
132
|
'transparent_background' => !!opts['transparent_background'],
|
125
133
|
'symbol_background' => opts['symbol_background'],
|
@@ -154,98 +162,114 @@ module OBF::PDF
|
|
154
162
|
page_num = options['pages'][obj['id']].to_i
|
155
163
|
pdf.add_dest("page#{page_num}", pdf.dest_fit) if options['links']
|
156
164
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
pdf.
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
165
|
+
pdf.font('Arial') do
|
166
|
+
# header
|
167
|
+
if !options['headerless']
|
168
|
+
header_height = 80
|
169
|
+
pdf.bounding_box([0, doc_height], :width => doc_width, :height => header_height) do
|
170
|
+
pdf.line_width = 2
|
171
|
+
pdf.font_size 16
|
172
|
+
pdf.fill_color "eeeeee"
|
173
|
+
pdf.stroke_color "888888"
|
174
|
+
include_back = options['pages'] && page_num != 1 && page_num != 0
|
175
|
+
# Go Back
|
176
|
+
if include_back
|
177
|
+
OBF::Utils.log " board backlinks #{obj['id']} #{options['backlinks'].to_json}"
|
178
|
+
options['backlinks'] ||= []
|
179
|
+
if options['backlinks'].length > 0
|
180
|
+
x = 110
|
181
|
+
pdf.fill_and_stroke_rounded_rectangle [x, header_height], 100, header_height, default_radius
|
182
|
+
pdf.fill_color "6D81D1"
|
183
|
+
pdf.fill_and_stroke_polygon([x + 5, 45], [x + 35, 70], [x + 35, 60], [x + 95, 60], [x + 95, 30], [x + 35, 30], [x + 35, 20])
|
184
|
+
pdf.fill_color "666666"
|
185
|
+
text_options = {:text => "Go Back"}
|
186
|
+
text_options[:anchor] = "page1" if options['links']
|
187
|
+
pdf.formatted_text_box [text_options], :at => [x + 10, header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
188
|
+
if options['backlinks'].length <= 3
|
189
|
+
backlinks = (options['backlinks'] || []).join(',')
|
190
|
+
pdf.fill_color "ffffff"
|
191
|
+
pdf.formatted_text_box [{:text => backlinks}], :at => [x + 20, header_height + 5 - 25], :width => 70, :height => 30, :align => :center, :valign => :center, :overflow => :shrink_to_fit
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
186
195
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
196
|
+
# Say it Out Loud
|
197
|
+
pdf.fill_color "ffffff"
|
198
|
+
shift = include_back ? 0 : 55
|
199
|
+
offset = include_back ? 110 : 55
|
200
|
+
box_shift = include_back ? 110 : 0
|
201
|
+
|
202
|
+
pdf.fill_and_stroke_rounded_rectangle [110 + box_shift, header_height], 170 + shift + shift, header_height, default_radius
|
203
|
+
pdf.fill_color "DDDB54"
|
204
|
+
pdf.fill_and_stroke do
|
205
|
+
pdf.move_to 160 + offset, 40
|
206
|
+
pdf.line_to 190 + offset, 55
|
207
|
+
pdf.curve_to [125 + offset, 40], :bounds => [[180 + offset, 80], [125 + offset, 80]]
|
208
|
+
pdf.curve_to [190 + offset, 25], :bounds => [[125 + offset, 0], [180 + offset, 0]]
|
209
|
+
pdf.line_to 160 + offset, 40
|
210
|
+
end
|
211
|
+
pdf.fill_color "444444"
|
212
|
+
pdf.text_box "Say that out loud for me", :at => [210 + offset, header_height], :width => 60, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
|
204
213
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
214
|
+
# Start Over
|
215
|
+
x = doc_width
|
216
|
+
pdf.fill_color "eeeeee"
|
217
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
218
|
+
pdf.fill_color "5c9c6d"
|
219
|
+
pdf.stroke_color "25783b"
|
220
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 50, 75], [doc_width - x + 80, 50], [doc_width - x + 80, 20], [doc_width - x + 20, 20], [doc_width - x + 20, 50])
|
221
|
+
pdf.stroke_color "888888"
|
222
|
+
pdf.fill_color "666666"
|
223
|
+
pdf.text_box "Start Over", :styles => [:bold], :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
215
224
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
225
|
+
# Oops
|
226
|
+
x = 210
|
227
|
+
pdf.fill_color "eeeeee"
|
228
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
229
|
+
pdf.fill_color "6653a6"
|
230
|
+
pdf.stroke_color "554a78"
|
231
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 75], [doc_width - x + 50 + 7, 75], [doc_width - x + 50 + 7, 40], [doc_width - x + 50 - 7, 40])
|
232
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 33], [doc_width - x + 50 + 7, 33], [doc_width - x + 50 + 7, 20], [doc_width - x + 50 - 7, 20])
|
233
|
+
pdf.stroke_color "888888"
|
234
|
+
pdf.fill_color "666666"
|
235
|
+
pdf.text_box "Oops", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
227
236
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
237
|
+
# Stop
|
238
|
+
x = 320
|
239
|
+
pdf.fill_color "eeeeee"
|
240
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
241
|
+
pdf.fill_color "944747"
|
242
|
+
pdf.stroke_color "693636"
|
243
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 39, 70], [doc_width - x + 61, 70], [doc_width - x + 75, 56], [doc_width - x + 75, 34], [doc_width - x + 61, 20], [doc_width - x + 39, 20], [doc_width - x + 25, 34], [doc_width - x + 25, 56])
|
244
|
+
pdf.stroke_color "888888"
|
245
|
+
pdf.fill_color "666666"
|
246
|
+
pdf.text_box "Stop", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
247
|
+
|
248
|
+
# Clear
|
249
|
+
x = 100
|
250
|
+
pdf.fill_color "eeeeee"
|
251
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
252
|
+
pdf.stroke_color "666666"
|
253
|
+
pdf.fill_color "888888"
|
254
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 10, 45], [doc_width - x + 35, 70], [doc_width - x + 90, 70], [doc_width - x + 90, 20], [doc_width - x + 35, 20])
|
255
|
+
pdf.stroke_color "888888"
|
256
|
+
pdf.fill_color "666666"
|
257
|
+
pdf.text_box "Clear", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
258
|
+
end
|
259
|
+
end
|
260
|
+
# footer
|
261
|
+
pdf.fill_color "bbbbbb"
|
262
|
+
obj['name'] = nil if obj['name'] == 'Unnamed Board'
|
263
|
+
if OBF::PDF.footer_text || obj['name']
|
264
|
+
text = [obj['name'], OBF::PDF.footer_text].compact.join(', ')
|
265
|
+
offset = options['pages'] ? 400 : 300
|
266
|
+
pdf.formatted_text_box [{:text => text, :link => OBF::PDF.footer_url}], :at => [doc_width - offset, text_height], :width => 300, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
267
|
+
end
|
268
|
+
pdf.fill_color "000000"
|
269
|
+
if options['pages'] && page_num != 0
|
270
|
+
text_options = {:text => page_num.to_s}
|
271
|
+
text_options[:anchor] = "page1" if options['links']
|
272
|
+
pdf.formatted_text_box [text_options], :at => [doc_width - 100, text_height], :width => 100, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
249
273
|
end
|
250
274
|
end
|
251
275
|
|
@@ -413,22 +437,6 @@ module OBF::PDF
|
|
413
437
|
end
|
414
438
|
end
|
415
439
|
end
|
416
|
-
|
417
|
-
# footer
|
418
|
-
pdf.fill_color "bbbbbb"
|
419
|
-
obj['name'] = nil if obj['name'] == 'Unnamed Board'
|
420
|
-
pdf.font('Arial')
|
421
|
-
if OBF::PDF.footer_text || obj['name']
|
422
|
-
text = [obj['name'], OBF::PDF.footer_text].compact.join(', ')
|
423
|
-
offset = options['pages'] ? 400 : 300
|
424
|
-
pdf.formatted_text_box [{:text => text, :link => OBF::PDF.footer_url}], :at => [doc_width - offset, text_height], :width => 300, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
425
|
-
end
|
426
|
-
pdf.fill_color "000000"
|
427
|
-
if options['pages'] && page_num != 0
|
428
|
-
text_options = {:text => page_num.to_s}
|
429
|
-
text_options[:anchor] = "page1" if options['links']
|
430
|
-
pdf.formatted_text_box [text_options], :at => [doc_width - 100, text_height], :width => 100, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
431
|
-
end
|
432
440
|
end
|
433
441
|
end
|
434
442
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.8.
|
4
|
+
version: 0.9.8.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Whitmer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- README.md
|
148
148
|
- lib/Arial.ttf
|
149
149
|
- lib/MiedingerBook.ttf
|
150
|
+
- lib/Sazanami-Hanazono-Mincho.ttf
|
150
151
|
- lib/THFahKwangBold.ttf
|
151
152
|
- lib/TimesNewRoman.ttf
|
152
153
|
- lib/obf.rb
|
@@ -168,7 +169,7 @@ homepage: https://github.com/CoughDrop/obf
|
|
168
169
|
licenses:
|
169
170
|
- MIT
|
170
171
|
metadata: {}
|
171
|
-
post_install_message:
|
172
|
+
post_install_message:
|
172
173
|
rdoc_options: []
|
173
174
|
require_paths:
|
174
175
|
- lib
|
@@ -183,9 +184,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
- !ruby/object:Gem::Version
|
184
185
|
version: '0'
|
185
186
|
requirements: []
|
186
|
-
rubyforge_project:
|
187
|
+
rubyforge_project:
|
187
188
|
rubygems_version: 2.7.6
|
188
|
-
signing_key:
|
189
|
+
signing_key:
|
189
190
|
specification_version: 4
|
190
191
|
summary: Open Board Format
|
191
192
|
test_files: []
|