hyla 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/.rakeTasks +7 -0
  2. data/.travis.yml +10 -0
  3. data/Gemfile +7 -0
  4. data/Gemfile.lock +49 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.adoc +136 -0
  7. data/Rakefile +61 -0
  8. data/archive/GruntFile.js +72 -0
  9. data/archive/watch_files.rb +70 -0
  10. data/bin/hyla +155 -0
  11. data/data/generated/A_Introduction_module/1_Chapter.adoc +42 -0
  12. data/data/generated/A_Introduction_module/2_Chapter.adoc +31 -0
  13. data/data/generated/A_Introduction_module/3_Chapter.adoc +23 -0
  14. data/data/generated/A_Introduction_module/A_Introduction_module_AllSlides.index +9 -0
  15. data/data/generated/B_Instruction_module/1_Chapter.adoc +27 -0
  16. data/data/generated/B_Instruction_module/B_Instruction_module_AllSlides.index +7 -0
  17. data/data/generated/C_Installation_module/1_Chapter.adoc +14 -0
  18. data/data/generated/C_Installation_module/2_Chapter.adoc +17 -0
  19. data/data/generated/C_Installation_module/C_Installation_module_AllSlides.index +8 -0
  20. data/data/generated/camel_AllSlides.index +9 -0
  21. data/data/js/livereload.js +1055 -0
  22. data/data/mime.types +85 -0
  23. data/data/toc.adoc +63 -0
  24. data/hyla.gemspec +37 -0
  25. data/hyla_frog.jpg +0 -0
  26. data/lib/hyla.rb +47 -0
  27. data/lib/hyla/command.rb +21 -0
  28. data/lib/hyla/commands/build.rb +40 -0
  29. data/lib/hyla/commands/create.rb +25 -0
  30. data/lib/hyla/commands/generate.rb +264 -0
  31. data/lib/hyla/commands/new.rb +82 -0
  32. data/lib/hyla/commands/publish.rb +8 -0
  33. data/lib/hyla/commands/reload.rb +109 -0
  34. data/lib/hyla/commands/serve.rb +59 -0
  35. data/lib/hyla/commands/watch.rb +172 -0
  36. data/lib/hyla/configuration.rb +47 -0
  37. data/lib/hyla/logger.rb +89 -0
  38. data/lib/hyla/project.rb +5 -0
  39. data/lib/hyla/training.rb +25 -0
  40. data/lib/hyla/websocket.rb +53 -0
  41. data/lib/templates/sample/asciidoc_article.adoc +64 -0
  42. data/lib/templates/sample/asciidoc_audio.adoc +4 -0
  43. data/lib/templates/sample/asciidoc_source_highlight.adoc +37 -0
  44. data/lib/templates/sample/asciidoc_video.adoc +4 -0
  45. data/lib/templates/sample/audio/ocean_waves.mp3 +0 -0
  46. data/lib/templates/sample/image/hyla_arborea.jpg +0 -0
  47. data/lib/templates/sample/slideshow_deckjs.adoc +186 -0
  48. data/lib/templates/sample/video/small.ogv +0 -0
  49. data/lib/templates/training-exercises/Gemfile +4 -0
  50. data/lib/templates/training-exercises/README.md +1 -0
  51. data/lib/templates/training-exercises/modules/introduction/docs/audio/ocean_waves.mp3 +0 -0
  52. data/lib/templates/training-exercises/modules/introduction/docs/video/small.ogv +0 -0
  53. data/lib/templates/training-exercises/modules/introduction/pom.xml +114 -0
  54. data/lib/templates/training-exercises/modules/introduction/src/main/java/HelloWorld.java +16 -0
  55. data/lib/templates/training-exercises/modules/introduction/src/test/java/HelloWorldTest.java +29 -0
  56. data/lib/templates/training-exercises/modules/pom.xml +61 -0
  57. data/lib/templates/training-exercises/modules/src/main/assembly/code.xml +31 -0
  58. data/lib/templates/training-exercises/modules/src/main/assembly/content.xml +16 -0
  59. data/lib/templates/training-exercises/pom.xml +157 -0
  60. data/lib/templates/training/GemFile +4 -0
  61. data/lib/templates/training/development/article.adoc +64 -0
  62. data/lib/templates/training/development/audio/ocean_waves.mp3 +0 -0
  63. data/lib/templates/training/development/image/hyla_frog.jpg +0 -0
  64. data/lib/templates/training/development/video/small.ogv +0 -0
  65. data/lib/templates/training/introduction/article.adoc +64 -0
  66. data/lib/templates/training/introduction/audio/ocean_waves.mp3 +0 -0
  67. data/lib/templates/training/introduction/image/hyla_frog.jpg +0 -0
  68. data/lib/templates/training/introduction/video/small.ogv +0 -0
  69. data/lib/templates/training/readme.adoc +1 -0
  70. data/scenario.adoc +59 -0
  71. data/test/my_test.rb +23 -0
  72. metadata +265 -0
data/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build asciidoctor-cli-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install asciidoctor-cli-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push asciidoctor-cli-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ cache: bundler
3
+ before_install:
4
+ - gem install bundler
5
+ rvm:
6
+ - 2.0.0
7
+ - 1.9.3
8
+ - 1.9.2
9
+ - 1.8.7
10
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in asciidoctor-cli.gemspec
4
+ gemspec
5
+
6
+ # gem 'hyla'
7
+
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hyla (1.0)
5
+ asciidoctor (~> 0.1.4)
6
+ colorator (~> 0.1)
7
+ commander (~> 4.1.3)
8
+ em-websocket (~> 0.5)
9
+ multi_json (~> 1.8)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ asciidoctor (0.1.4)
15
+ celluloid (0.15.2)
16
+ timers (~> 1.1.0)
17
+ colorator (0.1)
18
+ commander (4.1.5)
19
+ highline (~> 1.6.11)
20
+ em-websocket (0.5.0)
21
+ eventmachine (>= 0.12.9)
22
+ http_parser.rb (~> 0.5.3)
23
+ eventmachine (1.0.3)
24
+ ffi (1.9.3)
25
+ highline (1.6.20)
26
+ http_parser.rb (0.5.3)
27
+ json (1.8.1)
28
+ listen (2.4.0)
29
+ celluloid (>= 0.15.2)
30
+ rb-fsevent (>= 0.9.3)
31
+ rb-inotify (>= 0.9)
32
+ multi_json (1.8.2)
33
+ rake (10.1.0)
34
+ rb-fsevent (0.9.3)
35
+ rb-inotify (0.9.2)
36
+ ffi (>= 0.5.0)
37
+ rdoc (3.12.2)
38
+ json (~> 1.4)
39
+ timers (1.1.0)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ bundler (~> 1.3)
46
+ hyla!
47
+ listen (~> 2.0)
48
+ rake (~> 10.1)
49
+ rdoc (~> 3.11)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Charles Mouliard
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,136 @@
1
+ image:https://raw.github.com/cmoulliard/asciidoctor-hyla/master/hyla_frog.jpg[Hyla, 100, 100, role="left"] **Hyla** is a command line tool to create a new documentation/training/blog/static web site project, add artefacts (articles, blog, audio, video, content, code source, ...), render it in HTML, SlideShow using asciidoc(tro) as markup language. It also support to watch files and render them on the fly for browser configured with Livereload. The content generated is served by a HTTP server.
2
+
3
+ The Hyla project name comes from an arborical http://en.wikipedia.org/wiki/Hyla[frog] living in equatorial regions of Europe, Asia or Americas. Its name was inspired by the companion of Hercule (Hylas) in Greek mythology.
4
+
5
+ == Prerequisites
6
+
7
+ - https://www.ruby-lang.org/en/[Ruby] > 1.9.3
8
+ - http://guides.rubygems.org/[RubyGems] to install Ruby Applications
9
+
10
+ == Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'hyla'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ **Or** install it yourself as:
21
+
22
+ $ gem install hyla
23
+
24
+ == For Developer's only
25
+
26
+ gem build hyla.gemspec
27
+ sudo gem install hyla-1.0.gem
28
+
29
+ == Usage
30
+
31
+ Open a terminal and move to the folder where you would like to create a new project or develop an existing. As Hyla is command line tool, it will be used with one of the following commands :
32
+
33
+ create Creates a new file from asciidoc artefacts for an existing project
34
+ generate Generate modules and asciidoc files from an asciidoc Table Of Content file
35
+ help Display global or [command] help documentation.
36
+ new Creates a new Hyla project using a template or blank to the PATH specified
37
+ serve Serve locally your site
38
+ watch Watch directories for any change, add or file deleted and render document (HTML5)
39
+
40
+ More info about options and commands available can be find by running the `command line tool`
41
+
42
+ hyla --help
43
+
44
+ Here are some examples of commands to create a new project, add artefacts (asciidoc files) watch resources and serve it using HTTP Server
45
+
46
+ === New project
47
+
48
+ A Blank project
49
+
50
+ hyla new --blank ~/Temp/MyBlankProject
51
+
52
+
53
+ A Sample Project using as template --> training
54
+
55
+ hyla new --template_type training ~/Temp/MyTrainingProject
56
+
57
+
58
+ === Add an artefact to a project
59
+
60
+ Asciidoc(tor) documents
61
+
62
+ hyla create --t asciidoc --a article --d ~/Temp/MyBlankProject
63
+ hyla create --t asciidoc --a audio --d ~/Temp/MyBlankProject
64
+ hyla create --t asciidoc --a video --d ~/Temp/MyBlankProject
65
+ hyla create --t asciidoc --a source_highlight --d ~/Temp/MyBlankProject
66
+
67
+ Slideshow
68
+
69
+ hyla create --t slideshow --a deckjs --d ~/Temp/MyBlankProject
70
+
71
+ === Generate Asciidoctor project from a Table of Content
72
+
73
+ The entry point of a Documention site, Training, Publication or Book will consist most of the time to create
74
+ a Table Of Content which is a collection of modules with chapters that we will develop. As this process to elaborate
75
+ the structure of the project will consume lot of time/effort, Hyla will simplify your life as it allows from a TOC file
76
+
77
+
78
+ = A. Introduction module
79
+ >> This is the module 'A. Introduction'
80
+ == 1. Chapter
81
+ This is a chapter about ...
82
+ == 2. Chapter
83
+ This is a Chapter about ...
84
+ === 2.1. Section
85
+ ...
86
+ = B. Instruction module
87
+ >> This is the module 'B. Instruction module'
88
+ == 1. Chapter
89
+ This is a Chapter about ...`
90
+
91
+ to generate a collection of folders (= modules) containing files which represent the chapters (== Titles of the TOC ).
92
+ For each module (= Module), an index file is also created including the files listed in a module. That can be serve to generate a
93
+ slideshow presentation using as backend (DeckJS, DZSlides, ...) later on
94
+
95
+ hyla generate --p my-project --d ~/Temp/TocProject/ --r toc2html --toc ~/MyProjects/hyla/data/toc.adoc
96
+
97
+ >> Project Name : my-project <<
98
+ >> Directory created : ~/Temp/MyBookProject/A_Introduction_module <<
99
+ = File created : 1_Chapter
100
+ = File created : 2_Chapter
101
+ = File created : 3_Chapter
102
+ >> Directory created : ~/Temp/MyBookProject/B_Instruction_module <<
103
+ = File created : 1_Chapter
104
+ >> Directory created : /Users/chmoulli/Temp/MyBookProject/C_Installation_module <<
105
+ = File created : 1_Chapter
106
+ = File created : 2_Chapter
107
+
108
+ === Generate HTML pages from Asciidoc
109
+
110
+ hyla generate --s ~/Temp/MyTocProject/ --d ~/Temp/MyToCProject/generated_content/ --r adoc2html
111
+
112
+ === Watch content Live
113
+
114
+ While you develop asciidoc(tor) documents, it is interesting to consult the files rendered in HTML. Hyla supports such option with LiverReload
115
+ as a WebSocket server is exposed for the browser. To watch files and let's asciidoctor to render them, simply open a terminal and provide as
116
+ parameter the source directory containing the files to be watched.
117
+
118
+ hyla watch --s ~/Temp/MyTocProject/ --d ~/Temp/MyTocProject/generated_content/
119
+
120
+ === Serve your content locally
121
+
122
+ To simplify your life, a simple HTTP Server can be started by Hyla and will allow to consult/browse HTML files generated. In this case, start this
123
+ Hyla command in another Terminal
124
+
125
+ hyla serve -P 4000 -H localhost --out_dir ~/Temp/MyTrainingProject/generated_content/ -b /hyla/
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'bundler/version'
5
+
6
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
7
+
8
+ #############################################################################
9
+ #
10
+ # Helper functions
11
+ #
12
+ #############################################################################
13
+ def name
14
+ @name ||= Dir['*.gemspec'].first.split('.').first
15
+ end
16
+
17
+ def version
18
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
19
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
20
+ end
21
+
22
+ def date
23
+ Date.today.to_s
24
+ end
25
+
26
+ def gemspec_file
27
+ "#{name}.gemspec"
28
+ end
29
+
30
+ def gem_file
31
+ "#{name}-#{version}.gem"
32
+ end
33
+
34
+ #############################################################################
35
+ #
36
+ # Standard tasks
37
+ #
38
+ #############################################################################
39
+
40
+ Rake::TestTask.new do |t|
41
+ t.libs << 'test'
42
+ end
43
+
44
+ desc "Run tests"
45
+ task :default => :test
46
+
47
+ # Simple Test case
48
+ task :test do
49
+ ruby "test/my_test.rb"
50
+ end
51
+
52
+ task :build1 do
53
+ system "gem build #{gemspec_file}"
54
+ end
55
+
56
+ # Build project
57
+ task :build2 => :gemspec do
58
+ sh "mkdir -p pkg"
59
+ sh "gem build #{gemspec_file}"
60
+ sh "mv #{gem_file} pkg"
61
+ end
@@ -0,0 +1,72 @@
1
+ module.exports = function (grunt) {
2
+
3
+ // Nodes packages
4
+ grunt.loadNpmTasks('grunt-contrib-watch');
5
+ grunt.loadNpmTasks('grunt-shell');
6
+ grunt.loadNpmTasks('grunt-config');
7
+
8
+ // Retrieve Module & Mode from command line options
9
+ var MODULE = grunt.option('module') || 'A';
10
+ var MODE = grunt.option('mode') || 'LMSClass';
11
+ var THEME = grunt.option('css') || 'my_theme.css';
12
+ var BACKEND = grunt.option('backend') || 'html5';
13
+ var BACKEND_DIR;
14
+
15
+ var TARGET_DIR = '.';
16
+ var GENERATED_DIR = TARGET_DIR + "/content/" + MODULE
17
+ var SOURCE_DIR = MODULE;
18
+
19
+ grunt.initConfig({
20
+ shell: {
21
+ run_asciidoctor: {
22
+ // Options
23
+ options: {
24
+ stdout: true
25
+ },
26
+ command:
27
+ 'asciidoctor'
28
+ + ' -b ' + BACKEND
29
+ + ' -a embedAssets'
30
+ + ' ' + SOURCE_DIR + '/' + '<%= grunt.config.get("asciidocFile") %>'
31
+ + ' --out-file ' + GENERATED_DIR + '/' + '<%= grunt.config.get("fileName") %>' + '.html'
32
+ }
33
+ },
34
+ watch: {
35
+ asciidoc: {
36
+ files: [SOURCE_DIR + '/*.txt', SOURCE_DIR + '/*.adoc'],
37
+ tasks: ["shell:run_asciidoctor"],
38
+ options: {
39
+ nospawn: true
40
+ }
41
+ },
42
+ livereload: {
43
+ files: [GENERATED_DIR + '/*.html'],
44
+ tasks: [],
45
+ options: {
46
+ livereload: true,
47
+ spawn: false
48
+ }
49
+ }
50
+
51
+ }
52
+ });
53
+
54
+ // on watch events configure asciidoctor to only run on changed file
55
+ grunt.event.on('watch', function(action, filePath) {
56
+
57
+ // Split string receive to get only FileName
58
+ tokens = filePath.split('/');
59
+ // Remove file extension
60
+ fileName = tokens[1].substr(0, tokens[1].lastIndexOf('.'));
61
+
62
+ grunt.verbose.writeln("File Path received : " + filePath);
63
+ grunt.verbose.writeln("Asciidoc FileName : " + tokens[1]);
64
+ grunt.verbose.writeln("FileName without extension : " + fileName);
65
+
66
+ grunt.config.set('asciidocFile', tokens[1])
67
+ grunt.config.set('fileName', fileName)
68
+
69
+ grunt.task.run('shell:run_asciidoctor');
70
+ });
71
+
72
+ };
@@ -0,0 +1,70 @@
1
+ require 'listen'
2
+ require 'asciidoctor'
3
+ require 'erb'
4
+
5
+ class WatchFiles
6
+
7
+ DEFAULT_OPTIONS = {
8
+ :watch_dir => '.',
9
+ :watch_ext => %w(ad adoc asc asciidoc),
10
+ :run_on_start => false,
11
+ :backend => 'html5',
12
+ :eruby => 'erb',
13
+ :doctype => 'article',
14
+ :compact => false,
15
+ :attributes => {},
16
+ :always_build_all => false,
17
+ :to_dir => '.',
18
+ :to_file => '',
19
+ :safe => :unsafe
20
+ }
21
+
22
+ def initialize
23
+ puts "2. Class initialized !"
24
+ end
25
+
26
+ def watch()
27
+
28
+ puts "3. Watch function called"
29
+
30
+ @opts = DEFAULT_OPTIONS.clone
31
+
32
+ callback = Proc.new do |modified, added, removed|
33
+ puts "modified absolute path: #{modified}"
34
+ puts "added absolute path: #{added}"
35
+ puts "removed absolute path: #{removed}"
36
+
37
+ if !modified.nil? or !added.nil?
38
+
39
+ modified.each do |modify|
40
+ puts "File modified : #{modify}"
41
+
42
+ to_dir = File.dirname(modify)
43
+ @opts[:to_dir] = to_dir
44
+
45
+ file_to_process = Pathname.new(modify)
46
+ file_basename = file_to_process.basename
47
+ @ext_name = File.extname(file_basename)
48
+
49
+ puts "Extension of the file : #{@ext_name}"
50
+
51
+ if @ext_name != '.html'
52
+ to_file = file_to_process.to_s.gsub('adoc', 'html')
53
+ puts "Output Directory: #{to_dir}"
54
+ puts "To File : #{to_file}"
55
+ @opts[:to_file] = to_file
56
+ Asciidoctor.render_file(modify, @opts)
57
+ end
58
+ end
59
+ end
60
+
61
+
62
+ end
63
+
64
+ listener = Listen.to!('../../data/generated', &callback)
65
+
66
+ end
67
+ end
68
+
69
+ puts "1. Call & start Listen"
70
+ WatchFiles.new.watch