From: philipp Date: Wed, 27 Dec 2017 22:31:24 +0000 (+0000) Subject: coordtool.html now uses jinja2. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wradmin.git/commitdiff_plain/5965ae8ea5de10fd1a4a1e1ec502f43fb4749636 coordtool.html now uses jinja2. git-svn-id: http://www.winterrodeln.org/svn/wradmin/trunk@2765 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- diff --git a/wradmin/controllers/coordtool.py b/wradmin/controllers/coordtool.py index 1aefbc9..9dda22b 100644 --- a/wradmin/controllers/coordtool.py +++ b/wradmin/controllers/coordtool.py @@ -3,8 +3,7 @@ import re import xml.dom.minidom as minidom from xml.parsers.expat import ExpatError from enum import IntEnum -from flask import request, redirect, url_for, flash -from wradmin.genshi import render_genshi_template, TemplateContext +from flask import request, redirect, url_for, flash, render_template class MultiGeo(IntEnum): @@ -96,41 +95,41 @@ def multigeo_to_string(value, output_format): class CoordtoolController: def index(self): - c = TemplateContext() - c.result = None - return render_genshi_template('coordtool.html', c=c) + return render_template('coordtool.html', result=None) def convert(self): - c = TemplateContext() assert request.method == 'POST' input = request.form['input'] no_elevation = 'no_elevation' in request.form simplify = 'simplify' in request.form swap_latlon = 'swap_latlon' in request.form - c.no_geoformat = 'no_geoformat' in request.form - c.no_gpxformat = 'no_gpxformat' in request.form - c.no_gmapsformat = 'no_gmapsformat' in request.form - c.no_geocachingformat = 'no_geocachingformat' in request.form + no_geoformat = 'no_geoformat' in request.form + no_gpxformat = 'no_gpxformat' in request.form + no_gmapsformat = 'no_gmapsformat' in request.form + no_geocachingformat = 'no_geocachingformat' in request.form if input is None or len(input.strip()) == 0: - c.result = None return redirect(url_for('coordtool_index')) try: - c.result = multigeo_from_string(input, MultiGeo.FORMAT_GUESS) + result = multigeo_from_string(input, MultiGeo.FORMAT_GUESS) except ValueError as e: flash(str(e)) return redirect(url_for('coordtool_index')) if swap_latlon: - c.result = [(latitude, longitude, elevation) for (longitude, latitude, elevation) in c.result] + result = [(latitude, longitude, elevation) for (longitude, latitude, elevation) in result] if no_elevation: - c.result = [(longitude, latitude, None) for (longitude, latitude, elevation) in c.result] + result = [(longitude, latitude, None) for (longitude, latitude, elevation) in result] - c.geo_winterrodeln = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_WINTERRODELN) - c.geo_gmapplugin = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_GMAPPLUGIN) - c.geo_gpx = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_GPX) - c.geo_geocaching = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_GEOCACHING) + geo_winterrodeln = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_WINTERRODELN) + geo_gmapplugin = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_GMAPPLUGIN) + geo_gpx = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_GPX) + geo_geocaching = lambda value: multigeo_to_string(value, MultiGeo.FORMAT_GEOCACHING) - return render_genshi_template('coordtool.html', c=c) + return render_template('coordtool.html', result=result, + no_geoformat=no_geoformat, geo_winterrodeln=geo_winterrodeln, + no_gmapsformat=no_gmapsformat, geo_gmapplugin=geo_gmapplugin, + no_gpxformat=no_gpxformat, geo_gpx=geo_gpx, + no_geocachingformat=no_geocachingformat, geo_geocaching=geo_geocaching) diff --git a/wradmin/templates/coordtool.html b/wradmin/templates/coordtool.html index 3e5792e..8e3f1b7 100644 --- a/wradmin/templates/coordtool.html +++ b/wradmin/templates/coordtool.html @@ -1,66 +1,73 @@ - - - - - - - Koordinaten-Rechner - - - +{% extends "master.html" %} +{% block title %}Koordinaten-Rechner{% endblock %} +{% block content %}

Koordinaten-Rechner

-

Werkzeug für die Koordinatenumrechnung. Das Quellformat braucht nicht angegeben zu werden, es sollte automatisch erkannt werden. Wenn mehr als eine Koordinate gleichzeitig umgerechnet werden soll, dann bitte pro Zeile eine Koordinate angeben.

+{% if not result %} +

Werkzeug für die Koordinatenumrechnung. Das Quellformat braucht nicht angegeben zu werden, es sollte automatisch erkannt werden. Wenn mehr als eine Koordinate gleichzeitig umgerechnet werden soll, dann bitte pro Zeile eine Koordinate angeben.

+{% endif %} -

Winterrodeln-Format

-

- ${c.geo_winterrodeln([line])}
+{% if result and not no_geoformat %} +

Winterrodeln-Format

+

+ {% for line in result %} + {{geo_winterrodeln([line])}}
+ {% endfor %}

+{% endif %} -

Google Maps Plugin Format

-

- ${c.geo_gmapplugin([line])}
+{% if result and not no_gmapsformat %} +

Google Maps Plugin Format

+

+ {% for line in result %} + {{geo_gmapplugin([line])}}
+ {% endfor %}

+{% endif %} -

GPX Format

-

- ${c.geo_gpx([line])}
+{% if result and not no_gpxformat %} +

GPX Format

+

+ {% for line in result %} + {{geo_gpx([line])}}
+ {% endfor %}

+{% endif %} -

Geocaching-Format

-

- ${c.geo_geocaching([line])}
+{% if result and not no_geocachingformat %} +

Geocaching-Format

+

+ {% for line in result %} + {{geo_geocaching([line])}}
+ {% endfor %}

+{% endif %} -
+ - - + - + - +
Beispiel

47.222134 N 11.467211 E
47.222143 N 11.467209 E
47.222153 N 11.467210 E

-

N 47° 14.912 E 011° 27.432
- N 47° 14.925 E 011° 27.439
- N 47° 14.936 E 011° 27.440

+

N 47° 14.912 E 011° 27.432
+ N 47° 14.925 E 011° 27.439
+ N 47° 14.936 E 011° 27.440

47.232922, 11.452239
47.233008, 11.452201
47.233810, 11.452150

Höhe weglassen
Höhe weglassen
Weg vereinfachen (noch nicht implementiert)
Geogr. Länge und Breite vertauschen
Geogr. Länge und Breite vertauschen
Zielformat <geo> auslassen47.222134 N 11.467211 E
Zielformat <GPX> auslassen<trkpt lat="47.181289" lon="11.408827"><ele>1090.57</ele></trkpt>
Zielformat Google Maps Plugin auslassen47.232922, 11.452239
Zielformat Geocaching auslassenN 47° 14.029 E 011° 27.129
Zielformat Geocaching auslassenN 47° 14.029 E 011° 27.129
- - +{% endblock %}