Calculate end dates, show in calendar

This commit is contained in:
Stefan Schlott 2013-08-27 18:57:14 +02:00
parent d980530cb9
commit 1341647c2a
4 changed files with 29 additions and 3 deletions

1
Rules
View file

@ -3,6 +3,7 @@
preprocess do
expand_event_list("/_data/chaosevents/")
expand_event_list("/_data/stammtisch/", "CCCS Stammtisch")
calculate_to_dates
merge_location_data
generate_event_pages
generate_activity_pages

View file

@ -3,7 +3,7 @@ events:
-
#kind: event
startdate: 2013-09-06
duration: 2d
duration: 3d
title: "MRMCD2013 - Security Advice"
url: http://mrmcd.net/
location:
@ -15,7 +15,7 @@ events:
#public: true
-
startdate: 2013-12-27
duration: 3d
duration: 4d
title: "30C3"
url: https://events.ccc.de/
location:

View file

@ -9,7 +9,15 @@ if (upcomingEvents.size>0)
<ul>
<% upcomingEvents[0..9].each do |e| %>
<li>
<%= e[:startdate].strftime("%d.%m.") %>
<% if e[:startdate].instance_of?(Date) %>
<% if e[:startdate]<e[:enddate] %>
<%= e[:startdate].strftime("%d.%m.") %> - <%= e[:enddate].strftime("%d.%m.") %>:
<% else %>
<%= e[:startdate].strftime("%d.%m.") %>:
<% end %>
<% else %>
<%= e[:startdate].strftime("%d.%m., %H:%M") %>:
<% end %>
<% if e[:url] %><a href="<%= e[:url] %>"><%= e[:title] %></a><% else %><%= e[:title] %><% end %>
</li>
<% end %>

View file

@ -24,3 +24,20 @@ def get_public_events()
items.select { |i| (i[:kind]=='event') && i[:public] }
end
def calculate_to_dates()
items.select { |i| (i[:kind]=='event') && i[:duration] }.each do |e|
if e[:startdate].instance_of?(Date)
if e[:duration] =~ /(\d+)d/
e[:enddate] = e[:startdate] + ($1.to_i - 1)
end
else
if e[:duration] =~ /(\d+)h/
e[:enddate] = e[:startdate] + 60*60*$1.to_i
end
if e[:duration] =~ /(\d+)m/
e[:enddate] = e[:startdate] + 60*$1.to_i
end
end
end
end