Programme and collection templates
This commit is contained in:
parent
b461658c62
commit
70dadaf624
@ -2,10 +2,10 @@
|
||||
|
||||
from csv import DictReader
|
||||
from os import listdir
|
||||
from os.path import basename, dirname, splitext
|
||||
from os.path import basename, dirname
|
||||
from pathlib import Path
|
||||
|
||||
from flask import Flask, render_template
|
||||
from flask import Flask, abort, render_template
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
app = Flask(__name__)
|
||||
@ -13,6 +13,27 @@ cwd = dirname(Path(__file__).absolute())
|
||||
yaml = YAML()
|
||||
|
||||
|
||||
def get_programmes():
|
||||
programmes = []
|
||||
path = cwd / Path("static/programmes/")
|
||||
for file in listdir(path):
|
||||
with open(path / file, "r") as handle:
|
||||
contents = handle.read()
|
||||
loaded = yaml.load(contents)
|
||||
programmes.append(loaded)
|
||||
return programmes
|
||||
|
||||
|
||||
def get_collection():
|
||||
collection = []
|
||||
path = cwd / Path("static/csv/collection.csv")
|
||||
with open(path, "r") as handle:
|
||||
reader = DictReader(handle)
|
||||
for row in reader:
|
||||
collection.append(row)
|
||||
return collection
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def about():
|
||||
return render_template("about.html")
|
||||
@ -20,24 +41,24 @@ def about():
|
||||
|
||||
@app.route("/programmes")
|
||||
def programmes():
|
||||
programmes = []
|
||||
path = cwd / Path("static/programmes/")
|
||||
for file in listdir(path):
|
||||
with open(path / file, "r") as handle:
|
||||
contents = handle.read()
|
||||
loaded = yaml.load(contents)
|
||||
programmes.append(loaded)
|
||||
programmes = get_programmes()
|
||||
return render_template("programmes.html", programmes=programmes)
|
||||
|
||||
|
||||
@app.route("/programme/<name>")
|
||||
def programme(name):
|
||||
cleaned_name = name.replace("-", " ").lower()
|
||||
programmes = get_programmes()
|
||||
for programme in programmes:
|
||||
cleaned_programme = programme.get("title", "").lower()
|
||||
if cleaned_name == cleaned_programme:
|
||||
return render_template("programme.html", programme=programme)
|
||||
abort(404, description="Programme not found")
|
||||
|
||||
|
||||
@app.route("/collection")
|
||||
def collection():
|
||||
collection = []
|
||||
path = cwd / Path("static/csv/collection.csv")
|
||||
with open(path, "r") as handle:
|
||||
reader = DictReader(handle)
|
||||
for row in reader:
|
||||
collection.append(row)
|
||||
collection = get_collection()
|
||||
return render_template("collection.html", collection=collection)
|
||||
|
||||
|
||||
|
@ -26,6 +26,18 @@ body {
|
||||
animation-duration: 120s;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
ul li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#hbbs-logo {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
html * {
|
||||
border: 1px black solid;
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block content %}
|
||||
<p>TODO: home page</p>
|
||||
<p>
|
||||
This isn’t another link dump, nor is it an all-you-can-eat streaming site. We
|
||||
have files and we want to share them. The homebrew bioscoop offers programmes
|
||||
made by viewers, for viewers. Our programmes are cu- rated playlists of films
|
||||
in our collection. Playlists that en- courage play, sociality through the
|
||||
things we share. Download a programme, watch it, make a programme, share it.
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% block content %}
|
||||
<ul>
|
||||
{% for film in collection %}
|
||||
<li>{{ film }}</li>
|
||||
<li>{{ film.Title }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
@ -29,7 +29,8 @@
|
||||
<div class="row">
|
||||
<div id="navigation" class="col-md-4">
|
||||
<img
|
||||
class="img-fluid"
|
||||
id="hbbs-logo"
|
||||
class="img-fluid mx-auto d-block"
|
||||
src="/static/images/logo.png"
|
||||
alt="hbbs logo"
|
||||
/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block content %}
|
||||
<p>TODO: participate page</p>
|
||||
<p>Invite only for now...</p>
|
||||
{% endblock %}
|
||||
|
12
hbbs/templates/programme.html
Normal file
12
hbbs/templates/programme.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1> <a href="/programme/{{ programme.title | replace(' ', '-') | lower }}">{{ programme.title }}</a> </h1>
|
||||
<h2> {{ programme.tagline }} </h2>
|
||||
<ul>
|
||||
{% for film in programme.films %}
|
||||
<li>{{ film }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<a href="/programmes">All programmes...</a>
|
||||
{% endblock %}
|
@ -3,7 +3,15 @@
|
||||
{% block content %}
|
||||
<ul>
|
||||
{% for programme in programmes %}
|
||||
<li>{{ programme }}</li>
|
||||
<li>
|
||||
<h1> <a href="/programme/{{ programme.title | replace(' ', '-') | lower }}">{{ programme.title }}</a> </h1>
|
||||
<h2> {{ programme.tagline }} </h2>
|
||||
<ul>
|
||||
{% for film in programme.films %}
|
||||
<li>{{ film }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user