From a22209d48581e2ba9d87e6b87245bde5a52b1459 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Sat, 23 Jul 2016 22:06:06 +0200 Subject: [PATCH] finish up archive page somewhat --- Rules | 16 ++++++++++------ layouts/archive_page.erb | 10 ++++++++++ layouts/partials/_navbar.erb | 6 +++--- lib/archives.rb | 10 ++++++++-- 4 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 layouts/archive_page.erb diff --git a/Rules b/Rules index 01d4a99..6c7b88d 100644 --- a/Rules +++ b/Rules @@ -34,8 +34,7 @@ end passthrough '/tipuesearch_content.js' # ERB -compile '/*.erb' do - layout '/generic.*' +compile '/cammie.*' do layout '/default.*' filter :erb @@ -43,10 +42,7 @@ compile '/*.erb' do end compile '/archives/*' do - posts = items.find_all('/posts/**/*').select do |post| - post[:academic_year] == item[:academic_year] - end - + layout '/archive_page.*' layout '/generic.*' layout '/default.*' filter :erb @@ -80,6 +76,14 @@ compile '/posts/**/*', rep: :text do filter :strip_html end +compile '/*.erb' do + layout '/generic.*' + layout '/default.*' + filter :erb + + filter :relativize_paths, type: :html +end + route '/index.*' do '/index.html' end diff --git a/layouts/archive_page.erb b/layouts/archive_page.erb new file mode 100644 index 0000000..d8a056d --- /dev/null +++ b/layouts/archive_page.erb @@ -0,0 +1,10 @@ +<% posts_in_year(item[:academic_year]).each do |post| %> + +
+ <%= post[:title] %> +
+
+ <%= excerptize(post.reps[:text].compiled_content, length: 200) %> +
+
+<% end %> diff --git a/layouts/partials/_navbar.erb b/layouts/partials/_navbar.erb index 98a098b..0b3961f 100644 --- a/layouts/partials/_navbar.erb +++ b/layouts/partials/_navbar.erb @@ -2,14 +2,14 @@ About - - All posts + + Archief Contact - Search + Zoeken Cammie diff --git a/lib/archives.rb b/lib/archives.rb index c95ed46..adff811 100644 --- a/lib/archives.rb +++ b/lib/archives.rb @@ -14,7 +14,13 @@ module ArchiveHelper academic_years.map { |y| [y, items["/archives/#{y}-#{y + 1}.html"]] }.to_h end - def pretty_year(y) - "'#{y} - '#{y + 1}" + def pretty_year(year) + "'#{year} - '#{year + 1}" + end + + def posts_in_year(academic_year) + items.find_all('/posts/**/*').select do |post| + post[:academic_year] == academic_year + end end end