From 14ffd7a1ff75df6abb5421824bad438aebc85a5d Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Sat, 23 Jul 2016 21:17:24 +0200 Subject: [PATCH] mucho worko --- .travis.yml | 1 - Rules | 37 ++++++++++++++++++++++--- content/archives.erb | 7 +++++ content/index.erb | 43 ++++++------------------------ content/posts/{ => 15-16}/awk.md | 0 content/posts/{ => 15-16}/xtext.md | 0 content/posts/16-17/dink.md | 13 +++++++++ content/search.erb | 42 ++++++++--------------------- layouts/generic.erb | 28 +++++++++++++++++++ lib/archives.rb | 20 ++++++++++++++ lib/{builtin.rb => helpers.rb} | 3 +++ lib/strip_filter.rb | 2 -- 12 files changed, 124 insertions(+), 72 deletions(-) create mode 100644 content/archives.erb rename content/posts/{ => 15-16}/awk.md (100%) rename content/posts/{ => 15-16}/xtext.md (100%) create mode 100644 content/posts/16-17/dink.md create mode 100644 layouts/generic.erb create mode 100644 lib/archives.rb rename lib/{builtin.rb => helpers.rb} (71%) diff --git a/.travis.yml b/.travis.yml index 738191b..3c7664f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,4 @@ script: after_success: - mv deploy_key ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa -- chmod +x .travis/deploy.sh - '[[ $TRAVIS_BRANCH == "master" ]] && bundle exec nanoc deploy --target public' diff --git a/Rules b/Rules index 71e0250..01d4a99 100644 --- a/Rules +++ b/Rules @@ -4,9 +4,27 @@ require 'json' preprocess do - # Tag all posts with 'article' @items.find_all('/posts/**/*').each do |i| - i.attributes[:kind] = 'article' + year_str = %r{/(\d\d)-\d\d/}.match(i.identifier).captures[0] + academic_year = year_str.to_i + + attr_hash = { + # Tag all posts with article (for Blogging helper) + kind: 'article', + academic_year: academic_year + } + + i.update_attributes(attr_hash) + end + + # academic_years is defined in archives.rb + academic_years.each do |year| + @items.create( + '', + { academic_year: year }, + "/archives/#{year}-#{year + 1}.html", + binary: false + ) end @items.create('', {}, '/tipuesearch_content.js', binary: false) @@ -17,9 +35,22 @@ passthrough '/tipuesearch_content.js' # ERB compile '/*.erb' do + layout '/generic.*' layout '/default.*' - filter :erb + + filter :relativize_paths, type: :html +end + +compile '/archives/*' do + posts = items.find_all('/posts/**/*').select do |post| + post[:academic_year] == item[:academic_year] + end + + layout '/generic.*' + layout '/default.*' + filter :erb + filter :relativize_paths, type: :html end diff --git a/content/archives.erb b/content/archives.erb new file mode 100644 index 0000000..2872249 --- /dev/null +++ b/content/archives.erb @@ -0,0 +1,7 @@ + diff --git a/content/index.erb b/content/index.erb index 3a667f1..f06390e 100644 --- a/content/index.erb +++ b/content/index.erb @@ -1,37 +1,10 @@ -
-
-
-
- - - <%= render '/partials/_navbar.*' %> -
-
-
- <%= render '/partials/_tile.*', article: sorted_articles[0] %> -
- <% sorted_articles[1..-1].each do |article| %> -
- <%= render '/partials/_tile.*', article: article %> -
- <% end %> -
-
-
+
+ <%= render '/partials/_tile.*', article: sorted_articles[0] %> +
+ <% sorted_articles[1..-1].each do |article| %> +
+ <%= render '/partials/_tile.*', article: article %> +
+ <% end %>
diff --git a/content/posts/awk.md b/content/posts/15-16/awk.md similarity index 100% rename from content/posts/awk.md rename to content/posts/15-16/awk.md diff --git a/content/posts/xtext.md b/content/posts/15-16/xtext.md similarity index 100% rename from content/posts/xtext.md rename to content/posts/15-16/xtext.md diff --git a/content/posts/16-17/dink.md b/content/posts/16-17/dink.md new file mode 100644 index 0000000..72c2059 --- /dev/null +++ b/content/posts/16-17/dink.md @@ -0,0 +1,13 @@ +--- +title: AWK-les +banner: https://upload.wikimedia.org/wikipedia/commons/6/61/Een.jpg +created_at: 23-10-2016 +time: 23-10-2016 +location: Auditorium A1, Campus Sterre, Gebouw S9 +--- + +Op **dinsdag 23 februari 18:00** (na de les Scriptingtalen) in **Auditorium A1** organiseren we een **AWK-les** gegeven door **professor Peter Dawyndt**. + +**AWK** is een scriptingtaal, bedoeld om lijn per lijn tekstbestanden te verwerken. Zo wordt AWK vaak gebruikt voor de ingebouwde werking met delimiters om CSV bestanden en dergelijke te verwerken. AWK staat tevens bekend om de talloze [one-liners](http://www.pement.org/awk/awk1line.txt) die in de command line gebruikt kunnen worden. + +Sinds vorig jaar wordt AWK (samen met sed) niet meer gegeven in het vak Scriptingtalen, om meer te kunnen concentreren op Python en JavaScript. Hoewel deze zeer goede general purpose talen zijn, blijft AWK ongeƫvenaard voor razendsnelle tekstverwerking en transformaties. diff --git a/content/search.erb b/content/search.erb index 1a92bad..4bc0e7d 100644 --- a/content/search.erb +++ b/content/search.erb @@ -1,31 +1,11 @@ -
-
-
- - <%= render '/partials/_navbar.*' %> -
- -
-
- -
-
+
+ +
+
+ diff --git a/layouts/generic.erb b/layouts/generic.erb new file mode 100644 index 0000000..a312454 --- /dev/null +++ b/layouts/generic.erb @@ -0,0 +1,28 @@ +
+
+
+
+ + + <%= render '/partials/_navbar.*' %> +
+
+ <%= yield %> +
+
+
diff --git a/lib/archives.rb b/lib/archives.rb new file mode 100644 index 0000000..c95ed46 --- /dev/null +++ b/lib/archives.rb @@ -0,0 +1,20 @@ +module ArchiveHelper + def academic_years + academic_years = Set.new + + @items.find_all('/posts/**/*').each do |i| + academic_year = %r{/(\d\d)-\d\d/}.match(i.identifier).captures[0] + academic_years << academic_year.to_i + end + + academic_years + end + + def academic_years_items + academic_years.map { |y| [y, items["/archives/#{y}-#{y + 1}.html"]] }.to_h + end + + def pretty_year(y) + "'#{y} - '#{y + 1}" + end +end diff --git a/lib/builtin.rb b/lib/helpers.rb similarity index 71% rename from lib/builtin.rb rename to lib/helpers.rb index 9486cb2..be8a7a4 100644 --- a/lib/builtin.rb +++ b/lib/helpers.rb @@ -2,3 +2,6 @@ include Nanoc::Helpers::Blogging include Nanoc::Helpers::Capturing include Nanoc::Helpers::LinkTo include Nanoc::Helpers::Rendering +include Nanoc::Helpers::Text + +include ArchiveHelper diff --git a/lib/strip_filter.rb b/lib/strip_filter.rb index 21252a9..6b03ce9 100644 --- a/lib/strip_filter.rb +++ b/lib/strip_filter.rb @@ -1,5 +1,3 @@ -include Nanoc::Helpers::Text - class StripFilter < Nanoc::Filter identifier :strip_html