Browse Source

Programme and collection templates

master
Luke Murphy 4 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 csv import DictReader
from os import listdir from os import listdir
from os.path import basename, dirname, splitext from os.path import basename, dirname
from pathlib import Path from pathlib import Path
from flask import Flask, render_template from flask import Flask, abort, render_template
from ruamel.yaml import YAML from ruamel.yaml import YAML
app = Flask(__name__) app = Flask(__name__)
@ -13,13 +13,7 @@ cwd = dirname(Path(__file__).absolute())
yaml = YAML() yaml = YAML()
@app.route("/") def get_programmes():
def about():
return render_template("about.html")
@app.route("/programmes")
def programmes():
programmes = [] programmes = []
path = cwd / Path("static/programmes/") path = cwd / Path("static/programmes/")
for file in listdir(path): for file in listdir(path):
@ -27,17 +21,44 @@ def programmes():
contents = handle.read() contents = handle.read()
loaded = yaml.load(contents) loaded = yaml.load(contents)
programmes.append(loaded) programmes.append(loaded)
return render_template("programmes.html", programmes=programmes) return programmes
@app.route("/collection") def get_collection():
def collection():
collection = [] collection = []
path = cwd / Path("static/csv/collection.csv") path = cwd / Path("static/csv/collection.csv")
with open(path, "r") as handle: with open(path, "r") as handle:
reader = DictReader(handle) reader = DictReader(handle)
for row in reader: for row in reader:
collection.append(row) 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) return render_template("collection.html", collection=collection)

12
hbbs/static/css/styles.css

@ -26,6 +26,18 @@ body {
animation-duration: 120s; animation-duration: 120s;
} }
ul {
padding-left: 0;
}
ul li {
list-style: none;
}
#hbbs-logo {
width: 90%;
}
html * { html * {
border: 1px black solid; border: 1px black solid;
} }

8
hbbs/templates/about.html

@ -1,5 +1,11 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block content %} {% 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 %} {% endblock %}

2
hbbs/templates/collection.html

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

3
hbbs/templates/layout.html

@ -29,7 +29,8 @@
<div class="row"> <div class="row">
<div id="navigation" class="col-md-4"> <div id="navigation" class="col-md-4">
<img <img
class="img-fluid" id="hbbs-logo"
class="img-fluid mx-auto d-block"
src="/static/images/logo.png" src="/static/images/logo.png"
alt="hbbs logo" alt="hbbs logo"
/> />

2
hbbs/templates/participate.html

@ -1,5 +1,5 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% block content %} {% block content %}
<p>TODO: participate page</p> <p>Invite only for now...</p>
{% endblock %} {% 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 %} {% block content %}
<ul> <ul>
{% for programme in programmes %} {% 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 %} {% endfor %}
</ul> </ul>
{% endblock %} {% endblock %}

Loading…
Cancel
Save