awestruct 0.5.6.beta8 → 0.5.6.beta9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -4
- data/Rakefile +1 -1
- data/awestruct.gemspec +22 -18
- data/lib/awestruct/cli/auto.rb +25 -21
- data/lib/awestruct/cli/generate.rb +3 -2
- data/lib/awestruct/cli/init.rb +2 -1
- data/lib/awestruct/cli/invoker.rb +4 -3
- data/lib/awestruct/cli/manifest.rb +41 -0
- data/lib/awestruct/cli/options.rb +10 -1
- data/lib/awestruct/cli/server.rb +36 -6
- data/lib/awestruct/config/default-site.yml +3 -0
- data/lib/awestruct/context.rb +17 -0
- data/lib/awestruct/context_helper.rb +25 -21
- data/lib/awestruct/deploy/s3_deploy.rb +41 -3
- data/lib/awestruct/engine.rb +64 -33
- data/lib/awestruct/extensions/disqus.rb +2 -2
- data/lib/awestruct/extensions/flattr.rb +1 -1
- data/lib/awestruct/extensions/pipeline.rb +30 -8
- data/lib/awestruct/extensions/relative.rb +3 -1
- data/lib/awestruct/extensions/sitemap.rb +6 -0
- data/lib/awestruct/extensions/sitemap.xml.haml +2 -1
- data/lib/awestruct/extensions/tagger.rb +7 -6
- data/lib/awestruct/extensions/template.atom.haml +1 -1
- data/lib/awestruct/frameworks/base_Gemfile +12 -1
- data/lib/awestruct/frameworks/bootstrap/base_index.html.haml +22 -20
- data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +9 -7
- data/lib/awestruct/handlers/asciidoctor_handler.rb +1 -1
- data/lib/awestruct/handlers/base_tilt_handler.rb +3 -1
- data/lib/awestruct/pipeline.rb +57 -7
- data/lib/awestruct/rack/generate.rb +43 -0
- data/lib/awestruct/util/exception_helper.rb +3 -0
- data/lib/awestruct/version.rb +1 -1
- data/spec/awestruct/cli/invoker_spec.rb +1 -1
- data/spec/awestruct/cli/options_spec.rb +14 -13
- data/spec/awestruct/cli/server_spec.rb +15 -0
- data/spec/awestruct/context_helper_spec.rb +5 -5
- data/spec/awestruct/engine_spec.rb +110 -1
- data/spec/awestruct/extensions/relative_spec.rb +22 -0
- data/spec/awestruct/handlers/asciidoc_handler_spec.rb +7 -1
- data/spec/awestruct/handlers/layout_handler_spec.rb +7 -7
- data/spec/awestruct/handlers/tilt_handler_spec.rb +1 -1
- data/spec/awestruct/pipeline_spec.rb +27 -2
- data/spec/awestruct/scm/git_spec.rb +4 -4
- data/spec/spec_helper.rb +6 -1
- data/spec/support/emmet_matchers.rb +1 -1
- data/spec/support/nokogiri_matchers.rb +1 -1
- data/spec/support/shared_handler_example.rb +66 -71
- data/spec/support/test-data/engine-generate-no-errors/_config/site.yml +26 -0
- data/spec/support/test-data/engine-generate-no-errors/_ext/pipeline.rb +8 -0
- data/spec/support/test-data/engine-generate-no-errors/_layouts/base.html.slim +6 -0
- data/spec/support/test-data/engine-generate-no-errors/index.html.slim +5 -0
- data/spec/support/test-data/engine-generate-with-errors/_config/site.yml +26 -0
- data/spec/support/test-data/engine-generate-with-errors/_ext/pipeline.rb +8 -0
- data/spec/support/test-data/engine-generate-with-errors/_layouts/base.html.slim +6 -0
- data/spec/support/test-data/engine-generate-with-errors/index.html.slim +6 -0
- data/spec/support/test-data/engine-yaml/_config/site.yml +9 -0
- data/spec/support/test-data/pipeline/_ext/extensions.rb +26 -0
- data/spec/support/test-data/pipeline/_ext/pipeline.rb +12 -0
- metadata +229 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca256f329051e03285724bbdd41dde4562ce6ce6
|
4
|
+
data.tar.gz: 995924213e455a5840477dacda5263c860f44225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ac323c0af741443132a7e8c1fa15a7e2d35e82af15c0333ddc38997ff9743311843a3acf09afebb007f5908d2835dae488ec4f29dcf59eeeaca3c6e1bbf719f
|
7
|
+
data.tar.gz: 5841d1ab558f57cd09a8bcf51ab91d4e98a709fe76f6e6fe4a086240d823615a0d88740d58071418a2734ec0eee18a39b01fe3dc345df4a8162ef3c5561f8f6a
|
data/Gemfile
CHANGED
@@ -2,10 +2,8 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
group :development do
|
4
4
|
gem 'hashery', '~> 2.1.1'
|
5
|
-
gem 'rspec', '~> 2.14.1'
|
6
|
-
gem 'rake', '~> 10.2.2'
|
7
|
-
gem 'guard-rspec', '~> 4.2.0', :require => false
|
8
5
|
gem 'pry', :require => false
|
6
|
+
gem 'rake', :require => false
|
9
7
|
#gem 'pry-byebug', :require => false
|
10
8
|
end
|
11
9
|
|
@@ -14,7 +12,7 @@ group :test do
|
|
14
12
|
gem 'rack-test', '~> 0.6.2'
|
15
13
|
gem 'tilt', '~> 2.0.1'
|
16
14
|
gem 'coffee-script', '~> 2.2.0'
|
17
|
-
gem 'asciidoctor', '
|
15
|
+
gem 'asciidoctor', '1.5.2'
|
18
16
|
gem 'slim', '~> 2.0.2'
|
19
17
|
gem 'kramdown', '~> 1.3.3'
|
20
18
|
gem 'therubyracer', '~> 0.12.1', :platforms => :ruby
|
data/Rakefile
CHANGED
data/awestruct.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'awestruct/version'
|
|
4
4
|
spec = Gem::Specification.new do |s|
|
5
5
|
s.name = 'awestruct'
|
6
6
|
s.version = Awestruct::VERSION
|
7
|
-
s.date = '2015-
|
7
|
+
s.date = '2015-07-24'
|
8
8
|
|
9
9
|
s.authors = ['Bob McWhirter', 'Jason Porter', 'Lance Ball', 'Dan Allen', 'Torsten Curdt', 'other contributors']
|
10
10
|
s.email = ['bob@mcwhirter.org', 'lightguard.jp@gmail.com', 'lball@redhat.com', 'dan.j.allen@gmail.com', 'tcurdt@vafer.org']
|
@@ -32,22 +32,26 @@ Any markup languages you are using and its dependencies.
|
|
32
32
|
Haml and Markdown filters are touchy things. Redcarpet or Rdiscount work well if you're running on MRI. JRuby should be using haml 4.0.0+ with Kramdown.'
|
33
33
|
EOS
|
34
34
|
|
35
|
-
s.add_dependency 'haml', '~> 4.0.5'
|
36
|
-
s.add_dependency 'asciidoctor'
|
37
|
-
s.add_dependency 'tilt', '~> 2.0.1'
|
38
|
-
s.add_dependency 'compass', '~> 1.0.1'
|
39
|
-
s.add_dependency 'compass-960-plugin', '~> 0.10.4'
|
40
|
-
s.add_dependency 'bootstrap-sass', '~> 3.2.0.2'
|
41
|
-
s.add_dependency 'zurb-foundation', '~> 4.3.2'
|
35
|
+
s.add_dependency 'haml', '~> 4.0', '>= 4.0.5'
|
36
|
+
s.add_dependency 'asciidoctor', '~> 1.5', '>= 1.5.2'
|
37
|
+
s.add_dependency 'tilt', '~> 2.0', '>= 2.0.1'
|
42
38
|
s.add_dependency 'mime-types', '~> 2.1'
|
43
|
-
s.add_dependency 'rest-client', '~> 1.7.2'
|
44
|
-
s.add_dependency '
|
45
|
-
s.add_dependency '
|
46
|
-
s.add_dependency '
|
47
|
-
s.add_dependency '
|
48
|
-
s.add_dependency '
|
49
|
-
s.add_dependency '
|
50
|
-
s.add_dependency '
|
51
|
-
|
52
|
-
s.
|
39
|
+
s.add_dependency 'rest-client', '~> 1.7', '>= 1.7.2'
|
40
|
+
s.add_dependency 'listen', '~> 2.7', '>= 2.7.1'
|
41
|
+
s.add_dependency 'rack', '~> 1.5', '>= 1.5.2'
|
42
|
+
s.add_dependency 'git', '~> 1.2', '>= 1.2.6'
|
43
|
+
s.add_dependency 'guard-livereload', '~> 2.1', '>= 2.1.2'
|
44
|
+
s.add_dependency 'colorize', '~> 0.7', '>= 0.7.1'
|
45
|
+
s.add_dependency 'oga', '~> 0.3'
|
46
|
+
s.add_dependency 'sass', '~> 3.2'
|
47
|
+
s.add_dependency 'compass', '~> 1', '>= 1.0.1'
|
48
|
+
s.add_dependency 'parallel', '~> 1.1', '> 1.1.1'
|
49
|
+
|
50
|
+
s.add_development_dependency 'nokogiri', '~> 1.5.0','>= 1.5.10'
|
51
|
+
s.add_development_dependency 'compass-960-plugin', '~> 0.10','>= 0.10.4'
|
52
|
+
s.add_development_dependency 'bootstrap-sass', '~> 3', '>= 3.2.0.2'
|
53
|
+
s.add_development_dependency 'zurb-foundation', '~> 4.3.2', '>= 4.3.2'
|
54
|
+
s.add_development_dependency 'simplecov', '~> 0.9'
|
55
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
56
|
+
s.add_development_dependency 'guard-rspec', '~> 4.0'
|
53
57
|
end
|
data/lib/awestruct/cli/auto.rb
CHANGED
@@ -18,12 +18,18 @@ module Awestruct
|
|
18
18
|
generate_thread = nil
|
19
19
|
current_path = nil
|
20
20
|
|
21
|
-
|
22
|
-
guard =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
begin
|
22
|
+
guard = if ( @config.options.livereload )
|
23
|
+
Guard.init({})
|
24
|
+
guard = Guard::LiveReload.new
|
25
|
+
guard.start
|
26
|
+
guard
|
27
|
+
else
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
rescue => e
|
31
|
+
puts e
|
32
|
+
puts e.backtrace
|
27
33
|
end
|
28
34
|
|
29
35
|
force_polling = ( RUBY_PLATFORM =~ /mingw/ ? true : false )
|
@@ -45,26 +51,24 @@ module Awestruct
|
|
45
51
|
|
46
52
|
generate_thread = Thread.new {
|
47
53
|
begin
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
# pages aren't output in the correct directory
|
53
|
-
pages = []
|
54
|
-
else
|
55
|
-
page = engine.page_by_source_path(path)
|
56
|
-
pages = []
|
57
|
-
if ( page )
|
54
|
+
page = engine.page_by_source_path(path)
|
55
|
+
pages = []
|
56
|
+
if ( page )
|
57
|
+
unless ( guard )
|
58
58
|
pages = engine.generate_page_and_dependencies( page )
|
59
59
|
else
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
pages = engine.page_dependencies( page )
|
61
|
+
end
|
62
|
+
else
|
63
|
+
if File.exist? path
|
64
|
+
# chances are this is an extension or yaml file
|
65
|
+
pages = engine.run_auto_for_non_page(path, !@config.options.generate_on_access)
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
|
69
|
+
unless ( guard )
|
70
|
+
$LOG.info "Regeneration finished." if $LOG.info?
|
71
|
+
end
|
68
72
|
|
69
73
|
if ( guard )
|
70
74
|
urls = pages.map do |p|
|
@@ -6,11 +6,12 @@ module Awestruct
|
|
6
6
|
module CLI
|
7
7
|
class Generate
|
8
8
|
|
9
|
-
def initialize(config, profile=nil, base_url=nil, default_base_url=Options::DEFAULT_BASE_URL, force=false)
|
9
|
+
def initialize(config, profile=nil, base_url=nil, default_base_url=Options::DEFAULT_BASE_URL, force=false, generate=true)
|
10
10
|
@profile = profile
|
11
11
|
@base_url = base_url
|
12
12
|
@default_base_url = default_base_url
|
13
13
|
@force = force
|
14
|
+
@generate = generate
|
14
15
|
@engine = Awestruct::Engine.new( config )
|
15
16
|
end
|
16
17
|
|
@@ -18,7 +19,7 @@ module Awestruct
|
|
18
19
|
begin
|
19
20
|
base_url = @base_url || @default_base_url
|
20
21
|
$LOG.info "Generating site: #{base_url}" if $LOG.info?
|
21
|
-
@engine.run( @profile, @base_url, @default_base_url, @force )
|
22
|
+
@engine.run( @profile, @base_url, @default_base_url, @force, @generate )
|
22
23
|
rescue =>e
|
23
24
|
ExceptionHelper.log_building_error e, ''
|
24
25
|
return false
|
data/lib/awestruct/cli/init.rb
CHANGED
@@ -18,7 +18,6 @@ module Awestruct
|
|
18
18
|
copy_file('_ext/pipeline.rb', Init.framework_path('base_pipeline.rb'))
|
19
19
|
copy_file('.awestruct_ignore', Init.framework_path('base_awestruct_ignore'))
|
20
20
|
copy_file('Rakefile', Init.framework_path('base_Rakefile'))
|
21
|
-
copy_file('Gemfile', Init.framework_path('base_Gemfile'))
|
22
21
|
mkdir('stylesheets')
|
23
22
|
}
|
24
23
|
|
@@ -31,6 +30,8 @@ module Awestruct
|
|
31
30
|
def run()
|
32
31
|
manifest = Manifest.new(BASE_MANIFEST)
|
33
32
|
scaffold_name = @framework
|
33
|
+
manifest.template_file('Gemfile', Init.framework_path('base_Gemfile'), {:framework => @framework})
|
34
|
+
|
34
35
|
lib = nil
|
35
36
|
case @framework
|
36
37
|
when 'compass'
|
@@ -3,6 +3,7 @@ require 'logger'
|
|
3
3
|
require 'awestruct/logger'
|
4
4
|
require 'awestruct/cli/options'
|
5
5
|
require 'awestruct/util/exception_helper'
|
6
|
+
require 'erb'
|
6
7
|
|
7
8
|
module Awestruct
|
8
9
|
module CLI
|
@@ -72,7 +73,7 @@ module Awestruct
|
|
72
73
|
abort( "No config file at #{site_yaml_file}" )
|
73
74
|
end
|
74
75
|
|
75
|
-
site_yaml = YAML.load( File.read( site_yaml_file ) )
|
76
|
+
site_yaml = YAML.load( ERB.new(File.read( site_yaml_file )).result )
|
76
77
|
|
77
78
|
if ( !site_yaml )
|
78
79
|
abort( "Failed to parse #{site_yaml_file}" )
|
@@ -122,7 +123,7 @@ module Awestruct
|
|
122
123
|
|
123
124
|
def invoke_generate()
|
124
125
|
base_url = profile['base_url'] || options.base_url
|
125
|
-
@success = Awestruct::CLI::Generate.new( config, options.profile, base_url, Options::DEFAULT_BASE_URL, options.force ).run
|
126
|
+
@success = Awestruct::CLI::Generate.new( config, options.profile, base_url, Options::DEFAULT_BASE_URL, options.force, !options.generate_on_access ).run
|
126
127
|
end
|
127
128
|
|
128
129
|
def invoke_deploy()
|
@@ -144,7 +145,7 @@ module Awestruct
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def invoke_server()
|
147
|
-
run_in_thread( Awestruct::CLI::Server.new( options.output_dir, options.bind_addr, options.port ) )
|
148
|
+
run_in_thread( Awestruct::CLI::Server.new( options.output_dir, options.bind_addr, options.port, options.generate_on_access ) )
|
148
149
|
end
|
149
150
|
|
150
151
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'sass/callbacks'
|
2
2
|
require 'compass'
|
3
3
|
require 'compass/commands'
|
4
|
+
require 'erb'
|
5
|
+
require 'rubygems/specification'
|
6
|
+
require 'ostruct'
|
4
7
|
|
5
8
|
# TODO: We could create our own installer and use that
|
6
9
|
|
@@ -22,6 +25,10 @@ module Awestruct
|
|
22
25
|
steps << MkDir.new(path)
|
23
26
|
end
|
24
27
|
|
28
|
+
def template_file(path, input_path, state = {})
|
29
|
+
steps << TemplateFile.new(path, input_path, state.merge(load_gem))
|
30
|
+
end
|
31
|
+
|
25
32
|
def copy_file(path, input_path, opts = {})
|
26
33
|
steps << CopyFile.new(path, input_path, opts)
|
27
34
|
end
|
@@ -68,6 +75,18 @@ module Awestruct
|
|
68
75
|
end
|
69
76
|
end
|
70
77
|
|
78
|
+
private
|
79
|
+
|
80
|
+
def load_gem
|
81
|
+
spec = {:dependencies => {}}
|
82
|
+
gem_spec = Gem::Specification::load(
|
83
|
+
File.join(File.dirname(__FILE__), "../../../", "awestruct.gemspec"))
|
84
|
+
|
85
|
+
gem_spec.dependencies.each { |d| spec[:dependencies][d.name] = d}
|
86
|
+
spec[:awestruct_version] = gem_spec.version
|
87
|
+
spec
|
88
|
+
end
|
89
|
+
|
71
90
|
##
|
72
91
|
##
|
73
92
|
##
|
@@ -202,6 +221,28 @@ module Awestruct
|
|
202
221
|
|
203
222
|
end
|
204
223
|
|
224
|
+
class TemplateFile
|
225
|
+
def initialize(path, input_path, state = {})
|
226
|
+
@path = path
|
227
|
+
@input_path = input_path
|
228
|
+
@state = state
|
229
|
+
end
|
230
|
+
|
231
|
+
def perform(dir)
|
232
|
+
|
233
|
+
rendered = ERB.new(File.read(@input_path), nil, '<>').result(
|
234
|
+
OpenStruct.new(@state).instance_eval { binding })
|
235
|
+
|
236
|
+
p = File.join(dir, @path)
|
237
|
+
$LOG.info "Create file: #{p}" if $LOG.info?
|
238
|
+
File.open(p, 'w') { |f| f.write(rendered) }
|
239
|
+
end
|
240
|
+
|
241
|
+
def unperform(dir)
|
242
|
+
# nothing
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
205
246
|
class InstallCompass
|
206
247
|
def initialize(framework='compass')
|
207
248
|
@framework = framework
|
@@ -16,6 +16,7 @@ module Awestruct
|
|
16
16
|
DEFAULT_BIND_ADDR = '0.0.0.0'
|
17
17
|
DEFAULT_PORT = 4242
|
18
18
|
DEFAULT_BASE_URL = %(http://#{LOCAL_HOSTS[DEFAULT_BIND_ADDR] || DEFAULT_BIND_ADDR}:#{DEFAULT_PORT})
|
19
|
+
DEFAULT_GENERATE_ON_ACCESS = false
|
19
20
|
|
20
21
|
attr_accessor :generate
|
21
22
|
attr_accessor :server
|
@@ -36,6 +37,7 @@ module Awestruct
|
|
36
37
|
attr_accessor :output_dir
|
37
38
|
attr_accessor :livereload
|
38
39
|
attr_accessor :debug
|
40
|
+
attr_accessor :generate_on_access
|
39
41
|
|
40
42
|
def initialize()
|
41
43
|
@generate = nil
|
@@ -56,6 +58,7 @@ module Awestruct
|
|
56
58
|
@livereload = false
|
57
59
|
@source_dir = Dir.pwd
|
58
60
|
@output_dir = File.expand_path '_site'
|
61
|
+
@generate_on_access = DEFAULT_GENERATE_ON_ACCESS
|
59
62
|
end
|
60
63
|
|
61
64
|
def self.parse!(args)
|
@@ -92,12 +95,13 @@ module Awestruct
|
|
92
95
|
opts.on( '-u', '--url URL', 'Set site.base_url' ) do |url|
|
93
96
|
self.base_url = url
|
94
97
|
end
|
95
|
-
opts.on( '-d', '--dev', "Run site in development mode (--auto, --server, --port #{DEFAULT_PORT}
|
98
|
+
opts.on( '-d', '--dev', "Run site in development mode (--auto, --server, --port #{DEFAULT_PORT}, --profile development, --livereload and --generate_on_access)" ) do |url|
|
96
99
|
self.server = true
|
97
100
|
self.auto = true
|
98
101
|
self.port = DEFAULT_PORT
|
99
102
|
self.profile = 'development'
|
100
103
|
self.livereload = true
|
104
|
+
self.generate_on_access = true
|
101
105
|
end
|
102
106
|
opts.on( '-a', '--auto', 'Auto-generate when changes are noticed' ) do |a|
|
103
107
|
self.auto = a
|
@@ -105,6 +109,11 @@ module Awestruct
|
|
105
109
|
end
|
106
110
|
opts.on( '--[no-]livereload', 'Support for browser livereload' ) do |livereload|
|
107
111
|
self.livereload = livereload
|
112
|
+
self.generate_on_access = true if self.livereload
|
113
|
+
end
|
114
|
+
|
115
|
+
opts.on( '--[no-]generate-on-access', 'Support for calling generate on HTTP access' ) do |generate_on_access|
|
116
|
+
self.generate_on_access = generate_on_access
|
108
117
|
end
|
109
118
|
|
110
119
|
opts.on( '-P', '--profile PROFILE', 'Activate a configuration profile' ) do |profile|
|
data/lib/awestruct/cli/server.rb
CHANGED
@@ -1,27 +1,57 @@
|
|
1
1
|
require 'rack'
|
2
|
+
require 'rack/builder'
|
2
3
|
require 'rack/server'
|
3
4
|
require 'awestruct/rack/app'
|
5
|
+
require 'awestruct/rack/generate'
|
6
|
+
require 'awestruct/cli/options'
|
4
7
|
|
5
8
|
module Awestruct
|
6
9
|
module CLI
|
7
10
|
class Server
|
8
11
|
attr_reader :server
|
9
12
|
|
10
|
-
def initialize(path, bind_addr=Options::DEFAULT_BIND_ADDR, port=Options::DEFAULT_PORT)
|
13
|
+
def initialize(path, bind_addr=Options::DEFAULT_BIND_ADDR, port=Options::DEFAULT_PORT, generate_on_access=Options::DEFAULT_GENERATE_ON_ACCESS)
|
11
14
|
@path = path
|
12
15
|
@bind_addr = bind_addr
|
13
16
|
@port = port
|
17
|
+
@generate_on_access = generate_on_access
|
14
18
|
end
|
15
19
|
|
16
20
|
def run
|
21
|
+
unless port_open? (Options::LOCAL_HOSTS[@bind_addr] || @bind_addr), @port
|
22
|
+
$LOG.error "#{Options::LOCAL_HOSTS[@bind_addr] || @bind_addr}:#{@port} not available for server" if $LOG.error?
|
23
|
+
abort
|
24
|
+
end
|
17
25
|
url = %(http://#{Options::LOCAL_HOSTS[@bind_addr] || @bind_addr}:#{@port})
|
18
26
|
msg = %(Starting preview server at #{url} (Press Ctrl-C to shutdown))
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
27
|
+
$LOG.info %(#{'*' * msg.length}\n#{msg}\n#{'*' * msg.length}\n) if $LOG.info?
|
28
|
+
|
29
|
+
path = @path
|
30
|
+
generate_on_access = @generate_on_access
|
31
|
+
app = ::Rack::Builder.new do
|
32
|
+
use Awestruct::Rack::GenerateOnAccess if generate_on_access
|
33
|
+
map "/" do
|
34
|
+
run Awestruct::Rack::App.new( path )
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
::Rack::Server::start( :app => app,
|
39
|
+
:Port => @port,
|
40
|
+
:Host => @bind_addr
|
41
|
+
)
|
24
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
# Private. Checks to see if the port is open.
|
46
|
+
def port_open?(addr, port)
|
47
|
+
begin
|
48
|
+
s = TCPServer.new(addr, port)
|
49
|
+
s.close
|
50
|
+
true
|
51
|
+
rescue
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
25
55
|
end
|
26
56
|
end
|
27
57
|
end
|
data/lib/awestruct/context.rb
CHANGED
@@ -11,6 +11,23 @@ module Awestruct
|
|
11
11
|
@page = hash[:page]
|
12
12
|
@site = hash[:site]
|
13
13
|
|
14
|
+
# Update the front matter from the handler chain
|
15
|
+
@page.handler.front_matter.each do |k,v|
|
16
|
+
k_sym = k.to_sym
|
17
|
+
if @page.key? k_sym
|
18
|
+
if @page[k_sym].is_a?(Array) && v.is_a?(Array)
|
19
|
+
page_values = @page[k_sym].collect {|value| value.class.to_s}.sort
|
20
|
+
front_matter_values = v.collect {|value| value.class.to_s}.sort
|
21
|
+
@page[k_sym] = v if page_values.eql? front_matter_values
|
22
|
+
elsif @page[k_sym].is_a?(Hash) && v.is_a?(Hash)
|
23
|
+
page_values = @page[k_sym].collect {|key, value| value.class.to_s}.sort
|
24
|
+
front_matter_values = v.collect {|key, value| value.class.to_s}.sort
|
25
|
+
@page[k_sym] = v if page_values.eql? front_matter_values
|
26
|
+
else
|
27
|
+
@page[k_sym] = v if @page.key?(k_sym) && (@page[k_sym].class == v.class)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
14
31
|
end
|
15
32
|
|
16
33
|
def inspect
|