forked from beeware/beeware.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.html
More file actions
71 lines (69 loc) · 3.47 KB
/
events.html
File metadata and controls
71 lines (69 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{% extends "page.html" %}
{% from "macros/breadcrumbs.html" import breadcrumbs %}
{% from "macros/translation.html" import transbag %}
{% set t_past_events = transbag('translate', this.alt, 'past_events') %}
{% set t_upcoming_events = transbag('translate', this.alt, 'upcoming_events') %}
{% block title %}{{ this.title }}{% endblock %}
{% block extra_script %}
<script>
(function() {
var today = new Date();
$('.upcoming.event').each(function() {
var event_date = new Date($(this).data('date'));
var event_end_date = $(this).data('end_date') ? new Date($(this).data('end_date')) : new Date($(this).data('date'));
if (event_date > today || (event_date >= today && event_end_date >= today)) {
$(this).hide();
}
});
$('.current.event').each(function() {
var event_date = new Date($(this).data('date'));
var event_end_date = $(this).data('end_date') ? new Date($(this).data('end_date')) : new Date($(this).data('date'));
if ((event_date = today) || (event_date < today && event_end_date >= today)) {
$(this).hide();
}
});
$('.past.event').each(function() {
var event_date = new Date($(this).data('date'));
var event_end_date = $(this).data('end_date') ? new Date($(this).data('end_date')) : new Date($(this).data('date'));
if (event_date < today || (event_date < today && event_end_date < today) || (event_date < today && event_end_date >= today)) {
$(this).hide();
}
});
})();
</script>
{% endblock %}
{% block preamble %}
<div class="banner">
<div class="container">
<p>{{ breadcrumbs(this) }}</p>
<h1>{{ this.title }}</h1>
<p>{{ this.summary }}</p>
</div>
</div>
{% endblock %}
{% block main %}
{# As this is a static site, we can't just query on the date for upcoming
events, because the date is computed at the time the page is generated.
As a workaround, we render *all* the events in the past events list,
and use Javascript (which will be evaluated at the time of viewing) to
hide any events that shouldn't appear in each list. #}
<h2>{{ t_upcoming_events }}</h2>
{% for child in this.children.order_by("date") %}
<p class="{% if (child.date < today and child.end_date is not defined) or (child.date < today and child.end_date < today) %}past {% endif %}event" data-date="{{ child.date }}" data-end-date="{{ child.end_date }}">
{{ child.date|datetimeformat("MMMM d, YYYY", locale=this.alt)|title }}{% if child.end_date %} - {{child.end_date|datetimeformat("MMMM d, YYYY", locale=this.alt)|title}}{% endif %}
<a href="{{ child|url(alt=this.alt) }}">{{ child.title }} ({{ child.event_type|title }})</a>
</p>
{% endfor %}
<h2>{{ t_past_events }}</h2>
{% for child in this.children %}
<p class="{% if (child.date > today and child.end_date is not defined) or (child.date >= today and child.end_date >= today) %}upcoming
{% elif (child.date == today and child.end_date is not defined) or (child.date < today and child.end_date is defined and child.end_date >= today) %}current {% endif %}event" data-date="{{ child.date }}" data-end-date="{{ child.end_date }}">
{{ child.date|datetimeformat("MMMM d, YYYY", locale=this.alt)|title }}{% if child.end_date %} - {{child.end_date|datetimeformat("MMMM d, YYYY", locale=this.alt)|title}}{% endif %}
<a href="{{ child|url(alt=this.alt) }}">{{ child.title }} ({{ child.event_type|title }})</a></p>
{% endfor %}
{% endblock %}
{% block gutter %}
<div class="col-sm-12 col-md-4 gutter">
{{ this.gutter }}
</div>
{% endblock %}