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
ignore_old_blogposts if development?
update_blog_attributes
create_blog_items
create_yearly_items('Blog')
create_yearly_items('Events')
convert_event_time_to_timestamps
end
@ -42,7 +43,16 @@ end
#
# EVENTS
#
compile '/events/**/*' do
# Overview page
compile '/events/*' do
layout '/events.*'
layout '/generic.*'
layout '/default.*'
filter :erb
end
compile '/events/*/*' do
filter :kramdown
layout '/eventpost.*'
@ -50,12 +60,12 @@ compile '/events/**/*' do
filter :erb
end
compile '/events/**/*', rep: :text do
compile '/events/*/*', rep: :text do
filter :kramdown
filter :strip_html
end
compile '/events/**/*', rep: :ical do
compile '/events/*/*', rep: :ical do
filter :ical
write ext: 'ics'
end

View file

@ -35,7 +35,6 @@
#logo-link {
#logo {
padding-top: 10px;
padding-left: 10px;
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
</p>
<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 %>
<li>
<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
end
def academic_years_items
def academic_years_blog_items
academic_years.reverse.map { |y| [y, items["/blog/#{y}.html"]] }
end

View file

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

View file

@ -18,17 +18,19 @@ module PreprocessHelper
end
end
def create_blog_items
# academic_years is defined in archives.rb
academic_years.each do |year|
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.each do |year|
@items.create(
'',
{ academic_year: year, title: 'Blog' },
"/blog/#{year}.html"
{ academic_year: year, title: type },
"/#{type.downcase}/#{year}.html"
)
end
academic_years_items[0][1].update_attributes(
@items["/#{type.downcase}/#{years[-1]}.html"].update_attributes(
navigable: true,
order: 10
)