From 4a306e1564fb95cc3e1fcaa71f12ee22f01af2f1 Mon Sep 17 00:00:00 2001 From: "N. Harrison Ripps" Date: Mon, 21 Jul 2014 16:56:16 -0400 Subject: [PATCH] Revised build system to make Guard useful. --- .gitignore | 2 + _build_system/Gemfile => Gemfile | 0 Guardfile | 20 ++++++ _build_system/Rakefile => Rakefile | 14 ++--- _build_system/Gemfile.lock | 62 ------------------- _build_system/Guardfile | 14 ----- .../foundation.css | 0 .../stylesheets => _stylesheets}/origin.css | 0 .../sass/fonts/_overpass.scss | 0 .../sass/fonts/_sourcecode.scss | 0 .../sass/origin.scss | 0 .../sass/settings/_origin.scss | 0 .../document.html.haml | 0 13 files changed, 27 insertions(+), 85 deletions(-) rename _build_system/Gemfile => Gemfile (100%) create mode 100644 Guardfile rename _build_system/Rakefile => Rakefile (92%) delete mode 100644 _build_system/Gemfile.lock delete mode 100644 _build_system/Guardfile rename {_build_system/stylesheets => _stylesheets}/foundation.css (100%) rename {_build_system/stylesheets => _stylesheets}/origin.css (100%) rename {_build_system/stylesheets => _stylesheets}/sass/fonts/_overpass.scss (100%) rename {_build_system/stylesheets => _stylesheets}/sass/fonts/_sourcecode.scss (100%) rename {_build_system/stylesheets => _stylesheets}/sass/origin.scss (100%) rename {_build_system/stylesheets => _stylesheets}/sass/settings/_origin.scss (100%) rename {_build_system/templates => _templates}/document.html.haml (100%) diff --git a/.gitignore b/.gitignore index 1ae8e3a5ad26..39dde32f7be0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +Gemfile.lock *.html +*.swp _package _preview diff --git a/_build_system/Gemfile b/Gemfile similarity index 100% rename from _build_system/Gemfile rename to Gemfile diff --git a/Guardfile b/Guardfile new file mode 100644 index 000000000000..c6bfff0a742e --- /dev/null +++ b/Guardfile @@ -0,0 +1,20 @@ +require 'asciidoctor' +require 'erb' +require 'haml' +require 'tilt' + +guard 'shell' do + watch(/^.*\.adoc$/) { |m| + if not m[0].start_with?('_preview') + src_group_path = m[0].split('/')[0] + filename = m[0].split('/')[-1][0..-6] + tgt_file_path = "_preview/#{src_group_path}" + Asciidoctor.render_file m[0], :in_place => true, :safe => :unsafe, :template_dir => '_template', :attributes => ['source-highlighter=coderay','coderay-css=style',"stylesdir=_preview/stylesheets","imagesdir=#{src_group_path}/images",'stylesheet=origin.css','linkcss!','icons=font','idprefix=','idseparator=-','sectanchors'] + system('mv', "#{src_group_path}/#{filename}.html", "#{tgt_file_path}/") + end + } +end + +guard 'livereload' do + watch(%r{^_preview\.(css|js|html)$}) +end diff --git a/_build_system/Rakefile b/Rakefile similarity index 92% rename from _build_system/Rakefile rename to Rakefile index 3b540a15309e..f038e93e2519 100644 --- a/_build_system/Rakefile +++ b/Rakefile @@ -11,15 +11,11 @@ PACKAGE_DIRNAME = '_package' BLANK_STRING_RE = Regexp.new('^\s*$') def source_dir - @source_dir ||= File.expand_path('..',Dir.pwd) + @source_dir ||= File.expand_path(Dir.pwd) end -def builder_dir - @builder_dir = File.join(source_dir,BUILDER_DIRNAME) -end - -def builder_template_dir - @builder_template_dir ||= File.join(builder_dir,'templates') +def template_dir + @template_dir ||= File.join(source_dir,'_templates') end def preview_dir @@ -115,7 +111,7 @@ end task :build do # Copy stylesheets into preview area - system("cp -r #{builder_dir}/stylesheets #{preview_dir}") + system("cp -r _stylesheets #{preview_dir}/stylesheets") # Build the topic files build_config.each do |topic_group| src_group_path = File.join(source_dir,topic_group['Dir']) @@ -130,7 +126,7 @@ task :build do src_file_path = File.join(src_group_path,"#{topic['File']}.adoc") tgt_file_path = File.join(tgt_group_path,"#{topic['File']}.adoc") system('cp', src_file_path, tgt_file_path) - Asciidoctor.render_file tgt_file_path, :in_place => true, :safe => :unsafe, :template_dir => builder_template_dir, :attributes => ['source-highlighter=coderay','coderay-css=style',"stylesdir=#{preview_dir}/stylesheets","imagesdir=#{src_group_path}/images",'stylesheet=origin.css','linkcss!','icons=font','idprefix=','idseparator=-','sectanchors'] + Asciidoctor.render_file tgt_file_path, :in_place => true, :safe => :unsafe, :template_dir => template_dir, :attributes => ['source-highlighter=coderay','coderay-css=style',"stylesdir=#{preview_dir}/stylesheets","imagesdir=#{src_group_path}/images",'stylesheet=origin.css','linkcss!','icons=font','idprefix=','idseparator=-','sectanchors'] system('rm', tgt_file_path) end end diff --git a/_build_system/Gemfile.lock b/_build_system/Gemfile.lock deleted file mode 100644 index b639b08febdd..000000000000 --- a/_build_system/Gemfile.lock +++ /dev/null @@ -1,62 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - asciidoctor (0.1.4) - celluloid (0.15.2) - timers (~> 1.1.0) - coderay (1.1.0) - em-websocket (0.5.1) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - eventmachine (1.0.3) - ffi (1.9.3) - formatador (0.2.5) - guard (2.6.1) - formatador (>= 0.2.4) - listen (~> 2.7) - lumberjack (~> 1.0) - pry (>= 0.9.12) - thor (>= 0.18.1) - guard-livereload (2.3.0) - em-websocket (~> 0.5) - guard (~> 2.0) - multi_json (~> 1.8) - guard-shell (0.6.1) - guard (>= 1.1.0) - haml (4.0.5) - tilt - http_parser.rb (0.6.0) - listen (2.7.9) - celluloid (>= 0.15.2) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - lumberjack (1.0.9) - method_source (0.8.2) - multi_json (1.10.1) - pandoc-ruby (0.7.5) - pry (0.10.0) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - rake (10.3.2) - rb-fsevent (0.9.4) - rb-inotify (0.9.5) - ffi (>= 0.5.0) - slop (3.6.0) - thor (0.19.1) - tilt (2.0.1) - timers (1.1.0) - yajl-ruby (1.2.1) - -PLATFORMS - ruby - -DEPENDENCIES - asciidoctor - guard - guard-livereload - guard-shell - haml - pandoc-ruby - rake - yajl-ruby diff --git a/_build_system/Guardfile b/_build_system/Guardfile deleted file mode 100644 index c30306066f96..000000000000 --- a/_build_system/Guardfile +++ /dev/null @@ -1,14 +0,0 @@ -require 'asciidoctor' -require 'erb' -require 'haml' -require 'tilt' - -guard 'shell' do - watch(/^.*\.adoc$/) {|m| - Asciidoctor.render_file m[0], :in_place => true, :safe => :safe, :template_dir => './templates', :attributes => %w(source-highlighter=coderay coderay-css=style stylesdir=./stylesheets imagesdir=./images stylesheet=origin.css linkcss! icons=font idprefix= idseparator=- sectanchors) - } -end - -guard 'livereload' do - watch(%r{^.+\.(css|js|html)$}) -end diff --git a/_build_system/stylesheets/foundation.css b/_stylesheets/foundation.css similarity index 100% rename from _build_system/stylesheets/foundation.css rename to _stylesheets/foundation.css diff --git a/_build_system/stylesheets/origin.css b/_stylesheets/origin.css similarity index 100% rename from _build_system/stylesheets/origin.css rename to _stylesheets/origin.css diff --git a/_build_system/stylesheets/sass/fonts/_overpass.scss b/_stylesheets/sass/fonts/_overpass.scss similarity index 100% rename from _build_system/stylesheets/sass/fonts/_overpass.scss rename to _stylesheets/sass/fonts/_overpass.scss diff --git a/_build_system/stylesheets/sass/fonts/_sourcecode.scss b/_stylesheets/sass/fonts/_sourcecode.scss similarity index 100% rename from _build_system/stylesheets/sass/fonts/_sourcecode.scss rename to _stylesheets/sass/fonts/_sourcecode.scss diff --git a/_build_system/stylesheets/sass/origin.scss b/_stylesheets/sass/origin.scss similarity index 100% rename from _build_system/stylesheets/sass/origin.scss rename to _stylesheets/sass/origin.scss diff --git a/_build_system/stylesheets/sass/settings/_origin.scss b/_stylesheets/sass/settings/_origin.scss similarity index 100% rename from _build_system/stylesheets/sass/settings/_origin.scss rename to _stylesheets/sass/settings/_origin.scss diff --git a/_build_system/templates/document.html.haml b/_templates/document.html.haml similarity index 100% rename from _build_system/templates/document.html.haml rename to _templates/document.html.haml