awestruct 0.4.8 → 0.5.0.cr
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awestruct/astruct.rb +4 -0
- data/lib/awestruct/astruct_mixin.rb +3 -0
- data/lib/awestruct/cli/auto.rb +6 -6
- data/lib/awestruct/cli/deploy.rb +3 -3
- data/lib/awestruct/cli/generate.rb +5 -3
- data/lib/awestruct/cli/init.rb +1 -1
- data/lib/awestruct/cli/invoker.rb +10 -3
- data/lib/awestruct/cli/manifest.rb +18 -17
- data/lib/awestruct/cli/options.rb +7 -6
- data/lib/awestruct/cli/server.rb +7 -14
- data/lib/awestruct/config.rb +7 -1
- data/lib/awestruct/config/default-site.yml +30 -0
- data/lib/awestruct/context_helper.rb +7 -7
- data/lib/awestruct/dependencies.rb +14 -11
- data/lib/awestruct/deploy/base_deploy.rb +2 -2
- data/lib/awestruct/deploy/github_pages_deploy.rb +1 -1
- data/lib/awestruct/deploy/rsync_deploy.rb +11 -15
- data/lib/awestruct/deploy/s3_deploy.rb +9 -0
- data/lib/awestruct/engine.rb +72 -21
- data/lib/awestruct/extensions/minify.rb +21 -20
- data/lib/awestruct/extensions/paginator.rb +5 -5
- data/lib/awestruct/extensions/partial.rb +1 -1
- data/lib/awestruct/extensions/pipeline.rb +5 -1
- data/lib/awestruct/extensions/posts.rb +8 -4
- data/lib/awestruct/extensions/relative.rb +7 -2
- data/lib/awestruct/extensions/remotePartial.rb +1 -1
- data/lib/awestruct/extensions/sitemap.rb +1 -1
- data/lib/awestruct/frameworks/bootstrap/base_index.html.haml +1 -1
- data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +1 -1
- data/lib/awestruct/handler_chains.rb +8 -23
- data/lib/awestruct/handlers/asciidoctor_handler.rb +114 -0
- data/lib/awestruct/handlers/base_tilt_handler.rb +114 -0
- data/lib/awestruct/handlers/css_tilt_handler.rb +43 -0
- data/lib/awestruct/handlers/front_matter_handler.rb +1 -1
- data/lib/awestruct/handlers/interpolation_handler.rb +3 -3
- data/lib/awestruct/handlers/layout_handler.rb +6 -4
- data/lib/awestruct/handlers/restructuredtext_handler.rb +5 -5
- data/lib/awestruct/handlers/template/asciidoc.rb +41 -0
- data/lib/awestruct/handlers/template/mustache.rb +25 -0
- data/lib/awestruct/handlers/tilt_handler.rb +73 -0
- data/lib/awestruct/layouts.rb +1 -1
- data/lib/awestruct/logger.rb +59 -0
- data/lib/awestruct/page.rb +16 -3
- data/lib/awestruct/page_loader.rb +5 -5
- data/lib/awestruct/version.rb +1 -1
- data/man/awestruct.1 +163 -0
- data/spec/asciidoc_handler_spec.rb +75 -0
- data/spec/astruct_spec.rb +52 -0
- data/spec/coffeescript_handler_spec.rb +23 -0
- data/spec/config_spec.rb +22 -0
- data/spec/context_helper_spec.rb +115 -0
- data/spec/deploy_spec.rb +41 -0
- data/spec/disqus_spec.rb +43 -0
- data/spec/engine_spec.rb +115 -0
- data/spec/erb_handler_spec.rb +52 -0
- data/spec/file_handler_spec.rb +57 -0
- data/spec/front_matter_handler_spec.rb +42 -0
- data/spec/github_pages_deploy_spec.rb +56 -0
- data/spec/haml_handler_spec.rb +93 -0
- data/spec/handler_chain_spec.rb +44 -0
- data/spec/handler_chains_spec.rb +25 -0
- data/spec/interpolation_handler_spec.rb +35 -0
- data/spec/invoker_spec.rb +74 -0
- data/spec/javascript_handler_spec.rb +23 -0
- data/spec/layout_handler_spec.rb +77 -0
- data/spec/layouts_spec.rb +32 -0
- data/spec/less_handler_spec.rb +33 -0
- data/spec/markdown_handler_spec.rb +41 -0
- data/spec/minify_spec.rb +61 -0
- data/spec/mustache_handler_spec.rb +29 -0
- data/spec/options_spec.rb +97 -0
- data/spec/orgmode_handler_spec.rb +24 -0
- data/spec/page_delegating_handler_spec.rb +79 -0
- data/spec/page_loader_spec.rb +43 -0
- data/spec/page_loader_spec_for_layouts.rb +36 -0
- data/spec/page_spec.rb +65 -0
- data/spec/pipeline_spec.rb +12 -0
- data/spec/posts_archive_spec.rb +108 -0
- data/spec/redirect_handler_spec.rb +32 -0
- data/spec/restructuredtext_handler_spec.rb +22 -0
- data/spec/rsync_deploy_spec.rb +9 -0
- data/spec/sass_handler_spec.rb +23 -0
- data/spec/scss_handler_spec.rb +23 -0
- data/spec/server_spec.rb +45 -0
- data/spec/slim_handler_spec.rb +81 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/nokogiri_matchers.rb +21 -0
- data/spec/support/shared_handler_example.rb +98 -0
- data/spec/test-data/engine/_config/arbitrary.yml +2 -0
- data/spec/test-data/engine/_config/other.yml +1 -0
- data/spec/test-data/engine/_config/site.yml +14 -0
- data/spec/test-data/front-matter-file-no-content.txt +2 -0
- data/spec/test-data/front-matter-file-no-front.txt +1 -0
- data/spec/test-data/front-matter-file.txt +4 -0
- data/spec/test-data/handlers/asciidoc-page.ad +3 -0
- data/spec/test-data/handlers/asciidoc-page.adoc +3 -0
- data/spec/test-data/handlers/asciidoc-page.asciidoc +3 -0
- data/spec/test-data/handlers/asciidoctor_with_front_matter.ad +6 -0
- data/spec/test-data/handlers/asciidoctor_with_headers.ad +8 -0
- data/spec/test-data/handlers/coffeescript-page.coffee +8 -0
- data/spec/test-data/handlers/erb-page.html.erb +6 -0
- data/spec/test-data/handlers/erb-page.xml.erb +2 -0
- data/spec/test-data/handlers/erb-utf-page.html.erb +2 -0
- data/spec/test-data/handlers/haml-layout-two.html.haml +7 -0
- data/spec/test-data/handlers/haml-layout.html.haml +4 -0
- data/spec/test-data/handlers/haml-page.atom.haml +4 -0
- data/spec/test-data/handlers/haml-page.html.haml +2 -0
- data/spec/test-data/handlers/haml-page.xml.haml +1 -0
- data/spec/test-data/handlers/haml-with-markdown-page.html.haml +6 -0
- data/spec/test-data/handlers/haml-with-textile-page.html.haml +6 -0
- data/spec/test-data/handlers/haml-with-utf.html.haml +2 -0
- data/spec/test-data/handlers/haml-with-variables.html.haml +2 -0
- data/spec/test-data/handlers/inner-page.html.haml +4 -0
- data/spec/test-data/handlers/javascript-page.js +1 -0
- data/spec/test-data/handlers/less-page-include.less +1 -0
- data/spec/test-data/handlers/less-page-with-import.less +4 -0
- data/spec/test-data/handlers/less-page.less +4 -0
- data/spec/test-data/handlers/markdown-page.markdown +2 -0
- data/spec/test-data/handlers/markdown-page.md +2 -0
- data/spec/test-data/handlers/markdown-page.mkd +2 -0
- data/spec/test-data/handlers/mustache-page.html.mustache +2 -0
- data/spec/test-data/handlers/mustache-page.xml.mustache +1 -0
- data/spec/test-data/handlers/orgmode-page.org +6 -0
- data/spec/test-data/handlers/outer-layout.html.haml +2 -0
- data/spec/test-data/handlers/outside_relative/git_keep +3 -0
- data/spec/test-data/handlers/redirect-page.redirect +1 -0
- data/spec/test-data/handlers/restructuredtext-page.rst +8 -0
- data/spec/test-data/handlers/sass-page-include.sass +1 -0
- data/spec/test-data/handlers/sass-page.sass +4 -0
- data/spec/test-data/handlers/scss-page-include.scss +1 -0
- data/spec/test-data/handlers/scss-page.scss +5 -0
- data/spec/test-data/handlers/simple-redirect-page.redirect +1 -0
- data/spec/test-data/handlers/slim-page.atom.slim +4 -0
- data/spec/test-data/handlers/slim-page.html.slim +1 -0
- data/spec/test-data/handlers/slim-page.xml.slim +1 -0
- data/spec/test-data/handlers/slim-with-markdown-page.html.slim +5 -0
- data/spec/test-data/handlers/slim-with-utf.html.slim +2 -0
- data/spec/test-data/handlers/slim-with-variables.html.slim +1 -0
- data/spec/test-data/handlers/textile-page.textile +1 -0
- data/spec/test-data/images/logo.png +0 -0
- data/spec/test-data/index.html +242 -0
- data/spec/test-data/javascript/bootstrap-dropdown.js +92 -0
- data/spec/test-data/out-of-site/page-three.html.haml +2 -0
- data/spec/test-data/page-loader/_layouts/layout-one.md +2 -0
- data/spec/test-data/page-loader/_layouts/layout-two.html.haml +2 -0
- data/spec/test-data/page-loader/page-draft.md +5 -0
- data/spec/test-data/page-loader/page-one.md +2 -0
- data/spec/test-data/page-loader/page-two.html.haml +2 -0
- data/spec/test-data/simple-data.yaml +1 -0
- data/spec/test-data/simple-file.txt +1 -0
- data/spec/test-data/stylesheets/screen.css +688 -0
- data/spec/textile_handler_spec.rb +22 -0
- data/spec/tilt_handler_spec.rb +81 -0
- data/spec/yaml_handler_spec.rb +21 -0
- metadata +243 -202
- data/lib/awestruct/handlers/asciidoc_handler.rb +0 -86
- data/lib/awestruct/handlers/base_sass_handler.rb +0 -42
- data/lib/awestruct/handlers/coffeescript_handler.rb +0 -48
- data/lib/awestruct/handlers/erb_handler.rb +0 -43
- data/lib/awestruct/handlers/haml_handler.rb +0 -54
- data/lib/awestruct/handlers/less_handler.rb +0 -37
- data/lib/awestruct/handlers/markdown_handler.rb +0 -50
- data/lib/awestruct/handlers/mustache_handler.rb +0 -44
- data/lib/awestruct/handlers/orgmode_handler.rb +0 -48
- data/lib/awestruct/handlers/sass_handler.rb +0 -21
- data/lib/awestruct/handlers/scss_handler.rb +0 -21
- data/lib/awestruct/handlers/textile_handler.rb +0 -58
@@ -18,11 +18,11 @@ module Awestruct
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def publish_site
|
21
|
-
$
|
21
|
+
$LOG.error( "#{self.class.name}#publish_site not implemented." ) if $LOG.error?
|
22
22
|
end
|
23
23
|
|
24
24
|
def existing_changes
|
25
|
-
$
|
25
|
+
$LOG.error UNCOMMITTED_CHANGES if $LOG.error?
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -14,16 +14,12 @@ module Awestruct
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def publish_site
|
17
|
-
exclude_option = ""
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+sx,ug+rw --delete #{exclude_option} #{@site_path} #{@host}:#{@path}"
|
17
|
+
exclude_option = (!@exclude.nil? and !@exclude.empty?) ? "--exclude=" + Shellwords.escape(@exclude) : nil
|
18
|
+
site_path = Shellwords.escape(@site_path)
|
19
|
+
host = Shellwords.escape(@host)
|
20
|
+
path = Shellwords.escape(@path)
|
22
21
|
|
23
|
-
|
24
|
-
if(RUBY_PLATFORM !~ /mingw/)
|
25
|
-
cmd = Shellwords.escape(cmd)
|
26
|
-
end
|
22
|
+
cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+sx,ug+rw --delete #{exclude_option} #{site_path} #{host}:#{path}"
|
27
23
|
|
28
24
|
Open3.popen3( cmd ) do |stdin, stdout, stderr|
|
29
25
|
stdin.close
|
@@ -33,23 +29,23 @@ module Awestruct
|
|
33
29
|
line = i.readline
|
34
30
|
case line[0,9]
|
35
31
|
when '<f.sT....'
|
36
|
-
|
32
|
+
$LOG.info " updating #{line[10..-1]}" if $LOG.info?
|
37
33
|
when 'cd+++++++'
|
38
|
-
|
34
|
+
$LOG.info " creating #{line[10..-1]}" if $LOG.info?
|
39
35
|
when '<f+++++++'
|
40
|
-
|
36
|
+
$LOG.info " adding #{line[10..-1]}" if $LOG.info?
|
41
37
|
when '<f..T....'
|
42
38
|
# ignoring unchanged files
|
43
|
-
|
39
|
+
$LOG.debug " no change to #{line[10..-1]}" if $LOG.debug?
|
44
40
|
else
|
45
|
-
|
41
|
+
$LOG.info line if $LOG.info
|
46
42
|
end
|
47
43
|
end
|
48
44
|
end
|
49
45
|
threads << Thread.new(stderr) do |i|
|
50
46
|
while ( ! i.eof? )
|
51
47
|
line = i.readline
|
52
|
-
|
48
|
+
$LOG.info line if $LOG.info?
|
53
49
|
end
|
54
50
|
end
|
55
51
|
threads.each{|t|t.join}
|
@@ -1,10 +1,19 @@
|
|
1
1
|
require 'awestruct/deploy/base_deploy'
|
2
|
+
require 'ruby-s3cmd'
|
2
3
|
|
3
4
|
module Awestruct
|
4
5
|
module Deploy
|
5
6
|
class S3Deploy < Base
|
6
7
|
def initialize( site_config, deploy_config )
|
7
8
|
@site_path = site_config.output_dir
|
9
|
+
@bucket = deploy_config['bucket']
|
10
|
+
end
|
11
|
+
|
12
|
+
def publish_site
|
13
|
+
$LOG.info "Syncing #{@site_path} to bucket #{@bucket}" if $LOG.info?
|
14
|
+
s3cmd = RubyS3Cmd::S3Cmd.new
|
15
|
+
s3cmd.sync("#{@site_path}/", @bucket)
|
16
|
+
$LOG.info "DONE" if $LOG.info?
|
8
17
|
end
|
9
18
|
end
|
10
19
|
end
|
data/lib/awestruct/engine.rb
CHANGED
@@ -46,16 +46,29 @@ module Awestruct
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def run(profile, base_url, default_base_url, force=false)
|
49
|
+
$LOG.debug "adjust_load_path" if $LOG.debug?
|
49
50
|
adjust_load_path
|
51
|
+
$LOG.debug "load_default_site_yaml" if $LOG.debug?
|
52
|
+
load_default_site_yaml
|
53
|
+
$LOG.debug "load_site_yaml -- profile" if $LOG.debug?
|
50
54
|
load_site_yaml(profile)
|
55
|
+
$LOG.debug "set_base_url" if $LOG.debug?
|
51
56
|
set_base_url( base_url, default_base_url )
|
57
|
+
$LOG.debug "load_yamls" if $LOG.debug?
|
52
58
|
load_yamls
|
59
|
+
$LOG.debug "load_pipeline" if $LOG.debug?
|
53
60
|
load_pipeline
|
61
|
+
$LOG.debug "load_pages" if $LOG.debug?
|
54
62
|
load_pages
|
63
|
+
$LOG.debug "execute_pipeline" if $LOG.debug?
|
55
64
|
execute_pipeline
|
65
|
+
$LOG.debug "configure_compass" if $LOG.debug?
|
56
66
|
configure_compass
|
67
|
+
$LOG.debug "set_urls" if $LOG.debug?
|
57
68
|
set_urls( site.pages )
|
69
|
+
$LOG.debug "build_page_index" if $LOG.debug?
|
58
70
|
build_page_index
|
71
|
+
$LOG.debug "generate_output" if $LOG.debug?
|
59
72
|
generate_output
|
60
73
|
end
|
61
74
|
|
@@ -90,6 +103,16 @@ module Awestruct
|
|
90
103
|
|
91
104
|
end
|
92
105
|
|
106
|
+
def load_default_site_yaml
|
107
|
+
default_site_yaml = File.join( File.dirname( __FILE__ ), 'config', 'default-site.yml' )
|
108
|
+
if ( File.exist?( default_site_yaml ) )
|
109
|
+
data = YAML.load( File.read( default_site_yaml ) )
|
110
|
+
data.each do |k,v|
|
111
|
+
site.send( "#{k}=", v )
|
112
|
+
end if data
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
93
116
|
def load_site_yaml(profile)
|
94
117
|
site_yaml = File.join( site.config.config_dir, 'site.yml' )
|
95
118
|
if ( File.exist?( site_yaml ) )
|
@@ -100,13 +123,13 @@ module Awestruct
|
|
100
123
|
if ( ( k == 'profiles' ) && ( ! profile.nil? ) )
|
101
124
|
profile_data = ( v[profile] || {} )
|
102
125
|
else
|
103
|
-
site.send( "#{k}=", v )
|
126
|
+
site.send( "#{k}=", merge_data( site.send( "#{k}" ), v ) )
|
104
127
|
end
|
105
128
|
end if data
|
106
129
|
site.profile = profile
|
107
130
|
|
108
131
|
profile_data.each do |k,v|
|
109
|
-
site.send( "#{k}=", v )
|
132
|
+
site.send( "#{k}=", merge_data( site.send( "#{k}" ), v ) )
|
110
133
|
end
|
111
134
|
end
|
112
135
|
end
|
@@ -123,6 +146,25 @@ module Awestruct
|
|
123
146
|
site.send( "#{name}=", massage_yaml( data ) )
|
124
147
|
end
|
125
148
|
|
149
|
+
def merge_data(existing, new)
|
150
|
+
if existing.kind_of? Hash
|
151
|
+
existing.inject({}) do |merged, (k,v)|
|
152
|
+
if new.has_key? k
|
153
|
+
if v.kind_of? Hash
|
154
|
+
merged[k] = v.merge new[k]
|
155
|
+
else
|
156
|
+
merged[k] = new[k]
|
157
|
+
end
|
158
|
+
else
|
159
|
+
merged[k] = v
|
160
|
+
end
|
161
|
+
merged
|
162
|
+
end
|
163
|
+
else
|
164
|
+
new
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
126
168
|
def massage_yaml(obj)
|
127
169
|
result = obj
|
128
170
|
case ( obj )
|
@@ -150,7 +192,7 @@ module Awestruct
|
|
150
192
|
|
151
193
|
def set_urls(pages)
|
152
194
|
pages.each do |page|
|
153
|
-
|
195
|
+
$LOG.debug "relative_source_path #{page.relative_source_path}" if $LOG.debug?
|
154
196
|
page_path = page.output_path
|
155
197
|
if ( page_path =~ /^\// )
|
156
198
|
page.url = page_path
|
@@ -192,21 +234,30 @@ module Awestruct
|
|
192
234
|
Compass.configuration.sass_dir = 'stylesheets'
|
193
235
|
|
194
236
|
site.images_dir = File.join( site.config.output_dir, 'images' )
|
237
|
+
site.fonts_dir = File.join( site.config.output_dir, 'fonts' )
|
195
238
|
site.stylesheets_dir = File.join( site.config.output_dir, 'stylesheets' )
|
196
239
|
site.javascripts_dir = File.join( site.config.output_dir, 'javascripts' )
|
197
240
|
|
198
241
|
Compass.configuration.css_dir = site.css_dir
|
199
242
|
Compass.configuration.javascripts_dir = 'javascripts'
|
200
243
|
Compass.configuration.images_dir = 'images'
|
244
|
+
Compass.configuration.fonts_dir = 'fonts'
|
201
245
|
Compass.configuration.line_comments = include_line_comments?
|
246
|
+
Compass.configuration.output_style = compress_css?
|
202
247
|
end
|
203
248
|
|
204
249
|
def include_line_comments?
|
205
250
|
site.key?(:compass_line_comments) ? !!site.compass_line_comments : !site.profile.eql?('production')
|
206
251
|
end
|
207
252
|
|
253
|
+
def compress_css?
|
254
|
+
site.key?(:compass_output_style) ? site.compass_output_style.to_sym : site.profile.eql?('production') ? :compressed : :expanded
|
255
|
+
end
|
256
|
+
|
208
257
|
def load_pages
|
258
|
+
$LOG.debug "layout_page_loader.load_all :post" if $LOG.debug?
|
209
259
|
@layout_page_loader.load_all( :post )
|
260
|
+
$LOG.debug "site_page_loader.load_all :inline" if $LOG.debug?
|
210
261
|
@site_page_loader.load_all( :inline )
|
211
262
|
end
|
212
263
|
|
@@ -224,7 +275,7 @@ module Awestruct
|
|
224
275
|
|
225
276
|
def generate_page(page, generated_path, produce_output=true)
|
226
277
|
if ( produce_output )
|
227
|
-
|
278
|
+
$LOG.debug "Generating: #{generated_path}" if $LOG.debug?
|
228
279
|
FileUtils.mkdir_p( File.dirname( generated_path ) )
|
229
280
|
|
230
281
|
c = page.rendered_content
|
@@ -235,9 +286,9 @@ module Awestruct
|
|
235
286
|
end
|
236
287
|
elsif ( site.config.track_dependencies )
|
237
288
|
if page.dependencies.load!
|
238
|
-
|
289
|
+
$LOG.debug "Cached: #{generated_path}" if $LOG.debug?
|
239
290
|
else
|
240
|
-
|
291
|
+
$LOG.debug "Analyzing: #{generated_path}" if $LOG.debug?
|
241
292
|
page.rendered_content
|
242
293
|
end
|
243
294
|
end
|
@@ -256,19 +307,19 @@ module Awestruct
|
|
256
307
|
pages = [] << page
|
257
308
|
|
258
309
|
pages.each{|page|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
310
|
+
$LOG.debug "--------------------" if $LOG.debug?
|
311
|
+
$LOG.debug "Page: #{page.output_path} #{page.relative_source_path} #{page.__is_layout ? 'Layout':''}" if $LOG.debug?
|
312
|
+
$LOG.debug "Detected change in content (#{page.dependencies.content_hash})" if page.dependencies.has_changed_content if $LOG.debug?
|
313
|
+
$LOG.debug "!! Detected change in front matter. To fully reflect the change you'll need to restart Awestruct (#{page.dependencies.key_hash})" if page.dependencies.has_changed_keys if $LOG.debug?
|
314
|
+
$LOG.debug "No changes detected" unless page.dependencies.has_changed_content or page.dependencies.has_changed_keys if $LOG.debug?
|
315
|
+
$LOG.debug "Dependencies Matrix: (non unique source path)" if $LOG.debug?
|
316
|
+
$LOG.debug "\t Outgoing dependencies:" if $LOG.debug?
|
317
|
+
$LOG.debug "\t\t Content -> #{page.dependencies.dependencies.size}" if $LOG.debug?
|
318
|
+
$LOG.debug "\t\t Key -> #{page.dependencies.key_dependencies.size}" if $LOG.debug?
|
319
|
+
$LOG.debug "\t Incoming dependencies:" if $LOG.debug?
|
320
|
+
$LOG.debug "\t\t Content <- #{page.dependencies.dependents.size}" if $LOG.debug?
|
321
|
+
$LOG.debug "\t\t Key <- #{page.dependencies.key_dependents.size}" if $LOG.debug?
|
322
|
+
$LOG.debug "--------------------" if $LOG.debug?
|
272
323
|
}
|
273
324
|
|
274
325
|
regen_pages = Set.new
|
@@ -286,8 +337,8 @@ module Awestruct
|
|
286
337
|
yt <=> xt
|
287
338
|
end
|
288
339
|
|
289
|
-
|
290
|
-
regen_pages.each{|x|
|
340
|
+
$LOG.debug "Starting regeneration of content dependent pages:" if regen_pages.size > 0 && $LOG.debug?
|
341
|
+
regen_pages.each{|x| $LOG.info x.output_path if $LOG.info?}
|
291
342
|
|
292
343
|
regen_pages.each do |p|
|
293
344
|
generate_page_internal(p)
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'shellwords'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'htmlcompressor'
|
4
|
-
require '
|
4
|
+
require 'uglifier'
|
5
5
|
|
6
6
|
##
|
7
7
|
# Awestruct:Extensions:Minify is a transformer that minimizes JavaScript, CSS and HTML files.
|
8
8
|
# The transform runs on the rendered stream before it's written to the output path.
|
9
9
|
#
|
10
|
-
# Minification is performed by the following
|
10
|
+
# Minification is performed by the following libraries:
|
11
11
|
#
|
12
12
|
# htmlcompressor (minifies HTML): http://code.google.com/p/htmlcompressor/
|
13
|
-
#
|
13
|
+
# uglifier (minifies javascript): http://github.com/lautis/uglifier
|
14
14
|
# pngcrush (minifies PNG): http://pmt.sourceforge.net/pngcrush/
|
15
15
|
#
|
16
16
|
# These commands must be available on your PATH in order to use them.
|
@@ -22,12 +22,11 @@ require 'yui/compressor'
|
|
22
22
|
#
|
23
23
|
# This transform recognizes the following symbols:
|
24
24
|
#
|
25
|
-
# :css - CSS files with extension .css
|
26
25
|
# :js - JavaScript files with extension .js
|
27
26
|
# :html - HTML files with extension .html
|
28
27
|
# :png - PNG files with extension .png
|
29
28
|
#
|
30
|
-
# If no types are specified, the default value [:
|
29
|
+
# If no types are specified, the default value [:js] is used.
|
31
30
|
#
|
32
31
|
# In addition to registering the transformer in the pipeline, it must be enabled
|
33
32
|
# by setting the following site property in _ext/config.yml:
|
@@ -46,7 +45,6 @@ require 'yui/compressor'
|
|
46
45
|
# minify_html_opts:
|
47
46
|
# remove_intertag_spaces: true
|
48
47
|
# compress_js: true
|
49
|
-
# compress_css: true
|
50
48
|
#
|
51
49
|
# Note that any hypen (-) must be represented as an underscore (_) in the configuration.
|
52
50
|
|
@@ -54,7 +52,7 @@ module Awestruct
|
|
54
52
|
module Extensions
|
55
53
|
class Minify
|
56
54
|
|
57
|
-
def initialize(types = [ :
|
55
|
+
def initialize(types = [ :js ])
|
58
56
|
@types = types
|
59
57
|
end
|
60
58
|
|
@@ -69,11 +67,12 @@ module Awestruct
|
|
69
67
|
print "minifying html #{page.output_path}"
|
70
68
|
input = htmlcompressor(page, input, site.minify_html_opts)
|
71
69
|
when :css
|
72
|
-
|
73
|
-
|
70
|
+
# TODO: Figure out how to do this is sass / less and document it
|
71
|
+
#print "minifying css #{page.output_path}"
|
72
|
+
#input = yuicompressor_css(page, input)
|
74
73
|
when :js
|
75
74
|
print "minifying js #{page.output_path}"
|
76
|
-
input =
|
75
|
+
input = js_compressor(page, input)
|
77
76
|
when :png
|
78
77
|
print "minifying png #{page.output_path}"
|
79
78
|
input = pngcrush(page, input)
|
@@ -86,17 +85,19 @@ module Awestruct
|
|
86
85
|
|
87
86
|
private
|
88
87
|
|
88
|
+
class JSCompressor
|
89
|
+
def compress( input )
|
90
|
+
Uglifier.new(:mangle => false).compile(input)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
89
94
|
def htmlcompressor(page, input, minify_html_opts)
|
90
95
|
opts = minify_html_opts.nil? ? {}:minify_html_opts
|
91
96
|
compressor(page, input, HtmlCompressor::Compressor.new(opts))
|
92
97
|
end
|
93
98
|
|
94
|
-
def
|
95
|
-
compressor(page, input,
|
96
|
-
end
|
97
|
-
|
98
|
-
def yuicompressor_js(page, input)
|
99
|
-
compressor(page, input, YUI::JavaScriptCompressor.new)
|
99
|
+
def js_compressor(page, input)
|
100
|
+
compressor(page, input, JSCompressor.new)
|
100
101
|
end
|
101
102
|
|
102
103
|
def compressor(page, input, compressor)
|
@@ -106,10 +107,10 @@ module Awestruct
|
|
106
107
|
output_len = output.length
|
107
108
|
|
108
109
|
if input_len > output_len
|
109
|
-
|
110
|
+
$LOG.debug " %d bytes -> %d bytes = %.1f%%" % [ input_len, output_len, 100 * output_len/input_len ] if $LOG.debug?
|
110
111
|
output
|
111
112
|
else
|
112
|
-
|
113
|
+
$LOG.debug " no gain" if $LOG.debug?
|
113
114
|
input
|
114
115
|
end
|
115
116
|
end
|
@@ -127,10 +128,10 @@ module Awestruct
|
|
127
128
|
output_len = output.length
|
128
129
|
|
129
130
|
if input_len > output_len
|
130
|
-
|
131
|
+
$LOG.debug " %d bytes -> %d bytes = %.1f%%" % [ input_len, output_len, 100 * output_len/input_len ] if $LOG.debug?
|
131
132
|
output
|
132
133
|
else
|
133
|
-
|
134
|
+
$LOG.debug " no gain" if $LOG.debug?
|
134
135
|
input
|
135
136
|
end
|
136
137
|
end
|
@@ -13,7 +13,7 @@ module Awestruct
|
|
13
13
|
def links
|
14
14
|
html = %Q(<div class="pagination-links">)
|
15
15
|
unless ( previous_page.nil? )
|
16
|
-
html += %Q(<a href="#{
|
16
|
+
html += %Q(<a href="#{previous_page.url}" class="previous-link">Previous</a> )
|
17
17
|
end
|
18
18
|
first_skip = false
|
19
19
|
second_skip = false
|
@@ -21,7 +21,7 @@ module Awestruct
|
|
21
21
|
if ( i == current_page_index )
|
22
22
|
html += %Q(<span class="current-page">#{i+1}</span> )
|
23
23
|
elsif ( i <= window )
|
24
|
-
html += %Q(<a href="#{
|
24
|
+
html += %Q(<a href="#{page.url}" class="page-link">#{i+1}</a> )
|
25
25
|
elsif ( ( i > window ) && ( i < ( current_page_index - window ) ) && ! first_skip )
|
26
26
|
html += %Q(<span class="skip">...</span>)
|
27
27
|
first_skip = true
|
@@ -29,13 +29,13 @@ module Awestruct
|
|
29
29
|
html += %Q(<span class="skip">...</span>)
|
30
30
|
second_skip = true
|
31
31
|
elsif ( ( i >= ( current_page_index - window ) ) && ( i <= ( current_page_index + window ) ) )
|
32
|
-
html += %Q(<a href="#{
|
32
|
+
html += %Q(<a href="#{page.url}" class="page-link">#{i+1}</a> )
|
33
33
|
elsif ( i >= ( ( pages.size - window ) - 1 ) )
|
34
|
-
html += %Q(<a href="#{
|
34
|
+
html += %Q(<a href="#{page.url}" class="page-link">#{i+1}</a> )
|
35
35
|
end
|
36
36
|
end
|
37
37
|
unless ( next_page.nil? )
|
38
|
-
html += %Q(<a href="#{
|
38
|
+
html += %Q(<a href="#{next_page.url}" class="next-link">Next</a> )
|
39
39
|
end
|
40
40
|
html += %Q(</div>)
|
41
41
|
html
|