Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
9b84296c
Commit
9b84296c
authored
Sep 01, 2016
by
Julian Rother
Browse files
Cleanup
parent
c716b741
Changes
3
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
9b84296c
...
...
@@ -22,14 +22,12 @@ config.from_pyfile('config.py', silent=True)
from
db
import
query
,
searchquery
,
ldapauth
,
ldapget
app
.
jinja_env
.
globals
[
'videoprefix'
]
=
config
[
'VIDEOPREFIX'
]
mod_endpoints
=
[]
@
app
.
template_global
()
def
ismod
(
*
args
):
return
(
'user'
in
session
)
app
.
jinja_env
.
globals
[
'ismod'
]
=
ismod
def
mod_required
(
func
):
mod_endpoints
.
append
(
func
.
__name__
)
@
wraps
(
func
)
...
...
@@ -50,6 +48,18 @@ def register_navbar(name, icon=None):
return
func
return
wrapper
def
render_endpoint
(
endpoint
,
flashtext
=
None
,
**
kargs
):
if
flashtext
:
flash
(
flashtext
)
# request.endpoint is used for navbar highlighting
if
request
.
url_rule
:
request
.
url_rule
.
endpoint
=
endpoint
return
app
.
view_functions
[
endpoint
](
**
kargs
)
@
app
.
errorhandler
(
404
)
def
handle_not_found
(
e
):
return
render_endpoint
(
'index'
,
'Diese Seite existiert nicht!'
)
@
app
.
route
(
'/'
)
@
register_navbar
(
'Home'
,
icon
=
'home'
)
def
index
():
...
...
@@ -72,7 +82,7 @@ def videos():
if
course
[
'semester'
]
==
''
:
course
[
'semester'
]
=
'zeitlos'
groupedby
=
request
.
args
.
get
(
'groupedby'
)
if
groupedby
not
in
[
'title'
,
'semester'
,
'organizer'
]:
if
groupedby
not
in
[
'title'
,
'semester'
,
'organizer'
]:
groupedby
=
'semester'
return
render_template
(
'course.html'
,
courses
=
courses
,
groupedby
=
groupedby
)
...
...
@@ -80,8 +90,7 @@ def videos():
def
course
(
id
):
courses
=
query
(
'SELECT * FROM courses WHERE ((handle = ?) or id = ?) AND (? OR visible)'
,
id
,
id
,
ismod
())
if
not
courses
:
flash
(
'Diese Veranstaltung existiert nicht!'
)
return
app
.
view_functions
[
'videos'
](),
404
return
render_endpoint
(
'index'
,
'Diese Veranstaltung existiert nicht!'
),
404
lectures
=
query
(
'SELECT * FROM lectures WHERE course_id = ? AND (? OR visible)'
,
courses
[
0
][
'id'
],
ismod
())
videos
=
query
(
'''
SELECT videos.*, (videos.downloadable AND courses.downloadable) as downloadable, formats.description AS format_description
...
...
@@ -104,14 +113,12 @@ def play(id):
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
())
if
not
lectures
:
flash
(
'Diese Vorlesung existiert nicht!'
)
return
app
.
view_functions
[
'videos'
](),
404
return
render_endpoint
(
'videos'
,
'Diese Vorlesung existiert nicht!'
),
404
if
not
videos
:
flash
(
'Zu dieser Vorlesung wurden noch keine Videos veröffentlicht!'
)
courses
=
query
(
'SELECT * FROM courses WHERE id = ? AND (? OR (visible AND listed))'
,
lectures
[
0
][
'course_id'
],
ismod
())
if
not
courses
:
flash
(
'Diese Veranstaltung existiert nicht!'
)
return
app
.
view_functions
[
'videos'
](),
404
return
render_endpoint
(
'videos'
,
'Diese Veranstaltung existiert nicht!'
),
404
return
render_template
(
'play.html'
,
course
=
courses
[
0
],
lecture
=
lectures
[
0
],
videos
=
videos
)
@
app
.
route
(
'/search'
)
...
...
templates/base.html
View file @
9b84296c
...
...
@@ -49,7 +49,7 @@
{% for endpoint, caption, gly, visible in navbar %}
{% if visible or ismod() %}
<li
{%
if
endpoint =
=
request.endpoint
%}
class=
"active"
{%
endif
%}
>
<a
href=
"{{ url_for(endpoint)
|e
}}"
>
{% if gly != '' %}
<span
class=
"glyphicon glyphicon-{{ gly }}"
></span>
{% endif %}{{ caption }}
</a>
<a
href=
"{{ url_for(endpoint) }}"
>
{% if gly != '' %}
<span
class=
"glyphicon glyphicon-{{ gly }}"
></span>
{% endif %}{{ caption }}
</a>
</li>
{% endif %}
{% endfor %}
...
...
@@ -63,12 +63,12 @@
{
html
:
true
,
title
:
'
Login für Moderatoren
'
,
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>
'
content
:
'
<form method="post" action="{{url_for(
'
login
'
, ref=request.url
)}}"><input placeholder="User" name="user" type="text"><br><input placeholder="Password" name="password" type="password"><br><input type="submit" value="Login"></form>
'
}
)
</script>
{% else %}
<a
href=
"{{url_for('logout'
)}}?
ref=
{{
request.url
|urlencode
}}"
>
<a
href=
"{{url_for('logout'
,
ref=request.url
)
}}"
>
{{ session.user.givenName }}
<span
class=
"glyphicon glyphicon-log-out"
></span>
</a>
...
...
templates/macros.html
View file @
9b84296c
...
...
@@ -3,7 +3,7 @@
<li
class=
"list-group-item"
>
<a
class=
"hidden-xs"
href=
"{{url_for('play', id=lecture['id'])}}"
title=
"{{ lecture['coursetitle'] }}"
>
<div
class=
"row"
>
<img
class=
"col-xs-4"
src=
"{{
videoprefix
}}/{{ lecture['titlefile'] }}"
alt=
"Vorschaubild"
>
<img
class=
"col-xs-4"
src=
"{{
config.VIDEOPREFIX
}}/{{ lecture['titlefile'] }}"
alt=
"Vorschaubild"
>
<div
class=
"col-xs-4"
>
<span
style=
"color: #000;"
><strong>
{{ lecture['short'] }}
</strong></span><br>
<span
style=
"color: #000;"
>
{{ lecture['time'] }}
</span>
...
...
@@ -19,7 +19,7 @@
</a>
<a
class=
"visible-xs"
href=
"{{url_for('play', id=lecture['id'])}}"
title=
"{{ lecture['coursetitle'] }}"
>
<div
class=
"row"
>
<img
class=
"col-xs-12"
src=
"{{
videoprefix
}}/{{ lecture['titlefile'] }}"
alt=
"Vorschaubild"
>
<img
class=
"col-xs-12"
src=
"{{
config.VIDEOPREFIX
}}/{{ lecture['titlefile'] }}"
alt=
"Vorschaubild"
>
</div>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
...
...
@@ -54,7 +54,7 @@
<link
rel=
"stylesheet"
href=
"{{url_for('static', filename='mediaelementjs/mediaelementplayer.css')}}"
/>
<video
class=
"mejs-player"
width=
"640"
height=
"360"
style=
"width: 100%; height: 100%;"
>
{% for v in videos %}
<source
type=
"video/mp4"
src=
"{{
videoprefix
}}/{{ v.path }}"
/>
<source
type=
"video/mp4"
src=
"{{
config.VIDEOPREFIX
}}/{{ v.path }}"
/>
{% endfor %}
</video>
<script>
...
...
@@ -94,13 +94,13 @@
<button
class=
"btn btn-primary dropdown-toggle {% if videos|length is equalto 0 %}disabled{% endif %}"
type=
"button"
data-toggle=
"dropdown"
>
Download
<span
class=
"caret"
></span></button>
<ul
class=
"dropdown-menu"
>
{% for v in videos %}
{% if v.downloadable %}
<li><a
href=
"{{
videoprefix
}}/{{v.path}}"
>
{{ valuecheckbox(['videos',v.id,'visible'], v.visible) }} {{v.format_description}} ({{v.file_size|filesizeformat(true)}})
</a></li>
{% endif %}
{% if v.downloadable %}
<li><a
href=
"{{
config.VIDEOPREFIX
}}/{{v.path}}"
>
{{ valuecheckbox(['videos',v.id,'visible'], v.visible) }} {{v.format_description}} ({{v.file_size|filesizeformat(true)}})
</a></li>
{% endif %}
{% endfor %}
</ul>
<noscript>
<ul
class=
"pull-right list-unstyled"
style=
"margin-left:10px;"
>
{% for v in videos %}
<li><a
href=
"{{
videoprefix
}}/{{v.path}}"
>
{{v.format_description}} ({{v.file_size|filesizeformat(true)}})
</a></li>
<li><a
href=
"{{
config.VIDEOPREFIX
}}/{{v.path}}"
>
{{v.format_description}} ({{v.file_size|filesizeformat(true)}})
</a></li>
{% endfor %}
</ul>
</noscript>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment