From d980530cb95745b9e1d442c57f1ef8bdd0e5bead Mon Sep 17 00:00:00 2001 From: Stefan Schlott Date: Tue, 27 Aug 2013 18:32:04 +0200 Subject: [PATCH] Fix possible problems with Date/Time comparison. Calendar in sidebar. --- content/index.html | 8 ++++---- content/sidebar.html | 14 +++++++++++++- lib/eventhelpers.rb | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/content/index.html b/content/index.html index 92569ca2..2784969a 100644 --- a/content/index.html +++ b/content/index.html @@ -29,9 +29,9 @@ feed:
- <% upcomingEvents = get_events().select { |e| e[:startdate] > Time.now } + <% upcomingEvents = get_events().select { |e| e[:startdate].to_datetime > DateTime.now } if (upcomingEvents.size>0) - upcomingEvents.sort! { |a,b| a[:startdate] <=> b[:startdate] } + upcomingEvents.sort! { |a,b| a[:startdate].to_datetime <=> b[:startdate].to_datetime } %>
@@ -47,9 +47,9 @@ feed:
<% end %> - <% upcomingRegularsTable = get_regulars_tables().select { |e| e[:startdate] > Time.now } + <% upcomingRegularsTable = get_regulars_tables().select { |e| e[:startdate].to_datetime > DateTime.now } if (upcomingRegularsTable.size>0) - upcomingRegularsTable.sort! { |a,b| a[:startdate] <=> b[:startdate] } + upcomingRegularsTable.sort! { |a,b| a[:startdate].to_datetime <=> b[:startdate].to_datetime } %>
diff --git a/content/sidebar.html b/content/sidebar.html index 77c46a6c..212d4b8d 100644 --- a/content/sidebar.html +++ b/content/sidebar.html @@ -1,8 +1,20 @@ ----- style: none ----- +<% upcomingEvents = get_public_events().select { |e| e[:startdate].to_datetime > DateTime.now } +if (upcomingEvents.size>0) + upcomingEvents.sort! { |a,b| a[:startdate].to_datetime <=> b[:startdate].to_datetime } +%>

Kalender

- +
    + <% upcomingEvents[0..9].each do |e| %> +
  • + <%= e[:startdate].strftime("%d.%m.") %> + <% if e[:url] %><%= e[:title] %><% else %><%= e[:title] %><% end %> +
  • + <% end %> +
+<% end %>

Letzte Tweets

<%= render 'twitter_list', :items => twitter_by_date().first(5) %> diff --git a/lib/eventhelpers.rb b/lib/eventhelpers.rb index 9c269d13..68a81eb7 100644 --- a/lib/eventhelpers.rb +++ b/lib/eventhelpers.rb @@ -20,4 +20,7 @@ def get_regulars_tables() items.select { |i| (i[:kind]=='event') && i.identifier.start_with?('/_data/stammtisch/') } end +def get_public_events() + items.select { |i| (i[:kind]=='event') && i[:public] } +end