jekyll_asciidoctor_pdf 0.2.0 → 0.2.1

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: 4bab851fad6ffc5d464e79813ce0332c2a8daffb9f9eaa71bade8dc2de0bf9d0
4
- data.tar.gz: b3d8938359332905113447fd0107e2c0bd2ae37417853b4ab38895c2aea4811a
3
+ metadata.gz: 9c7baeda17a015c813d1081ac35e2241af1f6fd722af24a2bbfd45a5067737d5
4
+ data.tar.gz: 8e0a31816601b5241e1fb0f95945af92853d9b9fbcea4ac077e767174f01bf02
5
5
  SHA512:
6
- metadata.gz: ca508404667608e35385427825f3fe37c3acd9770f57d49ba1abb7294e0132911af6f201b1561b9aa7456169850090ef740253243c88a1ec04f09d25de197454
7
- data.tar.gz: c1b70827169817232a4a16d3aefcb49b8588e3fc6a3b5c129d68b3bf85b744805b5005fa0a51452bd658f06f1026179aaaff5125665a41a6704909032a22b6b9
6
+ metadata.gz: 8e43bc13d66a6b2513e76f7fe731b9b9a607dd0db369f9f63e0229c228d9bd8adbaa34d4d9c5a9bd1d687dc54e768ea04bea74ad02a690fd873052f27b11b9dd
7
+ data.tar.gz: a332b9b64a1ae676252cd75d0863244c7afae34c75db5801bc7b0d3f4de55eed06aa81475344c83d65a40eccb6669e39aa0c16870d77944202d84e8fe8225888
@@ -8,6 +8,16 @@ YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
8
8
 
9
9
  module JekyllAsciidoctorPdf
10
10
  class ADoc
11
+ def self.getAuthorsList(file)
12
+ names = %x[ git log --pretty=format:"%an" #{file} | sort | uniq ]
13
+ # last_commit_date can be nil iff the file was not committed.
14
+ if (names.nil? || names.empty?)
15
+ return 'NetApp'
16
+ end
17
+
18
+ return names.split(/\n+/).join(', ')
19
+ end
20
+
11
21
  ##
12
22
  # Generate a PDF of an individual page
13
23
  #
@@ -34,8 +44,9 @@ module JekyllAsciidoctorPdf
34
44
  filename = File.basename(file,'.*') + '.pdf'
35
45
  filename_path = output_path
36
46
  base_path = File.dirname(file)
47
+ authors = getAuthorsList(file)
37
48
 
38
- generateBookTypePdf(filename, filename_path, product_name, title, base_path, stream_adoc, parameters, cover_page, theme_pdf, revision)
49
+ generateBookTypePdf(filename, filename_path, product_name, title, base_path, stream_adoc, parameters, cover_page, theme_pdf, revision, authors)
39
50
 
40
51
  yield(front_matter, stream_adoc) if block_given?
41
52
  end
@@ -63,10 +74,10 @@ module JekyllAsciidoctorPdf
63
74
  # e.i image:http://example.org/image.png
64
75
  # (we may want to block this feature is too expensive)
65
76
  #
66
- def self.generateBookTypePdf(filename, filename_path, product_name, title, base_path, stream_adoc, parameters, cover_page, theme_pdf, revision)
77
+ def self.generateBookTypePdf(filename, filename_path, product_name, title, base_path, stream_adoc, parameters, cover_page, theme_pdf, revision, authors)
67
78
 
68
79
  Asciidoctor.convert(
69
- getFullsiteTemplate(title, product_name, stream_adoc, parameters, cover_page, theme_pdf, revision),
80
+ getFullsiteTemplate(title, product_name, stream_adoc, parameters, cover_page, theme_pdf, revision, authors),
70
81
  backend: 'pdf',
71
82
  doctype: 'book',
72
83
  to_file: filename,
@@ -83,10 +94,14 @@ module JekyllAsciidoctorPdf
83
94
  #
84
95
  # TODO: Add more configuracion
85
96
  #
86
- def self.getFullsiteTemplate(title, product_name, fullsite, parameters, cover_page, theme_pdf, revision)
97
+ def self.getFullsiteTemplate(title, product_name, fullsite, parameters, cover_page, theme_pdf, revision, authors)
87
98
  fullsite_config = parameters['fullsite']
88
99
 
89
- authors = fullsite_config['authors']
100
+ if (authors.nil?)
101
+ authors_s = fullsite_config['authors']
102
+ else
103
+ authors_s = authors
104
+ end
90
105
 
91
106
  if (revision.nil?)
92
107
  revision_s = DateTime.now.strftime('%m/%d/%Y')
@@ -96,14 +111,13 @@ module JekyllAsciidoctorPdf
96
111
 
97
112
  text = <<~TEXT
98
113
  = #{title} : #{product_name}
99
- #{authors}
114
+ #{authors_s}
100
115
  #{revision_s}
101
116
  :doctype: book
102
117
  :experimental:
103
118
  :reproducible:
104
119
  :icons: font
105
120
  :listing-caption: Listing
106
- :sectnums:
107
121
  :imagesdir: ./media/
108
122
  :toc:
109
123
  :toclevels: 2
@@ -62,7 +62,7 @@ module JekyllAsciidoctorPdf
62
62
  @theme_pdf = theme_pdf
63
63
 
64
64
  @section_output_path = File.join(output_path,name)
65
- @sidebar_output_path = File.join(output_path,'/fullsite')
65
+ @sidebar_output_path = File.join(output_path,'/fullsite-' + name)
66
66
 
67
67
  FileUtils::mkdir_p(section_output_path)
68
68
  FileUtils::mkdir_p(sidebar_output_path)
@@ -139,17 +139,18 @@ 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, product_name, node.title, base_path, node.content, parameters, cover_page, theme_pdf,nil)
142
+ JekyllAsciidoctorPdf::ADoc.generateBookTypePdf(filename, section_output_path, product_name, node.title, base_path, node.content, parameters, cover_page, theme_pdf,nil, 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
146
  first_child = children[0];
147
147
  title = first_child['title']
148
148
 
149
- filename = File.basename(file).ext('.pdf')
149
+ #filename = File.basename(file).ext('.pdf')
150
+ filename = title.gsub(/[^0-9A-Z]/i, '_') + '.pdf'
150
151
  filename_path = sidebar_output_path
151
152
 
152
- JekyllAsciidoctorPdf::ADoc.generateBookTypePdf(filename, filename_path, product_name, title, base_path, node.content, parameters, cover_page, theme_pdf,nil)
153
+ JekyllAsciidoctorPdf::ADoc.generateBookTypePdf(filename, filename_path, product_name, title, base_path, node.content, parameters, cover_page, theme_pdf,nil, nil)
153
154
  end
154
155
 
155
156
  return node
@@ -1,3 +1,3 @@
1
1
  module JekyllAsciidoctorPdf
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
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.2.0
4
+ version: 0.2.1
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-30 00:00:00.000000000 Z
11
+ date: 2020-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler