You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
5.6 KiB

<%
require 'redcarpet'
render = Redcarpet::Render::HTML
markdown = Redcarpet::Markdown.new render, autolink: true
planning = File.join Middleman::Application.root, 'config/current.yml'
planning = YAML.load_file(planning).deep_symbolize_keys
def parse_time(time)
hour, min = time.split ':'
60 * hour.to_i + min.to_i
end
def to_time(time)
'%02d:%02d' % [time/60, time % 60]
end
FROM = parse_time('10:00')
TO = parse_time('21:00')
STEP = parse_time('00:30')
columns = planning.collect do |day, events|
events = events.collect do |location, events|
tmp = events.collect do |event|
from = parse_time event[:from]
to = parse_time event[:to]
height = (to - from) / STEP
event.merge from: from, to: to, height: height
end.sort { |a, b| a[:from] <=> b[:from] }
events = []
last = FROM
tmp.each do |event|
from, to = event.values_at :from, :to
if from > last
height = (from - last) / STEP
events << { placeholder: true, from: last, to: from, height: height }
end
last = to
events << event
end
unless last == TO
height = (TO - last) / STEP
events << { placeholder: true, from: last, to: TO, height: height }
end
[location, events]
end.collect { |l, es| { day: day, location: l, events: es } }
end.flatten 1
%>
<div class="container-fluid">
<div class="row">
<table class="timetable table-bordered table-condensed col-xs-12">
<thead>
<tr>
<th rowspan="2">
<% link_to 'index.ics' do %>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
x="0px" y="0px"
viewBox="0 0 60 60" style="enable-background:new 0 0 60 60;" xml:space="preserve">
<g>
<title>Calendrier</title>
<g>
<rect x="1" y="13" style="fill:#ECF0F1;" width="56" height="39"/>
<polygon style="fill:#21AE5E;" points="42,0 16,0 1,0 1,13 57,13 57,0 "/>
<path style="fill:#556080;" d="M19,46c-0.552,0-1-0.447-1-1V19c0-0.553,0.448-1,1-1s1,0.447,1,1v26C20,45.553,19.552,46,19,46z"/>
<path style="fill:#556080;" d="M13,26c-0.256,0-0.512-0.098-0.707-0.293c-0.391-0.391-0.391-1.023,0-1.414l6-6
c0.391-0.391,1.023-0.391,1.414,0s0.391,1.023,0,1.414l-6,6C13.512,25.902,13.256,26,13,26z"/>
<path style="fill:#556080;" d="M38,32c-3.86,0-7-3.141-7-7s3.14-7,7-7s7,3.141,7,7S41.86,32,38,32z M38,20c-2.757,0-5,2.243-5,5
s2.243,5,5,5s5-2.243,5-5S40.757,20,38,20z"/>
<path style="fill:#556080;" d="M38,46c-3.86,0-7-3.141-7-7c0-0.553,0.448-1,1-1s1,0.447,1,1c0,2.757,2.243,5,5,5s5-2.243,5-5V25
c0-0.553,0.448-1,1-1s1,0.447,1,1v14C45,42.859,41.86,46,38,46z"/>
</g>
<g>
<rect x="37" y="38" style="fill:#21AE5E;" width="22" height="22"/>
<rect x="47" y="39.586" style="fill:#FFFFFF;" width="2" height="16"/>
<polygon style="fill:#FFFFFF;" points="48,57 41,50.293 42.476,48.879 48,54.172 53.524,48.879 55,50.293 "/>
</g>
</g>
</svg>
<% end %>
<div class="giggity">
<%= image_tag 'giggity.png', alt: 'Giggity', title: 'Giggity', class: 'logo' %>
<%= image_tag 'qrcode.png', class: 'qrcode hidden' %>
</div>
</th>
<% planning.each do |day, locations| %>
<%=
n = locations.size
attributes = n == 1 ? nil : { colspan: n }
content_tag(:th, attributes) { I18n.l day, format: '%A %d %B' }
%>
<% end %>
</tr>
<tr>
<% planning.each do |day, locations|
locations.each do |location, _| %>
<th>
<%= case location.to_sym
when :cinema
'Salle cinéma'
when :hall
'Accueil'
when :town
'Village asso'
when :young
'Espace jeunesse'
end
%>
</th>
<% end %>
<% end %>
</tr>
</thead>
<tbody>
<%
(FROM...TO).step(STEP).each do |time| %>
<tr>
<th><%= to_time(time) if time % 60 == 0 %></th>
<% columns.each do |column|
events = column[:events]
event = events.first
if event
from, to, height, placeholder = event.values_at :from, :to, :height, :placeholder
if from == time
events = events.delete_at 0
attributes = height == 1 ? {} : { rowspan: height }
%>
<% unless event[:placeholder]
content_tag :td, **attributes do %>
<% content_tag :div, class: "event #{event[:type]}" do %>
<div class="time">
<%= to_time from %> - <%= to_time to %>
</div>
<div class="title">
<%= event[:title] %>
</div>
<div class="author">
<%= event[:author] %>
</div>
<div class="description">
<%=
description = event[:description]
markdown.render description if description
%>
</div>
<% end %>
<% end %>
<% else %>
<%= content_tag :td, '', **attributes %>
<% end %>
<% end %>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<ul class="legend">
<li>
<span class="talk">&nbsp;</span> Conférence
</li>
<li>
<span class="workshop">&nbsp;</span> Atelier
</li>
<!-- <li>
<span class="round-table">&nbsp;</span> Table ronde
</li>
<li>
<span class="concert">&nbsp;</span> Concert
</li>
<li>
<span class="young">&nbsp;</span> Animations
</li> -->
<li>
<span class="misc">&nbsp;</span> Divers
</li>
</ul>
</div>
</div>
<div class="modal hidden">
<div class="header">
<div class="time"></div>
<div class="title"></div>
<div class="author"></div>
</div>
<div class="body"></div>
<div class="close"></div>
<div class="cover"></div>
</div>