macros.html 7.38 KB
Newer Older
1
{% macro preview(lecture) %}
Andreas Valder's avatar
Andreas Valder committed
2
<li class="list-group-item">
3
	<a class="hidden-xs" href="{{url_for('lecture', id=lecture['id'])}}" title="{{ lecture.course.title }}" style="color: #000">
Andreas Valder's avatar
Andreas Valder committed
4
		<div class="row">
Andreas Valder's avatar
Andreas Valder committed
5
			<img class="col-xs-4" style="max-height: 100px; width: auto;" src="{{ config.VIDEOPREFIX }}/{{ lecture['titlefile'] }}" alt="Vorschaubild" onerror="this.src='{{url_for('static',filename='no-thumbnail.png')}}'; this.onerror=''; ">
Andreas Valder's avatar
Andreas Valder committed
6
			<div class="col-xs-4">
7
				<span><strong>{{ lecture.course.short }}</strong></span><br>
8
				<span>{{ lecture['time'] }}</span>
9
				{% if lecture['speaker'] %}
10
					<div class="small">Gehalten von {{ lecture['speaker'] }} </div>
11
				{% endif %}
Andreas Valder's avatar
Andreas Valder committed
12
			</div>
13
			<div class="col-xs-4">
14
15
				<div>{{ lecture['title']|fixnl|safe  }}</div>
				<p style="font-style: italic; color: #777;">{{ lecture['comment']|fixnl|safe }}</p>
16
			</div>
Andreas Valder's avatar
Andreas Valder committed
17
18
		</div>
	</a>
19
	<a class="visible-xs" href="{{url_for('lecture', id=lecture['id'])}}" title="{{ lecture.course.title }}" style="color: #000">
20
21
		<ul class="list-unstyled">
			<li>
Andreas Valder's avatar
Andreas Valder committed
22
				<img style="width: 100%;" src="{{ config.VIDEOPREFIX }}/{{ lecture['titlefile'] }}" alt="Vorschaubild" onerror="this.src='{{url_for('static',filename='no-thumbnail.png')}}'; this.onerror=''; ">
23
24
			</li>
			<li>
25
				<strong>{{ lecture.course.short }}</strong> {{ lecture['time'] }}
26
27
28
			</li>
			{% if lecture['speaker'] %}
			<li>
29
				<span class="small">Gehalten von {{ lecture['speaker']|safe }} </span>
30
31
32
			</li>
			{% endif %}
			<li>
33
				{{ lecture['title']|fixnl|safe  }}
34
35
			</li>
			<li>
36
				<p style="font-style: italic; color: #777;">{{ lecture['comment']|fixnl|safe }}</p>
37
38
			</li>
		</ul>
Andreas Valder's avatar
Andreas Valder committed
39
	</a>
Andreas Valder's avatar
Andreas Valder committed
40
41
</li>

Andreas Valder's avatar
Andreas Valder committed
42
43
{% endmacro %}

Julian Rother's avatar
Julian Rother committed
44
{% macro player(lecture, videos) %}
45
46
47
48
<script src="{{url_for('static', filename='mediaelementjs/mediaelement-and-player.js')}}"></script>
<script src="{{url_for('static', filename='mediaelementjs/mep-feature-sourcechooser.js')}}"></script>
<link rel="stylesheet" href="{{url_for('static', filename='mediaelementjs/mediaelementplayer.css')}}"/>
<video class="player" width="640" height="360" style="width: 100%; height: 100%;" controls="controls">
49
	{% for v in videos|sort(attribute='player_prio', reverse=True) %}
50
		<source type="video/mp4" src="{{ config.VIDEOPREFIX }}/{{ v.path }}" title="{{ v.format_description }}"/>
Andreas Valder's avatar
Andreas Valder committed
51
	{% endfor %}
52
	<track srclang="en" kind="chapters" src="{{ url_for('chapters',lectureid=lecture.id) }}" />
Andreas Valder's avatar
Andreas Valder committed
53
</video>
Andreas Valder's avatar
Andreas Valder committed
54
<script>
55
56
57
58
59
60
61
62
		$(function($)
		{
			var player = new MediaElementPlayer('.player', {
				features: [
					'playpause', 'current', 'progress', 'duration', 'volume', 'tracks', 'sourcechooser', 'speed', 'fullscreen',
				],
			});
		});
Andreas Valder's avatar
Andreas Valder committed
63
</script>
Andreas Valder's avatar
Andreas Valder committed
64
{% endmacro %}
65
66

{% macro course_list_item(course,show_semester=False) %}
67
<li class="list-group-item list-group-item-condensed {% if (not course.visible) or (not course.listed) %}list-group-item-danger{% endif %}">
68
	<div class="row">
Andreas Valder's avatar
Andreas Valder committed
69
			{% if show_semester %}
70
				<span class="col-xs-2 col-md-1">
Andreas Valder's avatar
Andreas Valder committed
71
72
					{{ course.semester }}
				</span>
73
				<span class="col-xs-10 col-md-6">
Andreas Valder's avatar
Andreas Valder committed
74
			{% else %}
75
				<span class="col-xs-12 col-md-7">
Andreas Valder's avatar
Andreas Valder committed
76
			{% endif %}
77
				<a href="{{url_for('course', handle=course.handle)}}">
Andreas Valder's avatar
Andreas Valder committed
78
				{{ course.title }}
79
				</a>
80
			</span>
81
			<span class="col-xs-8 col-md-3">
Andreas Valder's avatar
Andreas Valder committed
82
83
				{{ course.organizer }}
			</span>
84
			<span class="col-xs-4 col-md-2">
Andreas Valder's avatar
Andreas Valder committed
85
86
				{{ course.subject }}
			</span>
87
88
89
	</div>
</li>
{% endmacro %}
Andreas Valder's avatar
Andreas Valder committed
90

91
{% macro video_download_btn(videos) %}
Andreas Valder's avatar
Andreas Valder committed
92
<span class="btn btn-primary dropdown-toggle{% if videos|length is equalto 0 %} disabled{% endif %}" type="button" data-toggle="dropdown">Download <span class="caret"></span></span>
93
<ul class="dropdown-menu">
94
	{% for v in videos|sort(attribute='prio', reverse=True) %}
Andreas Valder's avatar
Andreas Valder committed
95
96
97
		{% 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 %}
98
99
100
101
	{% endfor %}
</ul>
<noscript>
	<ul class="pull-right list-unstyled" style="margin-left:10px;">
102
		{% for v in videos|sort(attribute='prio', reverse=True) %}
Julian Rother's avatar
Cleanup    
Julian Rother committed
103
		<li><a href="{{ config.VIDEOPREFIX }}/{{v.path}}">{{v.format_description}} ({{v.file_size|filesizeformat(true)}})</a></li>
104
105
106
107
108
		{% endfor %}
	</ul>
</noscript>
{% endmacro %}

Andreas Valder's avatar
Andreas Valder committed
109
110
111
112
113
{%macro video_embed_btn(lectureid) %}
<a class="btn btn-default" id="embedcodebtn" data-container="body" data-toggle="popover" data-placement="bottom">
	<span>Einbetten</span>
</a>
<script>
Andreas Valder's avatar
Andreas Valder committed
114
{% set embedcode = '<iframe width="700" height="394" src="'+url_for('embed', id=lectureid, _external=True)+'" frameborder="0" allowfullscreen="true"></iframe>' %}
Andreas Valder's avatar
Andreas Valder committed
115
116
117
118
119
120
121
122
123
124
$('#embedcodebtn').popover(
		{
			html:true,
			title:'Einbettcode',
			content:'<span><input type="text" onclick="this.select()" value="{{embedcode}}"></span>'
		}
		)
</script>
{% endmacro %}

Andreas Valder's avatar
Andreas Valder committed
125
{% macro lecture_list_item(lecture,videos) %}
126
<li class="list-group-item" id="lecture-{{lecture.id}}">
Andreas Valder's avatar
Andreas Valder committed
127
	<div class="row">
Andreas Valder's avatar
Andreas Valder committed
128
		<img class="col-sm-2 col-xs-12"src="{{ config.VIDEOPREFIX }}/{{lecture.titlefile}}" alt="Vorschaubild" onerror="this.src='{{url_for('static',filename='no-thumbnail.png')}}'; this.onerror=''; ">
Andreas Valder's avatar
Andreas Valder committed
129
130
		<span class="col-sm-3 col-xs-12">
			<ul class="list-unstyled">
131
132
133
				<li>{{ valueeditor(['lectures',lecture.id,'title'], lecture.title) }}</li>
				{% if lecture.speaker or ismod() %}<li>Gehalten von {{ valueeditor(['lectures',lecture.id,'speaker'], lecture.speaker) }}</li>{% endif %}
				<li>{{ valueeditor(['lectures',lecture.id,'time'], lecture.time) }} </li>
134
				<li>Dauer: {{ valueeditor(['lectures',lecture.id,'duration'], lecture.duration) }} min</li>
135
136
				{% if  ismod() %}
				{% endif %}
Andreas Valder's avatar
Andreas Valder committed
137
			</ul>
Andreas Valder's avatar
Andreas Valder committed
138
		</span>
Andreas Valder's avatar
Andreas Valder committed
139
		<span class="col-sm-4 col-xs-12">
140
141
			<ul class="list-unstyled">
				<li>{{ valueeditor(['lectures',lecture.id,'comment'], lecture.comment) }}</li>
Andreas Valder's avatar
Andreas Valder committed
142
143
144
				{% if  ismod() %}
				<li>{{ valueeditor(['lectures',lecture.id,'internal'], lecture.internal) }}</li>
				<li>Sichtbar: {{ valuecheckbox(['lectures',lecture.id,'visible'], lecture.visible) }}</li>
145
				<li>Hörsaal: {{ valueeditor(['lectures',lecture.id,'place'], lecture.place) }} </li>
Andreas Valder's avatar
Andreas Valder committed
146
				{% endif %}
147
			</ul>
Andreas Valder's avatar
Andreas Valder committed
148
		</span>
Andreas Valder's avatar
Andreas Valder committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
		<div class="col-sm-3 col-xs-12">
			<ul class="pull-right list-inline">
				<li class="dropdown">
						{{ video_download_btn(videos) }}
				</li>
				<li>
						<a href="{{url_for('lecture', id=lecture.id)}}" class="btn btn-default {% if videos|length is equalto 0 %}disabled{% endif %}">
							<span class="glyphicon glyphicon-play"></span>
							Play
						</a>
				</li>
				<li>
						{{ valuedeletebtn(['lectures',lecture.id,'deleted']) }}
				</li>
			</ul>
		</div>
Andreas Valder's avatar
Andreas Valder committed
165
166
167
	</div>
</li>
{% endmacro %}
168
169
170
171
172

{% macro valueeditor (path,value) %}
	{% if ismod() %}
	<span class="modeditable" data-path="{{path|join('.')}}" ><a class="modeditablesign btn btn-default" tabindex="0" style="padding: 3px; margin-right: 5px;"><span class="glyphicon glyphicon-pencil"></span></a><span class="modeditablevalue">{{ value|safe }}</span></span>
	{% else %}
173
		{{value|fixnl|safe}}
174
	{% endif %}
175
176
177
178
{% endmacro %}

{% macro valuecheckbox (path,value) %}
	{% if ismod() %}
179
	<input type="checkbox" data-path="{{path|join('.')}}" {% if value %} checked {% endif %} onchange="moderatorinterface.change(this)"/>
180
181
	{% endif %}
{% endmacro %}
182
183
184
185
186
187
188
189

{% macro valuedeletebtn (path) %}
	{% if ismod() %}
	<button data-path="{{path|join('.')}}" onclick="moderatorinterface.delete(this)">
			<span class="glyphicon glyphicon-trash"></span>
		</button>
	{% endif %}
{% endmacro %}
Andreas Valder's avatar
Andreas Valder committed
190
191

{% macro vtttime(time) %}{{ '%02d:%02d:%02d.000'|format( time//3600, (time//60)%60, time%60) }}{% endmacro %}