jekyll_asciidoctor_pdf 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bab851fad6ffc5d464e79813ce0332c2a8daffb9f9eaa71bade8dc2de0bf9d0
|
4
|
+
data.tar.gz: b3d8938359332905113447fd0107e2c0bd2ae37417853b4ab38895c2aea4811a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca508404667608e35385427825f3fe37c3acd9770f57d49ba1abb7294e0132911af6f201b1561b9aa7456169850090ef740253243c88a1ec04f09d25de197454
|
7
|
+
data.tar.gz: c1b70827169817232a4a16d3aefcb49b8588e3fc6a3b5c129d68b3bf85b744805b5005fa0a51452bd658f06f1026179aaaff5125665a41a6704909032a22b6b9
|
@@ -15,9 +15,8 @@ module JekyllAsciidoctorPdf
|
|
15
15
|
# - Execute the convert process
|
16
16
|
# - Let the caller to collect information from the front_matter and from the file itself
|
17
17
|
#
|
18
|
-
def self.generatePdf(
|
18
|
+
def self.generatePdf(product_name, file, output_path, parameters, cover_page, theme_pdf, revision)
|
19
19
|
|
20
|
-
#filename = SafeYAML.load_file(file)
|
21
20
|
front_matter = {}
|
22
21
|
|
23
22
|
content = File.read(file)
|
@@ -28,12 +27,15 @@ module JekyllAsciidoctorPdf
|
|
28
27
|
|
29
28
|
stream_adoc = content.gsub(YAML_FRONT_MATTER_REGEXP, '')
|
30
29
|
|
30
|
+
# We should think about the performance of get the title in that way
|
31
|
+
adoc = Asciidoctor.load stream_adoc
|
32
|
+
title = adoc.doctitle
|
33
|
+
|
31
34
|
filename = File.basename(file,'.*') + '.pdf'
|
32
35
|
filename_path = output_path
|
33
|
-
subtitle = 'Page'
|
34
36
|
base_path = File.dirname(file)
|
35
37
|
|
36
|
-
generateBookTypePdf(filename, filename_path,
|
38
|
+
generateBookTypePdf(filename, filename_path, product_name, title, base_path, stream_adoc, parameters, cover_page, theme_pdf, revision)
|
37
39
|
|
38
40
|
yield(front_matter, stream_adoc) if block_given?
|
39
41
|
end
|
@@ -61,10 +63,10 @@ module JekyllAsciidoctorPdf
|
|
61
63
|
# e.i image:http://example.org/image.png
|
62
64
|
# (we may want to block this feature is too expensive)
|
63
65
|
#
|
64
|
-
def self.generateBookTypePdf(filename, filename_path,
|
66
|
+
def self.generateBookTypePdf(filename, filename_path, product_name, title, base_path, stream_adoc, parameters, cover_page, theme_pdf, revision)
|
65
67
|
|
66
68
|
Asciidoctor.convert(
|
67
|
-
getFullsiteTemplate(title,
|
69
|
+
getFullsiteTemplate(title, product_name, stream_adoc, parameters, cover_page, theme_pdf, revision),
|
68
70
|
backend: 'pdf',
|
69
71
|
doctype: 'book',
|
70
72
|
to_file: filename,
|
@@ -81,16 +83,21 @@ module JekyllAsciidoctorPdf
|
|
81
83
|
#
|
82
84
|
# TODO: Add more configuracion
|
83
85
|
#
|
84
|
-
def self.getFullsiteTemplate(title,
|
86
|
+
def self.getFullsiteTemplate(title, product_name, fullsite, parameters, cover_page, theme_pdf, revision)
|
85
87
|
fullsite_config = parameters['fullsite']
|
86
88
|
|
87
89
|
authors = fullsite_config['authors']
|
88
|
-
|
90
|
+
|
91
|
+
if (revision.nil?)
|
92
|
+
revision_s = DateTime.now.strftime('%m/%d/%Y')
|
93
|
+
else
|
94
|
+
revision_s = revision.strftime('%m/%d/%Y')
|
95
|
+
end
|
89
96
|
|
90
97
|
text = <<~TEXT
|
91
|
-
= #{title} : #{
|
98
|
+
= #{title} : #{product_name}
|
92
99
|
#{authors}
|
93
|
-
#{
|
100
|
+
#{revision_s}
|
94
101
|
:doctype: book
|
95
102
|
:experimental:
|
96
103
|
:reproducible:
|
@@ -70,7 +70,7 @@ module JekyllAsciidoctorPdf
|
|
70
70
|
|
71
71
|
callable_attr :jekyll_config_file, '_config.yml'
|
72
72
|
|
73
|
-
callable_attr :
|
73
|
+
callable_attr :product_name, 'NetApp'
|
74
74
|
|
75
75
|
|
76
76
|
##
|
@@ -207,6 +207,16 @@ module JekyllAsciidoctorPdf
|
|
207
207
|
rm_rf(output_assets, quiet)
|
208
208
|
end
|
209
209
|
|
210
|
+
|
211
|
+
##
|
212
|
+
# Taken from jekyll-last-modified-at
|
213
|
+
#
|
214
|
+
def last_modified_at_unix(file)
|
215
|
+
last_commit_date = value = %x[ git log -1 --pretty="format:%ct" #{file} ]
|
216
|
+
# last_commit_date can be nil iff the file was not committed.
|
217
|
+
last_commit_date.nil? || last_commit_date.empty? ? File.mtime(file) : Time.at(last_commit_date.to_i)
|
218
|
+
end
|
219
|
+
|
210
220
|
##
|
211
221
|
# Loop over each AsciiDoctor file recursively
|
212
222
|
#
|
@@ -229,13 +239,16 @@ module JekyllAsciidoctorPdf
|
|
229
239
|
cd absolute_source_path
|
230
240
|
FileList["**/*.adoc"].each do |file|
|
231
241
|
|
242
|
+
last_modified_at = last_modified_at_unix(file)
|
243
|
+
|
232
244
|
output_path = File.join(pdf_pages,File.dirname(file))
|
233
245
|
mkdir_p_if_not_exist(output_path)
|
234
246
|
|
235
|
-
|
247
|
+
|
248
|
+
JekyllAsciidoctorPdf::ADoc.generatePdf(product_name, file, output_path, parameters, absolute_cover_page, absolute_theme_pdf, last_modified_at ) do |front_matter, stream_adoc|
|
236
249
|
if front_matter.key?('permalink')
|
237
250
|
name = File.join('/', front_matter['permalink'])
|
238
|
-
data = PermalinkData.new(front_matter['sidebar'], stream_adoc, file)
|
251
|
+
data = PermalinkData.new(front_matter['sidebar'], stream_adoc, file, last_modified_at)
|
239
252
|
permalinks[name] = data
|
240
253
|
end
|
241
254
|
end
|
@@ -256,7 +269,7 @@ module JekyllAsciidoctorPdf
|
|
256
269
|
#
|
257
270
|
# <output_path>
|
258
271
|
# |__ <sidebar>/<section>.pdf -> Section output
|
259
|
-
# |__ fullsite
|
272
|
+
# |__ fullsite/<sidebar>.pdf -> whole sidebar content (a.k.a. fullsite PDF)
|
260
273
|
#
|
261
274
|
def generate_fullsite_adoc
|
262
275
|
|
@@ -267,7 +280,7 @@ module JekyllAsciidoctorPdf
|
|
267
280
|
name = File.basename(file).ext('')
|
268
281
|
|
269
282
|
JekyllAsciidoctorPdf::SidebarYAML.new(
|
270
|
-
|
283
|
+
product_name,
|
271
284
|
name,
|
272
285
|
file,
|
273
286
|
permalinks,
|
@@ -7,11 +7,12 @@ module JekyllAsciidoctorPdf
|
|
7
7
|
# We use to create a dictionary of all permalinks a its content (without frontmatter)
|
8
8
|
#
|
9
9
|
class PermalinkData
|
10
|
-
attr_reader :sidebar, :content, :filename
|
11
|
-
def initialize(sidebar, content, filename)
|
10
|
+
attr_reader :sidebar, :content, :filename, :last_modified_at
|
11
|
+
def initialize(sidebar, content, filename, last_modified_at)
|
12
12
|
@sidebar = sidebar
|
13
13
|
@content = content
|
14
14
|
@filename = filename
|
15
|
+
@last_modified_at = last_modified_at
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -48,18 +48,18 @@ module JekyllAsciidoctorPdf
|
|
48
48
|
#
|
49
49
|
class SidebarYAML
|
50
50
|
|
51
|
-
attr_reader :
|
51
|
+
attr_reader :product_name, :name, :file, :permalinks, :parameters, :section_output_path, :sidebar_output_path, :base_path, :cover_page, :theme_pdf
|
52
52
|
|
53
53
|
|
54
|
-
def initialize(
|
55
|
-
@
|
56
|
-
@name
|
57
|
-
@file
|
58
|
-
@permalinks
|
59
|
-
@parameters
|
60
|
-
@base_path
|
61
|
-
@cover_page
|
62
|
-
@theme_pdf
|
54
|
+
def initialize(product_name, name, file, permalinks, parameters, output_path, base_path, cover_page, theme_pdf )
|
55
|
+
@product_name = product_name
|
56
|
+
@name = name
|
57
|
+
@file = file
|
58
|
+
@permalinks = permalinks
|
59
|
+
@parameters = parameters
|
60
|
+
@base_path = base_path
|
61
|
+
@cover_page = cover_page
|
62
|
+
@theme_pdf = theme_pdf
|
63
63
|
|
64
64
|
@section_output_path = File.join(output_path,name)
|
65
65
|
@sidebar_output_path = File.join(output_path,'/fullsite')
|
@@ -139,14 +139,17 @@ module JekyllAsciidoctorPdf
|
|
139
139
|
node.add_content(":leveloffset: -1 \n")
|
140
140
|
filename = node.title.gsub(/[^0-9A-Z]/i, '_') + '.pdf'
|
141
141
|
|
142
|
-
JekyllAsciidoctorPdf::ADoc.generateBookTypePdf(filename, section_output_path,
|
142
|
+
JekyllAsciidoctorPdf::ADoc.generateBookTypePdf(filename, section_output_path, product_name, node.title, base_path, node.content, parameters, cover_page, theme_pdf,nil)
|
143
143
|
else
|
144
144
|
# This is the root of the sidebar
|
145
|
-
|
145
|
+
# WARNING: We are assuming too much!. We are getting the title from the first child
|
146
|
+
first_child = children[0];
|
147
|
+
title = first_child['title']
|
148
|
+
|
146
149
|
filename = File.basename(file).ext('.pdf')
|
147
150
|
filename_path = sidebar_output_path
|
148
151
|
|
149
|
-
JekyllAsciidoctorPdf::ADoc.generateBookTypePdf(filename, filename_path,
|
152
|
+
JekyllAsciidoctorPdf::ADoc.generateBookTypePdf(filename, filename_path, product_name, title, base_path, node.content, parameters, cover_page, theme_pdf,nil)
|
150
153
|
end
|
151
154
|
|
152
155
|
return node
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_asciidoctor_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guido Genzone
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|