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
5f1f10d0
Commit
5f1f10d0
authored
Aug 29, 2016
by
Julian Rother
Browse files
Implemented navbar items as decorators
parent
d3fadbf9
Changes
5
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
5f1f10d0
...
...
@@ -136,7 +136,15 @@ def mod_required(func):
return
func
(
*
args
,
**
kwargs
)
return
decorator
app
.
jinja_env
.
globals
[
'navbar'
]
=
[]
def
register_navbar
(
name
,
icon
=
None
):
def
wrapper
(
func
):
app
.
jinja_env
.
globals
[
'navbar'
].
append
((
func
.
__name__
,
name
,
icon
))
return
func
return
wrapper
@
app
.
route
(
'/'
)
@
register_navbar
(
'Home'
,
icon
=
'home'
)
def
index
():
return
render_template
(
'index.html'
,
latestvideos
=
query
(
'''
SELECT lectures.*, max(videos.time_updated) AS lastvidtime, courses.short, courses.downloadable, courses.title AS coursetitle
...
...
@@ -150,6 +158,7 @@ def index():
'''
,
ismod
()))
@
app
.
route
(
'/videos'
)
@
register_navbar
(
'Videos'
,
icon
=
'film'
)
def
videos
():
courses
=
query
(
'SELECT * FROM courses WHERE (? OR (visible AND listed))'
,
ismod
())
for
course
in
courses
:
...
...
@@ -161,6 +170,7 @@ def videos():
return
render_template
(
'videos.html'
,
courses
=
courses
,
groupedby
=
groupedby
)
@
app
.
route
(
'/faq'
)
@
register_navbar
(
'FAQ'
,
icon
=
'question-sign'
)
def
faq
():
return
render_template
(
'faq.html'
)
...
...
templates/base.html
View file @
5f1f10d0
{% set navigation_bar = [
('/', 'index', 'Home', 'home'),
('/videos', 'videos', 'Videos', 'film'),
('/faq', 'faq', 'FAQ', 'question-sign')
] -%}
{% set active_page = active_page|default('none') -%}
{% set page_border = page_border|default(1) -%}
<!DOCTYPE html>
...
...
@@ -53,9 +46,9 @@
<div
class=
"row"
>
<div
class=
"col-xs-12 col-sm-8"
>
<ul
class=
"nav nav-pills"
>
{% for
href, id
, caption, gly in nav
igation_
bar %}
<li
{%
if
id =
=
active_page
%}
class=
"active"
{%
endif
%}
>
<a
href=
"{{
href
|e }}"
>
{% if gly != '' %}
<span
class=
"glyphicon glyphicon-{{ gly }}"
></span>
{% endif %}{{ caption }}
</a>
{% for
endpoint
, caption, gly in navbar %}
<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>
</li>
{% endfor %}
<li
class=
"navbar-right"
>
...
...
templates/faq.html
View file @
5f1f10d0
{% from 'macros.html' import preview %}
{% extends "base.html" %}
{% set active_page = "faq" %}
{% block content %}
<div
class=
"alert alert-warning alert-dismissible"
role=
"alert"
id=
"kontakt"
>
Unter
<a
href=
"mailto:video@fsmpi.rwth-aachen.de"
>
video@fsmpi.rwth-aachen.de
</a>
stehen wir für alle Fragen bereit.
...
...
templates/index.html
View file @
5f1f10d0
{% from 'macros.html' import preview %}
{% extends "base.html" %}
{% set active_page = "index" %}
{% set page_border = 0 %}
{% block content %}
<div
class=
"row"
>
...
...
templates/videos.html
View file @
5f1f10d0
{% from 'macros.html' import course_list_item %}
{% set active_page = 'videos' -%}
{% extends "base.html" %}
{% block content %}
<div
class=
"row"
>
...
...
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