Add development/production mode
This commit is contained in:
parent
7dde052f1b
commit
d0f4b941df
2
Gemfile
2
Gemfile
|
@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
||||||
gem 'nanoc'
|
gem 'nanoc'
|
||||||
|
|
||||||
gem 'haml'
|
gem 'haml'
|
||||||
gem 'kramdown'
|
gem 'rdiscount'
|
||||||
|
|
||||||
gem 'pygments.rb'
|
gem 'pygments.rb'
|
||||||
|
|
||||||
|
|
34
Gemfile.lock
34
Gemfile.lock
|
@ -3,12 +3,12 @@ GEM
|
||||||
specs:
|
specs:
|
||||||
adsf (1.1.1)
|
adsf (1.1.1)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
builder (3.2.0)
|
builder (3.2.2)
|
||||||
chunky_png (1.2.7)
|
chunky_png (1.2.8)
|
||||||
coffee-script (2.2.0)
|
coffee-script (2.2.0)
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.6.2)
|
coffee-script-source (1.6.3)
|
||||||
colored (1.2)
|
colored (1.2)
|
||||||
compass (0.12.2)
|
compass (0.12.2)
|
||||||
chunky_png (~> 1.2)
|
chunky_png (~> 1.2)
|
||||||
|
@ -19,33 +19,35 @@ GEM
|
||||||
execjs (1.4.0)
|
execjs (1.4.0)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
fssm (0.2.10)
|
fssm (0.2.10)
|
||||||
haml (4.0.1)
|
haml (4.0.3)
|
||||||
tilt
|
tilt
|
||||||
i18n (0.6.4)
|
i18n (0.6.4)
|
||||||
json (1.7.7)
|
json (1.8.0)
|
||||||
kramdown (0.14.2)
|
mime-types (1.23)
|
||||||
mime-types (1.21)
|
mini_portile (0.5.1)
|
||||||
multi_json (1.7.1)
|
multi_json (1.7.7)
|
||||||
nanoc (3.6.1)
|
nanoc (3.6.4)
|
||||||
cri (~> 2.3)
|
cri (~> 2.3)
|
||||||
nanoc-cachebuster (0.3.1)
|
nanoc-cachebuster (0.3.1)
|
||||||
nanoc (>= 3.3.0)
|
nanoc (>= 3.3.0)
|
||||||
nanoc-javascript-concatenator (0.0.2)
|
nanoc-javascript-concatenator (0.0.2)
|
||||||
nanoc (>= 3.3.0)
|
nanoc (>= 3.3.0)
|
||||||
nokogiri (1.5.9)
|
nokogiri (1.6.0)
|
||||||
|
mini_portile (~> 0.5.0)
|
||||||
posix-spawn (0.3.6)
|
posix-spawn (0.3.6)
|
||||||
pygments.rb (0.4.2)
|
pygments.rb (0.5.2)
|
||||||
posix-spawn (~> 0.3.6)
|
posix-spawn (~> 0.3.6)
|
||||||
yajl-ruby (~> 1.1.0)
|
yajl-ruby (~> 1.1.0)
|
||||||
rack (1.5.2)
|
rack (1.5.2)
|
||||||
rake (10.0.3)
|
rake (10.1.0)
|
||||||
|
rdiscount (2.1.6)
|
||||||
rubypants (0.2.0)
|
rubypants (0.2.0)
|
||||||
sass (3.2.7)
|
sass (3.2.9)
|
||||||
systemu (2.5.2)
|
systemu (2.5.2)
|
||||||
tilt (1.3.6)
|
tilt (1.4.1)
|
||||||
typogruby (1.0.15)
|
typogruby (1.0.15)
|
||||||
rubypants
|
rubypants
|
||||||
uglifier (1.3.0)
|
uglifier (2.1.2)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
multi_json (~> 1.0, >= 1.0.2)
|
multi_json (~> 1.0, >= 1.0.2)
|
||||||
w3c_validators (1.2)
|
w3c_validators (1.2)
|
||||||
|
@ -63,7 +65,6 @@ DEPENDENCIES
|
||||||
compass
|
compass
|
||||||
haml
|
haml
|
||||||
i18n
|
i18n
|
||||||
kramdown
|
|
||||||
mime-types
|
mime-types
|
||||||
multi_json (~> 1.3)
|
multi_json (~> 1.3)
|
||||||
nanoc
|
nanoc
|
||||||
|
@ -73,6 +74,7 @@ DEPENDENCIES
|
||||||
pygments.rb
|
pygments.rb
|
||||||
rack
|
rack
|
||||||
rake
|
rake
|
||||||
|
rdiscount
|
||||||
sass
|
sass
|
||||||
systemu
|
systemu
|
||||||
typogruby
|
typogruby
|
||||||
|
|
39
Rules
39
Rules
|
@ -1,9 +1,19 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
puts "=" * 76
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
|
puts " > Running in PRODUCTION mode"
|
||||||
|
else
|
||||||
|
puts " > Running in DEVELOPMENT mode"
|
||||||
|
end
|
||||||
|
puts "=" * 76
|
||||||
|
|
||||||
preprocess do
|
preprocess do
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
create_robots_txt
|
create_robots_txt
|
||||||
create_webmaster_tools_authentications
|
create_webmaster_tools_authentications
|
||||||
create_sitemap
|
create_sitemap
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
compile %r{^/(google|robots|assets)} do
|
compile %r{^/(google|robots|assets)} do
|
||||||
|
@ -20,7 +30,10 @@ end
|
||||||
|
|
||||||
compile '/sitemap/', :rep => 'gzip' do
|
compile '/sitemap/', :rep => 'gzip' do
|
||||||
filter :erb
|
filter :erb
|
||||||
|
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
filter :shellcmd, :cmd => 'gzip'
|
filter :shellcmd, :cmd => 'gzip'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use screen.scss as the single entry point for styles, ignore everything else in /assets/css
|
# Use screen.scss as the single entry point for styles, ignore everything else in /assets/css
|
||||||
|
@ -33,7 +46,11 @@ compile '/css/*' do
|
||||||
end
|
end
|
||||||
|
|
||||||
route '/css/screen/' do
|
route '/css/screen/' do
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
fp = fingerprint(item[:filename])
|
fp = fingerprint(item[:filename])
|
||||||
|
else
|
||||||
|
fp = ''
|
||||||
|
end
|
||||||
item.identifier.chop + fp + '.css'
|
item.identifier.chop + fp + '.css'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +58,10 @@ compile '/js/*/' do
|
||||||
filter :coffeescript if @item[:extension] == 'coffee'
|
filter :coffeescript if @item[:extension] == 'coffee'
|
||||||
|
|
||||||
filter :concat_js
|
filter :concat_js
|
||||||
|
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
filter :uglify_js
|
filter :uglify_js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
route '/js/*/' do
|
route '/js/*/' do
|
||||||
|
@ -54,20 +74,29 @@ compile '/rss/' do
|
||||||
end
|
end
|
||||||
|
|
||||||
compile '/posts/*' do
|
compile '/posts/*' do
|
||||||
filter :kramdown
|
filter :rdiscount
|
||||||
filter :pygmentizer
|
filter :pygmentizer
|
||||||
|
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
filter :typogruby
|
filter :typogruby
|
||||||
|
end
|
||||||
|
|
||||||
layout 'post'
|
layout 'post'
|
||||||
layout 'default'
|
layout 'default'
|
||||||
|
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
filter :cache_buster
|
filter :cache_buster
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
compile %r{^/(404)/$} do
|
compile %r{^/(404)/$} do
|
||||||
filter :haml, format: :html5, ugly: true
|
filter :haml, format: :html5, ugly: true
|
||||||
|
|
||||||
layout 'default'
|
layout 'default'
|
||||||
|
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
filter :cache_buster
|
filter :cache_buster
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
compile '*' do
|
compile '*' do
|
||||||
|
@ -85,9 +114,12 @@ compile '*' do
|
||||||
if %w(html haml md).include?(item[:extension])
|
if %w(html haml md).include?(item[:extension])
|
||||||
layout 'page'
|
layout 'page'
|
||||||
layout 'default'
|
layout 'default'
|
||||||
|
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
filter :cache_buster
|
filter :cache_buster
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
route %r{/_.+/$} do
|
route %r{/_.+/$} do
|
||||||
|
@ -99,7 +131,12 @@ route %r{^/(assets/.*|sitemap|robots|atom)/$} do
|
||||||
ext = 'js' if ext == 'coffee'
|
ext = 'js' if ext == 'coffee'
|
||||||
ext = 'css' if ext == 'scss'
|
ext = 'css' if ext == 'scss'
|
||||||
|
|
||||||
|
if ENV['NANOC_ENV'] == "production"
|
||||||
fp = cachebust?(item) ? fingerprint(item[:filename]) : ''
|
fp = cachebust?(item) ? fingerprint(item[:filename]) : ''
|
||||||
|
else
|
||||||
|
fp = ''
|
||||||
|
end
|
||||||
|
|
||||||
item.identifier.chop + fp + '.' + ext
|
item.identifier.chop + fp + '.' + ext
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user