mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 09:21:25 +00:00
Display nsltv seperated in calender widget.
This commit is contained in:
parent
cf8c9d3ed0
commit
9d8b84b3e0
2 changed files with 41 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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 %>
|
||||
|
|
Loading…
Reference in a new issue