awestruct 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awestruct/astruct.rb +1 -1
- data/lib/awestruct/astruct_mixin.rb +6 -6
- data/lib/awestruct/cli/deploy.rb +1 -1
- data/lib/awestruct/cli/invoker.rb +1 -0
- data/lib/awestruct/cli/options.rb +4 -0
- data/lib/awestruct/config.rb +6 -4
- data/lib/awestruct/context.rb +5 -5
- data/lib/awestruct/deploy/base_deploy.rb +6 -2
- data/lib/awestruct/engine.rb +2 -1
- data/lib/awestruct/extensions/assets.rb +15 -19
- data/lib/awestruct/extensions/atomizer.rb +2 -2
- data/lib/awestruct/extensions/cachebuster.rb +7 -4
- data/lib/awestruct/extensions/disqus.rb +3 -0
- data/lib/awestruct/extensions/extend_string.rb +1 -1
- data/lib/awestruct/extensions/gsub.rb +17 -3
- data/lib/awestruct/extensions/minify.rb +1 -1
- data/lib/awestruct/extensions/paginator.rb +3 -2
- data/lib/awestruct/extensions/partial.rb +1 -0
- data/lib/awestruct/extensions/relative.rb +4 -2
- data/lib/awestruct/extensions/template.atom.haml +2 -2
- data/lib/awestruct/handler_chains.rb +2 -0
- data/lib/awestruct/handlers/front_matter_handler.rb +7 -1
- data/lib/awestruct/handlers/mustache_handler.rb +44 -0
- data/lib/awestruct/page.rb +13 -7
- data/lib/awestruct/page_loader.rb +9 -7
- data/lib/awestruct/rack/app.rb +19 -8
- data/lib/awestruct/site.rb +2 -0
- data/lib/awestruct/version.rb +1 -1
- metadata +28 -11
data/lib/awestruct/astruct.rb
CHANGED
@@ -13,7 +13,7 @@ module Awestruct
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def cascade_for_nils!
|
16
|
-
@cascade_for_nils = true
|
16
|
+
@cascade_for_nils = true
|
17
17
|
self
|
18
18
|
end
|
19
19
|
|
@@ -22,8 +22,8 @@ module Awestruct
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def [](key)
|
25
|
-
r =
|
26
|
-
transform_entry( key, r )
|
25
|
+
r = [key, key.to_sym, key.to_s].find { |fk| !super(fk).nil? }
|
26
|
+
transform_entry( key, super(r) )
|
27
27
|
end
|
28
28
|
|
29
29
|
def method_missing(sym, *args, &blk)
|
@@ -40,7 +40,7 @@ module Awestruct
|
|
40
40
|
if key?(name)
|
41
41
|
self[name]
|
42
42
|
elsif @cascade_for_nils
|
43
|
-
self[name] = AStruct.new.cascade_for_nils!
|
43
|
+
self[name] = AStruct.new.cascade_for_nils!
|
44
44
|
self[name]
|
45
45
|
else
|
46
46
|
nil
|
@@ -73,9 +73,9 @@ module Awestruct
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def inspect
|
76
|
-
"AStruct{
|
76
|
+
"AStruct<#{super.to_s}>"
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
end
|
80
80
|
|
81
81
|
end
|
data/lib/awestruct/cli/deploy.rb
CHANGED
@@ -20,6 +20,7 @@ module Awestruct
|
|
20
20
|
attr_accessor :profile
|
21
21
|
attr_accessor :deploy
|
22
22
|
attr_accessor :script
|
23
|
+
attr_accessor :verbose
|
23
24
|
|
24
25
|
def initialize()
|
25
26
|
@generate = nil
|
@@ -43,6 +44,9 @@ module Awestruct
|
|
43
44
|
|
44
45
|
def parse!(args)
|
45
46
|
opts = OptionParser.new do |opts|
|
47
|
+
opts.on('-w', '--verbose', 'Enable verbose mode') do |verbose|
|
48
|
+
self.verbose = true
|
49
|
+
end
|
46
50
|
opts.on( '-i', '--init', 'Initialize a new project in the current directory' ) do |init|
|
47
51
|
self.init = init
|
48
52
|
self.generate = false
|
data/lib/awestruct/config.rb
CHANGED
@@ -17,18 +17,20 @@ module Awestruct
|
|
17
17
|
attr_accessor :images_dir
|
18
18
|
attr_accessor :stylesheets_dir
|
19
19
|
|
20
|
+
attr_accessor :verbose
|
21
|
+
|
20
22
|
def initialize(dir = Dir.pwd)
|
21
|
-
@dir = Pathname.new( dir )
|
23
|
+
@dir = Pathname.new( dir )
|
22
24
|
@layouts_dir = Pathname.new( File.join(dir, '_layouts') )
|
23
25
|
@config_dir = Pathname.new( File.join(dir, '_config') )
|
24
26
|
@input_dir = Pathname.new( File.join(dir, '') )
|
25
27
|
@output_dir = Pathname.new( File.join(dir, '_site') )
|
26
28
|
@extension_dir = Pathname.new( File.join(dir, '_ext') )
|
27
29
|
@skin_dir = Pathname.new( File.join(dir, '_skin') )
|
28
|
-
@tmp_dir = Pathname.new( File.join(dir, '_tmp') )
|
30
|
+
@tmp_dir = Pathname.new( File.join(dir, '_tmp') )
|
29
31
|
|
30
|
-
@images_dir = Pathname.new( File.join(dir, 'images') )
|
31
|
-
@stylesheets_dir = Pathname.new( File.join(dir, 'stylesheets') )
|
32
|
+
@images_dir = Pathname.new( File.join(dir, 'images') )
|
33
|
+
@stylesheets_dir = Pathname.new( File.join(dir, 'stylesheets') )
|
32
34
|
|
33
35
|
@ignore = File.exists?(ignore_file = File.join(dir, ".awestruct_ignore")) ? Dir[*IO.read(ignore_file).each_line.map(&:strip)] : []
|
34
36
|
|
data/lib/awestruct/context.rb
CHANGED
@@ -8,15 +8,15 @@ module Awestruct
|
|
8
8
|
attr_accessor :page
|
9
9
|
|
10
10
|
def initialize(hash)
|
11
|
-
super
|
11
|
+
super
|
12
12
|
@page = hash[:page]
|
13
13
|
@site = hash[:site]
|
14
|
-
|
15
|
-
end
|
14
|
+
|
15
|
+
end
|
16
16
|
|
17
17
|
def inspect
|
18
|
-
"Awestruct::Context{:page=>#{self.page.inspect}}"
|
19
|
-
end
|
18
|
+
"Awestruct::Context{:page=>#{self.page.inspect}}"
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -5,8 +5,12 @@ module Awestruct
|
|
5
5
|
module Deploy
|
6
6
|
class Base
|
7
7
|
UNCOMMITTED_CHANGES = "You have uncommitted changes in the working branch. Please commit or stash them."
|
8
|
-
def run
|
9
|
-
|
8
|
+
def run(deploy_config)
|
9
|
+
if deploy_config['uncommitted'] == true
|
10
|
+
publish_site
|
11
|
+
else
|
12
|
+
git.status.changed.empty? ? publish_site : existing_changes
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def git
|
data/lib/awestruct/engine.rb
CHANGED
@@ -245,7 +245,8 @@ module Awestruct
|
|
245
245
|
|
246
246
|
def generate_page_by_output_path(path)
|
247
247
|
full_path = File.join( '', path )
|
248
|
-
page = site.pages.find{|p| p.relative_source_path.to_s==full_path} ||
|
248
|
+
page = site.pages.find{ |p| p.relative_source_path.to_s == full_path } ||
|
249
|
+
site.layouts.find{ |p| p.relative_source_path.to_s == full_path }
|
249
250
|
return if page.nil?
|
250
251
|
|
251
252
|
if !page.output_path.nil?
|
@@ -1,39 +1,35 @@
|
|
1
1
|
require 'awestruct/extensions/relative'
|
2
|
-
require 'pathname'
|
3
2
|
|
4
3
|
module Awestruct
|
5
4
|
module Extensions
|
6
5
|
module Assets
|
7
6
|
|
7
|
+
include Awestruct::Extensions::Relative
|
8
|
+
|
8
9
|
def asset(href)
|
9
10
|
if site.assets_url
|
10
11
|
File.join(site.assets_url, href)
|
11
12
|
else
|
12
|
-
relative(File.join("/#{site.assets_path||'assets'}", href))
|
13
|
+
relative(File.join("/#{site.assets_path || 'assets'}", href))
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
class
|
17
|
-
|
18
|
-
def
|
19
|
-
|
20
|
-
end
|
21
|
-
def asset(site, page, href)
|
22
|
-
if site.assets_url
|
23
|
-
File.join(site.assets_url, href)
|
24
|
-
else
|
25
|
-
relative(page, File.join("/#{site.assets_path||'assets'}", href))
|
26
|
-
end
|
17
|
+
class Extension
|
18
|
+
|
19
|
+
def execute(site)
|
20
|
+
site.pages.each{ |p| p.extend Extension }
|
27
21
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
|
23
|
+
module Extension
|
24
|
+
|
25
|
+
include Awestruct::Extensions::Relative
|
26
|
+
|
27
|
+
def assets_url
|
28
|
+
path = File.join("/#{site.assets_path || 'assets'}", File.join(File.dirname(output_path), File.basename(output_path, '.*')))
|
29
|
+
relative(path, self)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
36
|
-
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -8,6 +8,7 @@ module Awestruct
|
|
8
8
|
@num_entries = opts[:num_entries] || 50
|
9
9
|
@content_url = opts[:content_url]
|
10
10
|
@feed_title = opts[:feed_title]
|
11
|
+
@template = opts[:template] || File.join( File.dirname(__FILE__), 'template.atom.haml' )
|
11
12
|
end
|
12
13
|
|
13
14
|
def execute(site)
|
@@ -29,8 +30,7 @@ module Awestruct
|
|
29
30
|
|
30
31
|
site.engine.set_urls(atom_pages)
|
31
32
|
|
32
|
-
|
33
|
-
page = site.engine.load_page( input_page )
|
33
|
+
page = site.engine.load_page( @template )
|
34
34
|
page.date = page.timestamp unless page.timestamp.nil?
|
35
35
|
page.output_path = @output_path
|
36
36
|
page.entries = atom_pages
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module Awestruct
|
2
2
|
module Extensions
|
3
3
|
module Cachebuster
|
4
|
-
|
5
|
-
(Time.now.to_i / 1000).to_i
|
6
|
-
end
|
4
|
+
|
7
5
|
def cache(href)
|
8
|
-
|
6
|
+
"#{href}?#{cachebuster}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def cachebuster(p=page)
|
10
|
+
((site.timestamp || p.input_mtime || Time.now.to_i) / 1000).to_i.to_s
|
9
11
|
end
|
12
|
+
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
@@ -9,6 +9,7 @@ module Awestruct
|
|
9
9
|
end
|
10
10
|
|
11
11
|
module Disqus
|
12
|
+
|
12
13
|
def disqus_comments()
|
13
14
|
identifier = "null"
|
14
15
|
if self.disqus_identifier or site.disqus_generate_id
|
@@ -52,6 +53,8 @@ module Awestruct
|
|
52
53
|
}
|
53
54
|
end
|
54
55
|
|
56
|
+
private
|
57
|
+
|
55
58
|
def resolve_disqus_identifier()
|
56
59
|
self.disqus_identifier ? self.disqus_identifier : Digest::SHA1.hexdigest(self.date.strftime('%Y-%m-%d-') + self.slug)
|
57
60
|
end
|
@@ -4,17 +4,31 @@ module Awestruct
|
|
4
4
|
|
5
5
|
def initialize(pattern, replacement, options = {})
|
6
6
|
@pattern = pattern
|
7
|
-
@replacement = replacement
|
8
|
-
@gsub_required = options[:gsub_required]
|
7
|
+
@replacement = replacement.is_a?(Proc) ? replacement : lambda { |site, page| replacement }
|
8
|
+
@gsub_required = lambdaize(options[:gsub_required])
|
9
9
|
end
|
10
10
|
|
11
11
|
def transform(site, page, rendered)
|
12
12
|
if (@gsub_required.call(site, page))
|
13
|
-
|
13
|
+
replacement = @replacement.call(site, page).to_s
|
14
|
+
rendered = rendered.gsub(@pattern, replacement)
|
14
15
|
end
|
15
16
|
rendered
|
16
17
|
end
|
17
18
|
|
19
|
+
private
|
20
|
+
|
21
|
+
def lambdaize(param)
|
22
|
+
if param.nil?
|
23
|
+
lambdaize([".html"])
|
24
|
+
else
|
25
|
+
if param.is_a?(Array)
|
26
|
+
lambda { |site, page| param.any?{ |ext| page.output_path.end_with?(ext) } }
|
27
|
+
else
|
28
|
+
param
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|
@@ -125,7 +125,7 @@ module Awestruct
|
|
125
125
|
|
126
126
|
def yuicompressor(page, input, type)
|
127
127
|
output = ''
|
128
|
-
Open3.popen3("yuicompressor --type #{Shellwords.escape(type)}") do |stdin, stdout, stderr|
|
128
|
+
Open3.popen3("yuicompressor --type #{Shellwords.escape(type.to_s)}") do |stdin, stdout, stderr|
|
129
129
|
threads = []
|
130
130
|
threads << Thread.new(stdout) do |o|
|
131
131
|
while ( ! o.eof? )
|
@@ -50,6 +50,7 @@ module Awestruct
|
|
50
50
|
@window_size = opts[:window_size] || 2
|
51
51
|
@remove_input = opts.has_key?( :remove_input ) ? opts[:remove_input] : true
|
52
52
|
@output_prefix = opts[:output_prefix] || File.dirname( @input_path )
|
53
|
+
@page_name = opts[:page_name] || 'page/'
|
53
54
|
@collection = opts[:collection]
|
54
55
|
end
|
55
56
|
|
@@ -66,7 +67,7 @@ module Awestruct
|
|
66
67
|
if ( i == 1 )
|
67
68
|
page.output_path = File.join( @output_prefix, File.basename( @input_path ) + ".html" )
|
68
69
|
else
|
69
|
-
page.output_path = File.join( @output_prefix, "
|
70
|
+
page.output_path = File.join( @output_prefix, "#{@page_name}#{i}.html" )
|
70
71
|
end
|
71
72
|
page.paginate_generated = true
|
72
73
|
site.pages << page
|
@@ -83,7 +84,7 @@ module Awestruct
|
|
83
84
|
prev_page = nil
|
84
85
|
paginated_pages.each_with_index do |page,i|
|
85
86
|
slice = page.send( @prop_name )
|
86
|
-
|
87
|
+
|
87
88
|
slice.current_page = page
|
88
89
|
slice.current_page_index = i
|
89
90
|
slice.pages = paginated_pages
|
@@ -3,9 +3,11 @@ require 'pathname'
|
|
3
3
|
module Awestruct
|
4
4
|
module Extensions
|
5
5
|
module Relative
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
def relative(href, p = page)
|
8
|
+
Pathname.new(href).relative_path_from(Pathname.new(File.dirname(p.output_path))).to_s
|
8
9
|
end
|
10
|
+
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -14,14 +14,14 @@
|
|
14
14
|
- else
|
15
15
|
%name= site.author
|
16
16
|
- unless page.entries.empty?
|
17
|
-
%updated= page.entries.first.
|
17
|
+
%updated= page.entries.first.input_mtime.xmlschema
|
18
18
|
%link{:rel=>"self", :type=>"application/atom+xml", :href=>"#{site.base_url}#{page.url}" }
|
19
19
|
%link{:rel=>"alternate", :type=>"text/html", :href=>"#{page.content_url}/" }
|
20
20
|
- for entry in page.entries
|
21
21
|
%entry
|
22
22
|
%id #{site.base_url}#{entry.url}
|
23
23
|
%title= escape_once( entry.title )
|
24
|
-
%updated= entry.
|
24
|
+
%updated= entry.input_mtime.xmlschema
|
25
25
|
%published= entry.date.xmlschema
|
26
26
|
%link{:rel=>"alternate", :type=>"text/html", :href=>"#{site.base_url}#{entry.url}" }
|
27
27
|
- if ( defined?( entry.author ) )
|
@@ -7,6 +7,7 @@ require 'awestruct/handlers/restructuredtext_handler'
|
|
7
7
|
require 'awestruct/handlers/textile_handler'
|
8
8
|
require 'awestruct/handlers/erb_handler'
|
9
9
|
require 'awestruct/handlers/haml_handler'
|
10
|
+
require 'awestruct/handlers/mustache_handler'
|
10
11
|
require 'awestruct/handlers/sass_handler'
|
11
12
|
require 'awestruct/handlers/scss_handler'
|
12
13
|
require 'awestruct/handlers/javascript_handler'
|
@@ -25,6 +26,7 @@ module Awestruct
|
|
25
26
|
Awestruct::Handlers::AsciidocHandler::CHAIN,
|
26
27
|
Awestruct::Handlers::RestructuredtextHandler::CHAIN,
|
27
28
|
Awestruct::Handlers::HamlHandler::CHAIN,
|
29
|
+
Awestruct::Handlers::MustacheHandler::CHAIN,
|
28
30
|
Awestruct::Handlers::SassHandler::CHAIN,
|
29
31
|
Awestruct::Handlers::ScssHandler::CHAIN,
|
30
32
|
Awestruct::Handlers::JavascriptHandler::CHAIN,
|
@@ -75,7 +75,13 @@ module Awestruct
|
|
75
75
|
@content_line_offset = -1
|
76
76
|
end
|
77
77
|
|
78
|
-
|
78
|
+
begin
|
79
|
+
@front_matter = YAML.load( yaml_content ) || {}
|
80
|
+
rescue => e
|
81
|
+
puts "could not parse #{relative_source_path}"
|
82
|
+
raise e
|
83
|
+
end
|
84
|
+
|
79
85
|
@parsed_parts = true
|
80
86
|
|
81
87
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
require 'awestruct/handler_chain'
|
3
|
+
require 'awestruct/handlers/base_handler'
|
4
|
+
require 'awestruct/handlers/file_handler'
|
5
|
+
require 'awestruct/handlers/front_matter_handler'
|
6
|
+
require 'awestruct/handlers/layout_handler'
|
7
|
+
|
8
|
+
require 'mustache'
|
9
|
+
|
10
|
+
module Awestruct
|
11
|
+
module Handlers
|
12
|
+
class MustacheHandler < BaseHandler
|
13
|
+
|
14
|
+
CHAIN = Awestruct::HandlerChain.new( /\.mustache$/,
|
15
|
+
Awestruct::Handlers::FileHandler,
|
16
|
+
Awestruct::Handlers::FrontMatterHandler,
|
17
|
+
Awestruct::Handlers::MustacheHandler,
|
18
|
+
Awestruct::Handlers::LayoutHandler
|
19
|
+
)
|
20
|
+
|
21
|
+
def initialize(site, delegate)
|
22
|
+
super( site, delegate )
|
23
|
+
end
|
24
|
+
|
25
|
+
def simple_name
|
26
|
+
File.basename( self.path, "#{output_extension}.mustache" )
|
27
|
+
end
|
28
|
+
|
29
|
+
def output_filename
|
30
|
+
return File.basename( relative_source_path, ".mustache") unless relative_source_path.nil?
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def output_extension
|
35
|
+
File.extname( File.basename( path, ".mustache" ) )
|
36
|
+
end
|
37
|
+
|
38
|
+
def rendered_content(context, with_layouts=true)
|
39
|
+
Mustache.render( delegate.raw_content, context )
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/awestruct/page.rb
CHANGED
@@ -33,7 +33,7 @@ module Awestruct
|
|
33
33
|
|
34
34
|
def inspect
|
35
35
|
"Awestruct::Page{ #{self.object_id}: output_path=>#{output_path}, source_path=>#{source_path}, layout=>#{layout} }"
|
36
|
-
end
|
36
|
+
end
|
37
37
|
|
38
38
|
def create_context(content='')
|
39
39
|
context = Awestruct::Context.new( :site=>site, :page=>self, :content=>content )
|
@@ -86,11 +86,11 @@ module Awestruct
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def stale?
|
89
|
-
handler.stale? || @dependencies.dependencies.any?(&:stale?)
|
89
|
+
handler.stale? || @dependencies.dependencies.any?(&:stale?)
|
90
90
|
end
|
91
91
|
|
92
92
|
def stale_output?(output_path)
|
93
|
-
return true if ! File.exist?( output_path )
|
93
|
+
return true if ! File.exist?( output_path )
|
94
94
|
return true if input_mtime > File.mtime( output_path )
|
95
95
|
false
|
96
96
|
end
|
@@ -108,7 +108,7 @@ module Awestruct
|
|
108
108
|
t = e.mtime
|
109
109
|
end
|
110
110
|
end
|
111
|
-
t
|
111
|
+
t
|
112
112
|
end
|
113
113
|
|
114
114
|
def all_dependencies
|
@@ -127,7 +127,15 @@ module Awestruct
|
|
127
127
|
if context.site.config.track_dependencies
|
128
128
|
Awestruct::Dependencies.push_page( self )
|
129
129
|
end
|
130
|
-
c =
|
130
|
+
c = nil
|
131
|
+
|
132
|
+
begin
|
133
|
+
c = handler.rendered_content( context, with_layouts )
|
134
|
+
# c = site.engine.pipeline.apply_transformers( context.site, self, c )
|
135
|
+
rescue => e
|
136
|
+
raise $!, "Failed to render #{self.url}", $!.backtrace
|
137
|
+
end
|
138
|
+
|
131
139
|
if context.site.config.track_dependencies
|
132
140
|
Awestruct::Dependencies.pop_page
|
133
141
|
|
@@ -156,7 +164,5 @@ module Awestruct
|
|
156
164
|
self.object_id == other_page.object_id
|
157
165
|
end
|
158
166
|
|
159
|
-
|
160
167
|
end
|
161
|
-
|
162
168
|
end
|
@@ -8,7 +8,7 @@ module Awestruct
|
|
8
8
|
attr_reader :root_dir
|
9
9
|
|
10
10
|
def initialize(site, target=:pages)
|
11
|
-
@site = site
|
11
|
+
@site = site
|
12
12
|
@target = target
|
13
13
|
|
14
14
|
@root_dir = site.config.dir
|
@@ -18,31 +18,33 @@ module Awestruct
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def ignore?(path)
|
21
|
-
site.config.ignore.include?( path )
|
21
|
+
site.config.ignore.include?( path )
|
22
22
|
end
|
23
23
|
|
24
24
|
def load_all(prepare=:inline)
|
25
|
+
raise "No such dir #{root_dir}" unless File.directory?(root_dir)
|
25
26
|
pages = []
|
26
27
|
root_dir.find do |path|
|
27
28
|
if ( path == root_dir )
|
28
|
-
|
29
|
+
puts "skip #{path}" if (site.config.verbose)
|
29
30
|
next
|
30
31
|
end
|
31
32
|
basename = File.basename( path )
|
32
33
|
if ( basename == '.htaccess' )
|
33
34
|
#special case
|
34
35
|
elsif ( basename =~ /^[_.]/ )
|
35
|
-
|
36
|
+
puts "skip #{path} and prune" if (site.config.verbose)
|
36
37
|
Find.prune
|
37
38
|
next
|
38
39
|
end
|
39
40
|
relative_path = path.relative_path_from( root_dir ).to_s
|
40
41
|
if ignore?(relative_path)
|
41
|
-
|
42
|
+
puts "skip ignored #{path} and prune" if (site.config.verbose)
|
42
43
|
Find.prune
|
43
44
|
next
|
44
45
|
end
|
45
46
|
unless path.directory?
|
47
|
+
puts "loading #{relative_path}" if (site.config.verbose)
|
46
48
|
page = load_page( path, prepare )
|
47
49
|
if ( page )
|
48
50
|
#puts "loaded! #{path} and added to site"
|
@@ -53,7 +55,7 @@ module Awestruct
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
if ( prepare == :post )
|
56
|
-
pages.each{|p| p.prepare!}
|
58
|
+
pages.each{|p| p.prepare!}
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -73,7 +75,7 @@ module Awestruct
|
|
73
75
|
end
|
74
76
|
p.track_dependencies!
|
75
77
|
if prepare == :inline
|
76
|
-
p.prepare!
|
78
|
+
p.prepare!
|
77
79
|
end
|
78
80
|
p
|
79
81
|
end
|
data/lib/awestruct/rack/app.rb
CHANGED
@@ -8,9 +8,9 @@ module Awestruct
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
11
|
-
path = env['
|
11
|
+
path = env['PATH_INFO']
|
12
12
|
fs_path = File.join( @doc_root, path )
|
13
|
-
|
13
|
+
|
14
14
|
if ( File.directory?( fs_path ) )
|
15
15
|
if ( ! ( path =~ %r(/$) ) )
|
16
16
|
return [ 301,
|
@@ -21,20 +21,31 @@ module Awestruct
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
# There must be a Content-Type, except when the Status is 1xx,
|
25
|
+
# 204 or 304, in which case there must be none given.
|
26
|
+
#
|
27
|
+
# The Body must respond to each and must only yield String
|
28
|
+
# values. The Body itself should not be an instance of String,
|
29
|
+
# as this will break in Ruby 1.9.
|
24
30
|
if ( File.exist?( fs_path ) )
|
31
|
+
body = read_content( fs_path )
|
32
|
+
content_type = ::Rack::Mime.mime_type( File.extname(fs_path) )
|
33
|
+
length = body.size.to_s
|
25
34
|
[ 200,
|
26
|
-
{},
|
27
|
-
|
35
|
+
{"Content-Type" => content_type, "Content-Length" => length},
|
36
|
+
[body] ]
|
28
37
|
else
|
38
|
+
body = read_error_document(path)
|
39
|
+
length = body.size.to_s
|
29
40
|
[ 404,
|
30
|
-
{},
|
31
|
-
|
41
|
+
{"Content-Type" => 'text/plain', "Content-Length" => length},
|
42
|
+
[body] ]
|
32
43
|
end
|
33
44
|
end
|
34
45
|
|
35
46
|
def read_error_document( path )
|
36
47
|
doc_path = nil
|
37
|
-
htaccess = File.join( @doc_root, '.htaccess' )
|
48
|
+
htaccess = File.join( @doc_root, '.htaccess' )
|
38
49
|
if ( File.exist?( htaccess ) )
|
39
50
|
File.open( htaccess ).each_line do |line|
|
40
51
|
if ( line =~ %r(^.*ErrorDocument[ \t]+404[ \t]+(.+)$) )
|
@@ -44,7 +55,7 @@ module Awestruct
|
|
44
55
|
end
|
45
56
|
if ( doc_path )
|
46
57
|
fs_doc_path = File.join( @doc_root, doc_path )
|
47
|
-
return read_content( fs_doc_path ) if File.exist?( fs_doc_path )
|
58
|
+
return read_content( fs_doc_path ) if File.exist?( fs_doc_path )
|
48
59
|
end
|
49
60
|
"404: Not Found: #{path}"
|
50
61
|
end
|
data/lib/awestruct/site.rb
CHANGED
@@ -9,6 +9,7 @@ module Awestruct
|
|
9
9
|
attr_reader :dir
|
10
10
|
attr_reader :output_dir
|
11
11
|
attr_reader :tmp_dir
|
12
|
+
attr_reader :timestamp
|
12
13
|
|
13
14
|
attr_reader :pages
|
14
15
|
attr_reader :layouts
|
@@ -22,6 +23,7 @@ module Awestruct
|
|
22
23
|
@layouts = Layouts.new
|
23
24
|
@config = config
|
24
25
|
self.encoding = false
|
26
|
+
@timestamp = Time.now.to_i
|
25
27
|
end
|
26
28
|
|
27
29
|
def inspect
|
data/lib/awestruct/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awestruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hpricot
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.1.15
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mustache
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.99.4
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.99.4
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: rdiscount
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -242,7 +258,7 @@ dependencies:
|
|
242
258
|
requirements:
|
243
259
|
- - ~>
|
244
260
|
- !ruby/object:Gem::Version
|
245
|
-
version: 0.
|
261
|
+
version: 0.5.0
|
246
262
|
type: :runtime
|
247
263
|
prerelease: false
|
248
264
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -250,7 +266,7 @@ dependencies:
|
|
250
266
|
requirements:
|
251
267
|
- - ~>
|
252
268
|
- !ruby/object:Gem::Version
|
253
|
-
version: 0.
|
269
|
+
version: 0.5.0
|
254
270
|
- !ruby/object:Gem::Dependency
|
255
271
|
name: thin
|
256
272
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,7 +274,7 @@ dependencies:
|
|
258
274
|
requirements:
|
259
275
|
- - ~>
|
260
276
|
- !ruby/object:Gem::Version
|
261
|
-
version: 1.
|
277
|
+
version: 1.4.1
|
262
278
|
type: :runtime
|
263
279
|
prerelease: false
|
264
280
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -266,7 +282,7 @@ dependencies:
|
|
266
282
|
requirements:
|
267
283
|
- - ~>
|
268
284
|
- !ruby/object:Gem::Version
|
269
|
-
version: 1.
|
285
|
+
version: 1.4.1
|
270
286
|
- !ruby/object:Gem::Dependency
|
271
287
|
name: eventmachine
|
272
288
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,7 +290,7 @@ dependencies:
|
|
274
290
|
requirements:
|
275
291
|
- - ~>
|
276
292
|
- !ruby/object:Gem::Version
|
277
|
-
version: 1.0.0.
|
293
|
+
version: 1.0.0.rc.4
|
278
294
|
type: :runtime
|
279
295
|
prerelease: false
|
280
296
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -282,7 +298,7 @@ dependencies:
|
|
282
298
|
requirements:
|
283
299
|
- - ~>
|
284
300
|
- !ruby/object:Gem::Version
|
285
|
-
version: 1.0.0.
|
301
|
+
version: 1.0.0.rc.4
|
286
302
|
description: Awestruct is a framework for creating static HTML sites.
|
287
303
|
email: bob@mcwhirter.org
|
288
304
|
executables:
|
@@ -348,6 +364,7 @@ files:
|
|
348
364
|
- lib/awestruct/handlers/javascript_handler.rb
|
349
365
|
- lib/awestruct/handlers/layout_handler.rb
|
350
366
|
- lib/awestruct/handlers/markdown_handler.rb
|
367
|
+
- lib/awestruct/handlers/mustache_handler.rb
|
351
368
|
- lib/awestruct/handlers/no_op_handler.rb
|
352
369
|
- lib/awestruct/handlers/orgmode_handler.rb
|
353
370
|
- lib/awestruct/handlers/page_delegating_handler.rb
|
@@ -390,7 +407,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
390
407
|
version: '0'
|
391
408
|
segments:
|
392
409
|
- 0
|
393
|
-
hash:
|
410
|
+
hash: -1162804171460425165
|
394
411
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
395
412
|
none: false
|
396
413
|
requirements:
|
@@ -399,10 +416,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
416
|
version: '0'
|
400
417
|
segments:
|
401
418
|
- 0
|
402
|
-
hash:
|
419
|
+
hash: -1162804171460425165
|
403
420
|
requirements: []
|
404
421
|
rubyforge_project:
|
405
|
-
rubygems_version: 1.8.
|
422
|
+
rubygems_version: 1.8.23
|
406
423
|
signing_key:
|
407
424
|
specification_version: 3
|
408
425
|
summary: Static site-baking utility
|