Display nsltv seperated in calender widget.

This commit is contained in:
simplefl 2015-07-18 12:33:09 +02:00
parent cf8c9d3ed0
commit 9d8b84b3e0
2 changed files with 41 additions and 2 deletions

View file

@ -171,8 +171,26 @@ module ApplicationHelper
end
end
def nsltv_regex
/\[NSLTV\]/i
end
def upcoming_matches
GoogleCalendar.new(ENV['GOOGLE_CALENDAR_ID'], timezone_offset).upcoming.sort_by do |event|
GoogleCalendar.new(ENV['GOOGLE_CALENDAR_ID'], timezone_offset).
upcoming.
find_all{|e|
not nsltv_regex =~ (e.summary)
}.sort_by do |event|
event.start
end
end
def upcoming_nsltv
GoogleCalendar.new(ENV['GOOGLE_CALENDAR_ID'], timezone_offset).
upcoming.
find_all{|e|
nsltv_regex =~ (e.summary)
}.sort_by do |event|
event.start
end
end

View file

@ -2,7 +2,7 @@
<div class="widget calendar">
<h4><%= t('widget.schedule') %></h4>
<div class="widget-content-wrapper">
<div class="widget-content-wrapper">
<% upcoming_matches.group_by{ |e| e.start.month }.each do |month, events| %>
<% events.group_by { |e| e.start.day }.each do |day, day_events| %>
<div class="separator"><%= day_events.first.start.strftime("%A, %e %B") %></div>
@ -19,3 +19,24 @@
</div>
</div>
<% end %>
<% if upcoming_nsltv.size > 0 %>
<div class="widget calendar">
<h4>NSLTV</h4>
<div class="widget-content-wrapper">
<% upcoming_nsltv.group_by{ |e| e.start.month }.each do |month, events| %>
<% events.group_by { |e| e.start.day }.each do |day, day_events| %>
<div class="separator"><%= day_events.first.start.strftime("%A, %e %B") %></div>
<% day_events.each do |event| %>
<div class="entry">
<p class="summary">
<span class="time"><%= event.start.strftime("%H:%M %Z") %></span>
<%= event.formatted_summary.sub(nsltv_regex, '') %>
</p>
</div>
<% end %>
<% end %>
<% end %>
</div>
</div>
<% end %>