lpschedule-generator

libreplanet schedule generator - ricketyspace.net/lpschedule-generator
git clone git://git.ricketyspace.net/lpschedule-generator.git
Log | Files | Refs

commit 01997af8b0c04318c2c76afc29eb043052e3d793
parent 911fd27e4c4c61b978c2370f7e92b051f0636614
Author: jantwisted <janith@member.fsf.org>
Date:   Wed, 16 Dec 2015 01:39:41 +0530

HTMLRender added

Diffstat:
lps_gen.py | 13++++++++++++-
tests/files/index.html | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/lps_gen.py b/lps_gen.py @@ -19,6 +19,7 @@ # <http://www.gnu.org/licenses/>. import json +import jinja2 from argparse import ArgumentParser from collections import OrderedDict @@ -132,6 +133,15 @@ class LPSMarkdown(Markdown): html = super(LPSMarkdown, self).parse(text) return lps_dict +def HTMLRender(_dict): + + templateLoader = jinja2.FileSystemLoader( searchpath="./" ) + templateEnv = jinja2.Environment( loader=templateLoader ) + TEMPLATE_FILE = "tests/files/index.html" + template = templateEnv.get_template( TEMPLATE_FILE ) + _data = {'res':_dict} + outputText = template.render( _data ) + return outputText def main(): parser = ArgumentParser() @@ -143,8 +153,9 @@ def main(): markdown = LPSMarkdown() lps_dict = markdown(lps_md_content) + print HTMLRender(lps_dict) - print json.dumps(lps_dict, indent=4) + #print json.dumps(lps_dict, indent=4) if __name__ == "__main__": diff --git a/tests/files/index.html b/tests/files/index.html @@ -0,0 +1,52 @@ + {% for key, value in res.iteritems() %} + <header class="program-day-header"> + <hgroup> + <h2>{{ key }} + <a class="btn btn-default btn-xs" role="button" + data-toggle="collapse" aria-expanded="false" + aria-controls="sat-timeslots" + href="#sat-timeslots"> + &#x2193; + </a> + </h2> + </hgroup> + </header> + + <div class="collapse in" id="sat-timeslots"> + {% for key2, value2 in value.iteritems() %} + <article id="sat-ts-b0" + class="program-timeslot-break"> <!-- sat-ts-b0 start --> + <header class="program-timeslot-break-header"> + <hgroup> + <h2>{{ key2 }}</h2> + </hgroup> + </header> + {# conditional content #} + {% if value2|count > 0 %} + <div class="collapse in" + id="sat-ts0-sessions"> <!-- sat-ts0-sessions start --> + {% for key3, value3 in value2.iteritems() %} + <section id="sat-ts0-s0" class="program-session"> <!-- sat-ts0-s0 start --> + <header class="program-session-header"> + <h2>{{ key3 }}</h2> + </header> + <a href="#" class="program-session-speaker">{{ value3['speaker'] }}</a> + +<button class="btn btn-default btn-xs" +data-toggle="collapse" aria-expanded="false" +aria-controls="sat-ts0-s0-collapse" +data-target="#sat-ts0-s0-collapse"> +Details +</button> +<div class="collapse in" id="sat-ts0-s0-collapse"> +<p><span class="label label-default">{{ value3['room'] }}</span></p> + +<p>{{ value3['desc'][0].decode('utf-8') }}</p> +</div> +</section> <!-- sat-ts0-s0 end --> + </div> <!-- sat-ts0-sessions end --> + {% endfor %} + {% endif %} + </article> + {% endfor %} +{% endfor %}