hyla 1.0.6 → 1.0.7.pre.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.
Files changed (36) hide show
  1. checksums.yaml +8 -8
  2. data/README.adoc +7 -0
  3. data/lib/hyla/commands/generate.rb +288 -83
  4. data/lib/hyla/configuration.rb +62 -42
  5. data/lib/hyla/project.rb +1 -1
  6. data/lib/resources/backends/haml/deckjs/document.html.haml +2 -2
  7. data/lib/resources/backends/haml/html5/document.html.haml +2 -2
  8. data/lib/resources/backends/slim/html5/document.html.slim +2 -2
  9. data/lib/resources/backends/slim/revealjs/block_sidebar.html.slim +1 -1
  10. data/lib/resources/backends/slim/revealjs/document.html.slim +2 -2
  11. data/lib/resources/course/assessment.txt +7 -0
  12. data/lib/resources/course/audio.txt +3 -0
  13. data/lib/resources/course/cover.txt +13 -0
  14. data/lib/resources/course/footer.txt +10 -0
  15. data/lib/resources/course/header_index.txt +1 -0
  16. data/lib/resources/course/index.txt +3 -0
  17. data/lib/resources/course/labinstructions.txt +26 -0
  18. data/lib/resources/course/objectives.txt +28 -0
  19. data/lib/resources/course/summary.txt +27 -0
  20. data/lib/resources/cover.slim +1 -1
  21. data/lib/resources/revealjs/css/theme/conference-redhat.css +369 -61
  22. data/lib/resources/revealjs/css/theme/conference.css +179 -15
  23. data/lib/resources/revealjs/css/theme/gpe.css +362 -53
  24. data/lib/templates/_config.yaml +26 -2
  25. data/lib/templates/sample/{asciidoc_article.ad → asciidoc_article.adoc} +0 -0
  26. data/lib/templates/sample/{asciidoc_audio.ad → asciidoc_audio.adoc} +0 -0
  27. data/lib/templates/sample/{asciidoc_book.ad → asciidoc_book.adoc} +0 -0
  28. data/lib/templates/sample/{asciidoc_image.ad → asciidoc_image.adoc} +0 -0
  29. data/lib/templates/sample/{asciidoc_report.ad → asciidoc_report.adoc} +0 -0
  30. data/lib/templates/sample/{asciidoc_source.ad → asciidoc_source.adoc} +0 -0
  31. data/lib/templates/sample/{asciidoc_table.ad → asciidoc_table.adoc} +0 -0
  32. data/lib/templates/sample/{asciidoc_video.ad → asciidoc_video.adoc} +0 -0
  33. data/lib/templates/sample/{slideshow_deckjs.ad → slideshow_deckjs.adoc} +0 -0
  34. data/lib/templates/sample/{slideshow_revealjs.ad → slideshow_revealjs.adoc} +31 -0
  35. data/lib/templates/training-exercises/{README.ad → README.adoc} +0 -0
  36. metadata +24 -15
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDFkMzdiMWQyZmI5ODlhOWUwYzM5MDQ3NDViMTllOWEyMmNlMDBjNw==
4
+ Yjk4ODAzYjZhZDcwODI0ZmRlM2IxYWU5MGUwYWUzNGY3MWZmMGUxMg==
5
5
  data.tar.gz: !binary |-
6
- YzYyMjU2ZjRlOWExYzQ4YjA3YjdhNjExZjc2YzliNTA1ZDlkNjk3OQ==
6
+ MjJhYzVlNjA3ODkzNDIyN2VmYTg2NWM4ZDMyOTU2NTdhYWQ3ZGFkOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzdkZGE4NmYzYWRiMDM4YmQ3ZjdhZDg2Y2YxN2ZiOTkyNWUxMTEzZGVkMGIw
10
- M2E2YzlhNjlmYTMyMDZjZmFkMmY0NmI1NWM2MmNmMTNmMGQxODZlMmVjMmQ0
11
- NTEyODY2ZWM5MmI5ZjVjMzE2NThjOTA4OGI3ODAyMGQ2YWRlODA=
9
+ YjY1MzM2ODUwZWJmMzhhZWVlOGZkYjQyMGFhNzFiYmFjNTYzMWU4YThjOTcw
10
+ NzI2YzMwNWQ0M2NlYzRmNzNjZTgyNTQ5MjgyMWNjOWNhMWQxZDZhMGY1YWE3
11
+ NzhiNWYzZTAwZGU5MTg2NGE5Y2NkMmY4OGNmYmM5ZTdhZjU2ZmY=
12
12
  data.tar.gz: !binary |-
13
- ZWQ3ZTFhYTliMDBmOWY0ODE1Yjk5ZjUzMjNmY2IxNDY0MjFmMTJlYjMyZmI0
14
- MmVmOGI4ZGZlMzQ3YjRkZWZkNTM3MzBlNzk2YjY3ZWZjMGUyZWUxNmFhYzQx
15
- OWQ3YWNjMmI1ZjMxMjM4ZDgyN2YzYTI2NmIxZjQ5MjI4ODA2MjI=
13
+ NGI4ODIwYTAxOGZjNjU1NGQ4Nzg0YzViOTI0OWE2MjgxNjBkN2U0YzQwZWUw
14
+ YTJmODVhYTI4ODVmNzQxZDQ3NjQ4YmI5NzdjMWE2NzQ4YTk5NGEwZmY3MGQx
15
+ ZDE4NTIxODc2ZGNkYjc4OTc1MDE1YTA1MGNjZTE0YTc5YjM4ZTE=
data/README.adoc CHANGED
@@ -135,6 +135,13 @@ Issue tracker (GitHub):: {issues}
135
135
 
136
136
  == Changelog
137
137
 
138
+ === v1.0.7 - @cmoulliard
139
+
140
+ Enhancements / Improvements::
141
+
142
+ * Remove the prefix (which is the name of the folder) before text AllSlides of the file (link:{issues}75[#75])
143
+
144
+
138
145
  === v1.0.6 - @cmoulliard
139
146
 
140
147
  Enhancements / Improvements::
@@ -19,8 +19,9 @@ module Hyla
19
19
  @out_dir = options[:destination]
20
20
  @project_name = options[:project_name] if options[:project_name]
21
21
  @project_name = 'My Project' if !options[:project_name]
22
+ @image_path = options[:image_path] if options[:image_path]
22
23
 
23
- self.table_of_content_to_asciidoc(@toc_file, @out_dir, @project_name)
24
+ self.table_of_content_to_asciidoc(@toc_file, @out_dir, @project_name, @image_path)
24
25
 
25
26
  when 'adoc2html'
26
27
 
@@ -92,35 +93,11 @@ module Hyla
92
93
  out_dir = options[:destination] if self.check_mandatory_option?('-d / --destination', options[:destination])
93
94
  file_name = options[:cover_file]
94
95
  image_name = options[:cover_image]
96
+ course_name = options[:course_name]
97
+ module_name = options[:module_name]
98
+ bg_image_path = options[:image_path]
95
99
 
96
- # Configure Slim engine
97
- slim_file = Configuration::cover_template
98
- slim_tmpl = File.read(slim_file)
99
- template = Slim::Template.new(:pretty => true) { slim_tmpl }
100
-
101
- # Do the Rendering HTML
102
- parameters = {:course_name => options[:course_name],
103
- :module_name => options[:module_name],
104
- :image_path => options[:image_path]}
105
- res = template.render(Object.new, parameters)
106
-
107
- unless Dir.exist? out_dir
108
- FileUtils.mkdir_p out_dir
109
- end
110
-
111
- Dir.chdir(out_dir) do
112
- out_file = File.new(file_name, 'w')
113
- out_file.puts res
114
- out_file.puts "\n"
115
-
116
- # Do the Rendering Image
117
- kit = IMGKit.new(res, quality: 90, width: 950, height: 750)
118
- kit.to_img(:png)
119
- kit.to_file(image_name)
120
-
121
- # Convert HTML to Image
122
- # system ("wkhtmltoimage -f 'png' #{file_name} #{image_name}")
123
- end
100
+ self.cover_img(out_dir, file_name, image_name, course_name, module_name, bg_image_path)
124
101
 
125
102
  else
126
103
  Hyla.logger.error ">> Unknow rendering"
@@ -145,6 +122,50 @@ module Hyla
145
122
  end
146
123
  end
147
124
 
125
+ #
126
+ # Cover Function
127
+ # Create a png file using the HTML generated with the Slim cover template
128
+ #
129
+ def self.cover_img(out_dir, file_name, image_name, course_name, module_name, bg_image_path)
130
+
131
+ unless Dir.exist? out_dir
132
+ FileUtils.mkdir_p out_dir
133
+ end
134
+
135
+ # Configure Slim engine
136
+ slim_file = Configuration::cover_template
137
+ slim_tmpl = File.read(slim_file)
138
+ template = Slim::Template.new(:pretty => true) { slim_tmpl }
139
+
140
+ # Replace underscore with space
141
+ course_name = course_name.gsub('_', ' ')
142
+ # Replace underscore with space, next digits & space with nothing & Capitalize
143
+ module_name = module_name.gsub('_', ' ').gsub(/^\d{1,2}\s/, '').capitalize
144
+
145
+ Hyla.logger.debug "Module name : " + module_name
146
+
147
+ # Do the HTML Rendering
148
+ parameters = {:course_name => course_name,
149
+ :module_name => module_name,
150
+ :image_path => bg_image_path}
151
+ res = template.render(Object.new, parameters)
152
+
153
+ #
154
+ # Create the cover file and do the rendering of the image
155
+ #
156
+ Dir.chdir(out_dir) do
157
+ out_file = File.new(file_name, 'w')
158
+ out_file.puts res
159
+ out_file.puts "\n"
160
+
161
+ # Do the Rendering Image
162
+ kit = IMGKit.new(res, quality: 90, width: 950, height: 750)
163
+ kit.to_img(:png)
164
+ kit.to_file(image_name)
165
+ end
166
+
167
+ end
168
+
148
169
  #
149
170
  # Call Asciidoctor.render function
150
171
  #
@@ -186,9 +207,9 @@ module Hyla
186
207
  files = Dir[current_dir + "/**/*.{" + extensions + "}"].reject { |f| f =~ /\/#{excludes}\// }
187
208
 
188
209
  #
189
- # Check if companion parameter is defined
210
+ # Check if snippet parameter is defined
190
211
  # as we have to modify the AllSlides.txt file
191
- # containing as tag name this value [tag=snippet]
212
+ # to include within the brackets this tag --> [tag=snippet]
192
213
  #
193
214
  if options[:snippet_content] == true
194
215
  files.each do |f|
@@ -245,8 +266,8 @@ module Hyla
245
266
  end
246
267
 
247
268
  #
248
- # Check if companion parameter is defined
249
- # and remove the companion tag from indexed files
269
+ # Check if snippet parameter is defined
270
+ # and remove the snippet tag from indexed files
250
271
  #
251
272
  if options[:snippet_content] == true
252
273
  files.each do |f|
@@ -292,18 +313,21 @@ module Hyla
292
313
  # @param [Directory where asciidoc files will be generated] out_dir
293
314
  # @param [Project name used to create parent of index files] project_name
294
315
  #
295
- def self.table_of_content_to_asciidoc(toc_file, out_dir, project_name)
316
+ def self.table_of_content_to_asciidoc(toc_file, out_dir, project_name, image_path)
296
317
 
297
318
  Hyla.logger.info '>> Project Name : ' + project_name + ' <<'
298
319
 
299
320
  # Open file & parse it
300
- f = File.open(toc_file, 'r')
321
+ f = f = File.open(toc_file, 'r')
322
+ f_scan_occurences = File.open(toc_file, 'r')
301
323
 
302
324
  # Expand File Path
303
325
  @out_dir = File.expand_path out_dir
326
+ Hyla.logger.info '>> Output directory : ' + out_dir + ' <<'
304
327
 
305
328
  #
306
329
  # Create destination directory if it does not exist
330
+ #
307
331
  unless Dir.exist? @out_dir
308
332
  FileUtils.mkdir_p @out_dir
309
333
  end
@@ -312,22 +336,27 @@ module Hyla
312
336
  FileUtils.cp_r [Configuration::templates, Configuration::YAML_CONFIG_FILE_NAME] * '/', @out_dir
313
337
 
314
338
  # Copy styles
315
- FileUtils.cp_r Configuration::styles, @out_dir
339
+ # FileUtils.cp_r Configuration::styles, @out_dir
316
340
 
317
341
  #
318
- # Move to 'generated' directory as we will
342
+ # Move to the directory as we will
319
343
  # create content relative to this directory
320
344
  #
321
345
  Dir.chdir @out_dir
322
346
  @out_dir = Pathname.pwd
323
347
 
324
348
  # Create index file of all index files
325
- @project_index_file = self.create_index_file(project_name, Configuration::LEVEL_1)
326
-
327
-
349
+ @project_index_file = self.create_index_file_withoutprefix(project_name, Configuration::LEVEL_1)
350
+
351
+ # Count ho many modules we have
352
+ @modules = f_scan_occurences.read.scan(/^=\s/).size
353
+ f_scan_occurences.close
354
+
355
+ @counter = 0
356
+
328
357
  # File iteration
329
358
  f.each do |line|
330
-
359
+
331
360
  #
332
361
  # Check level 1
333
362
  # Create a directory where its name corresponds to 'Title Level 1' &
@@ -335,9 +364,20 @@ module Hyla
335
364
  # replaced ' ' by '_'
336
365
  #
337
366
  if line[/^=\s/]
367
+
368
+ # Increase counter. We will use it later to add the summary
369
+ @counter+=1
338
370
 
339
371
  #
340
- # Create Directory of the module and next the File
372
+ # Add the summary.adoc file
373
+ #
374
+ if @counter > 1
375
+ self.generate_summary_page()
376
+ end
377
+
378
+ #
379
+ # Create the Directory name for the module and next the files
380
+ # The special characters are removed from the string
341
381
  #
342
382
  dir_name = remove_special_chars(2, line)
343
383
  new_dir = [@out_dir, dir_name].join('/')
@@ -348,17 +388,23 @@ module Hyla
348
388
  Dir.chdir(new_dir)
349
389
 
350
390
  # Add image, audio, video directory
351
- self.create_asset_directory(['image', 'audio', 'video'])
391
+ # self.create_asset_directory(['image', 'audio', 'video'])
392
+ self.create_asset_directory(['image'])
352
393
 
353
394
  #
354
395
  # Create an index file
355
- # It is used to include files belonging to a module and will be used for SlideShows
396
+ # It is used to include files belonging to a module and will be used for SlideShow
356
397
  # The file created contains a title (= Dir Name) and header with attributes
357
398
  #
358
- @index_file = create_index_file(dir_name, Configuration::LEVEL_1)
399
+ @index_file = create_index_file_withoutprefix(dir_name, Configuration::LEVEL_1)
359
400
 
401
+ #
360
402
  # Include index file created to parent index file
361
- @project_index_file.puts Configuration::INCLUDE_PREFIX + dir_name + '/' + dir_name + Configuration::INDEX_SUFFIX + Configuration::INCLUDE_SUFFIX
403
+ # we don't prefix the AllSlides.txt file anymore
404
+ #
405
+ # BEFORE @project_index_file.puts Configuration::INCLUDE_PREFIX + dir_name + '/' + dir_name + Configuration::INDEX_SUFFIX + Configuration::INCLUDE_SUFFIX
406
+ #
407
+ @project_index_file.puts Configuration::INCLUDE_PREFIX + dir_name + '/' + Configuration::INDEX_FILE + Configuration::INCLUDE_SUFFIX
362
408
  @project_index_file.puts "\n"
363
409
 
364
410
  #
@@ -372,10 +418,85 @@ module Hyla
372
418
 
373
419
  #
374
420
  # Reset counter value used to generate file number
375
- # for the file 01, 00
421
+ # for the file 01, 00 within this module
376
422
  #
377
423
  @index = 0
378
424
 
425
+ #
426
+ # Add the cover.adoc file
427
+ #
428
+ @index += 1
429
+ file_index = sprintf('%02d', @index)
430
+ f_name = 'm' + @module_key + 'p' + file_index + '_cover' + Configuration::ADOC_EXT
431
+ Hyla.logger.debug '>> Directory name : ' + dir_name.to_s.gsub('_', ' ')
432
+ rep_txt = Configuration::COVER_TXT.gsub(/xxx\.png/, dir_name + '.png')
433
+ Hyla.logger.debug "Replaced by : " + rep_txt
434
+ cover_f = File.new(f_name, 'w')
435
+ cover_f.puts rep_txt
436
+ cover_f.close
437
+
438
+ #
439
+ # Use the filename & generate the cover image
440
+ #
441
+ out_dir = 'image'
442
+ file_name = dir_name + '.html'
443
+ image_name = dir_name + '.png'
444
+ course_name = @project_name
445
+ module_name= dir_name
446
+ bg_image_path = image_path
447
+ Hyla.logger.debug '>> Out Directory : ' + out_dir.to_s
448
+ Hyla.logger.debug '>> Image name : ' + image_name.to_s
449
+ Hyla.logger.debug '>> Course Name : ' + course_name.to_s
450
+ Hyla.logger.debug '>> Module Name : ' + module_name.to_s
451
+ Hyla.logger.debug '>> Bg Image : ' + bg_image_path.to_s
452
+
453
+ self.cover_img(out_dir, file_name, image_name, course_name, module_name, bg_image_path)
454
+
455
+ #
456
+ # Include cover file to index
457
+ #
458
+ @index_file.puts Configuration::INCLUDE_PREFIX + f_name + Configuration::INCLUDE_SUFFIX
459
+ @index_file.puts "\n"
460
+
461
+ #
462
+ # Add the objectives.adoc file
463
+ #
464
+ @index += 1
465
+ file_index = sprintf('%02d', @index)
466
+ f_name = 'm' + @module_key + 'p' + file_index + '_objectives'
467
+
468
+ rep_txt = Configuration::OBJECTIVES_TXT.gsub(/xxx\.mp3/, f_name + '.mp3')
469
+
470
+ f_name = f_name + Configuration::ADOC_EXT
471
+
472
+ objectives_f = File.new(f_name, 'w')
473
+ objectives_f.puts Configuration::HEADER_TXT
474
+ objectives_f.puts rep_txt
475
+ objectives_f.close
476
+
477
+ #
478
+ # Include cover file to index
479
+ #
480
+ @index_file.puts Configuration::INCLUDE_PREFIX + f_name + Configuration::INCLUDE_SUFFIX
481
+ @index_file.puts "\n"
482
+
483
+ #
484
+ # Add the labinstructions.adoc file
485
+ #
486
+ f_name = 'labinstructions' + Configuration::ADOC_EXT
487
+ lab_f = File.new(f_name, 'w')
488
+ lab_f.puts Configuration::HEADER_TXT
489
+ lab_f.puts Configuration::LABS_TXT
490
+ lab_f.close
491
+
492
+ #
493
+ # Add the assessment.txt file
494
+ #
495
+ f_name = 'assessment.txt'
496
+ assessment_f = File.new(f_name, 'w')
497
+ assessment_f.puts Configuration::ASSESSMENT_TXT
498
+ assessment_f.close
499
+
379
500
  # Move to next line record
380
501
  next
381
502
  end
@@ -389,33 +510,47 @@ module Hyla
389
510
 
390
511
  # Close File created previously if it exists
391
512
  if !@previous_f.nil?
513
+
514
+ #
515
+ # Add Footer_text to the file created
516
+ #
517
+ rep_txt = Configuration::FOOTER_TXT.gsub(/xxx\.mp3/, @previous_f.to_s + '.mp3')
518
+ @previous_f.puts rep_txt
392
519
  @previous_f.close
393
520
  end
394
521
 
395
522
  #
396
- # Replace special characters form the file and
397
- # add the module key followed by the index value for the file
398
- # Example : m01p01_MyTitle.ad, m01p02_Another_Title.ad
523
+ # Replace special characters from the title before to generate the file name
524
+ # Convert Uppercase to lowercase
525
+ #
526
+ f_name = remove_special_chars(3, line).downcase
527
+
528
+ #
529
+ # Create the prefix for the file
530
+ # Convention : m letter followed by module number, letter p & a number 01, 02, ..., 0n, next the title & .adoc extension
531
+ # Example : m01p01_mytitle.adoc, m01p02_anothertitle.adoc
399
532
  #
400
- f_name = remove_special_chars(3, line)
401
533
  @index += 1
402
- #file_index = @index.to_s.initial.rjust(2, '0')
403
534
  file_index = sprintf('%02d', @index)
404
- f_name = 'm' + @module_key + 'p' + file_index + '_' + f_name + '.ad'
535
+ f_name = 'm' + @module_key + 'p' + file_index + '_' + f_name
405
536
 
406
- Hyla.logger.info ' # File created : ' + f_name.to_s
537
+ rep_txt = Configuration::AUDIO_TXT.gsub(/xxx\.mp3/, f_name + '.mp3')
538
+
539
+ f_asciidoc_name = f_name + Configuration::ADOC_EXT
407
540
 
408
541
  #
409
- # Create File and add configuration HEADER
542
+ # Create File and add configuration HEADER_TXT
410
543
  #
411
- @new_f = File.new(f_name, 'w')
412
- @new_f.puts Configuration::HEADER
544
+ @new_f = File.new(f_asciidoc_name, 'w')
545
+ @new_f.puts Configuration::HEADER_TXT
413
546
  @new_f.puts "\n"
414
547
 
548
+ Hyla.logger.info ' # File created : ' + f_asciidoc_name.to_s
549
+
415
550
  @previous_f = @new_f
416
551
 
417
552
  # Include file to index
418
- @index_file.puts Configuration::INCLUDE_PREFIX + f_name + Configuration::INCLUDE_SUFFIX
553
+ @index_file.puts Configuration::INCLUDE_PREFIX + f_asciidoc_name + Configuration::INCLUDE_SUFFIX
419
554
  @index_file.puts "\n"
420
555
  end
421
556
 
@@ -423,11 +558,31 @@ module Hyla
423
558
  # Add Content to file if it exists and line does not start with characters to be skipped
424
559
  #
425
560
  if !@new_f.nil? and !line.start_with?(Configuration::SKIP_CHARACTERS)
426
- @new_f.puts line
561
+ #
562
+ # Add audio text after the name of the title
563
+ #
564
+ # ifdef::audioscript[]
565
+ # audio::audio/m01p03_why_use_messaging[]
566
+ # endif::[]
567
+ #
568
+ if line.start_with?('==')
569
+ @new_f.puts line
570
+ @new_f.puts "\n"
571
+ @new_f.puts rep_txt
572
+ else
573
+ @new_f.puts line
574
+ end
427
575
  end
428
576
 
429
577
  end
430
578
 
579
+ #
580
+ # Add the summary.adoc file
581
+ #
582
+ if @counter == @modules
583
+ self.generate_summary_page()
584
+ end
585
+
431
586
  end
432
587
 
433
588
  =begin
@@ -455,6 +610,21 @@ module Hyla
455
610
  end
456
611
  =end
457
612
 
613
+ def self.generate_summary_page()
614
+ @index += 1
615
+ file_index = sprintf('%02d', @index)
616
+ f_name = 'm' + @module_key + 'p' + file_index + '_summary'
617
+
618
+ rep_txt = Configuration::SUMMARY_TXT.gsub(/xxx\.mp3/, f_name + '.mp3')
619
+
620
+ f_name = f_name + Configuration::ADOC_EXT
621
+
622
+ summary_f = File.new(f_name, 'w')
623
+ summary_f.puts Configuration::HEADER_TXT
624
+ summary_f.puts rep_txt
625
+ summary_f.close
626
+ end
627
+
458
628
  def self.html_to_pdf(file_name, source, destination, footer_text, header_html_path, cover_path)
459
629
 
460
630
  @cover_path = cover_path
@@ -531,12 +701,16 @@ module Hyla
531
701
  end
532
702
 
533
703
  #
534
- # Remove space, dot from a String
704
+ # Remove space, dot, ampersand, hyphen, parenthesis characters from the String
705
+ # at a position specified
535
706
  #
536
707
  def self.remove_special_chars(pos, text)
537
708
  return text[pos, text.length].strip.gsub(/\s/, '_')
538
- .gsub('.', '')
539
- .gsub('&', '')
709
+ .gsub('.', '')
710
+ .gsub('&', '')
711
+ .gsub('-', '')
712
+ .gsub(/\(|\)/, '')
713
+ .gsub('__', '_')
540
714
  end
541
715
 
542
716
  #
@@ -556,8 +730,9 @@ module Hyla
556
730
  #
557
731
  # Create ascidoc index file
558
732
  # containing references to asciidoc files part of a module
733
+ # TODO : Not longer used -> can be removed
559
734
  #
560
- def self.create_index_file(file_name, level)
735
+ def self.create_index_file_withprefix(file_name, level)
561
736
  n_file_name = file_name + Configuration::INDEX_SUFFIX
562
737
  index_file = File.new(n_file_name, 'w')
563
738
 
@@ -573,18 +748,45 @@ module Hyla
573
748
  end
574
749
 
575
750
  #
576
- # Add snippet tag to index file with extension .ad[]
577
- # as this is not yet the case
751
+ # Create ascidoc index file
752
+ # containing references to asciidoc files part of a module
753
+ #
754
+ def self.create_index_file_withoutprefix(file_name, level)
755
+ index_file = File.new(Configuration::INDEX_FILE, 'w')
756
+
757
+ index_file.puts Configuration::HEADER_INDEX
758
+ index_file.puts "\n"
759
+ # TODO - until now we cannot use level 0 for parent/children files
760
+ # even if doctype: book
761
+ # This is why the level for each index file title is '=='
762
+
763
+ rep_txt = Configuration::INDEX.gsub(/xxx/, file_name)
764
+ index_file.puts rep_txt
765
+ index_file.puts "\n"
766
+
767
+ #
768
+ # index_file.puts "\n"
769
+
770
+ index_file
771
+ end
772
+
773
+ #
774
+ # Modify the content of an index file if
775
+ # it contains include::file with extension .ad, .adoc or .asciidoc
776
+ # and add the tag snippet ([] --> [tag=snippet])
578
777
  #
579
778
  def self.add_tag_to_index_file(index_file)
580
- content = File.read(index_file)
581
- #
582
- # Modify the content of an index file if
583
- # it contains include::file with extension .ad, .adoc or .asciidoc
584
- #
585
- if content =~ /(\.ad)|(\.adoc)|(\.asciidoc)/
586
- replace = content.gsub(/\[/, '[tag=' + Configuration::SNIPPET_TAG)
587
- replace_content(index_file, replace)
779
+ if File.basename(index_file) == "AllSlides.txt" then
780
+ content = ""
781
+ File.readlines(index_file).each do |line|
782
+ if line =~ /^include::.*\[\]$/
783
+ replace = line.gsub(/\[/, '[tag=' + Configuration::SNIPPET_TAG)
784
+ content = content.to_s + replace
785
+ else
786
+ content = content.to_s + line
787
+ end
788
+ end
789
+ replace_content(index_file, content)
588
790
  end
589
791
  end
590
792
 
@@ -592,14 +794,17 @@ module Hyla
592
794
  # Remove snippet tag from index file
593
795
  #
594
796
  def self.remove_tag_from_index_file(index_file)
595
- content = File.read(index_file)
596
- #
597
- # Modify the content of an index file if
598
- # it contains include::file with extension .ad, .adoc or .asciidoc
599
- #
600
- if content =~ /(\.ad)|(\.adoc)|(\.asciidoc)/
601
- replace = content.gsub('[tag=' + Configuration::SNIPPET_TAG, '[')
602
- replace_content(index_file, replace)
797
+ if File.basename(index_file) == "AllSlides.txt" then
798
+ content = ""
799
+ File.readlines(index_file).each do |line|
800
+ if line =~ /^include::.*\[tag\=.*\]$/
801
+ replace = line.gsub('[tag=' + Configuration::SNIPPET_TAG, '[')
802
+ content = content.to_s + replace
803
+ else
804
+ content = content.to_s + line
805
+ end
806
+ end
807
+ replace_content(index_file, content)
603
808
  end
604
809
  end
605
810
 
@@ -607,10 +812,10 @@ module Hyla
607
812
  # Replace content of a File
608
813
  #
609
814
  def self.replace_content(f, content)
610
- File.open(f, "w") { |f| f.puts content } if !content.empty?
815
+ File.open(f, "w") { |out| out << content } if !content.empty?
611
816
  end
612
817
 
613
- #
818
+
614
819
  # Check mandatory options
615
820
  #
616
821
  def self.check_mandatory_option?(key, value)