From 9df7c78046928cd43171e2dee586bb0241a65518 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Sat, 15 Oct 2016 21:32:45 +0200 Subject: [PATCH] make development faster by not compiling literally everything --- .travis.yml | 2 +- Rules | 29 ++++++++++++++--------------- lib/helpers/environment.rb | 9 +++++++++ lib/helpers_.rb | 1 + 4 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 lib/helpers/environment.rb diff --git a/.travis.yml b/.travis.yml index 2293d76..598d70f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: - echo -e "Host zeus.ugent.be\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - npm install script: -- bundle exec nanoc +- ZEUS_PRODUCTION=1 bundle exec nanoc - bundle exec nanoc check --deploy after_success: - mv deploy_key ~/.ssh/id_rsa diff --git a/Rules b/Rules index 0cf0623..53ace23 100644 --- a/Rules +++ b/Rules @@ -13,6 +13,17 @@ require 'icalendar' preprocess do `npm install` + # We don't want to compile old blogposts in development + if development? + @items.delete_if do |item| + ident = item.identifier.to_s + + next unless ident.to_s.start_with?('/posts/') + + !ident.start_with?('/posts/16-17/') + end + end + @items.find_all('/posts/**/*').each do |i| year_str = %r{/(\d\d)-\d\d/}.match(i.identifier).captures[0] academic_year = year_str.to_i @@ -66,8 +77,6 @@ compile '/blog/*' do layout '/generic.*' layout '/default.*' filter :erb - - filter :relativize_paths, type: :html end # @@ -79,8 +88,6 @@ compile '/events/**/*' do layout '/eventpost.*' layout '/default.*' filter :erb - - filter :relativize_paths, type: :html end compile '/events/**/*', rep: :text do @@ -104,8 +111,6 @@ compile '/posts/**/*' do layout '/blogpost.*' layout '/generic.*' layout '/default.*' - - filter :relativize_paths, type: :html end compile '/posts/**/*', rep: :text do @@ -119,7 +124,6 @@ end # compile '/projects/*' do filter :kramdown - filter :relativize_paths, type: :html end # @@ -132,14 +136,13 @@ end compile '/**/*.ics' do filter :erb + write @item.identifier.to_s end compile '/*.erb' do layout '/generic.*' layout '/default.*' filter :erb - - filter :relativize_paths, type: :html end # @@ -153,7 +156,7 @@ ignore '/assets/stylesheets/includes/**/*' compile '/assets/stylesheets/**/*.scss' do filter :sass, syntax: :scss - filter :autoprefixer + filter :autoprefixer if production? end passthrough '/assets/images/*.{png,svg}' @@ -176,7 +179,7 @@ route '/assets/scripts/**/*' do "#{item.identifier.without_ext}.js" end -# POSTS +# EVENTS route '/events/**/*', rep: :ical do "#{item.identifier.without_ext}.ics" end @@ -189,10 +192,6 @@ route '/**/*.{erb,html,md}' do end end -route '/**/*' do - item.identifier.to_s -end - # # # LAYOUTS diff --git a/lib/helpers/environment.rb b/lib/helpers/environment.rb new file mode 100644 index 0000000..4a33b6f --- /dev/null +++ b/lib/helpers/environment.rb @@ -0,0 +1,9 @@ +module EnvironmentHelper + def production? + ENV['ZEUS_PRODUCTION'] + end + + def development? + !production? + end +end diff --git a/lib/helpers_.rb b/lib/helpers_.rb index 0de314d..90fdc28 100644 --- a/lib/helpers_.rb +++ b/lib/helpers_.rb @@ -4,6 +4,7 @@ include Nanoc::Helpers::LinkTo include Nanoc::Helpers::Rendering include Nanoc::Helpers::Text +include EnvironmentHelper include ArchiveHelper include AssetHelper include EventsHelper