From e8a09b0b7d7abdce092c9c1ee76743a605929bf2 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Tue, 8 Mar 2016 15:29:31 -0500 Subject: [PATCH] Add 'draft' banner and show events status in timeline Change-Id: I383b5b67e09d84a64ef234727dae8b973c13599d --- doc/source/_exts/events.jinja | 10 +++++----- doc/source/_exts/events.py | 18 +++++++++++++++++- doc/source/index.rst | 8 +++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/doc/source/_exts/events.jinja b/doc/source/_exts/events.jinja index 185578f9..7c0427bb 100644 --- a/doc/source/_exts/events.jinja +++ b/doc/source/_exts/events.jinja @@ -12,10 +12,10 @@

-+--------------------------------+---------------------------------+ -| Events | Date | -+================================+=================================+ ++------------------------------------+------------------------------------+-----------+ +| Events | Date | Status | ++====================================+====================================+===========+ {% for event in events %} -| {{ "%29s" % event['name'] }} | {{ "%29s" % event['date_str'] }} | -+--------------------------------+---------------------------------+ +| {{ "%29s" % event['name_str'] }} | {{ "%29s" % event['date_str'] }} | {{ "%7s" % event['status'] }} | ++------------------------------------+------------------------------------+-----------+ {% endfor %} diff --git a/doc/source/_exts/events.py b/doc/source/_exts/events.py index f484eca4..96b36ada 100644 --- a/doc/source/_exts/events.py +++ b/doc/source/_exts/events.py @@ -15,6 +15,8 @@ import os import yaml +import calendar +import time from jinja2 import FileSystemLoader from jinja2.environment import Environment @@ -26,9 +28,23 @@ def build_timer(app): app.add_javascript("event_timer.js") data = yaml.load(open("events.yaml").read()) # add better text for tabulatted planning + now = time.time() + outdated = '*' for ev in data: d, h = ev['date'].split('T') - ev['date_str'] = "%s, %s UTC" % (d, h) + epoch_time = calendar.timegm( + time.strptime(ev['date'], "%Y-%m-%dT%H:%M")) + ev['status'] = 'past' + if epoch_time > now: + if outdated == '*': + # Mark upcoming event as bold + ev['status'] = 'current' + outdated = '**' + else: + ev['status'] = 'future' + outdated = '' + ev['date_str'] = "%s%s, %s UTC%s" % (outdated, d, h, outdated) + ev['name_str'] = "%s%s%s" % (outdated, ev['name'], outdated) output_file = os.path.join(PATH_PREFIX, "events.rst") with open(output_file, "w") as out: template_dir = os.path.join(".", "doc", "source", "_exts") diff --git a/doc/source/index.rst b/doc/source/index.rst index 90bd2f6a..a1f598a9 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1,6 +1,8 @@ -==================== - OpenStack Election -==================== +================== +OpenStack Election +================== + +.. warning:: This is a test for Newton cycle .. include:: ./candidates/events.rst