events a bit more
This commit is contained in:
parent
bc5da5b81e
commit
ec990ac755
6 changed files with 54 additions and 14 deletions
2
Gemfile
2
Gemfile
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
gem 'nanoc', '~>4.2'
|
gem 'nanoc', '~>4.3.1'
|
||||||
gem 'kramdown'
|
gem 'kramdown'
|
||||||
gem 'coffee-script'
|
gem 'coffee-script'
|
||||||
# Needed for relativize_urls
|
# Needed for relativize_urls
|
||||||
|
|
|
@ -3,7 +3,7 @@ GEM
|
||||||
specs:
|
specs:
|
||||||
adsf (1.2.1)
|
adsf (1.2.1)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
autoprefixer-rails (6.4.0.2)
|
autoprefixer-rails (6.4.0.3)
|
||||||
execjs
|
execjs
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
coderay (1.1.1)
|
coderay (1.1.1)
|
||||||
|
@ -45,7 +45,7 @@ GEM
|
||||||
lumberjack (1.0.10)
|
lumberjack (1.0.10)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mini_portile2 (2.1.0)
|
mini_portile2 (2.1.0)
|
||||||
nanoc (4.3.0)
|
nanoc (4.3.2)
|
||||||
cri (~> 2.3)
|
cri (~> 2.3)
|
||||||
hamster (~> 3.0)
|
hamster (~> 3.0)
|
||||||
ref (~> 2.0)
|
ref (~> 2.0)
|
||||||
|
@ -87,7 +87,7 @@ DEPENDENCIES
|
||||||
highline
|
highline
|
||||||
icalendar
|
icalendar
|
||||||
kramdown
|
kramdown
|
||||||
nanoc (~> 4.2)
|
nanoc (~> 4.3.1)
|
||||||
nokogiri
|
nokogiri
|
||||||
sass
|
sass
|
||||||
w3c_validators
|
w3c_validators
|
||||||
|
|
25
content/events.erb
Normal file
25
content/events.erb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
navigable: true
|
||||||
|
title: Events
|
||||||
|
---
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class="content">
|
||||||
|
<h1>Upcoming events</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% all_events.each do |event| %>
|
||||||
|
<div class="box">
|
||||||
|
<a href="<%= relative_path_to(event) %>">
|
||||||
|
<%= event[:title] %>
|
||||||
|
</a>
|
||||||
|
<% sub_events(event).each do |sub_event| %>
|
||||||
|
[
|
||||||
|
<a href="<%= relative_path_to(sub_event) %>">
|
||||||
|
<%= sub_event[:title] %>
|
||||||
|
</a>
|
||||||
|
]
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
|
@ -1,11 +1,5 @@
|
||||||
# This doesn't use the new define syntax yet because item
|
Nanoc::Filter.define(:ical) do |_content, _params|
|
||||||
# is not available there
|
|
||||||
class IcalFilter < Nanoc::Filter
|
|
||||||
identifier :ical
|
|
||||||
|
|
||||||
def run(_content, _params = {})
|
|
||||||
cal = Icalendar::Calendar.new
|
cal = Icalendar::Calendar.new
|
||||||
cal.add_event(event_for(item))
|
cal.add_event(event_for(item))
|
||||||
cal.to_ical
|
cal.to_ical
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
20
lib/helpers/events.rb
Normal file
20
lib/helpers/events.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module EventsHelper
|
||||||
|
def all_events
|
||||||
|
@items.find_all('/events/*/*') + grouped_events
|
||||||
|
end
|
||||||
|
|
||||||
|
def grouped_events
|
||||||
|
@items.find_all('/events/*/*/main.md')
|
||||||
|
end
|
||||||
|
|
||||||
|
def sub_events(grouped_event)
|
||||||
|
if grouped_event.identifier =~ /main.md/
|
||||||
|
query = grouped_event.identifier.to_s.split('/')[0..-2].join('/') + '/*'
|
||||||
|
@items.find_all(query).reject do |i|
|
||||||
|
i.identifier =~ /main.md/
|
||||||
|
end
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,6 +6,7 @@ include Nanoc::Helpers::Text
|
||||||
|
|
||||||
include ArchiveHelper
|
include ArchiveHelper
|
||||||
include AssetHelper
|
include AssetHelper
|
||||||
|
include EventsHelper
|
||||||
include IcalHelper
|
include IcalHelper
|
||||||
include NavigationHelper
|
include NavigationHelper
|
||||||
include DataHelper
|
include DataHelper
|
||||||
|
|
Loading…
Reference in a new issue