Commit 44bdc7e5 authored by gijs's avatar gijs
Browse files

Added content types: programme item, note, external-project.

parent ccfbce19
# -*- coding: utf-8 -*-
FIELD_DATE_FORMAT = '%d-%m-%Y'
FIELD_DATE_FORMAT_ALT = '%d %b %Y'
FIELD_TIME_FORMAT = '%H:%M'
from .settings import TIME_OUTPUT_FORMAT, FIELD_DATE_FORMATS, FIELD_TIME_FORMAT
import datetime
import re
import markdown
......@@ -15,7 +11,15 @@ class TimeRange(object):
self.end = end
def __str__ (self):
return '{} - {}'.format(self.start, self.end)
return '{} - {}'.format(self.start.strftime(TIME_OUTPUT_FORMAT), self.end.strftime(TIME_OUTPUT_FORMAT))
class Time (object):
def __init__ (self, time):
self.time = time
def __str__ (self):
return self.time.strftime(TIME_OUTPUT_FORMAT)
class Field (object):
def __init__ (self, default = []):
......@@ -49,10 +53,13 @@ class Single(object):
class DateField (Field):
def parse (self, value):
try:
return datetime.datetime.strptime(value, FIELD_DATE_FORMAT).date()
except ValueError:
return datetime.datetime.strptime(value, FIELD_DATE_FORMAT_ALT).date()
for frm in FIELD_DATE_FORMATS:
try:
return datetime.datetime.strptime(value, frm).date()
except ValueError:
pass
return None
class DateTimeField (Field):
def parse (self, value):
......@@ -63,13 +70,13 @@ class DateTimeField (Field):
class TimeField (Field):
def parse (self, value):
m = re.match(r'(\d{1,2}\:\d{1,2})\s*[-|―]\s*(\d{1,2}\:\d{1,2})', value)
m = re.match(r'(\d{1,2}\:\d{1,2})\s*[-|―|─]\s*(\d{1,2}\:\d{1,2})', value)
if m:
start = datetime.datetime.strptime(m.group(1), FIELD_TIME_FORMAT).time()
end = datetime.datetime.strptime(m.group(2), FIELD_TIME_FORMAT).time()
return TimeRange(start, end)
else:
return datetime.datetime.strptime(value, FIELD_TIME_FORMAT).time()
return Time(datetime.datetime.strptime(value, FIELD_TIME_FORMAT).time())
class IntField (Field):
def parse (self, value):
......
......@@ -48,8 +48,8 @@ def output (path, template, context):
info('Writing {} -> {}'.format(template, path))
w.write(loader.render_to_string(template, context))
def generate_single_pages (collection, template, outputdir, make_context):
for model in collection.models:
def generate_single_pages (models, template, outputdir, make_context):
for model in models:
output(os.path.join(outputdir, model.prefix, '{}.html'.format(model.key)), template, make_context(model))
produser_role_sorting = ['artist', 'co-producer', 'other professional', 'team', 'partner']
......@@ -67,6 +67,7 @@ def generate ():
os.mkdir(os.path.join(outputdir, 'events'))
os.mkdir(os.path.join(outputdir, 'pages'))
os.mkdir(os.path.join(outputdir, 'tags'))
os.mkdir(os.path.join(outputdir, 'notes'))
print('Copying static files')
......@@ -84,6 +85,8 @@ def generate ():
pages = collectionFor('page')
tags = collectionFor('tag')
bibliography = collectionFor('bibliography')
externalProjects = collectionFor('external-project')
notes = collectionFor('notes')
grouped_produsers = sorted(regroup(sorted(produsers.models, key=lambda produser: try_attributes(produser, ['name', 'produser'])), 'role'), key=lambda group: produser_role_sorting.index(group[0]) if group[0] in produser_role_sorting else inf)
......@@ -91,6 +94,7 @@ def generate ():
# output(os.path.join(outputdir, 'produsers.layout.html'), 'produsers.layout.html', { 'produsers': sorted(produsers.models, key=lambda r: str(r.key)), 'grouped_produsers': grouped_produsers })
output(os.path.join(outputdir, 'tags.html'), 'tags.html', { 'tags': sorted(tags.models, key=lambda m: getattr(m, m.labelField)) })
output(os.path.join(outputdir, 'bibliography.html'), 'bibliography.html', { 'bibliography': sorted(bibliography.models, key=lambda m: getattr(m, m.labelField)) })
output(os.path.join(outputdir, 'external-projects.html'), 'external-projects.html', { 'externalProjects': sorted(externalProjects.models, key=lambda m: getattr(m, m.labelField)) })
# for produser in produsers.models:
# output(os.path.join(outputdir, produser.prefix, '{}.html'.format(produser.key)), 'produser.html', { 'produser': produser })
......@@ -98,10 +102,13 @@ def generate ():
# output(os.path.join(outputdir, event.prefix, '{}.html'.format(event.key)), 'event.html', { 'event': event })
generate_single_pages(produsers, 'produser.html', outputdir, lambda produser: { 'produser': produser })
generate_single_pages(events, 'event.html', outputdir, lambda event: { 'event': event })
generate_single_pages(pages, 'page.html', outputdir, lambda page: { 'page': page })
generate_single_pages(tags, 'tag.html', outputdir, lambda tag: { 'tag': tag })
generate_single_pages(produsers.models, 'produser.html', outputdir, lambda produser: { 'produser': produser })
generate_single_pages(pages.models, 'page.html', outputdir, lambda page: { 'page': page })
generate_single_pages(tags.models, 'tag.html', outputdir, lambda tag: { 'tag': tag })
generate_single_pages(filter(lambda e: not hasattr(e, 'programmeItems') or not e.programmeItems, events.models), 'event.html', outputdir, lambda event: { 'event': event })
generate_single_pages(filter(lambda e: hasattr(e, 'programmeItems') and e.programmeItems, events.models), 'event-with-programme-items.html', outputdir, lambda event: { 'event': event })
generate_single_pages(notes.models, 'note.html', outputdir, lambda note: { 'note': note })
def isdate (candidate):
return type(candidate) is datetime.date
......
from . import fields
from .utils import info, debug, CMAGENTA, keyFilter
from .utils import info, debug, CMAGENTA, keyFilter, try_attributes
import os.path
import datetime
import re
......@@ -107,6 +107,9 @@ def includeAudio(audio):
def includeImage(image):
return '<img src="{}" />'.format(image.image)
def includeExternalProject(project):
return '<a href="{}" class="external-project">{}</a>'.format(try_attributes(project, ['link', 'project']), project.project)
def labelReference(target):
return '<span class="{}">{}</span>'.format(target.contentType, str(target))
......@@ -384,7 +387,7 @@ class Event (Model):
}
class ProgrammeItem (Model):
contentType = 'programme_item'
contentType = 'programme-item'
metadataFields = {
'date': fields.Single(fields.DateField()),
......@@ -392,7 +395,7 @@ class ProgrammeItem (Model):
'time': fields.Single(fields.TimeField()),
'produser': multiLinkMultiReverse('produser', 'events'),
'participant': multiLinkMultiReverse('produser', 'events_participant'),
'event': fields.Single(fields.StringField()),
'event': multiLinkMultiReverse('event', 'programmeItems'),
'title': fields.Single(fields.StringField()),
'summary': fields.Single(fields.MarkdownField()),
'location': fields.Single(fields.StringField()),
......@@ -437,6 +440,7 @@ class Note (Model):
metadataFields = {
'produser': linkMultiReverse('produser', 'notes'),
'event': linkMultiReverse('event', 'notes'),
'project-item': linkMultiReverse('project-item', 'notes'),
'tags': multiLinkMultiReverse('tag', 'notes'),
'bibliography': multiLinkMultiReverse('bibliography', 'notes'),
}
......@@ -520,7 +524,19 @@ class Image (Model):
metadataFields = {
'image': fields.Single(fields.StringField()),
'tags': multiLinkMultiReverse('tag', 'image'),
'produser': multiLinkMultiReverse('produser', 'image')
'produser': multiLinkMultiReverse('produser', 'image'),
'caption': fields.Single(fields.StringField()),
}
class ExternalProject (Model):
contentType = 'external-project'
keyField = 'project'
labelField = 'project'
metadataFields = {
'title': fields.Single(fields.StringField()),
'link': fields.Single(fields.StringField()),
'tags': multiLinkMultiReverse('tag', 'externalProject'),
}
class Text (Model):
......@@ -551,7 +567,8 @@ contentTypes = {
'audio': { 'model': Audio, 'collection': Collection(Audio) },
'image': { 'model': Image, 'collection': Collection(Image) },
'text': { 'model': Text, 'collection': Collection(Text) },
'note': { 'model': Note, 'collecion': Collection(Note) },
'notes': { 'model': Note, 'collection': Collection(Note) },
'external-project': { 'model': ExternalProject, 'collection': Collection(ExternalProject) },
}
knownContentTypes = contentTypes.keys()
......
......@@ -2,8 +2,10 @@ from ethertoff.settings import DEBUG
MENU_ITEMS = [
('About', 'pages/about.html'),
('Activities', 'pages/activities.html'),
('Produsers', 'produsers.html' ),
('Bibliography', 'bibliography.html' ),
('Projects & Initiatives', 'external-projects.html'),
('Tags', 'tags.html' ),
('Contact', 'pages/contact.html')
]
......@@ -13,6 +15,11 @@ DEFAULT_CONTENT_TYPE = 'pad'
SHOW_LOG_MESSAGES = True
SHOW_DEBUG_MESSAGES = True
FIELD_DATE_FORMATS = ['%d-%m-%Y', '%d %b %Y']
FIELD_TIME_FORMAT = '%H:%M'
TIME_OUTPUT_FORMAT = '%H:%M'
try:
LOCAL_SETTINGS
except NameError:
......
{% extends "generator_base_two_columns.html" %}
{% block title %}Caveat → activities → {{ event.title }}{% endblock %}
{% block content %}
<nav class="breadcrumbs">
<ul>
<li><a href="../events.html">Activities</a></li>
<li>{{ event.title }}</li>
</ul>
</nav>
<h1>{% if event.event %}{{ event.event }}{% else %}{{ event.title }}{% endif %}</h1>
<section class="info">
<time datetime="2019-05-24">{{ event.date }}</time>
<p>
{{ event.location }}<br />
{% if event.address %}
{% for addressline in event.address %}
{{ addressline }}<br />
{% endfor %}
{% endif %}
</p>
<p class="event-infos">
{% for produser in event.produser %}
<a href="{{ produser.link }}" class="produser">{{ produser }}</a>
{% endfor %}
</p>
</section>
{{ event.summary }}
{{ event.content }}
{% if event.notes %}
<ul>
{% for note in event.notes %}
<li><a href="{{ note.link }}" class="note">{{ note }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
{% block sidebar %}
<ul>
{% for item in event.programmeItems %}
<li>
{{ item.time }} {{ item.title }}
<p>
{{ item.content }}
</p>
{% if item.notes %}
<ul>
{% for note in event.notes %}
<li><a href="{{ note.link }}" class="note">{{ note }}</a></li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends "generator_base.html" %}
{% block title %}Caveat → events → {{ event.title }}{% endblock %}
{% block title %}Caveat → activities → {{ event.title }}{% endblock %}
{% block content %}
<nav class="breadcrumbs">
<ul>
<li><a href="../events.html">Events</a></li>
<li><a href="../events.html">Activities</a></li>
<li>{{ event.title }}</li>
</ul>
</nav>
......@@ -28,4 +28,11 @@
</section>
{{ event.summary }}
{{ event.content }}
{% if event.notes %}
<ul>
{% for note in event.notes %}
<li><a href="{{ note.link }}" class="note">{{ note }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
\ No newline at end of file
{% extends "generator_base.html" %}
{% block title %}Projects & Initiatives{% endblock %}
{% block content %}
<h1>Projects & Initiatives</h1>
<ul>
{% for project in externalProjects %}
<li>{{ project }}</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" media="all" href="{{ SITE_URL }}static/styles.simple.css" />
<title>Caveat → Produsers → {% if produser.name %}{{ produser.name }}{% else %}{{ produser.produser }}{% endif %}</title>
</head>
<body>
<header>
<nav>
<a href="{{ SITE_URL }}index.html" id="site-logo">
<img src="{{ SITE_URL }}static/images/logos/caveat.png" />
</a>
<ul>
{% for label, url in MENU_ITEMS %}
<li><a href="{{ SITE_URL}}{{ url }}">{{ label }}</a></li>
{% endfor %}
</ul>
</nav>
<section id="header-map" style="background-image:url({{ SITE_URL }}static/images/maps/reading-room8-cover.png);">
</section>
<section id="header-content">
{% block header-text %}
<p>
<strong>Caveat</strong> tries to find more sustainable, balanced ways of operating
within the existing legal frameworks. And when the limits of the existing system are
reached, it tries to come up with possible new narratives that open up space for reflection.
</p>
{% endblock %}
</section>
</header>
<main>
{% block content %}
{% endblock %}
</main>
<footer>
<p class=""><img class="logo-partners" src="{{ SITE_URL }}static/images/logos/innoviris.svg"/>
<strong>Caveat</strong> is a co-create research project convened by the Brussels-based artists’
initiative Jubilee, in partnership with Open Source Publishing, No New Enemies and Été 78 and
supported by Innoviris, Brussels Institute for Research and Innovation.</p>
</footer>
<script>
(function () {
var images = document.querySelectorAll('main img');
for (var i=0; i < images.length; i++) {
images[i].addEventListener('click', function () {
this.classList.toggle('full');
})
}
})();
</script>
</body>
</html>
\ No newline at end of file
{% extends "page_structure.html" %}
{% block main %}
<main>
{% block content %}
{% endblock %}
</main>
{% endblock %}
\ No newline at end of file
{% extends "page_structure.html" %}
{% block body_classes %}two-columns{% endblock %}
{% block main %}
<main>
{% block content %}
{% endblock %}
</main>
<aside>
{% block sidebar %}
{% endblock %}
</aside>
{% endblock %}
\ No newline at end of file
{% extends "generator_base.html" %}
{% block title %}
Caveat → {{ note.title }}
{% endblock %}
{% block content %}
<nav class="breadcrumbs">
<ul>
</ul>
</nav>
<h1>{{ note.title }}</h1>
{{ note.content }}
{% endif %}
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" media="all" href="{{ SITE_URL }}static/styles.simple.css" />
<title>{% block title %}Caveat{% endblock %}</title>
</head>
<body class="{% block body_classes %}{% endblock %}">
<header>
<nav>
<a href="{{ SITE_URL }}index.html" id="site-logo">
<img src="{{ SITE_URL }}static/images/logos/caveat.png" />
</a>
<ul>
{% for label, url in MENU_ITEMS %}
<li><a href="{{ SITE_URL}}{{ url }}">{{ label }}</a></li>
{% endfor %}
</ul>
</nav>
<section id="header-map" style="background-image:url({{ SITE_URL }}static/images/maps/reading-room8-cover.png);">
</section>
<section id="header-content">
{% block header-text %}
<p>
<strong>Caveat</strong> tries to find more sustainable, balanced ways of operating
within the existing legal frameworks. And when the limits of the existing system are
reached, it tries to come up with possible new narratives that open up space for reflection.
</p>
{% endblock %}
</section>
</header>
{% block main %}
{% endblock %}
<footer>
<p class=""><img class="logo-partners" src="{{ SITE_URL }}static/images/logos/innoviris.svg"/>
<strong>Caveat</strong> is a co-create research project convened by the Brussels-based artists’
initiative Jubilee, in partnership with Open Source Publishing, No New Enemies and Été 78 and
supported by Innoviris, Brussels Institute for Research and Innovation.</p>
</footer>
<script>
(function () {
var images = document.querySelectorAll('main img, aside img');
for (var i=0; i < images.length; i++) {
images[i].addEventListener('click', function () {
this.classList.toggle('full');
})
}
})();
</script>
</body>
</html>
\ No newline at end of file
{% extends "generator_base.html" %}
{% block title %}
Caveat → Produsers → {% if produser.name %}{{ produser.name }}{% else %}{{ produser.produser }}{% endif %}</title>
{% endblock %}
{% block title %}Caveat → Produsers → {% if produser.name %}{{ produser.name }}{% else %}{{ produser.produser }}{% endif %}{% endblock %}
{% block content %}
<nav class="breadcrumbs">
<ul>
......@@ -9,56 +7,56 @@
<li>{% if produser.name %}{{ produser.name }}{% else %}{{ produser.produser }}{% endif %}</li>
</ul>
</nav>
<h1 class="produser">{% if produser.name %}{{ produser.name }}{% else %}{{ produser.produser }}{% endif %}</h1>
{% if produser.trajectories %}
{% for trajectory in produser.trajectories %}
<h2>Trajectory</h2>
{{ trajectory.content}}
<h1 class="produser">{% if produser.name %}{{ produser.name }}{% else %}{{ produser.produser }}{% endif %}</h1>
{% if produser.trajectories %}
{% for trajectory in produser.trajectories %}
<h2>Trajectory</h2>
{{ trajectory.content}}
{% endfor %}
{% endif %}
{% if produser.content %}
<h2>Biography</h2>
{{ produser.content }}
{% endif %}
{% if produser.events %}
<h2>Activities</h2>
<ul class="simplelist">
{% for event in produser.events %}
<li>
<section class="event-preview">
<a href="{{ event.link }}">{{ event.event }} {{ event.title }}</a>
{{ event.summary }}
</section>
</li>
{% endfor %}
{% endif %}
{% if produser.content %}
<h2>Biography</h2>
{{ produser.content }}
{% endif %}
{% if produser.events %}
<h2>Events</h2>
<ul class="simplelist">
{% for event in produser.events %}
<li>
<section class="event-preview">
<a href="{{ event.link }}">{{ event.event }} {{ event.title }}</a>
{{ event.summary }}
</section>
</li>
{% endfor %}
</ul>
{% endif %}
</ul>
{% endif %}
{% if produser.bibliography %}
<h2>Bibliography</h2>
<ul class="simplelist">
{% for entry in produser.bibliography %}
<li>{{ entry }}</li>
{% endfor %}
</ul>
{% endif %}
{% if produser.bibliography %}
<h2>Bibliography</h2>
<ul class="simplelist">
{% for entry in produser.bibliography %}
<li>{{ entry }}</li>
{% endfor %}
</ul>
{% endif %}
{% if produser.video %}
<h2>Video</h2>
<ul class="simplelist">
{% for video in produser.video %}
<li>
<video controls>
<source type="{{ video.type }}" src="{{ video.video }}">
</video>
</li>
{% endfor %}
</ul>
{% endif %}
{% if produser.video %}
<h2>Video</h2>
<ul class="simplelist">
{% for video in produser.video %}
<li>
<video controls>
<source type="{{ video.type }}" src="{{ video.video }}">
</video>
</li>
{% endfor %}
</ul>
{% endif %}
{% if produser.audio %}
{% if produser.audio %}
<h2>Audio</h2>
<ul class="simplelist">
{% for audio in produser.audio %}
......@@ -70,4 +68,14 @@
{% endfor %}
</ul>
{% endif %}
{% if event.notes %}
<h2>Notes</h2>
<ul>
{% for note in event.notes %}
<li>
<a href="{{ note.link }}" class="note">{{ note }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
\ No newline at end of file
......@@ -272,6 +272,17 @@ main {
overflow-y: auto;
}
.two-columns main {
grid-column: content-start / content-middle;
}
.two-columns aside {
grid-row: top / footer;
grid-column: content-middle / content-end;
overflow-y: auto;
}
footer {
border-top: 2px solid;
grid-column: left / right;
......
{% extends "generator_base.html" %}
{% block title %}
Caveat → Produsers → {{ tag.tag }}
Caveat → {{ tag.tag }}
{% endblock %}
{% block content %}
<nav class="breadcrumbs">
......@@ -10,6 +10,9 @@
</ul>
</nav>
<h1>{{ tag.tag }}</h1>
{% if tag.content %}
{{ tag.content }}
{% endif %}