lpschedule-generator

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

commit d939dadedf6b9d8b431ae15a2fdfcf5b5ffd63d5
parent 263ad0a887908d5bbfc93837ab7fc9903a088f5b
Author: rsiddharth <rsd@gnu.org>
Date:   Sat, 19 Dec 2015 23:44:57 -0500

Moved templates/ under lpschedule_generator module

Diffstat:
MANIFEST.in | 2+-
lps_gen.py | 4++--
lpschedule_generator/__init__.py | 0
lpschedule_generator/templates/lp-sch-2016.jinja2 | 136+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
setup.py | 5+++--
templates/lp-sch-2016.jinja2 | 136-------------------------------------------------------------------------------
6 files changed, 142 insertions(+), 141 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in @@ -1,4 +1,4 @@ include COPYING CONTRIBUTORS README.md -recursive-include templates * +recursive-include lpschedule_generator * recursive-include tests * recursive-exclude tests *.pyc \ No newline at end of file diff --git a/lps_gen.py b/lps_gen.py @@ -30,7 +30,7 @@ from jinja2 import Environment, PackageLoader from jinja2.exceptions import TemplateNotFound from mistune import Renderer, Markdown -__version__ = '0.1.0.dev1' +__version__ = '0.1.0.dev2' # unicode magic reload(sys) @@ -149,7 +149,7 @@ def RenderHTML(lps_dict, year): Returns the HTML as a string. """ - env = Environment(loader=PackageLoader('lps_gen', + env = Environment(loader=PackageLoader('lpschedule_generator', 'templates'), trim_blocks=True, lstrip_blocks=True) diff --git a/lpschedule_generator/__init__.py b/lpschedule_generator/__init__.py diff --git a/lpschedule_generator/templates/lp-sch-2016.jinja2 b/lpschedule_generator/templates/lp-sch-2016.jinja2 @@ -0,0 +1,136 @@ +{# -*- mode: jinja2; -*- #} +{# + Copyright (C) 2015 lpschedule-generator contributors. See CONTRIBUTORS. + + This file is part of lpschedule-generator. + + lpschedule-generator is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + lpschedule-generator is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with lpschedule-generator (see COPYING). If not, see + <http://www.gnu.org/licenses/>. +#} + +{# macros start #} + +{# make speakers macro #} +{% macro mk_speakers(speakers) %} + <span class="program-session-speaker"> + {% for speaker in speakers %} + {% if loop.last %} + {{ speaker }} + {% else %} + {{ speaker }}, + {% endif %} + {% endfor %} + </span> +{% endmacro %} + +{# make room macro #} +{% macro mk_room(room) %} + <p><span class="label label-default">{{ room }}</span></p> +{% endmacro %} + +{# make day header macro #} +{% macro mk_day_header(day, collapse_area) %} + <header class="program-day-header"> + <hgroup> + <h2>{{ day }} + <a class="btn btn-default btn-xs" role="button" + data-toggle="collapse" aria-expanded="false" + aria-controls="{{ collapse_area }}" + href="#{{ collapse_area }}"> + &#x2193; + </a> + </h2> + </hgroup> + </header> +{% endmacro %} + +{# make timeslot header macro #} +{% macro mk_timeslot_header(timeslot, collapse, collapse_area='') %} + <header class="program-timeslot-header"> + <hgroup> + <h2>{{ timeslot }} + {% if collapse %} + <a class="btn btn-default btn-xs" role="button" + data-toggle="collapse" aria-expanded="false" + aria-controls="{{ collapse_area }}" + href="#{{ collapse_area }}"> + &#x2193; + </a> + {% endif %} + </h2> + </hgroup> + </header> +{% endmacro %} + +{# make session header macro #} +{% macro mk_session_header(session) %} + <header class="program-session-header"> + <hgroup> + <h2>{{ session }}</h2> + </hgroup> + </header> +{% endmacro %} + +{# desc macro #} +{% macro desc(disc_list) %} + {% for desc_p in disc_list %} + <p>{{ desc_p }}</p> + {% endfor %} +{% endmacro %} + +{# populate sessions macro #} +{% macro populate_sessions(sessions, day_index, timeslot_index) %} + {% for session, session_info in sessions.iteritems() %} {# session start #} + <section id="day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}" class="program-session"> + {{ mk_session_header(session) }} + {{ mk_speakers(session_info['speakers']) }} + <button class="btn btn-default btn-xs" + data-toggle="collapse" aria-expanded="false" + aria-controls="day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse" + data-target="#day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse"> + Details + </button> + <div class="collapse in" + id="day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse"> + {{ mk_room(session_info['room']) }} + {{ desc(session_info['desc']) }} + </div> <!-- day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse end --> + </section> <!-- day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }} end --> + {% endfor %} {# session end #} +{% endmacro %} + +{# populate timeslots macro #} +{% macro populate_timeslots(timeslots, day_index) %} + {% for timeslot, sessions in timeslots.iteritems() %} {# timeslot start #} + <article id="day-{{ day_index }}-timeslot-{{ loop.index }}" class="program-timeslot"> + {{ mk_timeslot_header(timeslot, sessions|length > 0, "day-%d-timeslot-%d-sessions"|format(day_index, loop.index)) }} + {% if sessions|length > 0 %} + <div class="collapse in" + id="day-{{ day_index }}-timeslot-{{ loop.index }}-sessions"> + {{ populate_sessions(sessions, day_index, loop.index) }} + </div> <!-- day-{{ day_index }}-timeslot-{{ loop.index }}-sessions end --> + {% endif %} + </article> <!-- day-{{ day_index }}-timeslot-{{ loop.index }} end --> + {% endfor %} {# timeslot start #} +{% endmacro %} + +{# lp 2016 template start #} +{% for day, timeslots in schedule.iteritems() %} {# day start #} + <article id="day-{{ loop.index }}-program" class="program-day"> + {{ mk_day_header(day, "day-%d-timeslots"|format(loop.index)) }} + <div class="collapse in" id="day-{{ loop.index }}-timeslots"> + {{ populate_timeslots(timeslots, loop.index) }} + </div> <!-- day-{{ loop.index }}-timeslots end --> + </article> <!-- day-{{ loop.index }} end --> +{% endfor %} {# day loop end #} diff --git a/setup.py b/setup.py @@ -22,7 +22,7 @@ import lps_gen try: - from setuptools import setup + from setuptools import setup, find_packages except ImportError: from distutils.core import setup @@ -38,7 +38,8 @@ config = { 'author_email': 'rsd@gnu.org', 'install_requires': ['nose', 'mock', 'mistune', 'Jinja2', 'beautifulsoup4'], 'py_modules': ['lps_gen'], - 'data_files':[('templates',['templates/lp-sch-2016.jinja2'])], + 'packages': find_packages(exclude=['tests']), + 'package_data': { 'lpschedule_generator': ['templates/*.jinja2'] }, 'entry_points': { 'console_scripts': ['lps_gen = lps_gen:main'] }, diff --git a/templates/lp-sch-2016.jinja2 b/templates/lp-sch-2016.jinja2 @@ -1,136 +0,0 @@ -{# -*- mode: jinja2; -*- #} -{# - Copyright (C) 2015 lpschedule-generator contributors. See CONTRIBUTORS. - - This file is part of lpschedule-generator. - - lpschedule-generator is free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - lpschedule-generator is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with lpschedule-generator (see COPYING). If not, see - <http://www.gnu.org/licenses/>. -#} - -{# macros start #} - -{# make speakers macro #} -{% macro mk_speakers(speakers) %} - <span class="program-session-speaker"> - {% for speaker in speakers %} - {% if loop.last %} - {{ speaker }} - {% else %} - {{ speaker }}, - {% endif %} - {% endfor %} - </span> -{% endmacro %} - -{# make room macro #} -{% macro mk_room(room) %} - <p><span class="label label-default">{{ room }}</span></p> -{% endmacro %} - -{# make day header macro #} -{% macro mk_day_header(day, collapse_area) %} - <header class="program-day-header"> - <hgroup> - <h2>{{ day }} - <a class="btn btn-default btn-xs" role="button" - data-toggle="collapse" aria-expanded="false" - aria-controls="{{ collapse_area }}" - href="#{{ collapse_area }}"> - &#x2193; - </a> - </h2> - </hgroup> - </header> -{% endmacro %} - -{# make timeslot header macro #} -{% macro mk_timeslot_header(timeslot, collapse, collapse_area='') %} - <header class="program-timeslot-header"> - <hgroup> - <h2>{{ timeslot }} - {% if collapse %} - <a class="btn btn-default btn-xs" role="button" - data-toggle="collapse" aria-expanded="false" - aria-controls="{{ collapse_area }}" - href="#{{ collapse_area }}"> - &#x2193; - </a> - {% endif %} - </h2> - </hgroup> - </header> -{% endmacro %} - -{# make session header macro #} -{% macro mk_session_header(session) %} - <header class="program-session-header"> - <hgroup> - <h2>{{ session }}</h2> - </hgroup> - </header> -{% endmacro %} - -{# desc macro #} -{% macro desc(disc_list) %} - {% for desc_p in disc_list %} - <p>{{ desc_p }}</p> - {% endfor %} -{% endmacro %} - -{# populate sessions macro #} -{% macro populate_sessions(sessions, day_index, timeslot_index) %} - {% for session, session_info in sessions.iteritems() %} {# session start #} - <section id="day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}" class="program-session"> - {{ mk_session_header(session) }} - {{ mk_speakers(session_info['speakers']) }} - <button class="btn btn-default btn-xs" - data-toggle="collapse" aria-expanded="false" - aria-controls="day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse" - data-target="#day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse"> - Details - </button> - <div class="collapse in" - id="day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse"> - {{ mk_room(session_info['room']) }} - {{ desc(session_info['desc']) }} - </div> <!-- day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }}-collapse end --> - </section> <!-- day-{{ day_index }}-timeslot-{{ timeslot_index }}-session-{{ loop.index }} end --> - {% endfor %} {# session end #} -{% endmacro %} - -{# populate timeslots macro #} -{% macro populate_timeslots(timeslots, day_index) %} - {% for timeslot, sessions in timeslots.iteritems() %} {# timeslot start #} - <article id="day-{{ day_index }}-timeslot-{{ loop.index }}" class="program-timeslot"> - {{ mk_timeslot_header(timeslot, sessions|length > 0, "day-%d-timeslot-%d-sessions"|format(day_index, loop.index)) }} - {% if sessions|length > 0 %} - <div class="collapse in" - id="day-{{ day_index }}-timeslot-{{ loop.index }}-sessions"> - {{ populate_sessions(sessions, day_index, loop.index) }} - </div> <!-- day-{{ day_index }}-timeslot-{{ loop.index }}-sessions end --> - {% endif %} - </article> <!-- day-{{ day_index }}-timeslot-{{ loop.index }} end --> - {% endfor %} {# timeslot start #} -{% endmacro %} - -{# lp 2016 template start #} -{% for day, timeslots in schedule.iteritems() %} {# day start #} - <article id="day-{{ loop.index }}-program" class="program-day"> - {{ mk_day_header(day, "day-%d-timeslots"|format(loop.index)) }} - <div class="collapse in" id="day-{{ loop.index }}-timeslots"> - {{ populate_timeslots(timeslots, loop.index) }} - </div> <!-- day-{{ loop.index }}-timeslots end --> - </article> <!-- day-{{ loop.index }} end --> -{% endfor %} {# day loop end #}