prepare events for new year, fixes #173 (#178)

* prepare events for new year, fixes #173

* remove unnused method

* remove dummy event
This commit is contained in:
lorin 2017-06-07 10:23:02 +02:00 committed by Wout Schellaert
parent 2d78c03fe7
commit c8797ec86a
8 changed files with 110 additions and 53 deletions

18
Rules
View file

@ -16,7 +16,8 @@ preprocess do
# We don't want to compile old blogposts in development # We don't want to compile old blogposts in development
ignore_old_blogposts if development? ignore_old_blogposts if development?
update_blog_attributes update_blog_attributes
create_blog_items create_yearly_items('Blog')
create_yearly_items('Events')
convert_event_time_to_timestamps convert_event_time_to_timestamps
end end
@ -42,7 +43,16 @@ end
# #
# EVENTS # EVENTS
# #
compile '/events/**/*' do
# Overview page
compile '/events/*' do
layout '/events.*'
layout '/generic.*'
layout '/default.*'
filter :erb
end
compile '/events/*/*' do
filter :kramdown filter :kramdown
layout '/eventpost.*' layout '/eventpost.*'
@ -50,12 +60,12 @@ compile '/events/**/*' do
filter :erb filter :erb
end end
compile '/events/**/*', rep: :text do compile '/events/*/*', rep: :text do
filter :kramdown filter :kramdown
filter :strip_html filter :strip_html
end end
compile '/events/**/*', rep: :ical do compile '/events/*/*', rep: :ical do
filter :ical filter :ical
write ext: 'ics' write ext: 'ics'
end end

View file

@ -35,7 +35,6 @@
#logo-link { #logo-link {
#logo { #logo {
padding-top: 10px;
padding-left: 10px; padding-left: 10px;
width: 100px; width: 100px;
} }
@ -75,3 +74,13 @@
} }
} }
} }
.hero {
#logo {
padding-top: 25px;
}
.nav-right {
padding-right: 10px;
}
}

View file

@ -1,34 +0,0 @@
---
navigable: true
title: Events
order: 20
---
<div class="container">
<div class="content">
<h1>Upcoming events</h1>
</div>
<% upcoming_events.each_slice(2) do |slice| %>
<div class="columns">
<% slice.each do |event| %>
<div class="tile is-parent ">
<%= render '/partials/_events_tile.*', event: event %>
</div>
<% end %>
</div>
<% end %>
</div>
<div class="container">
<div class="content">
<h1>Past events</h1>
</div>
<% past_events.each_slice(2) do |slice| %>
<div class="columns">
<% slice.each do |event| %>
<div class="tile is-parent ">
<%= render '/partials/_events_tile.*', event: event %>
</div>
<% end %>
</div>
<% end %>
</div>

View file

@ -5,7 +5,7 @@
Academiejaar Academiejaar
</p> </p>
<ul class="menu-list"> <ul class="menu-list">
<% academic_years_items.each do |year, item| %> <% academic_years_blog_items.each do |year, item| %>
<% if @item_rep && @item_rep.path == item.path %> <% if @item_rep && @item_rep.path == item.path %>
<li> <li>
<a href="#" class="is-active"> <a href="#" class="is-active">

56
layouts/events.erb Normal file
View file

@ -0,0 +1,56 @@
<div class="columns">
<div class="column is-2 is-narrow">
<aside class="menu">
<p class="menu-label">
Academiejaar
</p>
<ul class="menu-list">
<% academic_years_event_items.each do |year, item| %>
<% if @item_rep && @item_rep.path == item.path %>
<li>
<a href="#" class="is-active">
<%= pretty_year(year) %>
</a>
</li>
<% else %>
<li>
<%= link_to pretty_year(year), item %>
</li>
<% end %>
<% end %>
</ul>
</aside>
</div>
<div class="column">
<% unless upcoming_events(@item[:academic_year]).empty? %>
<div class="content">
<h1>Upcoming events</h1>
</div>
<% upcoming_events(@item[:academic_year]).each_slice(2) do |slice| %>
<div class="columns">
<% slice.each do |event| %>
<div class="tile is-parent ">
<%= render '/partials/_events_tile.*', event: event %>
</div>
<% end %>
</div>
<% end %>
<% end %>
<% unless past_events(@item[:academic_year]).empty? %>
<div class="content">
<h1>Past events</h1>
</div>
<% past_events(@item[:academic_year]).each_slice(2) do |slice| %>
<div class="columns">
<% slice.each do |event| %>
<div class="tile is-parent ">
<%= render '/partials/_events_tile.*', event: event %>
</div>
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>

View file

@ -3,7 +3,7 @@ module ArchiveHelper
Set.new(items.find_all('/blog/*/*').map { |i| i.identifier.to_s[/\d\d-\d\d/] }).to_a Set.new(items.find_all('/blog/*/*').map { |i| i.identifier.to_s[/\d\d-\d\d/] }).to_a
end end
def academic_years_items def academic_years_blog_items
academic_years.reverse.map { |y| [y, items["/blog/#{y}.html"]] } academic_years.reverse.map { |y| [y, items["/blog/#{y}.html"]] }
end end

View file

@ -1,17 +1,31 @@
# frozen_string_literal: true
require 'uri' require 'uri'
module EventsHelper module EventsHelper
def all_events def all_events(year = nil)
@items.find_all('/events/*/*.md').sort_by { |x| x[:time] } items_ = if year
@items.find_all("/events/#{year}/*.md")
else
@items.find_all('/events/*/*.md')
end
items_.sort_by { |x| x[:time] }
end end
def upcoming_events def upcoming_events(year = nil)
all_events.reject { |x| x[:time] <= Date.today } all_events(year).reject { |x| x[:time] <= Date.today }
end end
def past_events def past_events(year = nil)
all_events.reject { |x| x[:time] > Date.today }.reverse all_events(year).reject { |x| x[:time] > Date.today }.reverse
end end
def academic_years_event_items
items.find_all('/events/*').map { |e| [e[:academic_year], e] }.reverse
end
def grouped_events def grouped_events
@items.find_all('/events/*/*/main.md') @items.find_all('/events/*/*/main.md')
end end

View file

@ -18,17 +18,19 @@ module PreprocessHelper
end end
end end
def create_blog_items def create_yearly_items(type)
# academic_years is defined in archives.rb type = type.to_s
academic_years.each do |year| years = @items.find_all("/#{type.downcase}/*/*").map { |i| i.identifier.to_s[/\d\d-\d\d/] }.uniq
years.each do |year|
@items.create( @items.create(
'', '',
{ academic_year: year, title: 'Blog' }, { academic_year: year, title: type },
"/blog/#{year}.html" "/#{type.downcase}/#{year}.html"
) )
end end
academic_years_items[0][1].update_attributes( @items["/#{type.downcase}/#{years[-1]}.html"].update_attributes(
navigable: true, navigable: true,
order: 10 order: 10
) )