Skip to content
Snippets Groups Projects
Commit 5b261a32 authored by Julian Rother's avatar Julian Rother
Browse files

Change url schema so mandatory args are handled by flask and converted links to url_for

parent 5cfac18c
No related branches found
No related tags found
No related merge requests found
...@@ -81,11 +81,8 @@ def videos(): ...@@ -81,11 +81,8 @@ def videos():
def faq(): def faq():
return render_template('faq.html') return render_template('faq.html')
@app.route('/play') @app.route('/play/<int:id>')
def play(): def play(id):
if not 'lectureid' in request.args:
return redirect(url_for('videos'))
id = request.args.get('lectureid')
lectures = query('SELECT * FROM lectures WHERE id = ? AND (? OR visible)', id, ismod()) lectures = query('SELECT * FROM lectures WHERE id = ? AND (? OR visible)', id, ismod())
videos = query('SELECT * FROM videos WHERE lecture_id = ? AND (? OR visible)', id, ismod()) videos = query('SELECT * FROM videos WHERE lecture_id = ? AND (? OR visible)', id, ismod())
if not lectures: if not lectures:
...@@ -112,11 +109,8 @@ def search(): ...@@ -112,11 +109,8 @@ def search():
'WHERE (? OR (coursevisible AND listed AND visible)) GROUP BY id ORDER BY _score DESC, time DESC LIMIT 30', ismod()) 'WHERE (? OR (coursevisible AND listed AND visible)) GROUP BY id ORDER BY _score DESC, time DESC LIMIT 30', ismod())
return render_template('search.html', searchtext=request.args['q'], courses=courses, lectures=lectures) return render_template('search.html', searchtext=request.args['q'], courses=courses, lectures=lectures)
@app.route('/course') @app.route('/course/<id>')
def course(): def course(id):
if not 'courseid' in request.args:
return redirect(url_for('videos'))
id = request.args['courseid']
courses = query('SELECT * FROM courses WHERE handle = ? AND (? OR visible)', id, ismod()) courses = query('SELECT * FROM courses WHERE handle = ? AND (? OR visible)', id, ismod())
if not courses: if not courses:
flash('Diese Veranstaltung existiert nicht!') flash('Diese Veranstaltung existiert nicht!')
......
...@@ -5,23 +5,23 @@ ...@@ -5,23 +5,23 @@
<head> <head>
<title>Video AG</title> <title>Video AG</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="static/jquery.js"></script> <script src="{{url_for('static', filename='jquery.js')}}"></script>
<link rel="stylesheet" type="text/css" href="static/style.css"> <link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}">
<link rel="icon" type="image/png" href="static/favicon.png"> <link rel="icon" type="image/png" href="{{url_for('static', filename='favicon.png')}}">
<meta http-equiv="content-language" content="de-DE"> <meta http-equiv="content-language" content="de-DE">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="static/bootstrap/bootstrap.css" rel="stylesheet"> <link href="{{url_for('static', filename='bootstrap/bootstrap.css')}}" rel="stylesheet">
<script src="static/bootstrap/bootstrap.js"></script> <script src="{{url_for('static', filename='bootstrap/bootstrap.js')}}"></script>
{%if ismod() %}<script src="static/moderator.js"></script>{% endif %} {%if ismod() %}<script src="{{url_for('static', filename='moderator.js')}}"></script>{% endif %}
</head> </head>
<body> <body>
<nav class="navbar navbar-default navbar-static-top"> <nav class="navbar navbar-default navbar-static-top">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-xs-1 hidden-xs hidden-sm"> <div class="col-xs-1 hidden-xs hidden-sm">
<a href="/"><img src="/static/logo.png" style="width: 80px; padding: 5px"></a> <a href="/"><img src="{{url_for('static', filename='logo.png')}}" style="width: 80px; padding: 5px"></a>
</div> </div>
<div class="col-xs-12 col-md-11"> <div class="col-xs-12 col-md-11">
<div class="row"> <div class="row">
...@@ -63,12 +63,12 @@ ...@@ -63,12 +63,12 @@
{ {
html:true, html:true,
title:'Login für Moderatoren', title:'Login für Moderatoren',
content:'<form method="post" action="login"><input placeholder="User" name="user" type="text"><br><input placeholder="Password" name="password" type="password"><br><input type="hidden" name="ref" value="{{ request.url|e }}"><input type="submit" value="Login"></form>' content:'<form method="post" action="{{url_for('login')}}"><input placeholder="User" name="user" type="text"><br><input placeholder="Password" name="password" type="password"><br><input type="hidden" name="ref" value="{{ request.url|e }}"><input type="submit" value="Login"></form>'
} }
) )
</script> </script>
{% else %} {% else %}
<a href="/logout?ref={{ request.url|urlencode }}"> <a href="{{url_for('logout')}}?ref={{ request.url|urlencode }}">
{{ session.user.givenName }} {{ session.user.givenName }}
<span class="glyphicon glyphicon-log-out"></span> <span class="glyphicon glyphicon-log-out"></span>
</a> </a>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<p>Wir machen Vorlesungsvideos, damit du dir deine Vorlesungen angucken kannst, wann, wo und so oft <strong>du</strong> willst ;)</p> <p>Wir machen Vorlesungsvideos, damit du dir deine Vorlesungen angucken kannst, wann, wo und so oft <strong>du</strong> willst ;)</p>
<p><strong>Probleme?</strong><a href="/faq"> Hier gehts zur FAQ</a></p> <p><strong>Probleme?</strong><a href="{{url_for('faq')}}"> Hier gehts zur FAQ</a></p>
<p>Wenn du die Videos nützlich fandest, schreib doch bitte den Dozenten eine kurze E-Mail. Waren die Videos grauenhaft? Kritik an uns.</p> <p>Wenn du die Videos nützlich fandest, schreib doch bitte den Dozenten eine kurze E-Mail. Waren die Videos grauenhaft? Kritik an uns.</p>
<p>Wenn du mitmachen willst, Fragen oder Anregungen hast, oder nur mal schauen möchtest, komm zu unserem AG-Treffen oder schreib uns eine E-Mail. <p>Wenn du mitmachen willst, Fragen oder Anregungen hast, oder nur mal schauen möchtest, komm zu unserem AG-Treffen oder schreib uns eine E-Mail.
Insbesondere freuen wir uns über Studis der Mathematik und Physik, die ihre Vorlesungen filmen wollen.</p> Insbesondere freuen wir uns über Studis der Mathematik und Physik, die ihre Vorlesungen filmen wollen.</p>
......
{% macro preview(lecture) %} {% macro preview(lecture) %}
<li class="list-group-item"> <li class="list-group-item">
<a class="hidden-xs" href="/play?lectureid={{ lecture['id'] }}" title="{{ lecture['coursetitle'] }}"> <a class="hidden-xs" href="{{url_for('play', id=lecture['id'])}}" title="{{ lecture['coursetitle'] }}">
<div class="row"> <div class="row">
<img class="col-xs-4" src="{{ videoprefix }}/{{ lecture['titlefile'] }}" alt="Vorschaubild"> <img class="col-xs-4" src="{{ videoprefix }}/{{ lecture['titlefile'] }}" alt="Vorschaubild">
<div class="col-xs-4"> <div class="col-xs-4">
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
</div> </div>
</a> </a>
<a class="visible-xs" href="/play?lectureid={{ lecture['id'] }}" title="{{ lecture['coursetitle'] }}"> <a class="visible-xs" href="{{url_for('play', id=lecture['id'])}}" title="{{ lecture['coursetitle'] }}">
<div class="row"> <div class="row">
<img class="col-xs-12" src="{{ videoprefix }}/{{ lecture['titlefile'] }}" alt="Vorschaubild"> <img class="col-xs-12" src="{{ videoprefix }}/{{ lecture['titlefile'] }}" alt="Vorschaubild">
</div> </div>
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
{% endmacro %} {% endmacro %}
{% macro player(lecture, videos) %} {% macro player(lecture, videos) %}
<script src="static/mediaelementjs/mediaelement-and-player.min.js"></script> <script src="{{url_for('static', filename='/mediaelementjs/mediaelement-and-player.min.js')}}"></script>
<link rel="stylesheet" href="static/mediaelementjs/mediaelementplayer.css" /> <link rel="stylesheet" href="{{url_for('static', filename='mediaelementjs/mediaelementplayer.css')}}" />
<video class="mejs-player" width="640" height="360" style="width: 100%; height: 100%;"> <video class="mejs-player" width="640" height="360" style="width: 100%; height: 100%;">
{% for v in videos %} {% for v in videos %}
<source type="video/mp4" src="{{ videoprefix }}/{{ v.path }}" /> <source type="video/mp4" src="{{ videoprefix }}/{{ v.path }}" />
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
{% macro course_list_item(course,show_semester=False) %} {% macro course_list_item(course,show_semester=False) %}
<li class="list-group-item {% if (not course.visible) or (not course.listed) %}list-group-item-danger{% endif %}"> <li class="list-group-item {% if (not course.visible) or (not course.listed) %}list-group-item-danger{% endif %}">
<div class="row"> <div class="row">
<a href=/course?courseid={{course.handle}}> <a href="{{url_for('course', id=course.handle)}}">
{% if show_semester %} {% if show_semester %}
<span class="col-xs-1"> <span class="col-xs-1">
{{ course.semester }} {{ course.semester }}
...@@ -147,7 +147,7 @@ $('#embedcodebtn').popover( ...@@ -147,7 +147,7 @@ $('#embedcodebtn').popover(
<span class="dropdown"> <span class="dropdown">
{{ video_download_btn(videos) }} {{ video_download_btn(videos) }}
</span> </span>
<a href="/play?lectureid={{lecture.id}}" class="btn btn-default {% if videos|length is equalto 0 %}disabled{% endif %}"> <a href="{{url_for('play', id=lecture.id)}}" class="btn btn-default {% if videos|length is equalto 0 %}disabled{% endif %}">
<span class="glyphicon glyphicon-play"></span> <span class="glyphicon glyphicon-play"></span>
Play Play
</a> </a>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<p class="col-xs-12" style="padding: 0px;"> <p class="col-xs-12" style="padding: 0px;">
<span><a href="/course?courseid={{course.handle}}" class="btn btn-default" >Zur Veranstaltungsseite</a><span> <span><a href="{{url_for('course', id=course.handle)}}" class="btn btn-default" >Zur Veranstaltungsseite</a><span>
<span class="pull-right"> <span class="pull-right">
<span>{{ video_embed_btn(lecture.id) }}</span> <span>{{ video_embed_btn(lecture.id) }}</span>
<span>{{video_download_btn(videos)}}</span> <span>{{video_download_btn(videos)}}</span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment