hyla 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +8 -8
  2. data/README.adoc +38 -3
  3. data/bin/hyla +21 -8
  4. data/data/toc.adoc +3 -3
  5. data/documentation/introduction.adoc +30 -26
  6. data/documentation/scripts/create_adoc_from_toc.sh +3 -0
  7. data/documentation/scripts/create_myblankproject_add_artefacts.sh +7 -7
  8. data/documentation/scripts/create_myblankproject_add_artefacts_config.sh +14 -8
  9. data/documentation/scripts/create_myblankproject_add_artefacts_my_config.sh +15 -0
  10. data/documentation/scripts/generate_content_myblankproject.sh +7 -7
  11. data/documentation/scripts/generate_content_myblankproject_config.sh +17 -11
  12. data/documentation/scripts/generate_content_myblankproject_other_style.sh +7 -7
  13. data/documentation/scripts/generate_pdf_from_html.sh +1 -1
  14. data/documentation/scripts/generate_slideshow_deckjs.sh +4 -4
  15. data/documentation/scripts/generate_slideshow_mytoc_all.sh +2 -2
  16. data/documentation/scripts/generate_slideshow_mytoc_module.sh +1 -1
  17. data/documentation/scripts/generate_slideshow_revealjs.sh +13 -4
  18. data/documentation/scripts/generate_slideshow_revealjs_config.sh +36 -0
  19. data/documentation/scripts/sendmail.sh +1 -1
  20. data/hyla.gemspec +2 -1
  21. data/lib/hyla.rb +2 -1
  22. data/lib/hyla/commands/{create.rb → add.rb} +18 -1
  23. data/lib/hyla/commands/generate.rb +215 -44
  24. data/lib/hyla/commands/new.rb +16 -9
  25. data/lib/hyla/commands/sendmail.rb +37 -13
  26. data/lib/hyla/commands/serve.rb +2 -2
  27. data/lib/hyla/configuration.rb +73 -33
  28. data/lib/hyla/core_ext.rb +11 -1
  29. data/lib/hyla/project.rb +1 -1
  30. data/lib/resources/backends/haml/revealjs/document.html.haml +9 -2
  31. data/lib/resources/backends/slim/html5/block_image.html.slim +1 -0
  32. data/lib/resources/backends/slim/html5/document.html.slim +18 -9
  33. data/lib/resources/backends/slim/revealjs/block_sidebar.html.slim +5 -5
  34. data/lib/resources/backends/slim/revealjs/document.html.slim +10 -2
  35. data/lib/resources/backends/slim/revealjs/section.html.slim +5 -1
  36. data/lib/resources/cover.slim +70 -0
  37. data/lib/resources/fonts/liberation/Sans-Bold.ttf +0 -0
  38. data/lib/resources/fonts/liberation/Sans-BoldItalic.ttf +0 -0
  39. data/lib/resources/fonts/liberation/Sans-Italic.ttf +0 -0
  40. data/lib/resources/fonts/liberation/Sans-Regular.ttf +0 -0
  41. data/lib/resources/revealjs/css/theme/gpe.css +225 -0
  42. data/lib/resources/styles/liberation.css +3 -1
  43. data/lib/templates/_config.yaml +26 -8
  44. data/lib/templates/book/readme.adoc +1 -1
  45. data/lib/templates/sample/{asciidoc_article.adoc → asciidoc_article.ad} +0 -0
  46. data/lib/templates/sample/{asciidoc_audio.adoc → asciidoc_audio.ad} +0 -0
  47. data/lib/templates/sample/{asciidoc_book.adoc → asciidoc_book.ad} +0 -0
  48. data/lib/templates/sample/{asciidoc_image.adoc → asciidoc_image.ad} +0 -0
  49. data/lib/templates/sample/{asciidoc_report.adoc → asciidoc_report.ad} +3 -2
  50. data/lib/templates/sample/{asciidoc_source.adoc → asciidoc_source.ad} +0 -0
  51. data/lib/templates/sample/{asciidoc_table.adoc → asciidoc_table.ad} +0 -0
  52. data/lib/templates/sample/{asciidoc_video.adoc → asciidoc_video.ad} +0 -0
  53. data/lib/templates/sample/{slideshow_deckjs.adoc → slideshow_deckjs.ad} +0 -0
  54. data/lib/templates/sample/{slideshow_revealjs.adoc → slideshow_revealjs.ad} +1 -1
  55. data/lib/templates/training-exercises/{README.md → README.ad} +0 -0
  56. data/lib/templates/training/readme.adoc +1 -1
  57. metadata +61 -32
  58. data/documentation/scripts/create_adoc_from_toc_config.sh +0 -24
  59. data/lib/resources/backends/slim/document.html.bk.slim +0 -335
  60. data/lib/resources/styles/redhat.css +0 -1
  61. data/test/reports/test-1.0.x-11-12-2013.txt +0 -123
@@ -2,17 +2,29 @@ module Hyla
2
2
  module Commands
3
3
  class New < Command
4
4
 
5
+ @readme_content = <<-EOS
6
+ == Readme Asciidoctor Project
7
+
8
+ This is an empty Asciidoctor readme file.
9
+
10
+ To create **asciidoc(tor)** content, more info is available http://asciidoctor.org/docs/user-manual[here]
11
+
12
+ Otherwise, you can add content to this newly project created using this hyla command :
13
+
14
+ hyla add --t asciidoc --a xxx --d pathToProjectCreated
15
+
16
+ where xxx can be article, book, source, audio, video, ...
17
+ EOS
18
+
5
19
  def self.process(args, options = {})
6
- # raise ArgumentError.new('You must specify a project name to be created.') if args.empty?
20
+
7
21
  out_dir = options[:destination] if self.check_mandatory_option?('-d / --destination', options[:destination])
8
22
 
9
23
  #
10
24
  # Calculate project path (rel/absolute)
11
25
  #
12
- #new_project_path = File.expand_path(args[0], Dir.pwd)
13
26
  new_project_path = File.expand_path(out_dir, Dir.pwd)
14
27
 
15
-
16
28
  if Dir.exist? new_project_path
17
29
 
18
30
  Hyla.logger.debug("Dir exists: #{new_project_path}")
@@ -73,12 +85,7 @@ module Hyla
73
85
  def self.create_blank_project(path)
74
86
  Dir.chdir(path) do
75
87
  f = File.open('readme.ad', 'w')
76
- f.puts "= Readme Asciidoctor Project"
77
- f.puts "This is an empty Asciidoctor readme file."
78
- f.puts "To create **asciidoc(tor)** content, more info are available http://asciidoctor.org/docs/user-manual[here]"
79
- f.puts "otherwise, you can add content to this newly project created using this hyla command :"
80
- f.puts "hyla create --t asciidoc --a xxx --d pathToProjectCreated"
81
- f.puts "where xxx can be article, book, source, audio, video, ..."
88
+ f.puts @readme_content
82
89
  end
83
90
  end
84
91
 
@@ -4,9 +4,10 @@ module Hyla
4
4
 
5
5
  def self.process(args, options)
6
6
 
7
- location = options[:location] if check_mandatory_option?('-s / --location', options[:location])
7
+ location = options[:source] if self.check_mandatory_option?('-s / --source', options[:source])
8
8
  file_name = options[:file] if check_mandatory_option?('-f / --file', options[:file])
9
9
  email_attributes = options[:email_attributes] if check_mandatory_option?('-e / --email_attributes', options[:email_attributes])
10
+ attachment = options[:attachment]
10
11
 
11
12
  sender = email_attributes[:from]
12
13
  recipients = email_attributes[:to]
@@ -46,20 +47,22 @@ module Hyla
46
47
  </html>
47
48
  EOS
48
49
 
49
- mail = Mail.new do
50
- to recipients
51
- from sender
52
- subject subject
53
- content_type 'multipart/related'
54
- end
50
+ mail = populate_email(recipients, sender, subject)
51
+
52
+ case attachment
53
+ when true
55
54
 
56
- attachment = File.read(file_path)
57
- mail.attachments[file_name] = {
58
- :mime_type => 'application/x-html',
59
- :content => attachment,
60
- :Content_Transfer_Encoding => 'quoted-printable'}
55
+ attachment = File.read(file_path)
56
+ mail.attachments[file_name] = {
57
+ :mime_type => 'application/x-html',
58
+ :content => attachment,
59
+ :Content_Transfer_Encoding => 'quoted-printable'}
61
60
 
62
- inline_html = inline_body_with_attachments(body, mail.attachments)
61
+ inline_html = inline_body_with_attachments(body, mail.attachments)
62
+
63
+ when false
64
+ inline_html = File.read(file_path)
65
+ end
63
66
 
64
67
  html_part = Mail::Part.new do
65
68
  content_type 'text/html; charset=UTF-8'
@@ -73,6 +76,24 @@ module Hyla
73
76
  Hyla.logger.info "Email send to SMTP server from #{sender} with this subject : #{subject}"
74
77
  end
75
78
 
79
+ #
80
+ # Create Mail using
81
+ # Recipients, Sender and subject
82
+ #
83
+ def self.populate_email(recipients, sender, subject)
84
+ mail = Mail.new do
85
+ to recipients
86
+ from sender
87
+ subject subject
88
+ content_type 'multipart/related'
89
+ end
90
+ return mail
91
+ end
92
+
93
+ #
94
+ # Generate the Hash of the parameters
95
+ # used by mail compoent nto send email
96
+ #
76
97
  def self.parameters()
77
98
  parameters = {}
78
99
  parameters[:address] = @smtp_server unless @smtp_server.nil?
@@ -84,6 +105,9 @@ module Hyla
84
105
  return parameters
85
106
  end
86
107
 
108
+ #
109
+ # Substitute filename with cid
110
+ #
87
111
  def self.inline_body_with_attachments(html, attachments)
88
112
  attachments.each do |attachment|
89
113
  if (html =~ /#{attachment.filename}/)
@@ -5,18 +5,18 @@ module Hyla
5
5
  def self.process(args, options)
6
6
  include WEBrick
7
7
 
8
- my_opts = options
8
+ my_opts = {}
9
9
 
10
10
  destination = options[:destination] if self.check_mandatory_option?('-d / --destination', options[:destination])
11
11
 
12
12
  my_opts[:Port] = options[:port]
13
13
  my_opts[:BindAddress] = options[:host]
14
+ my_opts[:baseurl] = options[:baseurl]
14
15
  my_opts[:MimeTypes] = self.mime_types
15
16
  my_opts[:DoNotReverseLookupmy_opts] = true
16
17
  my_opts[:StartCallback] = start_callback(options[:detach])
17
18
  my_opts[:AccessLog] = []
18
19
  my_opts[:Logger] = Log::new([], Log::WARN)
19
- my_opts[:baseurl] = options[:baseurl]
20
20
 
21
21
  # recreate NondisclosureName under utf-8 circumstance
22
22
  fh_option = WEBrick::Config::FileHandler
@@ -3,33 +3,43 @@ module Hyla
3
3
 
4
4
  attr_reader :HEADER, :INDEX_SUFFIX, :HEADER_INDEX, :INCLUDE_PREFIX, :INCLUDE_SUFFIX, :LEVEL_1, :LEVEL_2, :SKIP_CHARACTERS,
5
5
  :ADOC_EXT, :PREFIX_ARTEFACT, :YAML_CONFIG_FILE_NAME, :DEFAULTS,
6
- :templates, :samples, :resources, :styles, :backends
6
+ :templates, :cover_template, :samples, :resources, :styles, :fonts, :backends
7
7
 
8
8
  DEFAULTS = {
9
- 'source' => Dir.pwd,
10
- 'destination' => File.join(Dir.pwd, 'generated_content'),
11
- 'watch_dir' => '.',
12
- 'watch_ext' => %w(ad adoc asc asciidoc txt index),
9
+ 'source' => Dir.pwd,
10
+ 'destination' => File.join(Dir.pwd, 'generated_content'),
11
+ 'watch_dir' => '.',
12
+ 'watch_ext' => %w(ad adoc asc asciidoc txt index),
13
13
 
14
14
  # Asciidoctor
15
- 'backend' => 'html5',
16
- 'eruby' => 'erb',
17
- 'doctype' => 'article',
18
- 'compact' => false,
19
- 'to_dir' => '.',
20
- 'to_file' => '',
21
- 'attributes' => {
15
+ 'backend' => 'html5',
16
+ 'eruby' => 'erb',
17
+ 'doctype' => 'article',
18
+ 'compact' => false,
19
+ 'to_dir' => '.',
20
+ 'to_file' => '',
21
+ 'attributes' => {
22
22
  'source-highlighter' => 'coderay',
23
- 'linkcss!' => 'true',
24
- 'data-uri' => 'true',
25
- 'stylesheet' => 'asciidoctor.css',
26
- 'stylesdir' => 'styles'
23
+ 'linkcss!' => 'true',
24
+ 'data-uri' => 'true',
25
+ 'stylesheet' => 'asciidoctor.css',
26
+ 'stylesdir' => 'styles'
27
27
  },
28
- 'safe' => 'unsafe',
28
+ 'safe' => 'unsafe',
29
29
  'header_footer' => true
30
30
 
31
31
  }
32
32
 
33
+ #
34
+ # Matches an include preprocessor directive.
35
+ #
36
+ # Examples
37
+ #
38
+ # include::chapter1.ad[]
39
+ # include::example.txt[lines=1;2;5..10]
40
+ #
41
+ IncludeDirectiveRx = /^\\?include::([^\[]+)\[(.*?)\]$/
42
+
33
43
  INCLUDE_PREFIX = 'include::'
34
44
 
35
45
  INCLUDE_SUFFIX = '[]'
@@ -42,11 +52,12 @@ module Hyla
42
52
  ":source-highlighter: coderay\n"
43
53
 
44
54
  HEADER_INDEX = ":data-uri:\n" +
45
- ":navigation:\n" +
46
- ":menu:\n" +
47
- ":status:\n" +
48
- ":goto:\n" +
49
- ":notitle:\n"
55
+ ":navigation: # navigation attribute used for DeckJS Slideshow\n" +
56
+ ":menu: # navigation attribute used for DeckJS Slideshow\n" +
57
+ ":status: # navigation attribute used for DeckJS Slideshow\n" +
58
+ ":goto: # navigation attribute used for DeckJS Slideshow\n" +
59
+ ":notitle: \n" +
60
+ ":toc: left # Comment or uncomment this attribute if you don't need to display left part of the HTML page a table of content\n"
50
61
 
51
62
  LEVEL_1 = '= '
52
63
 
@@ -54,7 +65,7 @@ module Hyla
54
65
 
55
66
  SKIP_CHARACTERS = '>>'
56
67
 
57
- ADOC_EXT = '.adoc'
68
+ ADOC_EXT = '.ad'
58
69
 
59
70
  PREFIX_ARTEFACT = 'asciidoc_'
60
71
 
@@ -66,10 +77,21 @@ module Hyla
66
77
 
67
78
  STYLES = '../../lib/resources/styles'
68
79
 
80
+ FONTS = '../../lib/resources/fonts'
81
+
69
82
  BACKENDS = '../../lib/resources/backends'
70
83
 
84
+ COVER_TEMPLATE = '../../lib/resources/cover.slim'
85
+
71
86
  YAML_CONFIG_FILE_NAME = '_config.yaml'
72
87
 
88
+ #
89
+ # Cover Slim Template
90
+ #
91
+ def self.cover_template
92
+ File.expand_path(COVER_TEMPLATE, File.dirname(__FILE__))
93
+ end
94
+
73
95
  #
74
96
  # Templates Location
75
97
  #
@@ -91,6 +113,13 @@ module Hyla
91
113
  File.expand_path(STYLES, File.dirname(__FILE__))
92
114
  end
93
115
 
116
+ #
117
+ # Fonts Location
118
+ #
119
+ def self.fonts
120
+ File.expand_path(FONTS, File.dirname(__FILE__))
121
+ end
122
+
94
123
  #
95
124
  # Backends Location
96
125
  #
@@ -133,13 +162,21 @@ module Hyla
133
162
  config = DEFAULTS
134
163
  Hyla::logger.debug("DEFAULTS Keys: #{config.inspect}")
135
164
 
136
- # Read YAML config file IF it exists and
137
- # Merge content with DEFAULT config
138
- new_config = read_config_file(YAML_CONFIG_FILE_NAME)
139
- Hyla::logger.debug("OVERRIDE Keys: #{new_config.inspect}") if !new_config.nil?
140
- config = config.deep_merge(new_config) if !new_config.nil?
165
+ #
166
+ # Read the config file passed as parameter if it exists
167
+ # otherwise read default _config.yaml file if it exists and
168
+ # merge content with DEFAULT config
169
+ #
170
+ alt_config = read_config_file(override['config']) if override['config']
171
+ if !alt_config.nil?
172
+ config = config.deep_merge(alt_config)
173
+ else
174
+ new_config = read_config_file(YAML_CONFIG_FILE_NAME)
175
+ Hyla::logger.debug("OVERRIDE Keys: #{new_config.inspect}") if !new_config.nil?
176
+ config = config.deep_merge(new_config) if !new_config.nil?
177
+ end
141
178
 
142
- # Merge DEFAULTS < _config.yaml < override
179
+ # Merge DEFAULTS < _config.yaml or your_config.yaml file < override
143
180
  config = config.deep_merge(override)
144
181
  # Convert String Keys to Symbols Keys
145
182
  config = Configuration[].transform_keys_to_symbols(config)
@@ -156,7 +193,7 @@ module Hyla
156
193
  config = safe_load_file(f)
157
194
  config
158
195
  rescue SystemCallError
159
- Hyla::logger.warn "No _config.yaml file retrieved"
196
+ Hyla::logger.warn "No configuration file retrieved for the name : #{filename}"
160
197
  end
161
198
 
162
199
  #
@@ -180,8 +217,10 @@ module Hyla
180
217
  return hash if not hash.is_a?(Hash)
181
218
  hash.inject({}) { |result, (key, value)|
182
219
  new_key = case key
183
- when String then key.to_sym
184
- else key
220
+ when String then
221
+ key.to_sym
222
+ else
223
+ key
185
224
  end
186
225
  new_value = case value
187
226
  when Hash
@@ -190,7 +229,8 @@ module Hyla
190
229
  else
191
230
  transform_keys_to_symbols(value)
192
231
  end
193
- else value
232
+ else
233
+ value
194
234
  end
195
235
  result[new_key] = new_value
196
236
  result
data/lib/hyla/core_ext.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  class Hash
3
2
 
4
3
  # Merges self with another hash, recursively.
@@ -21,4 +20,15 @@ class Hash
21
20
 
22
21
  target
23
22
  end
23
+ end
24
+
25
+ class String
26
+
27
+ #
28
+ # Get the first position
29
+ #
30
+ def initial
31
+ self[0,1]
32
+ end
33
+
24
34
  end
data/lib/hyla/project.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Hyla
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  DESCRIPTION = 'Asciidoctor Hyla - Command Line tool to create new project, watch modifications, generate content, publish or consult it live !'
4
4
  SUMMARY = 'Asciidoctor Hyla - builder/generator of HTML5, slideshow. Watch modifications, generate content, publish or consult it live !'
5
5
  end
@@ -19,11 +19,18 @@
19
19
  %meta(name='keywords'){:content=>(attr :keywords)}
20
20
  - if attr? :author
21
21
  %meta(name='author'){:content=>(attr :author)}
22
-
22
+ :javascript
23
+ document.write( '<link rel="stylesheet" href="revealjs/css/print/' +
24
+ ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) +
25
+ '.css" type="text/css" media="print">' );
23
26
  %body{:id=>@id, :class=>['reveal-container',(attr :doctype)]}
24
27
  .reveal
28
+ .header
29
+ %img(src='image/rhheader_thin.png' alt='RedHat Corporate Logo')
25
30
  .slides
26
31
  =content
32
+ .footer
33
+ Copyright ©2014 Red Hat, Inc.
27
34
  %script(src='lib/js/head.min.js')
28
35
  %script(src='reveal.js/js/reveal.min.js')
29
36
  :javascript
@@ -53,7 +60,7 @@
53
60
  // Apply a 3D roll to links on hover
54
61
  rollingLinks: true,
55
62
  // Transition style
56
- transition: 'default', // default/cube/page/concave/zoom/linear/fade/none
63
+ transition: 'none', // default/cube/page/concave/zoom/linear/fade/none
57
64
  // Transition speed
58
65
  transitionSpeed: 'default', // default/fast/slow
59
66
  // Transition style for full page backgrounds
@@ -8,3 +8,4 @@
8
8
  img src=image_uri(attr :target) alt=(attr :alt) width=(attr :width) height=(attr :height)
9
9
  - if title?
10
10
  .title=captioned_title
11
+ x
@@ -67,6 +67,8 @@ html lang=(attr :lang, 'en' unless attr? :nolang)
67
67
  / AsciiDoc leaves an empty header div even if there's no doctitle
68
68
  #header
69
69
  - if has_header?
70
+ - if attr? :header_image_path
71
+ img src=image_uri(attr :header_image_path)
70
72
  - unless notitle
71
73
  h1=@header.title
72
74
  - if attr? :author
@@ -89,6 +91,9 @@ html lang=(attr :lang, 'en' unless attr? :nolang)
89
91
  - if attr? :revremark
90
92
  br
91
93
  span#revremark=attr :revremark
94
+ - else
95
+ - if attr? :header_image_path
96
+ img src=image_uri(attr :header_image_path)
92
97
  - if (attr? :toc) && (attr? 'toc-placement', 'auto')
93
98
  #toc class=(attr 'toc-class', 'toc')
94
99
  #toctitle=attr 'toc-title'
@@ -101,12 +106,16 @@ html lang=(attr :lang, 'en' unless attr? :nolang)
101
106
  - footnotes.each do |fn|
102
107
  .footnote id='_footnote_#{fn.index}'
103
108
  <a href="#_footnoteref_#{fn.index}">#{fn.index}</a>. #{fn.text}
104
- #footer
105
- #footer-text
106
- - if attr? :revnumber
107
- | #{attr 'version-label'} #{attr :revnumber}
108
- - if attr? 'last-update-label'
109
- br
110
- | #{attr 'last-update-label'} #{attr :docdatetime}
111
- - unless (docinfo_content = (docinfo :footer)).empty?
112
- =docinfo_content
109
+ - if attr? :footer_copyright
110
+ .footer-copyright
111
+ =attr :footer_copyright
112
+ - unless attr? :nofooter
113
+ #footer
114
+ #footer-text
115
+ - if attr? :revnumber
116
+ | #{attr 'version-label'} #{attr :revnumber}
117
+ - if attr? 'last-update-label'
118
+ br
119
+ | #{attr 'last-update-label'} #{attr :docdatetime}
120
+ - unless (docinfo_content = (docinfo :footer)).empty?
121
+ =docinfo_content
@@ -1,5 +1,5 @@
1
- .sidebarblock id=@id class=role
2
- .content
3
- - if title?
4
- .title=title
5
- =content
1
+ aside id=@id class='notes'
2
+ - if title?
3
+ .title=title
4
+ =content
5
+