From ab78e16186132b87b0ca2a18187ecf11fb69bb17 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Thu, 29 Dec 2016 13:37:22 +0100 Subject: [PATCH] automate christmas and minify stuff --- Gemfile | 11 +++++++---- Gemfile.lock | 25 ++++++++++++++++++++----- Rules | 5 +++++ layouts/eventpost.erb | 5 +---- layouts/partials/_navbar.erb | 4 +++- lib/filters/htmlpress.rb | 5 +++++ lib/helpers/time.rb | 5 +++++ lib/helpers_.rb | 1 + 8 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 lib/filters/htmlpress.rb create mode 100644 lib/helpers/time.rb diff --git a/Gemfile b/Gemfile index 14f76d5..f8fd2b7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ # frozen_string_literal: true source 'https://rubygems.org' -gem 'nanoc', '4.4.3' +gem 'nanoc', '4.4.6' gem 'kramdown' gem 'coffee-script' gem 'sass' @@ -13,9 +13,6 @@ gem 'icalendar' gem 'therubyracer' -# Autoprefixing for class -gem 'autoprefixer-rails' - # Word counting gem (which takes special characters into account) # for reading time gem 'words_counted' @@ -26,6 +23,12 @@ group :development do gem 'terminal-notifier-guard' end +group :production do + # Autoprefixing for class + gem 'autoprefixer-rails' + gem 'html_press' +end + group :nanoc do gem 'guard-nanoc' end diff --git a/Gemfile.lock b/Gemfile.lock index 9348254..c9aa1a3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,9 +12,13 @@ GEM execjs coffee-script-source (1.10.0) colored (1.2) - concurrent-ruby (1.0.2) + concurrent-ruby (1.0.4) cri (2.7.1) colored (~> 1.2) + css_press (0.3.2) + csspool-st (= 3.1.2) + json + csspool-st (3.1.2) execjs (2.7.0) ffi (1.9.14) formatador (0.2.5) @@ -35,6 +39,11 @@ GEM hamster (3.0.0) concurrent-ruby (~> 1.0) highline (1.7.8) + html_press (0.8.2) + htmlentities + multi_css (>= 0.1.0) + multi_js (>= 0.1.0) + htmlentities (4.3.4) icalendar (2.4.1) json (2.0.2) kramdown (1.13.0) @@ -46,10 +55,13 @@ GEM lumberjack (1.0.10) method_source (0.8.2) mini_portile2 (2.1.0) - nanoc (4.4.3) + multi_css (0.1.0) + css_press + multi_js (0.1.0) + uglifier (~> 2) + nanoc (4.4.6) cri (~> 2.3) hamster (~> 3.0) - parallel (~> 1.9) ref (~> 2.0) nenv (0.3.0) nokogiri (1.6.8.1) @@ -57,7 +69,6 @@ GEM notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.10.0) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -76,6 +87,9 @@ GEM libv8 (~> 3.16.14.0) ref thor (0.19.1) + uglifier (2.7.2) + execjs (>= 0.3.0) + json (>= 1.8.0) w3c_validators (1.2) json nokogiri @@ -91,9 +105,10 @@ DEPENDENCIES coffee-script guard-nanoc highline + html_press icalendar kramdown - nanoc (= 4.4.3) + nanoc (= 4.4.6) sass terminal-notifier-guard therubyracer diff --git a/Rules b/Rules index 36603fe..d79441f 100644 --- a/Rules +++ b/Rules @@ -38,6 +38,7 @@ compile '/blog/*' do layout '/generic.*' layout '/default.*' filter :erb + filter :html_press if production? end # @@ -49,6 +50,7 @@ compile '/events/**/*' do layout '/eventpost.*' layout '/default.*' filter :erb + filter :html_press if production? end compile '/events/**/*', rep: :text do @@ -70,6 +72,8 @@ compile '/blog/*/*' do layout '/blogpost.erb' layout '/generic.*' layout '/default.*' + filter :erb + filter :html_press if production? end compile '/blog/*/*', rep: :text do @@ -103,6 +107,7 @@ compile '/**/*.erb' do layout '/generic.*' layout '/default.*' filter :erb + filter :html_press if production? end # diff --git a/layouts/eventpost.erb b/layouts/eventpost.erb index 14104d0..2fb5b4b 100644 --- a/layouts/eventpost.erb +++ b/layouts/eventpost.erb @@ -68,10 +68,7 @@
- +
diff --git a/layouts/partials/_navbar.erb b/layouts/partials/_navbar.erb index a1560d7..162f21c 100644 --- a/layouts/partials/_navbar.erb +++ b/layouts/partials/_navbar.erb @@ -2,7 +2,9 @@
diff --git a/lib/filters/htmlpress.rb b/lib/filters/htmlpress.rb new file mode 100644 index 0000000..8654caa --- /dev/null +++ b/lib/filters/htmlpress.rb @@ -0,0 +1,5 @@ +require 'html_press' + +Nanoc::Filter.define(:html_press) do |content, _params| + HtmlPress.press content +end diff --git a/lib/helpers/time.rb b/lib/helpers/time.rb new file mode 100644 index 0000000..7c27091 --- /dev/null +++ b/lib/helpers/time.rb @@ -0,0 +1,5 @@ +module TimeHelper + def christmastime? + Time.now.month == 12 + end +end diff --git a/lib/helpers_.rb b/lib/helpers_.rb index fc9d4dd..6b6ae4e 100644 --- a/lib/helpers_.rb +++ b/lib/helpers_.rb @@ -16,3 +16,4 @@ include ProjectsHelper include SearchHelper include BlogHelper include PreprocessHelper +include TimeHelper