Add development/production mode

This commit is contained in:
Ariejan de Vroom 2013-07-24 16:46:33 +02:00
parent 7dde052f1b
commit d0f4b941df
3 changed files with 68 additions and 29 deletions

View File

@ -3,7 +3,7 @@ source 'https://rubygems.org'
gem 'nanoc'
gem 'haml'
gem 'kramdown'
gem 'rdiscount'
gem 'pygments.rb'

View File

@ -3,12 +3,12 @@ GEM
specs:
adsf (1.1.1)
rack (>= 1.0.0)
builder (3.2.0)
chunky_png (1.2.7)
builder (3.2.2)
chunky_png (1.2.8)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.2)
coffee-script-source (1.6.3)
colored (1.2)
compass (0.12.2)
chunky_png (~> 1.2)
@ -19,33 +19,35 @@ GEM
execjs (1.4.0)
multi_json (~> 1.0)
fssm (0.2.10)
haml (4.0.1)
haml (4.0.3)
tilt
i18n (0.6.4)
json (1.7.7)
kramdown (0.14.2)
mime-types (1.21)
multi_json (1.7.1)
nanoc (3.6.1)
json (1.8.0)
mime-types (1.23)
mini_portile (0.5.1)
multi_json (1.7.7)
nanoc (3.6.4)
cri (~> 2.3)
nanoc-cachebuster (0.3.1)
nanoc (>= 3.3.0)
nanoc-javascript-concatenator (0.0.2)
nanoc (>= 3.3.0)
nokogiri (1.5.9)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
posix-spawn (0.3.6)
pygments.rb (0.4.2)
pygments.rb (0.5.2)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.5.2)
rake (10.0.3)
rake (10.1.0)
rdiscount (2.1.6)
rubypants (0.2.0)
sass (3.2.7)
sass (3.2.9)
systemu (2.5.2)
tilt (1.3.6)
tilt (1.4.1)
typogruby (1.0.15)
rubypants
uglifier (1.3.0)
uglifier (2.1.2)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
w3c_validators (1.2)
@ -63,7 +65,6 @@ DEPENDENCIES
compass
haml
i18n
kramdown
mime-types
multi_json (~> 1.3)
nanoc
@ -73,6 +74,7 @@ DEPENDENCIES
pygments.rb
rack
rake
rdiscount
sass
systemu
typogruby

61
Rules
View File

@ -1,9 +1,19 @@
#!/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
create_robots_txt
create_webmaster_tools_authentications
create_sitemap
if ENV['NANOC_ENV'] == "production"
create_robots_txt
create_webmaster_tools_authentications
create_sitemap
end
end
compile %r{^/(google|robots|assets)} do
@ -20,7 +30,10 @@ end
compile '/sitemap/', :rep => 'gzip' do
filter :erb
filter :shellcmd, :cmd => 'gzip'
if ENV['NANOC_ENV'] == "production"
filter :shellcmd, :cmd => 'gzip'
end
end
# Use screen.scss as the single entry point for styles, ignore everything else in /assets/css
@ -33,7 +46,11 @@ compile '/css/*' do
end
route '/css/screen/' do
fp = fingerprint(item[:filename])
if ENV['NANOC_ENV'] == "production"
fp = fingerprint(item[:filename])
else
fp = ''
end
item.identifier.chop + fp + '.css'
end
@ -41,7 +58,10 @@ compile '/js/*/' do
filter :coffeescript if @item[:extension] == 'coffee'
filter :concat_js
filter :uglify_js
if ENV['NANOC_ENV'] == "production"
filter :uglify_js
end
end
route '/js/*/' do
@ -54,20 +74,29 @@ compile '/rss/' do
end
compile '/posts/*' do
filter :kramdown
filter :rdiscount
filter :pygmentizer
filter :typogruby
if ENV['NANOC_ENV'] == "production"
filter :typogruby
end
layout 'post'
layout 'default'
filter :cache_buster
if ENV['NANOC_ENV'] == "production"
filter :cache_buster
end
end
compile %r{^/(404)/$} do
filter :haml, format: :html5, ugly: true
layout 'default'
filter :cache_buster
if ENV['NANOC_ENV'] == "production"
filter :cache_buster
end
end
compile '*' do
@ -85,7 +114,10 @@ compile '*' do
if %w(html haml md).include?(item[:extension])
layout 'page'
layout 'default'
filter :cache_buster
if ENV['NANOC_ENV'] == "production"
filter :cache_buster
end
end
end
end
@ -99,7 +131,12 @@ route %r{^/(assets/.*|sitemap|robots|atom)/$} do
ext = 'js' if ext == 'coffee'
ext = 'css' if ext == 'scss'
fp = cachebust?(item) ? fingerprint(item[:filename]) : ''
if ENV['NANOC_ENV'] == "production"
fp = cachebust?(item) ? fingerprint(item[:filename]) : ''
else
fp = ''
end
item.identifier.chop + fp + '.' + ext
end