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
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'nanoc', '~>4.2'
|
||||
gem 'nanoc', '~>4.3.1'
|
||||
gem 'kramdown'
|
||||
gem 'coffee-script'
|
||||
# Needed for relativize_urls
|
||||
|
|
|
@ -3,7 +3,7 @@ GEM
|
|||
specs:
|
||||
adsf (1.2.1)
|
||||
rack (>= 1.0.0)
|
||||
autoprefixer-rails (6.4.0.2)
|
||||
autoprefixer-rails (6.4.0.3)
|
||||
execjs
|
||||
builder (3.2.2)
|
||||
coderay (1.1.1)
|
||||
|
@ -45,7 +45,7 @@ GEM
|
|||
lumberjack (1.0.10)
|
||||
method_source (0.8.2)
|
||||
mini_portile2 (2.1.0)
|
||||
nanoc (4.3.0)
|
||||
nanoc (4.3.2)
|
||||
cri (~> 2.3)
|
||||
hamster (~> 3.0)
|
||||
ref (~> 2.0)
|
||||
|
@ -87,7 +87,7 @@ DEPENDENCIES
|
|||
highline
|
||||
icalendar
|
||||
kramdown
|
||||
nanoc (~> 4.2)
|
||||
nanoc (~> 4.3.1)
|
||||
nokogiri
|
||||
sass
|
||||
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
|
||||
# is not available there
|
||||
class IcalFilter < Nanoc::Filter
|
||||
identifier :ical
|
||||
|
||||
def run(_content, _params = {})
|
||||
cal = Icalendar::Calendar.new
|
||||
cal.add_event(event_for(item))
|
||||
cal.to_ical
|
||||
end
|
||||
Nanoc::Filter.define(:ical) do |_content, _params|
|
||||
cal = Icalendar::Calendar.new
|
||||
cal.add_event(event_for(item))
|
||||
cal.to_ical
|
||||
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 AssetHelper
|
||||
include EventsHelper
|
||||
include IcalHelper
|
||||
include NavigationHelper
|
||||
include DataHelper
|
||||
|
|
Loading…
Reference in a new issue