Browse Source

Upcoming or latest event page

master
crunk 4 years ago
parent
commit
a34cc1f634
  1. 31
      library/page.py
  2. 6
      library/rnrfeed/rnrfeeder.py
  3. 10
      library/static/css/style.css
  4. 2
      library/static/svg/bookmark-latest.svg
  5. 42
      library/static/svg/bookmark-svgrepo-com.svg
  6. 6
      library/templates/base.html
  7. 2
      library/templates/pastevents.html
  8. 17
      library/templates/upcomingevent.html

31
library/page.py

@ -2,8 +2,11 @@
import flask
from requests import get
from icalendar import Calendar
import datetime
from flask import render_template
from rnrfeed.rnrfeeder import getevents
from rnrfeed.rnrfeeder import getevents, getlatestevent
from csvparser.csvparser import (
getlicenses,
getpublications,
@ -47,6 +50,32 @@ def pastevents():
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__":
APP.debug = True
APP.run(port=5000)

6
library/rnrfeed/rnrfeeder.py

@ -15,6 +15,12 @@ def getentries():
return entries
def getlatestevent():
for entry in feed.entries:
if "readrepair" in entry.category:
return entry
def gettitles():
titles = []
for entry in feed.entries:

10
library/static/css/style.css

@ -75,6 +75,16 @@ body:after {
margin-top: 3em;
}
#latestevent {
text-align: center;
color: #DD4F77;
}
#upcomingevent {
text-align: center;
color: #404d81;
}
.event {
margin: 0 1em 1em;
max-width: 90%;

2
library/static/svg/bookmark-latest.svg

@ -74,7 +74,7 @@
id="tspan21"
x="98.764069"
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"
x="98.764069"
y="300.75204"

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

42
library/static/svg/bookmark-svgrepo-com.svg

@ -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

6
library/templates/base.html

@ -18,7 +18,11 @@
</svg>
<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="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 %}
{% endblock main %}
</body>

2
library/templates/pastevents.html

@ -9,7 +9,7 @@
<h2>{{ eventtitle }}</h2>
{{ text[0]|safe }}
<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>
{% for link, booktitle in text[1].items() %}
<li><a href="/{{ link }}">{{ booktitle }}</a></li>

17
library/templates/upcomingevent.html

@ -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…
Cancel
Save