template dates imports content from a rst table
authorReimar Bauer <rb.proj AT googlemail DOT com>
Sun, 19 Jan 2014 11:40:20 +0100
changeset 161cb62df6e4e77
parent 160 e4f16be8b5b0
child 162 90e47d2a2c40
template dates imports content from a rst table
pymove3d.py
templates/dates.html
templates/de/dates.html
templates/de/rst/dates.rst
templates/en/dates.html
templates/en/rst/dates.rst
     1.1 --- a/pymove3d.py	Sun Jan 19 10:52:51 2014 +0100
     1.2 +++ b/pymove3d.py	Sun Jan 19 11:40:20 2014 +0100
     1.3 @@ -14,6 +14,10 @@
     1.4  from sayings import get_saying
     1.5  from jinja2 import Environment, FileSystemLoader
     1.6  
     1.7 +import codecs
     1.8 +from docutils.core import publish_parts
     1.9 +
    1.10 +
    1.11  LANGUAGE_SELECTED = "de"
    1.12  #ToDo after engelish is implemented set LANGUAGE_SELECTED = None
    1.13  
    1.14 @@ -103,8 +107,15 @@
    1.15  
    1.16  @app.route("/dates")
    1.17  def dates():
    1.18 -    return render_template(get_locale() + "/dates.html",
    1.19 -                           act="dates")
    1.20 +    content = u""
    1.21 +    filename = os.path.join("templates", get_locale(), "rst", "dates.rst")
    1.22 +    if os.path.isfile(filename):
    1.23 +        with codecs.open(filename, 'r', 'utf-8') as f:
    1.24 +            rst_data = f.read()
    1.25 +        f.close()
    1.26 +        content = publish_parts(rst_data, writer_name='html')['html_body']
    1.27 +    return render_template("/dates.html",
    1.28 +                           act="dates", content=content)
    1.29  
    1.30  
    1.31  @app.errorhandler(404)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/templates/dates.html	Sun Jan 19 11:40:20 2014 +0100
     2.3 @@ -0,0 +1,8 @@
     2.4 +{% extends "theme.html" %} 
     2.5 +{% block body %}
     2.6 +<div class="container">
     2.7 + <div class="col-lg-12">
     2.8 +{{ content|safe }}
     2.9 + </div>
    2.10 +</div>
    2.11 +{% endblock %}
     3.1 --- a/templates/de/dates.html	Sun Jan 19 10:52:51 2014 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,49 +0,0 @@
     3.4 -{% extends "theme.html" %} 
     3.5 -{% block body %}
     3.6 -<div class="container">
     3.7 - <div class="col-lg-12">
     3.8 -     <h2>Termine</h2>
     3.9 -     <table class="table table-striped">
    3.10 -         <tbody>
    3.11 -             <tr>
    3.12 -                 <td><b>Datum</b></td>
    3.13 -                 <td><b>Ort</b></td>
    3.14 -                 <td><b>Aktivität</b></td>
    3.15 -             </tr>
    3.16 -             <tr>
    3.17 -                 <td>13.-14.03.2014</td>
    3.18 -                 <td>Chemnitz (Linuxtag)</td>
    3.19 -                 <td>Kurs/Workshop</td>
    3.20 -             </tr>
    3.21 -             <tr>
    3.22 -                 <td>29.-30.03.2014</td>
    3.23 -                 <td>Köln</td>
    3.24 -                 <td>Barcamp</td>
    3.25 -             </tr>
    3.26 -             <tr>
    3.27 -                 <td>01.05.2014</td>
    3.28 -                 <td>-</td>
    3.29 -                 <td>Einsendeschluss</td>
    3.30 -             </tr>
    3.31 -             <tr>
    3.32 -                 <td>21.07. - 27.07.2014</td>
    3.33 -                 <td>Berlin (EuroPython 2014)</td>
    3.34 -                 <td>Preisverleihung</td>
    3.35 -             </tr>
    3.36 -             <tr>
    3.37 -                 <td></td>
    3.38 -                 <td></td>
    3.39 -                 <td></td>
    3.40 -             </tr>
    3.41 -             <tr>
    3.42 -                 <td></td>
    3.43 -                 <td></td>
    3.44 -                 <td></td>
    3.45 -             </tr>
    3.46 -         <tbody>
    3.47 -     </table>
    3.48 -     
    3.49 -     
    3.50 - </div>
    3.51 -</div>
    3.52 -{% endblock %}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/templates/de/rst/dates.rst	Sun Jan 19 11:40:20 2014 +0100
     4.3 @@ -0,0 +1,16 @@
     4.4 +Termine
     4.5 +-------
     4.6 +
     4.7 ++------------------------+---------------------------+--------------------+
     4.8 +| Datum                  | Ort                       | Aktivität          |
     4.9 ++========================+===========================+====================+
    4.10 +| 13.-14.03.2014         | Chemnitz (Linuxtag)       | Kurs/Workshop      |
    4.11 ++------------------------+---------------------------+--------------------+
    4.12 +| 29.-30.03.2014         | Köln                      | Barcamp...         |
    4.13 ++------------------------+---------------------------+--------------------+
    4.14 +| 01.05.2014             |                           | Einsendeschluss    |
    4.15 ++------------------------+---------------------------+--------------------+
    4.16 +| 21.07. - 27.07.2014    | Berlin (EuroPython 2014)  | Preisverleihung    |
    4.17 ++------------------------+---------------------------+--------------------+
    4.18 +
    4.19 +
     5.1 --- a/templates/en/dates.html	Sun Jan 19 10:52:51 2014 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,49 +0,0 @@
     5.4 -{% extends "theme.html" %} 
     5.5 -{% block body %}
     5.6 -<div class="container">
     5.7 - <div class="col-lg-12">
     5.8 -     <h2>Termine</h2>
     5.9 -     <table class="table table-striped">
    5.10 -         <tbody>
    5.11 -             <tr>
    5.12 -                 <td><b>Datum</b></td>
    5.13 -                 <td><b>Ort</b></td>
    5.14 -                 <td><b>Aktivität</b></td>
    5.15 -             </tr>
    5.16 -             <tr>
    5.17 -                 <td>13.-14.03.2014</td>
    5.18 -                 <td>Chemnitz (Linuxtag)</td>
    5.19 -                 <td>Kurs/Workshop</td>
    5.20 -             </tr>
    5.21 -             <tr>
    5.22 -                 <td>29.-30.03.2014</td>
    5.23 -                 <td>Köln</td>
    5.24 -                 <td>Barcamp</td>
    5.25 -             </tr>
    5.26 -             <tr>
    5.27 -                 <td>01.05.2014</td>
    5.28 -                 <td>-</td>
    5.29 -                 <td>Einsendeschluss</td>
    5.30 -             </tr>
    5.31 -             <tr>
    5.32 -                 <td>21.07. - 27.07.2014</td>
    5.33 -                 <td>Berlin (EuroPython 2014)</td>
    5.34 -                 <td>Preisverleihung</td>
    5.35 -             </tr>
    5.36 -             <tr>
    5.37 -                 <td></td>
    5.38 -                 <td></td>
    5.39 -                 <td></td>
    5.40 -             </tr>
    5.41 -             <tr>
    5.42 -                 <td></td>
    5.43 -                 <td></td>
    5.44 -                 <td></td>
    5.45 -             </tr>
    5.46 -         <tbody>
    5.47 -     </table>
    5.48 -     
    5.49 -     
    5.50 - </div>
    5.51 -</div>
    5.52 -{% endblock %}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/templates/en/rst/dates.rst	Sun Jan 19 11:40:20 2014 +0100
     6.3 @@ -0,0 +1,16 @@
     6.4 +Dates
     6.5 +-------
     6.6 +
     6.7 ++--------------------------+---------------------------+--------------------+
     6.8 +| Date                     | Location                  | Activity           |
     6.9 ++==========================+===========================+====================+
    6.10 +| 2014-03-13 - 2014-03-14  | Chemnitz (Linuxtag)       | Kurs/Workshop      |
    6.11 ++--------------------------+---------------------------+--------------------+
    6.12 +| 2014-03-29 - 2014-03-30  | Cologne                   | Barcamp...         |
    6.13 ++--------------------------+---------------------------+--------------------+
    6.14 +| 2014-05-0114             |                           | Deadline           |
    6.15 ++--------------------------+---------------------------+--------------------+
    6.16 +| 2014-07-21 - 2014-07-27  | Berlin (EuroPython 2014)  | Price-giving       |
    6.17 ++--------------------------+---------------------------+--------------------+
    6.18 +
    6.19 +
Impressum Datenschutzerklärung