From 70dadaf6240d63330f10c665f05ac17a6020c604 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 4 Apr 2020 21:34:32 +0200 Subject: [PATCH] Programme and collection templates --- hbbs/server.py | 45 ++++++++++++++++++++++++--------- hbbs/static/css/styles.css | 12 +++++++++ hbbs/templates/about.html | 8 +++++- hbbs/templates/collection.html | 2 +- hbbs/templates/layout.html | 3 ++- hbbs/templates/participate.html | 2 +- hbbs/templates/programme.html | 12 +++++++++ hbbs/templates/programmes.html | 10 +++++++- 8 files changed, 77 insertions(+), 17 deletions(-) create mode 100644 hbbs/templates/programme.html diff --git a/hbbs/server.py b/hbbs/server.py index e84d010..38df026 100644 --- a/hbbs/server.py +++ b/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/") +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) diff --git a/hbbs/static/css/styles.css b/hbbs/static/css/styles.css index 5e81d3c..f23cb34 100644 --- a/hbbs/static/css/styles.css +++ b/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; } diff --git a/hbbs/templates/about.html b/hbbs/templates/about.html index f503649..43a8382 100644 --- a/hbbs/templates/about.html +++ b/hbbs/templates/about.html @@ -1,5 +1,11 @@ {% extends "layout.html" %} {% block content %} -

TODO: home page

+

+ 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. +

{% endblock %} diff --git a/hbbs/templates/collection.html b/hbbs/templates/collection.html index cc49016..048795d 100644 --- a/hbbs/templates/collection.html +++ b/hbbs/templates/collection.html @@ -3,7 +3,7 @@ {% block content %} {% endblock %} diff --git a/hbbs/templates/layout.html b/hbbs/templates/layout.html index 6560b18..33a1222 100644 --- a/hbbs/templates/layout.html +++ b/hbbs/templates/layout.html @@ -29,7 +29,8 @@