Skip to content

Commit 4a306e1

Browse files
committed
Revised build system to make Guard useful.
1 parent 8e8bafc commit 4a306e1

File tree

13 files changed

+27
-85
lines changed

13 files changed

+27
-85
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Gemfile.lock
12
*.html
3+
*.swp
24
_package
35
_preview
File renamed without changes.

Guardfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'asciidoctor'
2+
require 'erb'
3+
require 'haml'
4+
require 'tilt'
5+
6+
guard 'shell' do
7+
watch(/^.*\.adoc$/) { |m|
8+
if not m[0].start_with?('_preview')
9+
src_group_path = m[0].split('/')[0]
10+
filename = m[0].split('/')[-1][0..-6]
11+
tgt_file_path = "_preview/#{src_group_path}"
12+
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']
13+
system('mv', "#{src_group_path}/#{filename}.html", "#{tgt_file_path}/")
14+
end
15+
}
16+
end
17+
18+
guard 'livereload' do
19+
watch(%r{^_preview\.(css|js|html)$})
20+
end

_build_system/Rakefile renamed to Rakefile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ PACKAGE_DIRNAME = '_package'
1111
BLANK_STRING_RE = Regexp.new('^\s*$')
1212

1313
def source_dir
14-
@source_dir ||= File.expand_path('..',Dir.pwd)
14+
@source_dir ||= File.expand_path(Dir.pwd)
1515
end
1616

17-
def builder_dir
18-
@builder_dir = File.join(source_dir,BUILDER_DIRNAME)
19-
end
20-
21-
def builder_template_dir
22-
@builder_template_dir ||= File.join(builder_dir,'templates')
17+
def template_dir
18+
@template_dir ||= File.join(source_dir,'_templates')
2319
end
2420

2521
def preview_dir
@@ -115,7 +111,7 @@ end
115111

116112
task :build do
117113
# Copy stylesheets into preview area
118-
system("cp -r #{builder_dir}/stylesheets #{preview_dir}")
114+
system("cp -r _stylesheets #{preview_dir}/stylesheets")
119115
# Build the topic files
120116
build_config.each do |topic_group|
121117
src_group_path = File.join(source_dir,topic_group['Dir'])
@@ -130,7 +126,7 @@ task :build do
130126
src_file_path = File.join(src_group_path,"#{topic['File']}.adoc")
131127
tgt_file_path = File.join(tgt_group_path,"#{topic['File']}.adoc")
132128
system('cp', src_file_path, tgt_file_path)
133-
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']
129+
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']
134130
system('rm', tgt_file_path)
135131
end
136132
end

_build_system/Gemfile.lock

Lines changed: 0 additions & 62 deletions
This file was deleted.

_build_system/Guardfile

Lines changed: 0 additions & 14 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)