macros.html 7.99 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
<video id="videoplayer" style="width: 100%" class="video-js vjs-default-skin vjs-big-play-centered" width="640" height="320" controls  data-setup='{ "plugins" : {"videoJsResolutionSwitcher": { "ui": true, "default": "720p", "dynamicLabel": true } }, "customControlsOnMobile": true, "playbackRates": [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] }'>
46
	{% for v in videos|sort(attribute='player_prio', reverse=True) %}
47
		<source type="video/mp4" src="{{ config.VIDEOPREFIX }}/{{ v.path }}" label="{{ v.format_description }}"/>
Andreas Valder's avatar
Andreas Valder committed
48
	{% endfor %}
49
	<track srclang="en" kind="chapters" src="{{ url_for('chapters',lectureid=lecture.id) }}" />
Andreas Valder's avatar
Andreas Valder committed
50
</video>
Andreas Valder's avatar
Andreas Valder committed
51
<script>
52
53
$('#videoplayer').addClass("vjs-16-9");
$('#videoplayer').css("width");
Andreas Valder's avatar
Andreas Valder committed
54
</script>
Andreas Valder's avatar
Andreas Valder committed
55
{% endmacro %}
56
57

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

82
{% macro video_download_btn(videos) %}
Andreas Valder's avatar
Andreas Valder committed
83
<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>
84
<ul class="dropdown-menu">
85
	{% for v in videos|sort(attribute='prio', reverse=True) %}
Andreas Valder's avatar
Andreas Valder committed
86
87
88
		{% 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 %}
89
90
91
92
	{% endfor %}
</ul>
<noscript>
	<ul class="pull-right list-unstyled" style="margin-left:10px;">
93
		{% for v in videos|sort(attribute='prio', reverse=True) %}
Julian Rother's avatar
Cleanup    
Julian Rother committed
94
		<li><a href="{{ config.VIDEOPREFIX }}/{{v.path}}">{{v.format_description}} ({{v.file_size|filesizeformat(true)}})</a></li>
95
96
97
98
99
		{% endfor %}
	</ul>
</noscript>
{% endmacro %}

Andreas Valder's avatar
Andreas Valder committed
100
101
102
103
104
{%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
105
{% 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
106
107
108
109
110
111
112
113
114
115
$('#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
116
{% macro lecture_list_item(lecture,videosi,global_acls) %}
117
<li class="list-group-item" id="lecture-{{lecture.id}}">
Andreas Valder's avatar
Andreas Valder committed
118
	<div class="row">
Andreas Valder's avatar
Andreas Valder committed
119
		<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
120
121
		<span class="col-sm-3 col-xs-12">
			<ul class="list-unstyled">
122
123
124
				<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>
125
				<li>Dauer: {{ valueeditor(['lectures',lecture.id,'duration'], lecture.duration) }} min</li>
126
127
				{% if  ismod() %}
				{% endif %}
Andreas Valder's avatar
Andreas Valder committed
128
			</ul>
Andreas Valder's avatar
Andreas Valder committed
129
		</span>
Andreas Valder's avatar
Andreas Valder committed
130
		<span class="col-sm-3 col-xs-12">
131
132
			<ul class="list-unstyled">
				<li>{{ valueeditor(['lectures',lecture.id,'comment'], lecture.comment) }}</li>
Andreas Valder's avatar
Andreas Valder committed
133
134
135
				{% if  ismod() %}
				<li>{{ valueeditor(['lectures',lecture.id,'internal'], lecture.internal) }}</li>
				<li>Sichtbar: {{ valuecheckbox(['lectures',lecture.id,'visible'], lecture.visible) }}</li>
136
				<li>Hörsaal: {{ valueeditor(['lectures',lecture.id,'place'], lecture.place) }} </li>
Andreas Valder's avatar
Andreas Valder committed
137
				{% endif %}
138
			</ul>
Andreas Valder's avatar
Andreas Valder committed
139
		</span>
Andreas Valder's avatar
Andreas Valder committed
140
		<div class="col-sm-4 col-xs-12">
Andreas Valder's avatar
Andreas Valder committed
141
142
			<ul class="pull-right list-inline">
				<li class="dropdown">
Andreas Valder's avatar
Andreas Valder committed
143
144
145
146
147
148
149
					{{ 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>
Andreas Valder's avatar
Andreas Valder committed
150
151
				</li>
				<li>
Andreas Valder's avatar
Andreas Valder committed
152
					{{ valuedeletebtn(['lectures',lecture.id,'deleted']) }}
Andreas Valder's avatar
Andreas Valder committed
153
154
				</li>
				<li>
Andreas Valder's avatar
Andreas Valder committed
155
					{{ editacl('lecture', lecture.id, lecture.auth, global_acls) }}
Andreas Valder's avatar
Andreas Valder committed
156
157
158
				</li>
			</ul>
		</div>
Andreas Valder's avatar
Andreas Valder committed
159
160
161
	</div>
</li>
{% endmacro %}
162
163
164
165
166

{% 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 %}
167
		{{value|fixnl|safe}}
168
	{% endif %}
169
170
171
172
{% endmacro %}

{% macro valuecheckbox (path,value) %}
	{% if ismod() %}
173
	<input type="checkbox" data-path="{{path|join('.')}}" {% if value %} checked {% endif %} onchange="moderatorinterface.change(this)"/>
174
175
	{% endif %}
{% endmacro %}
176
177
178

{% macro valuedeletebtn (path) %}
	{% if ismod() %}
Andreas Valder's avatar
Andreas Valder committed
179
180
181
182
183
184
	<button class="btn btn-default" style="background-color: red;" data-path="{{path|join('.')}}" onclick="moderatorinterface.delete(this)">
		<span class="glyphicon glyphicon-trash"></span>
	</button>
	{% endif %}
{% endmacro %}

Andreas Valder's avatar
Andreas Valder committed
185
186
{% macro editacl(type,id,acl,global_acls) %}
	{% set tmp = global_acls.extend(acl) %}
187
	{% if (not acl) %}
Andreas Valder's avatar
Andreas Valder committed
188
		{% if ismod() %}
189
190
191
		<button class="btn btn-default modeditacl" data-type="{{ type }}" data-id="{{ id }}">
			<span class="fa fa-unlock" aria-hidden="true" style="color: green;"></span>
		</button>
Andreas Valder's avatar
Andreas Valder committed
192
193
194
		{% endif %}
	{% else %}
			{% if ismod() %}
195
			<button class="btn btn-default modeditacl" data-type="{{ type }}" data-id="{{ id }}" onclick="">
Andreas Valder's avatar
Andreas Valder committed
196
197
198
199
200
201
202
203
204
			{% else %}
			<a>
			{% endif %}
				<span class="fa fa-lock" aria-hidden="true" style="color: red;"></span>
			{% if ismod() %}
			</button>
			{% else %}
			</a>
			{% endif %}
205
	{% endif %}
Andreas Valder's avatar
Andreas Valder committed
206
	
207
{% endmacro %}
Andreas Valder's avatar
Andreas Valder committed
208
209

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