Upcoming or latest event page
This commit is contained in:
parent
8fce482348
commit
a34cc1f634
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
|
from requests import get
|
||||||
|
from icalendar import Calendar
|
||||||
|
import datetime
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from rnrfeed.rnrfeeder import getevents
|
from rnrfeed.rnrfeeder import getevents, getlatestevent
|
||||||
from csvparser.csvparser import (
|
from csvparser.csvparser import (
|
||||||
getlicenses,
|
getlicenses,
|
||||||
getpublications,
|
getpublications,
|
||||||
@ -47,6 +50,32 @@ def pastevents():
|
|||||||
return render_template("pastevents.html", events=events)
|
return render_template("pastevents.html", events=events)
|
||||||
|
|
||||||
|
|
||||||
|
@APP.route("/upcoming")
|
||||||
|
def latestevent():
|
||||||
|
"""show upcoming or latest event and book recommendations"""
|
||||||
|
event = getlatestevent()
|
||||||
|
return render_template("upcomingevent.html", event=event)
|
||||||
|
|
||||||
|
|
||||||
|
@APP.context_processor
|
||||||
|
def upcoming_or_latest():
|
||||||
|
upcoming = True
|
||||||
|
ics = get("https://varia.zone/events.ics").text
|
||||||
|
gcal = Calendar.from_ical(ics)
|
||||||
|
eventtimes = [
|
||||||
|
c.get("dtstart").dt for c in gcal.walk()
|
||||||
|
if c.name == "VEVENT"
|
||||||
|
and "Read & Repair" in c.get("summary")
|
||||||
|
]
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
eventtimes.sort()
|
||||||
|
eventtimes.reverse()
|
||||||
|
if now > eventtimes[0]:
|
||||||
|
upcoming = False
|
||||||
|
|
||||||
|
return dict(upcoming=upcoming)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
APP.debug = True
|
APP.debug = True
|
||||||
APP.run(port=5000)
|
APP.run(port=5000)
|
||||||
|
@ -15,6 +15,12 @@ def getentries():
|
|||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|
||||||
|
def getlatestevent():
|
||||||
|
for entry in feed.entries:
|
||||||
|
if "readrepair" in entry.category:
|
||||||
|
return entry
|
||||||
|
|
||||||
|
|
||||||
def gettitles():
|
def gettitles():
|
||||||
titles = []
|
titles = []
|
||||||
for entry in feed.entries:
|
for entry in feed.entries:
|
||||||
|
@ -75,6 +75,16 @@ body:after {
|
|||||||
margin-top: 3em;
|
margin-top: 3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#latestevent {
|
||||||
|
text-align: center;
|
||||||
|
color: #DD4F77;
|
||||||
|
}
|
||||||
|
|
||||||
|
#upcomingevent {
|
||||||
|
text-align: center;
|
||||||
|
color: #404d81;
|
||||||
|
}
|
||||||
|
|
||||||
.event {
|
.event {
|
||||||
margin: 0 1em 1em;
|
margin: 0 1em 1em;
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
id="tspan21"
|
id="tspan21"
|
||||||
x="98.764069"
|
x="98.764069"
|
||||||
y="245.41867"
|
y="245.41867"
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:42.6667px;font-family:Carlito;-inkscape-font-specification:Carlito;text-align:center;text-anchor:middle;fill:#ffffff">Upcoming</tspan><tspan
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:42.6667px;font-family:Carlito;-inkscape-font-specification:Carlito;text-align:center;text-anchor:middle;fill:#ffffff">Latest</tspan><tspan
|
||||||
sodipodi:role="line"
|
sodipodi:role="line"
|
||||||
x="98.764069"
|
x="98.764069"
|
||||||
y="300.75204"
|
y="300.75204"
|
||||||
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
@ -1,42 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
||||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
||||||
width="537.953px" height="537.952px" viewBox="0 0 537.953 537.952" style="enable-background:new 0 0 537.953 537.952;"
|
|
||||||
xml:space="preserve">
|
|
||||||
<g>
|
|
||||||
<path d="M346.164,0H191.939c-11.857,0-21.497,9.716-21.497,21.497v505.894c0,11.857,6.12,14.076,13.617,4.896
|
|
||||||
c0,0,56.304-68.697,70.609-87.822c14.306-19.125,15.683-21.268,32.972,0c17.365,21.268,66.938,87.363,66.938,87.363
|
|
||||||
c7.191,9.41,12.929,7.496,12.929-4.283V21.497C367.66,9.716,357.945,0,346.164,0z"/>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
<g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1006 B |
@ -18,7 +18,11 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<h1 id="varia">VARIA LIBRARY COLLECTION</h1>
|
<h1 id="varia">VARIA LIBRARY COLLECTION</h1>
|
||||||
<a href="pastevents"><img src="{{ url_for('static', filename='svg/bookmark-past.svg')}}" id="pastevents" /></a>
|
<a href="pastevents"><img src="{{ url_for('static', filename='svg/bookmark-past.svg')}}" id="pastevents" /></a>
|
||||||
<a href="upcomingevents"><img src="{{ url_for('static', filename='svg/bookmark-upcoming.svg')}}" id="upcomingevents" /></a>
|
{% if upcoming %}
|
||||||
|
<a href="upcoming"><img src="{{ url_for('static', filename='svg/bookmark-upcoming.svg')}}" id="upcomingevents" /></a>
|
||||||
|
{% else %}
|
||||||
|
<a href="upcoming"><img src="{{ url_for('static', filename='svg/bookmark-latest.svg')}}" id="upcomingevents" /></a>
|
||||||
|
{% endif %}
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
</body>
|
</body>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<h2>{{ eventtitle }}</h2>
|
<h2>{{ eventtitle }}</h2>
|
||||||
{{ text[0]|safe }}
|
{{ text[0]|safe }}
|
||||||
<hr>
|
<hr>
|
||||||
<p>For those interested in this read and repair event the physical library at varia offers the following books.</p>
|
<p>For those interested in this read and repair event the physical library at varia offers the following books:</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for link, booktitle in text[1].items() %}
|
{% for link, booktitle in text[1].items() %}
|
||||||
<li><a href="/{{ link }}">{{ booktitle }}</a></li>
|
<li><a href="/{{ link }}">{{ booktitle }}</a></li>
|
||||||
|
17
library/templates/upcomingevent.html
Normal file
17
library/templates/upcomingevent.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block main %}
|
||||||
|
<div id="nav" class="container">
|
||||||
|
<button id="leftmostbtn"><a href="/">All books</a></button>
|
||||||
|
<button><a href="/upload">Upload</a></button>
|
||||||
|
</div>
|
||||||
|
<div class="event">
|
||||||
|
{% if upcoming %}
|
||||||
|
<h2 id="upcomingevent">Upcoming event!</h2>
|
||||||
|
{% else %}
|
||||||
|
<p id="latestevent">Unfortunately this Read&Repair event has already happened, keep an eye on <a href="http://varia.zone/">Varia.zone</a>
|
||||||
|
or this site for upcoming Read&Repair and other varia events!</p>
|
||||||
|
{% endif %}
|
||||||
|
<h2>{{ event.title }}</h2>
|
||||||
|
{{ event.description|safe }}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user