Merge pull request #411 from ZeusWPI/events/tags

Events/tags
This commit is contained in:
redfast00 2020-11-19 04:58:38 +01:00 committed by GitHub
commit c2a1000a29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 134 additions and 16 deletions

2
Rules
View file

@ -24,6 +24,8 @@ preprocess do
update_blog_attributes
create_yearly_items('Blog')
create_yearly_items('Events')
create_tagly_items('Blog')
create_tagly_items('Events')
convert_event_time_to_timestamps
all_events.each do |event|

View file

@ -3,6 +3,8 @@ title: "Zeus en Corona"
created_at: 11-03-2020
description: Corona en de invloed ervan op Zeus WPI
author: Robbe Van Herck
tags:
- Corona
---
Beste Zeussers en Zeusinnen,

View file

@ -4,6 +4,8 @@ title: "Het vervolg op het avontuur van de Vleor"
created_at: 07-07-2020
description: Eindelijk, de Zeuskelder heeft weer een nieuwe vloer!
toc: true
tags:
- vloer
---
**vleor** (_de; m;_ meervoud: _vleoren_)

View file

@ -3,6 +3,8 @@ title: "Zeusbestuur 2020-2021"
created_at: 6-7-2020
description: "Het gloriZeuse nieuw bestuur"
author: "Robbe Van Herck"
tags:
- Bestuur
---
> Hallo mijn naam is Jasper en ik zou nog steeds sysadmin willen blijven
@ -25,4 +27,3 @@ Voor iedereen die niet op de verkiezingen was of de uitslag vergeten is, hier ee
| Evenementen | Ruben De Facq |
Veel succes en veel plezier van jullie oud bestuur. Het gaat gegarandeerd onvergetelijk worden! 🧡

View file

@ -3,6 +3,9 @@ title: "Wij coden voort"
created_at: 21-7-2020
description: "We mogen de kelder opnieuw openen"
author: "Jasper Devreker"
tags:
- Corona
- General
---
We hebben via het WVK[^wvk] doorgekregen dat we onze geliefde kelder terug mogen openen.

View file

@ -9,6 +9,8 @@ locationlink: $s9
facebook: //www.facebook.com/events/2759136070856741/
banner: //zeus.ugent.be/zeuswpi/Itsb0YbN.png
header_text_background: true
tags:
- Code Hacking
---
@ -31,4 +33,3 @@ Er kunnen snacks en drank gekocht worden op het event. Er zal ook om takeaway ge
[hacktob]: https://hacktoberfest.digitalocean.com/
[gandalf]: https://event.fkgent.be/events/305

View file

@ -11,6 +11,8 @@ banner: //zeus.ugent.be/zeuswpi/7k6hvPJw.webp
image: //zeus.ugent.be/zeuswpi/a28GvLuO.png
header_text_background: true
header_text_background_color: 'rgba(80, 50, 80, 0.75)'
tags:
- Esoterisch
---
UPDATE: datum veranderd naar 28 oktober!

View file

@ -19,24 +19,41 @@
<% end %>
<% end %>
</ul>
<p class="menu-label">
Tag
</p>
<ul class="menu-list">
<% tag_blog_items.each do |tag, item| %>
<% if @item_rep && @item_rep.path == item.path %>
<li>
<a href="#" class="is-active">
<%= tag %>
</a>
</li>
<% else %>
<li>
<%= link_to tag, item %>
</li>
<% end %>
<% end %>
</ul>
</aside>
</div>
<div class="column">
<div class="columns is-multiline">
<div class="column">
<% posts_in_year(item[:academic_year]).each_with_index.select {|e, i| i.even?}.map(&:first).each do |post| %>
<% posts_in_year_or_with_tag(item).each_with_index.select {|e, i| i.even?}.map(&:first).each do |post| %>
<%= render '/partials/_blog_preview.*', post: post %>
<% end %>
</div>
<div class="column">
<% posts_in_year(item[:academic_year]).each_with_index.reject {|e, i| i.even?}.map(&:first).each do |post| %>
<% posts_in_year_or_with_tag(item).each_with_index.reject {|e, i| i.even?}.map(&:first).each do |post| %>
<%= render '/partials/_blog_preview.*', post: post %>
<% end %>
</div>
</div>
<% if posts_in_year(@item[:academic_year]).empty? %>
<% if posts_in_year_or_with_tag(item).empty? %>
<div class="content has-text-centered">
<h1>Sorry.</h1>
<h2>No blog posts yet this year.</h2>

View file

@ -19,15 +19,33 @@
<% end %>
<% end %>
</ul>
<p class="menu-label">
Tag
</p>
<ul class="menu-list">
<% tag_event_items.each do |tag, item| %>
<% if @item_rep && @item_rep.path == item.path %>
<li>
<a href="#" class="is-active">
<%= tag %>
</a>
</li>
<% else %>
<li>
<%= link_to tag, item %>
</li>
<% end %>
<% end %>
</ul>
</aside>
</div>
<div class="column">
<% unless upcoming_events(@item[:academic_year]).empty? %>
<% unless upcoming_events_in_year_or_tag(@item).empty? %>
<div class="content">
<h1>Upcoming events</h1>
</div>
<% upcoming_events(@item[:academic_year]).each_slice(1) do |slice| %>
<% upcoming_events_in_year_or_tag(@item).each_slice(1) do |slice| %>
<div class="columns">
<% slice.each do |event| %>
<div class="tile is-parent ">
@ -38,11 +56,11 @@
<% end %>
<% end %>
<% unless past_events(@item[:academic_year]).empty? %>
<% unless past_events_in_year_or_tag(@item).empty? %>
<div class="content">
<h1>Past events</h1>
</div>
<% past_events(@item[:academic_year]).each_slice(1) do |slice| %>
<% past_events_in_year_or_tag(@item).each_slice(1) do |slice| %>
<div class="columns">
<% slice.each do |event| %>
<div class="tile is-parent ">
@ -53,7 +71,7 @@
<% end %>
<% end %>
<% if past_events(@item[:academic_year]).empty? and upcoming_events(@item[:academic_year]).empty? %>
<% if past_events_in_year_or_tag(@item).empty? and upcoming_events_in_year_or_tag(@item).empty? %>
<div class="content has-text-centered">
<h1>Sorry.</h1>
<h2>No events planned yet this year.</h2>

View file

@ -3,8 +3,8 @@ module ArchiveHelper
# Set.to_a to prevent duplicates
Set.new(items
.find_all('/blog/*/*')
.map { |i| i.identifier.to_s[/\d\d-\d\d/] })
.to_a
.map { |i| i.identifier.to_s.split('/')[-2] })
.to_a
.sort
.push(@config[:academic_year])
.uniq
@ -14,6 +14,15 @@ module ArchiveHelper
academic_years.reverse.map { |y| [y, items["/blog/#{y}.html"]] }
end
def tag_blog_items
Set.new(items
.find_all('/blog/*/*')
.flat_map { |i| i[:tags] || [] })
.to_a
.sort
.uniq.map { |y| [y, items["/blog/#{y.gsub(' ', '_')}.html"]]}
end
def pretty_year(year)
year = year.scan(/\d\d/)
"'#{year[0]} - '#{year[1]}"
@ -22,4 +31,18 @@ module ArchiveHelper
def posts_in_year(y)
items.find_all("/blog/#{y}/*").sort_by { |x| x[:created_at] }.reverse
end
def posts_with_tag(tag)
items
.find_all('/blog/*/*')
.filter{|i| (i[:tags] || []).include? tag }
end
def posts_in_year_or_with_tag(item)
if item[:is_yearly]
posts_in_year(item[:academic_year])
else
posts_with_tag(item[:tag])
end
end
end

View file

@ -13,6 +13,22 @@ module EventsHelper
items_.select { |x| x[:soon] == soon }.sort_by { |x| x[:time] }
end
def tag_event_items
Set.new(items
.find_all('/events/*/*')
.flat_map { |i| i[:tags] || [] })
.to_a
.sort
.uniq.map { |y| [y, items["/events/#{y.gsub(' ', '_')}.html"]]}
end
def all_events_by_tag(tag = nil, soon = nil)
@items.find_all('/events/*/*.md')
.filter{|i| (i[:tags] || []).include? tag }
.select { |x| x[:soon] == soon }
.sort_by { |x| x[:time] }
end
def soon_events
all_events(nil, true)
end
@ -21,12 +37,28 @@ module EventsHelper
all_events(year).reject { |x| x[:time] <= Date.today }
end
def upcoming_events_in_year_or_tag(item)
if item[:is_yearly]
upcoming_events(item[:academic_year])
else
all_events_by_tag(item[:tag]).reject { |x| x[:time] <= Date.today }
end
end
def past_events(year = nil)
all_events(year).reject { |x| x[:time] > Date.today }.reverse
end
def past_events_in_year_or_tag(item)
if item[:is_yearly]
past_events(item[:academic_year])
else
all_events_by_tag(item[:tag]).reject { |x| x[:time] > Date.today }.reverse
end
end
def academic_years_event_items
items.find_all('/events/*').map { |e| [e[:academic_year], e] }.sort_by(&:first).reverse
items.find_all('/events/*').reject { |e| e[:academic_year].nil? }.map { |e| [e[:academic_year], e] }.sort_by(&:first).reverse
end
def grouped_events

View file

@ -56,7 +56,7 @@ module PreprocessHelper
i.update_attributes(
# Tag all posts with article (for Blogging helper)
kind: 'article',
academic_year: i.identifier.to_s[/\d\d-\d\d/],
academic_year: i.identifier.to_s[/\d-\d/],
created_at: Date.parse(i[:created_at])
)
end
@ -72,7 +72,7 @@ module PreprocessHelper
years.each do |year|
@items.create(
'',
{ academic_year: year, title: type },
{ academic_year: year, title: type, is_yearly: true },
"/#{type.downcase}/#{year}.html"
)
end
@ -84,6 +84,21 @@ module PreprocessHelper
)
end
def create_tagly_items(type)
type = type.to_s
tags = @items.find_all("/#{type.downcase}/*/*")
.flat_map { |i| i[:tags] || [] }
.uniq
tags.each do |tag|
@items.create(
'',
{ tag: tag, title: type, is_yearly: false },
"/#{type.downcase}/#{tag.gsub(' ', '_')}.html"
)
end
end
def convert_event_time_to_timestamps
@items.find_all('/events/*/*.md').each do |event|
# HACK: Strings in a format like "2017-10-05T20:45:00+0200" automatically get converted to Time