From 786c73eaeb45fb4b979671f39de027b4dafd5f93 Mon Sep 17 00:00:00 2001 From: Wout Schellaert Date: Sat, 17 Aug 2019 14:36:17 +0200 Subject: [PATCH 1/2] Fix event/blog-page 13-14 bug --- nanoc.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nanoc.yaml b/nanoc.yaml index 2e20a7c..90cf094 100644 --- a/nanoc.yaml +++ b/nanoc.yaml @@ -1,5 +1,7 @@ title: Zeus WPI -academic_year: 19-20 +# If you update this, make sure to create a new directory for blogs and events, +# and add an entry to both. +academic_year: 18-19 # Needed for atom_feed author_name: '' author_uri: '' From 481b0f57b932b2e727a63af13adc69a77b0e290a Mon Sep 17 00:00:00 2001 From: Wout Schellaert Date: Sat, 17 Aug 2019 15:09:27 +0200 Subject: [PATCH 2/2] Fix the problems with bumping the current acedemic year while no posts have been made --- Rules | 2 +- layouts/{archive_page.erb => blogs.erb} | 8 ++++++++ layouts/events.erb | 8 ++++++++ lib/helpers/archives.rb | 2 ++ lib/helpers/preprocess.rb | 5 ++++- nanoc.yaml | 4 +--- 6 files changed, 24 insertions(+), 5 deletions(-) rename layouts/{archive_page.erb => blogs.erb} (81%) diff --git a/Rules b/Rules index 22f34cc..887d982 100644 --- a/Rules +++ b/Rules @@ -41,7 +41,7 @@ end # ARCHIVES # compile '/blog/*' do - layout '/archive_page.*' + layout '/blogs.*' layout '/generic.*' layout '/default.*' filter :erb diff --git a/layouts/archive_page.erb b/layouts/blogs.erb similarity index 81% rename from layouts/archive_page.erb rename to layouts/blogs.erb index 7a93594..41f6de0 100644 --- a/layouts/archive_page.erb +++ b/layouts/blogs.erb @@ -34,6 +34,14 @@ <%= render '/partials/_blog_preview.*', post: post %> <% end %> + + <% if posts_in_year(@item[:academic_year]).empty? %> +
+

Sorry.

+

No blog posts yet this year.

+

Soon TM.

+
+ <% end %> diff --git a/layouts/events.erb b/layouts/events.erb index e8e1d62..14478c5 100644 --- a/layouts/events.erb +++ b/layouts/events.erb @@ -52,5 +52,13 @@ <% end %> <% end %> + + <% if past_events(@item[:academic_year]).empty? and upcoming_events(@item[:academic_year]).empty? %> +
+

Sorry.

+

No events planned yet this year.

+

Soon TM.

+
+ <% end %> diff --git a/lib/helpers/archives.rb b/lib/helpers/archives.rb index 5c15ccc..68ec04f 100644 --- a/lib/helpers/archives.rb +++ b/lib/helpers/archives.rb @@ -6,6 +6,8 @@ module ArchiveHelper .map { |i| i.identifier.to_s[/\d\d-\d\d/] }) .to_a .sort + .push(@config[:academic_year]) + .uniq end def academic_years_blog_items diff --git a/lib/helpers/preprocess.rb b/lib/helpers/preprocess.rb index 7553844..3574b6a 100644 --- a/lib/helpers/preprocess.rb +++ b/lib/helpers/preprocess.rb @@ -46,7 +46,10 @@ module PreprocessHelper def create_yearly_items(type) type = type.to_s - years = @items.find_all("/#{type.downcase}/*/*").map { |i| i.identifier.to_s[/\d\d-\d\d/] }.uniq + years = @items.find_all("/#{type.downcase}/*/*") + .map { |i| i.identifier.to_s[/\d\d-\d\d/] } + .push(@config[:academic_year]) + .uniq years.each do |year| @items.create( diff --git a/nanoc.yaml b/nanoc.yaml index 90cf094..2e20a7c 100644 --- a/nanoc.yaml +++ b/nanoc.yaml @@ -1,7 +1,5 @@ title: Zeus WPI -# If you update this, make sure to create a new directory for blogs and events, -# and add an entry to both. -academic_year: 18-19 +academic_year: 19-20 # Needed for atom_feed author_name: '' author_uri: ''