diff -r 4fae7e615b2b -r 878b81ffb8f7 eskp.py --- a/eskp.py Mon Feb 03 16:20:55 2020 +0100 +++ b/eskp.py Mon Feb 03 17:20:42 2020 +0100 @@ -49,6 +49,14 @@ content = publish_parts(rst_data, writer_name='html', settings_overrides=overrides)['html_body'] return content +def get_html_content(filename, overrides=None): + html_content = u"" + filename = os.path.join(ESKP_PATH, filename) + if os.path.isfile(filename): + with codecs.open(filename, 'r', 'utf-8') as f: + html_content = f.read() + + return html_content def get_newest_date(): getdates = get_valid_dates(FILES) @@ -279,7 +287,11 @@ def ozoneloss_uvmap(): filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvmap.rst") content = get_content(filename) - return render_template("/ozoneloss_uvmap.html", act="ozoneloss/uvmap", content=content) + + htmlfile = os.path.join("templates", get_locale(), "html", "uvi_table.html") + html_content = get_html_content(htmlfile) + return render_template("/ozoneloss_uvmap.html", act="ozoneloss/uvmap", content=content, + html_content=html_content) @app.route("/ozoneloss/vpsc") @@ -291,22 +303,31 @@ @app.route("/ozoneloss/uvi", methods=['GET']) def ozoneloss_uvi(): - # XXX check 'POST' does not work filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst") content = get_content(filename) + htmlfile = os.path.join("templates", get_locale(), "html", "ozoneloss_uvi_form.html") + html_content = get_html_content(htmlfile) + htmlfile = os.path.join("templates", get_locale(), "html", "uvi_table.html") + html_table = get_html_content(htmlfile) lat = 50. o3offset = 50. figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, o3offset) + button_text = _("Graph anzeigen") return render_template('ozoneloss_uvi.html', act="ozoneloss/uvi", content=content, figname=figname, - alt=_(u"UV increase at {{lat}} degrees N for {{o3offset}} DU ozone depletion")) + alt=_(u"UV increase at {{lat}} degrees N for {{o3offset}} DU ozone depletion"), + html_content=html_content, html_table=html_table, button_text=button_text) @app.route("/ozoneloss/uvi_graph", methods=['POST']) def ozoneloss_uvi_graph(): filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst") content = get_content(filename) + htmlfile = os.path.join("templates", get_locale(), "html", "ozoneloss_uvi_form.html") + html_content = get_html_content(htmlfile) + htmlfile = os.path.join("templates", get_locale(), "html", "uvi_table.html") + html_table = get_html_content(htmlfile) latstr = request.form['Gradzahl'] o3offsetstr = request.form['Dobson-Unit'] @@ -321,9 +342,12 @@ lat = -float(latstr2) figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, float(o3offsetstr)) + button_text = _("Graph anzeigen") return render_template('graph.html', act="ozoneloss_uvi_graph", content=content, figname=figname, - o3offsetstr=o3offsetstr, latstr=latstr) + alt=_(u"UV increase at {{lat}} degrees N for {{o3offset}} DU ozone depletion"), + o3offsetstr=o3offsetstr, latstr=latstr, html_content=html_content, + html_table=html_table, button_text=button_text) @app.route("/ozoneloss/decadal") def ozoneloss_decadal():