From ef02a3e2085481f838f6b6bdf25f6330429c4c6f Mon Sep 17 00:00:00 2001
From: Andreas Valder <andreasv@fsmpi.rwth-aachen.de>
Date: Thu, 25 Aug 2016 07:13:56 +0200
Subject: [PATCH] enhanced course site

---
 server.py             |  5 +++--
 templates/course.html | 10 ++++------
 templates/macros.html | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/server.py b/server.py
index f538f64..84e3492 100755
--- a/server.py
+++ b/server.py
@@ -145,9 +145,10 @@ def search():
 def course():
 	if 'courseid' in request.args:
 		id = request.args['courseid']
+		course = query('SELECT * FROM courses WHERE handle = ?', id)[0]
 		return render_template('course.html',
-				course=query('SELECT * FROM courses WHERE handle = ?', id),
-				lectures=query('SELECT * FROM lectures WHERE course_id = ?', id))
+				course=course,
+				lectures=query('SELECT * FROM lectures WHERE course_id = ?', course['id']))
 	else:
 		return redirect(url_for('index'))
 
diff --git a/templates/course.html b/templates/course.html
index 5f7606c..54fa781 100644
--- a/templates/course.html
+++ b/templates/course.html
@@ -1,4 +1,4 @@
-{% from 'macros.html' import course_list_item %}
+{% from 'macros.html' import lecture_list_item %}
 {% from 'macros.html' import preview %}
 {% extends "base.html" %}
 {% block content %}
@@ -8,11 +8,9 @@
 			<div class="panel-heading">
 				<h1 class="panel-title">Veranstaltungen</h1>
 			</div>
-			{{course|pprint}}
-			{{lectures|pprint}}
-			<ul class="list-group courselist">
-				{% for course in courses %}
-					{{ course_list_item(course,true) }}
+			<ul class="list-group lectureslist">
+				{% for l in lectures %}
+					{{ lecture_list_item(l) }}
 				{% endfor %}
 			</ul>
 		</div>
diff --git a/templates/macros.html b/templates/macros.html
index 2d9904f..561a028 100644
--- a/templates/macros.html
+++ b/templates/macros.html
@@ -55,6 +55,12 @@
 <video class="mejs-player" width="640" height="360" style="width: 100%; height: 80%;">
 	<source type="video/mp4" src="https://videoag.fsmpi.rwth-aachen.de/{{ videos[0]['path'] }}" />
 </video>
+<script>
+$('.mejs-player').mediaelementplayer({ 
+	features: ['playpause','progress','current','duration','tracks','volume','fullscreen'],
+	speeds:   ['3.00', '2.50', '2.00', '1.50', '1.25', '1.00', '0.75']
+});
+</script>
 {% endmacro %}
 
 {% macro course_list_item(course,show_semester=False) %}
@@ -81,3 +87,31 @@
 	</div>
 </li>
 {% endmacro %}
+
+{% macro lecture_list_item(lecture) %}
+<li class="list-group-item">
+	<div class="row">
+		<span class="col-xs-3">
+			{{ lecture.title }}
+		</span>
+		<span class="col-xs-2">
+			{{ lecture.time }}
+		</span>
+		<span class="col-xs-3">
+			{{ lecture.comment|safe }}
+		</span>
+		<span class="col-xs-2 pull-right">
+			<span class="dropdown">
+				<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Download<span class="caret"></span></button>
+				<ul class="dropdown-menu">
+					<li><a href="#">HTML</a></li>
+					<li><a href="#">CSS</a></li>
+					<li><a href="#">JavaScript</a></li>
+				</ul>
+			</span>
+			<span class="glyphicon glyphicon-play"></span>
+			</ul>
+		</span>
+	</div>
+</li>
+{% endmacro %}
-- 
GitLab