Commit 570430ef authored by Andreas Valder's avatar Andreas Valder

moved legacy handling to own file, closes #345

parent ee8e162b
from server import *
def legacy_index():
# handle legacy urls...
if 'course' in request.args:
return redirect(url_for('course', handle=request.args['course']),code=302)
if 'view' in request.args:
if (request.args['view'] == 'player') and ('lectureid' in request.args) :
courses = query('SELECT courses.handle FROM courses JOIN lectures ON courses.id = lectures.course_id WHERE lectures.id = ?', request.args['lectureid'])
if not courses:
return "Not found", 404
return redirect(url_for('lecture', course=courses[0]['handle'], id=request.args['lectureid']),code=302)
return None
@app.route('/site/')
@app.route('/site/<string:phpfile>')
def legacy(phpfile=None):
if phpfile=='embed.php' and ('lecture' in request.args):
courses = query('SELECT courses.handle FROM courses JOIN lectures ON courses.id = lectures.course_id WHERE lectures.id = ?', request.args['lecture'])
if not courses:
return render_endpoint('index', 'Diese Seite existiert nicht!'), 404
return redirect(url_for('embed', course=courses[0]['handle'], id=request.args['lecture']),code=302)
if phpfile=='embed.php' and ('vid' in request.args):
lectures = query('SELECT lecture_id FROM videos WHERE id = ?', request.args['vid'])
if not lectures:
return render_endpoint('index', 'Dieses Videos existiert nicht!'), 404
courses = query('SELECT courses.handle FROM courses JOIN lectures ON courses.id = lectures.course_id WHERE lectures.id = ?', lectures[0]['lecture_id'])
if not courses:
return render_endpoint('index', 'Diese Seite existiert nicht!'), 404
return redirect(url_for('embed', course=courses[0]['handle'], id=lectures[0]['lecture_id']),code=302)
if phpfile=='feed.php' and ('all' in request.args):
return redirect(url_for('feed'),code=302)
if phpfile=='feed.php' and ('newcourses' in request.args):
return redirect(url_for('courses_feed'),code=302)
if phpfile=='feed.php':
return redirect(url_for('feed', handle=request.args.copy().popitem()[0]),code=302)
print("Unknown legacy url:",request.url)
return redirect(url_for('index'),code=302)
......@@ -15,6 +15,7 @@ from ipaddress import ip_address, ip_network
import math
import locale
import base64
import json
locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
......@@ -74,6 +75,7 @@ if not config.get('SECRET_KEY', None):
from db import query, modify, show, searchquery
from ldap import ldapauth
from legacy import legacy_index
mod_endpoints = []
......@@ -176,14 +178,9 @@ def genlive(streams):
@register_navbar('Home', icon='home')
def index():
# handle legacy urls...
if 'course' in request.args:
return redirect(url_for('course', handle=request.args['course']),code=302)
if 'view' in request.args:
if (request.args['view'] == 'player') and ('lectureid' in request.args) :
courses = query('SELECT courses.handle FROM courses JOIN lectures ON courses.id = lectures.course_id WHERE lectures.id = ?', request.args['lectureid'])
if not courses:
return "Not found", 404
return redirect(url_for('lecture', course=courses[0]['handle'], id=request.args['lectureid']),code=302)
result = legacy_index()
if result:
return result
start = date.today()
end = start + timedelta(days=7)
......@@ -475,34 +472,6 @@ def sitemap():
return Response(render_template('sitemap.xml', pages=pages), 200, {'Content-Type': 'application/atom+xml'} )
@app.route('/site/')
@app.route('/site/<string:phpfile>')
def legacy(phpfile=None):
if phpfile=='embed.php' and ('lecture' in request.args):
courses = query('SELECT courses.handle FROM courses JOIN lectures ON courses.id = lectures.course_id WHERE lectures.id = ?', request.args['lecture'])
if not courses:
return render_endpoint('index', 'Diese Seite existiert nicht!'), 404
return redirect(url_for('embed', course=courses[0]['handle'], id=request.args['lecture']),code=302)
if phpfile=='embed.php' and ('vid' in request.args):
lectures = query('SELECT lecture_id FROM videos WHERE id = ?', request.args['vid'])
if not lectures:
return render_endpoint('index', 'Dieses Videos existiert nicht!'), 404
courses = query('SELECT courses.handle FROM courses JOIN lectures ON courses.id = lectures.course_id WHERE lectures.id = ?', lectures[0]['lecture_id'])
if not courses:
return render_endpoint('index', 'Diese Seite existiert nicht!'), 404
return redirect(url_for('embed', course=courses[0]['handle'], id=lectures[0]['lecture_id']),code=302)
if phpfile=='feed.php' and ('all' in request.args):
return redirect(url_for('feed'),code=302)
if phpfile=='feed.php' and ('newcourses' in request.args):
return redirect(url_for('courses_feed'),code=302)
if phpfile=='feed.php':
return redirect(url_for('feed', handle=request.args.copy().popitem()[0]),code=302)
print("Unknown legacy url:",request.url)
return redirect(url_for('index'),code=302)
import json
@app.route('/internal/dbstatus')
@register_navbar('DB-Status', icon='ok')
@mod_required
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment