Browse Source

Programme and collection templates

master
Luke Murphy 5 years ago
parent
commit
70dadaf624
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 45
      hbbs/server.py
  2. 12
      hbbs/static/css/styles.css
  3. 8
      hbbs/templates/about.html
  4. 2
      hbbs/templates/collection.html
  5. 3
      hbbs/templates/layout.html
  6. 2
      hbbs/templates/participate.html
  7. 12
      hbbs/templates/programme.html
  8. 10
      hbbs/templates/programmes.html

45
hbbs/server.py

@ -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,13 +13,7 @@ cwd = dirname(Path(__file__).absolute())
yaml = YAML()
@app.route("/")
def about():
return render_template("about.html")
@app.route("/programmes")
def programmes():
def get_programmes():
programmes = []
path = cwd / Path("static/programmes/")
for file in listdir(path):
@ -27,17 +21,44 @@ def programmes():
contents = handle.read()
loaded = yaml.load(contents)
programmes.append(loaded)
return render_template("programmes.html", programmes=programmes)
return programmes
@app.route("/collection")
def collection():
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")
@app.route("/programmes")
def programmes():
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 = get_collection()
return render_template("collection.html", collection=collection)

12
hbbs/static/css/styles.css

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

8
hbbs/templates/about.html

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

2
hbbs/templates/collection.html

@ -3,7 +3,7 @@
{% block content %}
<ul>
{% for film in collection %}
<li>{{ film }}</li>
<li>{{ film.Title }}</li>
{% endfor %}
</ul>
{% endblock %}

3
hbbs/templates/layout.html

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

2
hbbs/templates/participate.html

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

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

10
hbbs/templates/programmes.html

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