-from flask import request, abort, redirect, url_for, flash, render_template
+from urllib.parse import quote_plus
+
import paginate
import sqlalchemy as sa
+from flask import request, abort, redirect, url_for, flash, render_template, current_app
-import wrpylib.wrmwmarkup
-import wrpylib.wrmwcache
import wrpylib.mwmarkup
-
+import wrpylib.wrmwcache
+import wrpylib.wrmwmarkup
from wradmin.app import db
from wradmin.model import WrSledrunCache, WrReport
from wradmin.template_helper import PylonsHelper
sledrun = q.get(sledrun_id)
if sledrun is None:
abort(404)
- h = PylonsHelper()
- return render_template('json_editor.html',
- schema_url=url_for('static', filename='schema_v1.json'),
- #json_url=url_for('static', filename='latschenhuette.json')
- json_url=h.wiki(sledrun.page_title)
- )
+ mediawiki_index = f'{current_app.config["MEDIAWIKI_ROOT"]}/index.php'
+ schema_url = f'{mediawiki_index}?title=Winterrodeln:Datenschema/Rodelbahn/V1.json&action=raw'
+ json_url = f'{mediawiki_index}?title={quote_plus(sledrun.page_title)}/Rodelbahn.json&action=raw'
+ return render_template('json_editor.html', schema_url=schema_url, json_url=json_url)
def update(self):
"""Updates the wrsledruncache table from the wiki"""
-from flask import url_for
+from flask import url_for, current_app
import wrpylib.wrvalidators
"""Creates a link to the specified page in the www.winterrodeln.org wiki"""
if page_title is None:
page_title = 'Hauptseite'
- return 'https://www.winterrodeln.org/wiki/' + page_title
+ return current_app.config['MEDIAWIKI_WIKI'] + '/' + page_title
def forum(self, forum=None):
"""Creates a link to the specified forum. If no id is given, a general link is created."""
if forum is None:
- return 'http://winterrodeln-forum.org/'
+ return 'https://winterrodeln-forum.org/'
return 'https://winterrodeln-forum.org/viewforum.php?f={}'.format(forum)
def google_maps(self, latitude, longitude):
// Initialize the editor with a JSON schema
var editor = new JSONEditor(document.getElementById('editor_holder'), {
- // https://www.winterrodeln.org/mediawiki/index.php?title=Winterrodeln:Datenschema/Rodelbahn/V1.json&action=raw
- schema: {"$ref": "{{schema_url}}"},
+ schema: {"$ref": {{schema_url|tojson}}},
theme: 'bootstrap4',
ajax: true
});
editor.on('ready',() => {
- // https://www.winterrodeln.org/mediawiki/index.php?title=Latschenh%C3%BCtte/Rodelbahn.json&action=raw
- fetch("{{json_url}}").then(
+ fetch({{json_url|tojson}}).then(
function(response) {
return response.json();
}).then(