initial support for marking up entries as events as well, mainly for trips/excursions

This commit is contained in:
Peter Molnar 2018-11-04 15:45:54 +01:00
parent c9b28af1ab
commit 10045afa09
2 changed files with 39 additions and 1 deletions

15
nasg.py
View file

@ -510,6 +510,20 @@ class Singular(MarkdownDoc):
else: else:
return False return False
@property
def event(self):
if 'event' not in self.meta:
return False
event = self.meta.get('event', {})
event.update({
'startdate': arrow.get(event.get('start')).format(settings.dateformat.get('display')),
'starttime': arrow.get(event.get('start')).format(settings.dateformat.get('iso')),
'enddate': arrow.get(event.get('end')).format(settings.dateformat.get('display')),
'endtime': arrow.get(event.get('end')).format(settings.dateformat.get('iso')),
})
return event
@cached_property @cached_property
def tmplvars(self): def tmplvars(self):
v = { v = {
@ -532,6 +546,7 @@ class Singular(MarkdownDoc):
'url': self.url, 'url': self.url,
'review': self.review, 'review': self.review,
'has_code': self.has_code, 'has_code': self.has_code,
'event': self.event,
} }
if (self.is_photo): if (self.is_photo):
v.update({ v.update({

View file

@ -105,8 +105,13 @@
</header> </header>
{% block content %} {% block content %}
{% if post.event %}
{% set mftype = 'h-entry h-event' %}
{% else %}
{% set mftype = 'h-entry' %}
{% endif %}
<main> <main>
<article class="h-entry hentry singular" lang="{{ post.lang }}" property="h-entry" itemscope="" itemprop="blogPost" itemtype="http://schema.org/BlogPosting" itemref="author"> <article class="{{ mftype }} hentry singular" lang="{{ post.lang }}" property="{{ mftype }}" itemscope="" itemprop="blogPost" itemtype="http://schema.org/BlogPosting" itemref="author">
<header> <header>
<h1 class="entry-title p-name" itemprop="name headline" property="p-name"> <h1 class="entry-title p-name" itemprop="name headline" property="p-name">
{% if post.is_reply %} {% if post.is_reply %}
@ -166,6 +171,24 @@
<hr/> <hr/>
<footer> <footer>
<dl> <dl>
{% if post.event %}
<dt>Trip details</dt>
<dd>
From
<time class="dt-start dtstart" property="dt-end" datetime="{{ post.event.starttime }}">
{{ post.event.startdate }}
</time>
to
<time class="dt-end dtend" property="dt-end" datetime="{{ post.event.endtime }}">
{{ post.event.enddate }}
</time>, in
<span class="p-location location" property="p-location">
{{ post.event.location }}
</span>
</dd>
{% endif %}
<dt>Published</dt> <dt>Published</dt>
<dd class="published updated"> <dd class="published updated">
<time class="dt-published dt-updated" <time class="dt-published dt-updated"