From 4a3fdf61f56739d02ecf6e4cbfd315c64f95d2c9 Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Tue, 11 Apr 2017 03:20:43 +0200 Subject: [PATCH] Restructured featured template --- templates/index.html | 29 ++--------------------------- templates/macros.html | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/templates/index.html b/templates/index.html index a97c47a..984d29c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,4 @@ -{% from 'macros.html' import preview, course_list_item %} +{% from 'macros.html' import preview, featured_content %} {% extends "base.html" %} {% set page_border = 0 %} {% if ismod() %} @@ -98,32 +98,7 @@ {% endif %} </h1> </div> - {% if item.type == 'image' %} - <!-- Putting image tag here makes it borderless. This should be replaced by a bootstrap-compatible solution. --> - <img src="{{item.param}}" style="width: 100%;"/> - {% if ismod() %} - <p>{{moderator_editor(('featured',item.id,'param'), item.param)}}</p> - {% endif %} - {% endif %} - {% if item.text or ismod() %} - <div class="panel-body"> - {{ moderator_editor(('featured',item.id,'text'), item.text) }} - </div> - {% endif %} - {% if item.type == 'courses' %} - <ul class="courses-list list-group"> - {% for i in item.courses %} - {{ course_list_item(i) }} - {% endfor %} - </ul> - <div class="panel-footer"> - {% if ismod() %} - <p>Kategorie: {{ moderator_editor(('featured',item.id,'param'), item.param) }}</p> - <p>Parameter: {{ moderator_editor(('featured',item.id,'param2'), item.param2) }}</p> - {% endif %} - Die vollständige Liste findest du <a href="{{ url_for('courses') }}">hier</a>. - </div> - {% endif %} + {{ featured_content(item) }} </div> {% endfor %} </div> diff --git a/templates/macros.html b/templates/macros.html index 7f7c80b..a2db0c2 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -306,3 +306,46 @@ $('#embedcodebtn').popover( }); </script> {% endmacro %} + +{% macro featured_content(item) %} {# This macro is used in a panel div after the panel header #} + {% if item.type == 'image' %} + <!-- Putting image tag here makes it borderless. This should be replaced by a bootstrap-compatible solution. --> + <img src="{{item.param}}" style="width: 100%;"/> + {% if ismod() %} + <p>{{moderator_editor(('featured',item.id,'param'), item.param)}}</p> + {% endif %} + {% if item.text or ismod() %} + <div class="panel-body">{{ moderator_editor(('featured',item.id,'text'), item.text) }}</div> + {% endif %} + {% elif item.type == 'courses' %} + {% if item.text or ismod() %} + <div class="panel-body">{{ moderator_editor(('featured',item.id,'text'), item.text) }}</div> + {% endif %} + <ul class="courses-list list-group"> + {% for i in item.courses %} + {{ course_list_item(i) }} + {% endfor %} + </ul> + <div class="panel-footer"> + {% if ismod() %} + <ul class="list-inline"> + <li><div class="dropdown"> + {% set params = {'semester': 'Semester', 'title': 'Veranstaltung', 'organizer': 'Dozent', 'subject': 'Kategorie'} %} + <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">{{params[item.param]}}: <span class="caret"></span></button> + <ul class="dropdown-menu"> + {% for key, name in params.items() %} + <li><a href="{{url_for('edit', **{'featured.'+item.id|string+'.param': key, 'ref': request.url})}}">{{name}}</a></li> + {% endfor %} + </ul> + </div></li> + <li>{{ moderator_editor(('featured',item.id,'param2'), item.param2) }}</li> + </ul> + {% endif %} + Die vollständige Liste findest du <a href="{{ url_for('courses') }}">hier</a>. + </div> + {% else %} + {% if item.text or ismod() %} + <div class="panel-body">{{ moderator_editor(('featured',item.id,'text'), item.text) }}</div> + {% endif %} + {% endif %} +{% endmacro %} -- GitLab