eskp.py
changeset 264 bdf11bb4cb98
parent 257 e953d3dc48b7
child 265 69babac65a72
equal deleted inserted replaced
263:b732704e750d 264:bdf11bb4cb98
     2 
     2 
     3 import os
     3 import os
     4 import codecs
     4 import codecs
     5 
     5 
     6 from docutils.core import publish_parts
     6 from docutils.core import publish_parts
     7 from flask import Flask
     7 from flask import Flask, Response
     8 from flask import render_template
     8 from flask import render_template
     9 from flask import request
     9 from flask import request
    10 from flask.ext.babel import gettext as _
    10 from flask.ext.babel import gettext as _
    11 from flask.ext.babel import Babel
    11 from flask.ext.babel import Babel
    12 from config import LANGUAGES
    12 from config import LANGUAGES
    19 
    19 
    20 app = Flask(__name__)
    20 app = Flask(__name__)
    21 babel = Babel(app)
    21 babel = Babel(app)
    22 
    22 
    23 app.config['BABEL_DEFAULT_LOCALE'] = 'de'
    23 app.config['BABEL_DEFAULT_LOCALE'] = 'de'
    24 
       
    25 
    24 
    26 def get_content(filename, overrides=None):
    25 def get_content(filename, overrides=None):
    27     content = u""
    26     content = u""
    28     filename = os.path.join(ESKP_PATH, filename)
    27     filename = os.path.join(ESKP_PATH, filename)
    29     if os.path.isfile(filename):
    28     if os.path.isfile(filename):
    59              ]
    58              ]
    60     return menue
    59     return menue
    61 
    60 
    62 app.jinja_env.globals.update(get_o3lossclams_dates=get_o3lossclams_dates)
    61 app.jinja_env.globals.update(get_o3lossclams_dates=get_o3lossclams_dates)
    63 app.jinja_env.globals.update(get_vpsc_dates=get_vpsc_dates)
    62 app.jinja_env.globals.update(get_vpsc_dates=get_vpsc_dates)
       
    63 
       
    64 def author_info(name, filename):
       
    65     content = get_content(filename)
       
    66     html = render_template("/author_info.html", act="author", title=name, content=content, exit=_(u"Close"))
       
    67     return html
       
    68 
    64 
    69 
    65 @babel.localeselector
    70 @babel.localeselector
    66 def get_locale():
    71 def get_locale():
    67     """ToDo: if translation is completed, switch to en """
    72     """ToDo: if translation is completed, switch to en """
    68     return LANGUAGE_SELECTED or request.accept_languages.best_match(LANGUAGES.keys()) or 'de'
    73     return LANGUAGE_SELECTED or request.accept_languages.best_match(LANGUAGES.keys()) or 'de'
   124 
   129 
   125 @app.route("/ozoneloss")
   130 @app.route("/ozoneloss")
   126 def ozoneloss():
   131 def ozoneloss():
   127     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst")
   132     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst")
   128     content = get_content(filename)
   133     content = get_content(filename)
   129     return render_template("/ozoneloss.html", act="ozoneloss", content=content)
   134     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_author.rst")
       
   135     author = author_info(_(u"Ozoneloss"), filename)
       
   136     return render_template("/ozoneloss.html", act="ozoneloss", content=content,
       
   137                            author=author, contact = u"Dr. Jens-Uwe Grooß", publications=u"Publications" )
   130 
   138 
   131 @app.route("/ozoneloss/clams")
   139 @app.route("/ozoneloss/clams")
   132 def ozoneloss_clams():
   140 def ozoneloss_clams():
   133     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_clams.rst")
   141     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_clams.rst")
   134     content = get_content(filename)
   142     content = get_content(filename)
   142 
   150 
   143 @app.route("/iek-7")
   151 @app.route("/iek-7")
   144 def institute():
   152 def institute():
   145     filename = os.path.join("templates", get_locale(), "rst", "iek-7.rst")
   153     filename = os.path.join("templates", get_locale(), "rst", "iek-7.rst")
   146     content = get_content(filename)
   154     content = get_content(filename)
   147     return render_template("/iek-7.html", act="iek-7", content=content)
   155     filename = os.path.join("templates", get_locale(), "rst", "iek-7_author.rst")
       
   156     author = author_info(_(u"IEK-7"), filename)
       
   157     return render_template("/iek-7.html", act="iek-7", content=content,
       
   158                            author=author, contact = u"Sandra Stein")
   148 
   159 
   149 
   160 
   150 @app.route("/imprint")
   161 @app.route("/imprint")
   151 def imprint():
   162 def imprint():
   152     filename = os.path.join("templates", get_locale(), "rst", "imprint.rst")
   163     filename = os.path.join("templates", get_locale(), "rst", "imprint.rst")
   153     content = get_content(filename)
   164     content = get_content(filename)
   154     return render_template("/content.html", act="imprint", content=content)
   165     return render_template("/content.html", act="imprint", content=content)
       
   166 
       
   167 
   155 
   168 
   156 
   169 
   157 
   170 
   158 @app.errorhandler(404)
   171 @app.errorhandler(404)
   159 def page_not_found(e):
   172 def page_not_found(e):
Impressum Datenschutzerklärung