awestruct 0.5.3 → 0.5.4.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awestruct/cli/init.rb +35 -34
- data/lib/awestruct/cli/invoker.rb +4 -4
- data/lib/awestruct/cli/manifest.rb +57 -55
- data/lib/awestruct/cli/options.rb +11 -0
- data/lib/awestruct/config.rb +17 -14
- data/lib/awestruct/deploy/base_deploy.rb +13 -7
- data/lib/awestruct/deploy/github_pages_deploy.rb +14 -9
- data/lib/awestruct/engine.rb +17 -12
- data/lib/awestruct/extensions/intense_debate.rb +1 -1
- data/lib/awestruct/extensions/minify.rb +1 -1
- data/lib/awestruct/extensions/pipeline.rb +2 -2
- data/lib/awestruct/extensions/relative.rb +7 -1
- data/lib/awestruct/frameworks/base_Gemfile +5 -1
- data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +2 -2
- data/lib/awestruct/handler_chains.rb +2 -2
- data/lib/awestruct/handlers/asciidoctor_handler.rb +22 -4
- data/lib/awestruct/handlers/base_tilt_handler.rb +34 -10
- data/lib/awestruct/handlers/file_handler.rb +8 -12
- data/lib/awestruct/handlers/front_matter_handler.rb +1 -1
- data/lib/awestruct/handlers/interpolation_handler.rb +1 -6
- data/lib/awestruct/handlers/tilt_handler.rb +1 -7
- data/lib/awestruct/handlers/verbatim_file_handler.rb +12 -0
- data/lib/awestruct/scm/git.rb +14 -0
- data/lib/awestruct/version.rb +1 -1
- data/man/awestruct.1 +14 -3
- data/spec/asciidoc_handler_spec.rb +43 -40
- data/spec/awestruct/scm/git_spec.rb +29 -0
- data/spec/config_spec.rb +8 -2
- data/spec/engine_spec.rb +31 -9
- data/spec/erb_handler_spec.rb +33 -31
- data/spec/front_matter_handler_spec.rb +17 -6
- data/spec/github_pages_deploy_spec.rb +13 -7
- data/spec/haml_handler_spec.rb +62 -59
- data/spec/interpolation_handler_spec.rb +4 -8
- data/spec/javascript_handler_spec.rb +16 -13
- data/spec/minify_spec.rb +3 -1
- data/spec/mustache_handler_spec.rb +11 -7
- data/spec/options_spec.rb +20 -11
- data/spec/page_loader_spec.rb +3 -1
- data/spec/page_loader_spec_for_layouts.rb +3 -1
- data/spec/redirect_handler_spec.rb +21 -17
- data/spec/slim_handler_spec.rb +51 -49
- data/spec/support/shared_handler_example.rb +12 -8
- data/spec/test-data/front-matter-file-utf8.txt +5 -0
- data/spec/test-data/handlers/haml-error.html.haml +4 -0
- data/spec/test-data/handlers/hello.bogus +1 -0
- data/spec/tilt_handler_spec.rb +70 -3
- metadata +16 -25
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'awestruct/deploy/base_deploy'
|
2
|
+
require 'git'
|
2
3
|
|
3
4
|
module Awestruct
|
4
5
|
module Deploy
|
5
6
|
class GitHubPagesDeploy < Base
|
6
|
-
def initialize(
|
7
|
+
def initialize(site_config, deploy_config)
|
7
8
|
@site_path = site_config.output_dir
|
8
|
-
@branch
|
9
|
-
@repo
|
9
|
+
@branch = deploy_config['branch'] || 'gh-pages'
|
10
|
+
@repo = deploy_config['repository'] || 'origin'
|
10
11
|
end
|
11
12
|
|
12
13
|
def publish_site
|
@@ -16,15 +17,15 @@ module Awestruct
|
|
16
17
|
if current_branch == '(no branch)'
|
17
18
|
current_branch = git.revparse('HEAD')
|
18
19
|
end
|
19
|
-
git.branch(
|
20
|
+
git.branch(@branch).checkout
|
20
21
|
add_and_commit_site @site_path
|
21
|
-
git.push(
|
22
|
-
git.checkout(
|
22
|
+
git.push(@repo, @branch)
|
23
|
+
git.checkout(current_branch)
|
23
24
|
end
|
24
25
|
|
25
26
|
private
|
26
|
-
def add_and_commit_site(
|
27
|
-
git.with_working(
|
27
|
+
def add_and_commit_site(path)
|
28
|
+
git.with_working(path) do
|
28
29
|
git.add(".")
|
29
30
|
begin
|
30
31
|
git.commit("Published #{@branch} to GitHub pages.")
|
@@ -34,8 +35,12 @@ module Awestruct
|
|
34
35
|
end
|
35
36
|
git.reset_hard
|
36
37
|
end
|
38
|
+
|
39
|
+
def git
|
40
|
+
@git ||= ::Git.open('.')
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
41
|
-
Awestruct::Deployers.instance[
|
46
|
+
Awestruct::Deployers.instance[:github_pages] = Awestruct::Deploy::GitHubPagesDeploy
|
data/lib/awestruct/engine.rb
CHANGED
@@ -24,6 +24,7 @@ module Awestruct
|
|
24
24
|
|
25
25
|
attr_reader :site
|
26
26
|
attr_reader :pipeline
|
27
|
+
attr_reader :config
|
27
28
|
|
28
29
|
def self.instance
|
29
30
|
@instance
|
@@ -39,6 +40,7 @@ module Awestruct
|
|
39
40
|
@pipeline = Pipeline.new
|
40
41
|
@site_page_loader = PageLoader.new( @site )
|
41
42
|
@layout_page_loader = PageLoader.new( @site, :layouts )
|
43
|
+
@config = config
|
42
44
|
end
|
43
45
|
|
44
46
|
def config
|
@@ -46,29 +48,29 @@ module Awestruct
|
|
46
48
|
end
|
47
49
|
|
48
50
|
def run(profile, base_url, default_base_url, force=false)
|
49
|
-
$LOG.debug
|
51
|
+
$LOG.debug 'adjust_load_path' if $LOG.debug?
|
50
52
|
adjust_load_path
|
51
|
-
$LOG.debug
|
53
|
+
$LOG.debug 'load_default_site_yaml' if $LOG.debug?
|
52
54
|
load_default_site_yaml
|
53
|
-
$LOG.debug
|
55
|
+
$LOG.debug 'load_site_yaml -- profile' if $LOG.debug?
|
54
56
|
load_site_yaml(profile)
|
55
|
-
$LOG.debug
|
57
|
+
$LOG.debug 'set_base_url' if $LOG.debug?
|
56
58
|
set_base_url( base_url, default_base_url )
|
57
|
-
$LOG.debug
|
59
|
+
$LOG.debug 'load_yamls' if $LOG.debug?
|
58
60
|
load_yamls
|
59
|
-
$LOG.debug
|
61
|
+
$LOG.debug 'load_pipeline' if $LOG.debug?
|
60
62
|
load_pipeline
|
61
|
-
$LOG.debug
|
63
|
+
$LOG.debug 'load_pages' if $LOG.debug?
|
62
64
|
load_pages
|
63
|
-
$LOG.debug
|
65
|
+
$LOG.debug 'execute_pipeline' if $LOG.debug?
|
64
66
|
execute_pipeline
|
65
|
-
$LOG.debug
|
67
|
+
$LOG.debug 'configure_compass' if $LOG.debug?
|
66
68
|
configure_compass
|
67
|
-
$LOG.debug
|
69
|
+
$LOG.debug 'set_urls' if $LOG.debug?
|
68
70
|
set_urls( site.pages )
|
69
|
-
$LOG.debug
|
71
|
+
$LOG.debug 'build_page_index' if $LOG.debug?
|
70
72
|
build_page_index
|
71
|
-
$LOG.debug
|
73
|
+
$LOG.debug 'generate_output' if $LOG.debug?
|
72
74
|
generate_output
|
73
75
|
end
|
74
76
|
|
@@ -233,6 +235,7 @@ module Awestruct
|
|
233
235
|
Compass.configuration.project_type = :standalone
|
234
236
|
Compass.configuration.project_path = site.config.dir
|
235
237
|
Compass.configuration.sass_dir = 'stylesheets'
|
238
|
+
Compass.configuration.http_path = site.base_url
|
236
239
|
|
237
240
|
site.images_dir = File.join( site.config.output_dir, 'images' )
|
238
241
|
site.fonts_dir = File.join( site.config.output_dir, 'fonts' )
|
@@ -245,6 +248,8 @@ module Awestruct
|
|
245
248
|
Compass.configuration.fonts_dir = 'fonts'
|
246
249
|
Compass.configuration.line_comments = include_line_comments?
|
247
250
|
Compass.configuration.output_style = compress_css?
|
251
|
+
Compass.configuration.relative_assets = false
|
252
|
+
# TODO: Should we add an on_stylesheet_error block?
|
248
253
|
|
249
254
|
# port old style configuration to new Tilt-based configuration
|
250
255
|
# TODO consider deprecating the old config mechanism and move to default-site.yml
|
@@ -26,7 +26,7 @@ module Awestruct
|
|
26
26
|
html = %Q(<script>\n)
|
27
27
|
html += %Q( var idcomments_acct='#{site.intense_debate_acct}';\n)
|
28
28
|
html += %Q( var idcomments_post_id='#{post_id}';\n )
|
29
|
-
html += %Q( var idcomments_post_url='#{self.url}';\n)
|
29
|
+
html += %Q( var idcomments_post_url='#{site.intense_debate_base_url || site.base_url}#{self.url}';\n)
|
30
30
|
html += %Q(</script>\n)
|
31
31
|
html += %Q(<script type='text/javascript' src='http://www.intensedebate.com/js/genericLinkWrapperV2.js'></script>\n)
|
32
32
|
html
|
@@ -117,7 +117,7 @@ module Awestruct
|
|
117
117
|
|
118
118
|
def pngcrush(page, input)
|
119
119
|
filename = page.source_path
|
120
|
-
cmd = Shellwords.escape("
|
120
|
+
cmd = "pngcrush " + Shellwords.escape("#{filename}") + " /tmp/pngcrush"
|
121
121
|
`#{cmd}`
|
122
122
|
if $?.exitstatus != 0
|
123
123
|
raise "Failed to execute pngcrush: #{cmd}"
|
@@ -3,9 +3,9 @@ Dir[ File.join( File.dirname(__FILE__), '*.rb' ) ].each do |f|
|
|
3
3
|
begin
|
4
4
|
require f
|
5
5
|
rescue LoadError => e
|
6
|
-
puts "WARNING: Missing required dependency to activate optional built-in extension #{File.basename(f)}\n #{e}"
|
6
|
+
puts "WARNING: Missing required dependency to activate optional built-in extension #{File.basename(f)}\n #{e}" if $LOG.debug?
|
7
7
|
rescue StandardError => e
|
8
|
-
puts "WARNING: Missing runtime configuration to activate optional built-in extension #{File.basename(f)}\n #{e}"
|
8
|
+
puts "WARNING: Missing runtime configuration to activate optional built-in extension #{File.basename(f)}\n #{e}" if $LOG.debug?
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -6,7 +6,13 @@ module Awestruct
|
|
6
6
|
|
7
7
|
def relative(href, p = page)
|
8
8
|
begin
|
9
|
-
|
9
|
+
# Ignore absolute links
|
10
|
+
if href.start_with?("http://") || href.start_with?("https://")
|
11
|
+
result = href
|
12
|
+
else
|
13
|
+
result = Pathname.new(href).relative_path_from(Pathname.new(File.dirname(p.output_path))).to_s
|
14
|
+
end
|
15
|
+
result
|
10
16
|
rescue Exception => e
|
11
17
|
$LOG.error "#{e}" if $LOG.error?
|
12
18
|
$LOG.error "#{e.backtrace.join("\n")}" if $LOG.error?
|
@@ -24,9 +24,13 @@
|
|
24
24
|
|
25
25
|
source 'https://rubygems.org' # This tells Bundler where to look for gems
|
26
26
|
|
27
|
-
gem 'awestruct', '>= 0.5.
|
27
|
+
gem 'awestruct', '>= 0.5.3' # Goes without saying
|
28
28
|
gem 'rake', '>= 0.9.2' # Needed for the Rakefile to work
|
29
29
|
# gem 'coffee-script', '>= 2.2.0' # If using coffee-script or to remove the warning
|
30
|
+
# gem 'rb-fsevent', '~> 0.9', :require => false # to remove warning about pulling, Mac OSX
|
31
|
+
# gem 'rb-inotify', '>= 0.9.0', :require => false # to remove warning about pulling, Linux
|
32
|
+
# gem 'wdm', :platforms => [:mswin, :mingw], :require => false # to remove warning about pulling, Windows (ruby 1.9+)
|
33
|
+
# gem 'rb-fchange', '~> 0.0.6', :require => false # to remove warning about pulling, Windows (ruby 1.8.7)
|
30
34
|
# gem 'therubyracer', '0.10.0', :platforms => :ruby # Javascript runtime on mri (needed for LESS and coffee-script)
|
31
35
|
# gem 'therubyrhino', '~> 2.0.2', :platforms => :jruby # Javascript runtime on jruby (needed for LESS and coffee-script)
|
32
36
|
# gem 'less', '>= 2.2.2' # If using LESS instead of sass
|
@@ -15,7 +15,7 @@
|
|
15
15
|
.navbar.navbar-fixed-top
|
16
16
|
.navbar-inner
|
17
17
|
.container
|
18
|
-
%a.brand{ :href=>"#{site.base_url}" }
|
18
|
+
%a.brand{ :href=>"#{site.base_url}" } #{site.name}
|
19
19
|
%ul.nav
|
20
20
|
%li
|
21
21
|
%a{ :href=>"#{site.base_url}" } Home
|
@@ -23,7 +23,7 @@
|
|
23
23
|
~ content
|
24
24
|
%hr
|
25
25
|
%footer
|
26
|
-
%p ©
|
26
|
+
%p © #{site.org} #{Date.today.year}
|
27
27
|
-# Uncomment script tags (remove leading -#) when you're ready to use behaviors
|
28
28
|
-# %script{ :type=>'text/javascript', :src=>'//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js' }
|
29
29
|
-# %script{ :type=>'text/javascript', :src=>"#{site.base_url}/javascripts/bootstrap-collapse.js" }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'awestruct/handler_chain'
|
2
|
-
require 'awestruct/handlers/
|
2
|
+
require 'awestruct/handlers/verbatim_file_handler'
|
3
3
|
require 'awestruct/handlers/css_tilt_handler'
|
4
4
|
require 'awestruct/handlers/restructuredtext_handler'
|
5
5
|
require 'awestruct/handlers/javascript_handler'
|
@@ -19,7 +19,7 @@ module Awestruct
|
|
19
19
|
Awestruct::Handlers::AsciidoctorHandler::CHAIN,
|
20
20
|
Awestruct::Handlers::TiltHandler::NON_INTERPOLATION_CHAIN,
|
21
21
|
Awestruct::Handlers::TiltHandler::INTERPOLATION_CHAIN,
|
22
|
-
HandlerChain.new( /.*/, Awestruct::Handlers::
|
22
|
+
HandlerChain.new( /.*/, Awestruct::Handlers::VerbatimFileHandler )
|
23
23
|
]
|
24
24
|
|
25
25
|
def initialize(include_defaults=true)
|
@@ -10,16 +10,34 @@ require 'tilt'
|
|
10
10
|
module Awestruct
|
11
11
|
module Handlers
|
12
12
|
|
13
|
-
class
|
13
|
+
class AsciidoctorTiltMatcher < TiltMatcher
|
14
|
+
# Use a lightweight lookup to avoid loading Tilt templates for
|
15
|
+
# non-matching paths. Once we are sure this is a match, then
|
16
|
+
# attempt to load the Tilt template for AsciiDoc files.
|
14
17
|
def match(path)
|
15
|
-
|
16
|
-
|
18
|
+
# formal lookup as implemented in Tilt
|
19
|
+
pattern = File.basename(path.downcase)
|
20
|
+
registered = false
|
21
|
+
until pattern.empty? || (registered = Tilt.registered?(pattern))
|
22
|
+
# shave pattern down to next extension
|
23
|
+
pattern = pattern.sub(/^[^.]*\.?/, '')
|
24
|
+
end
|
25
|
+
if registered && (Tilt.mappings[pattern] || []).include?(Tilt::AsciidoctorTemplate)
|
26
|
+
begin
|
27
|
+
Tilt[File.basename(path)]
|
28
|
+
rescue LoadError
|
29
|
+
# swallowing error as it will be picked up again by primary TiltHandler
|
30
|
+
false
|
31
|
+
end
|
32
|
+
else
|
33
|
+
false
|
34
|
+
end
|
17
35
|
end
|
18
36
|
end
|
19
37
|
|
20
38
|
class AsciidoctorHandler < BaseTiltHandler
|
21
39
|
|
22
|
-
CHAIN = Awestruct::HandlerChain.new( Awestruct::Handlers::
|
40
|
+
CHAIN = Awestruct::HandlerChain.new( Awestruct::Handlers::AsciidoctorTiltMatcher.new(),
|
23
41
|
Awestruct::Handlers::FileHandler,
|
24
42
|
Awestruct::Handlers::FrontMatterHandler,
|
25
43
|
Awestruct::Handlers::AsciidoctorHandler,
|
@@ -4,10 +4,26 @@ require 'tilt'
|
|
4
4
|
|
5
5
|
module Awestruct
|
6
6
|
module Handlers
|
7
|
+
|
8
|
+
class TiltMatcher
|
9
|
+
# Returns the Tilt template class if a portion of the path is registered
|
10
|
+
# to a Tilt template and the Tilt template can be loaded. Returns false
|
11
|
+
# if no portions of the path are registered to a Tilt template or the
|
12
|
+
# Tilt template cannot be loaded.
|
13
|
+
def match(path)
|
14
|
+
begin
|
15
|
+
Tilt[File.basename(path)]
|
16
|
+
rescue LoadError => e
|
17
|
+
$LOG.warn(%(Copying #{path} to generated site without processing; missing required gem -- #{e.message.split(/ *-- */).last} (or equivalent)))
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
7
23
|
class BaseTiltHandler < BaseHandler
|
8
24
|
|
9
25
|
def initialize(site, delegate)
|
10
|
-
super(
|
26
|
+
super(site, delegate)
|
11
27
|
end
|
12
28
|
|
13
29
|
def source_file_name
|
@@ -22,8 +38,8 @@ module Awestruct
|
|
22
38
|
end
|
23
39
|
|
24
40
|
def simple_name
|
25
|
-
base = File.basename(
|
26
|
-
return File.basename(
|
41
|
+
base = File.basename(source_file_name, File.extname(source_file_name))
|
42
|
+
return File.basename(base, File.extname(base)) if double_extension?
|
27
43
|
return base
|
28
44
|
end
|
29
45
|
|
@@ -32,11 +48,11 @@ module Awestruct
|
|
32
48
|
end
|
33
49
|
|
34
50
|
def input_extension
|
35
|
-
File.extname(
|
51
|
+
File.extname(source_file_name)
|
36
52
|
end
|
37
53
|
|
38
54
|
def output_extension
|
39
|
-
return File.extname(
|
55
|
+
return File.extname(File.basename(source_file_name, File.extname(source_file_name))) if double_extension?
|
40
56
|
|
41
57
|
template = Tilt[path]
|
42
58
|
if !template.nil?
|
@@ -55,7 +71,7 @@ module Awestruct
|
|
55
71
|
def content_syntax
|
56
72
|
# Check configuration for override, else convert extension to sym
|
57
73
|
extension = input_extension[1..-1]
|
58
|
-
if (
|
74
|
+
if (!site[:content_syntax].nil? && !site[:content_syntax].empty?)
|
59
75
|
syntax = site[:content_syntax][extension]
|
60
76
|
return syntax.to_sym unless syntax.nil? or syntax.empty?
|
61
77
|
end
|
@@ -103,10 +119,18 @@ module Awestruct
|
|
103
119
|
|
104
120
|
def rendered_content(context, with_layouts=true)
|
105
121
|
$LOG.debug "invoking tilt for #{delegate.path.to_s} with_layouts = #{with_layouts}" if $LOG.debug?
|
106
|
-
|
107
|
-
delegate.
|
108
|
-
|
109
|
-
|
122
|
+
begin
|
123
|
+
template = Tilt::new(delegate.path.to_s, delegate.content_line_offset + 1, options) { |engine|
|
124
|
+
delegate.rendered_content(context, with_layouts)
|
125
|
+
}
|
126
|
+
return template.render(context)
|
127
|
+
rescue LoadError => e
|
128
|
+
$LOG.error "Could not load template library required for rendering #{delegate.path.to_s}, please see rendered output for more information" if $LOG.error?
|
129
|
+
return "<h1>#{e.message}</h1><h2>Rendering file #{delegate.path.to_s} resulted in a failure.</h2><p>Backtrace: #{e.backtrace.join '<br>'}</p>"
|
130
|
+
rescue Exception => e
|
131
|
+
$LOG.error "An error during rendering #{delegate.path.to_s} occurred, please see rendered output for more information" if $LOG.error?
|
132
|
+
return "<h1>#{e.message}</h1><h2>Rendering file #{delegate.path.to_s} resulted in a failure.</h2><h3>Line: #{e.line if e.respond_to?(:line)}</h3><p>Backtrace: #{e.backtrace.join '<br>'}</p>"
|
133
|
+
end
|
110
134
|
end
|
111
135
|
|
112
136
|
end
|
@@ -43,27 +43,23 @@ module Awestruct
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def raw_content
|
46
|
-
|
47
|
-
@content
|
46
|
+
load_content
|
48
47
|
end
|
49
48
|
|
50
49
|
def rendered_content(context, with_layouts=true)
|
51
50
|
raw_content
|
52
51
|
end
|
52
|
+
|
53
|
+
def read_content
|
54
|
+
File.open(@path, 'r') {|is| is.read }
|
55
|
+
end
|
53
56
|
|
54
57
|
private
|
55
58
|
|
56
|
-
def
|
57
|
-
( @content =
|
59
|
+
def load_content
|
60
|
+
( @content = read_content ) if stale?
|
58
61
|
@mtime = File.mtime( @path )
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def open
|
63
|
-
input_stream = IO.open(IO.sysopen(@path, "rb"), "rb" )
|
64
|
-
result = input_stream.read
|
65
|
-
input_stream.close
|
66
|
-
return result
|
62
|
+
@content
|
67
63
|
end
|
68
64
|
|
69
65
|
end
|
@@ -44,7 +44,7 @@ module Awestruct
|
|
44
44
|
full_content = delegate.raw_content
|
45
45
|
|
46
46
|
#if force_encoding is supported then set to charset defined in site config
|
47
|
-
full_content.force_encoding(site.encoding) if (full_content.respond_to?(:force_encoding)
|
47
|
+
full_content.force_encoding(site.encoding) if (site.encoding && full_content.respond_to?(:force_encoding))
|
48
48
|
|
49
49
|
yaml_content = ''
|
50
50
|
|
@@ -17,7 +17,7 @@ module Awestruct
|
|
17
17
|
|
18
18
|
content = content.gsub( /\\/, '\\\\\\\\' )
|
19
19
|
content = content.gsub( /\\\\#/, '\\#' )
|
20
|
-
content = content.gsub(
|
20
|
+
content = content.gsub( /#(?!\{)/, '\#' )
|
21
21
|
content = content.gsub( '@', '\@' )
|
22
22
|
content = "%@#{content}@"
|
23
23
|
begin
|
@@ -30,11 +30,6 @@ module Awestruct
|
|
30
30
|
c
|
31
31
|
|
32
32
|
end
|
33
|
-
|
34
|
-
def ruby_19?
|
35
|
-
@is_ruby_19 ||= RUBY_VERSION >= '1.9'
|
36
|
-
end
|
37
|
-
|
38
33
|
end
|
39
34
|
end
|
40
35
|
end
|
@@ -11,18 +11,12 @@ require 'tilt'
|
|
11
11
|
module Awestruct
|
12
12
|
module Handlers
|
13
13
|
|
14
|
-
class TiltMatcher
|
15
|
-
def match(path)
|
16
|
-
!Tilt[path].nil?
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
14
|
class NonInterpolatingTiltMatcher
|
21
15
|
EXT_REGEX = /\.(haml|slim|erb|mustache)$/
|
22
16
|
|
23
17
|
def match(path)
|
24
18
|
if match = EXT_REGEX.match(path)
|
25
|
-
if match[0] == '.slim' && Tilt
|
19
|
+
if match[0] == '.slim' && !Tilt.registered?('slim')
|
26
20
|
require 'slim'
|
27
21
|
end
|
28
22
|
true
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'awestruct/handlers/file_handler'
|
2
|
+
|
3
|
+
module Awestruct
|
4
|
+
module Handlers
|
5
|
+
class VerbatimFileHandler < FileHandler
|
6
|
+
# Read file in binary mode so that it can be copied to the generated site as is
|
7
|
+
def read_content
|
8
|
+
File.open(@path, 'rb') {|is| is.read }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|