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

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

Julian Rother's avatar
Julian Rother committed
45
{% macro player(lecture, videos) %}
46
<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] }'>
47
	{% for v in videos|sort(attribute='player_prio', reverse=True) %}
48
		<source type="video/mp4" src="{{ config.VIDEOPREFIX }}/{{ v.path }}" label="{{ v.format_description }}"/>
Andreas Valder's avatar
Andreas Valder committed
49
	{% endfor %}
50
	<track srclang="de" kind="chapters" src="{{ url_for('chapters',lectureid=lecture.id) }}" />
Andreas Valder's avatar
Andreas Valder committed
51
</video>
Andreas Valder's avatar
Andreas Valder committed
52
<script>
53
54
$('#videoplayer').addClass("vjs-16-9");
$('#videoplayer').css("width");
Andreas Valder's avatar
Andreas Valder committed
55
</script>
Andreas Valder's avatar
Andreas Valder committed
56
{% endmacro %}
57
58

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

83
{% macro video_download_btn(videos) %}
84
<span class="btn btn-default dropdown-toggle{% if videos|length is equalto 0 %} disabled{% endif %}" type="button" data-toggle="dropdown">Download <span class="caret"></span></span>
85
<ul class="dropdown-menu">
86
	{% for v in videos|sort(attribute='prio', reverse=True) %}
Andreas Valder's avatar
Andreas Valder committed
87
		{% if v.downloadable or ismod() %}	
88
		<li><a href="{{ config.VIDEOPREFIX }}/{{v.path}}">{{ moderator_checkbox(['videos',v.id,'visible'], v.visible) }} {{v.format_description}} ({{v.file_size|filesizeformat(true)}}) {{moderator_delete(['videos',v.id,'deleted'])}} </a></li>
Andreas Valder's avatar
Andreas Valder committed
89
		{% endif %}
90
91
92
93
	{% endfor %}
</ul>
<noscript>
	<ul class="pull-right list-unstyled" style="margin-left:10px;">
94
		{% for v in videos|sort(attribute='prio', reverse=True) %}
Julian Rother's avatar
Cleanup    
Julian Rother committed
95
		<li><a href="{{ config.VIDEOPREFIX }}/{{v.path}}">{{v.format_description}} ({{v.file_size|filesizeformat(true)}})</a></li>
96
97
98
99
100
		{% endfor %}
	</ul>
</noscript>
{% endmacro %}

Andreas Valder's avatar
Andreas Valder committed
101
102
103
104
105
{%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
106
{% 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
107
108
109
110
111
112
113
114
115
116
$('#embedcodebtn').popover(
		{
			html:true,
			title:'Einbettcode',
			content:'<span><input type="text" onclick="this.select()" value="{{embedcode}}"></span>'
		}
		)
</script>
{% endmacro %}

117
{% macro lecture_list_item(lecture,videos,global_acls) %}
118
<li class="list-group-item" id="lecture-{{lecture.id}}">
Andreas Valder's avatar
Andreas Valder committed
119
	<div class="row">
Andreas Valder's avatar
Andreas Valder committed
120
		<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
121
122
		<span class="col-sm-3 col-xs-12">
			<ul class="list-unstyled">
123
124
125
126
				<li>{{ moderator_editor(['lectures',lecture.id,'title'], lecture.title) }}</li>
				{% if lecture.speaker or ismod() %}<li>Gehalten von {{ moderator_editor(['lectures',lecture.id,'speaker'], lecture.speaker) }}</li>{% endif %}
				<li>{{ moderator_editor(['lectures',lecture.id,'time'], lecture.time) }} </li>
				<li>Dauer: {{ moderator_editor(['lectures',lecture.id,'duration'], lecture.duration) }} min</li>
127
				{% if  ismod() %}
128
				<li>ID: <a href="{{url_for('course',handle=lecture.course.handle)}}#lecture-{{lecture.id}}">{{lecture.id}}</a></i>
129
				{% endif %}
Andreas Valder's avatar
Andreas Valder committed
130
			</ul>
Andreas Valder's avatar
Andreas Valder committed
131
		</span>
Andreas Valder's avatar
Andreas Valder committed
132
		<span class="col-sm-3 col-xs-12">
133
			<ul class="list-unstyled">
134
				<li>{{ moderator_editor(['lectures',lecture.id,'comment'], lecture.comment) }}</li>
Andreas Valder's avatar
Andreas Valder committed
135
				{% if  ismod() %}
136
137
138
				<li>{{ moderator_editor(['lectures',lecture.id,'internal'], lecture.internal) }}</li>
				<li>Sichtbar: {{ moderator_checkbox(['lectures',lecture.id,'visible'], lecture.visible) }}</li>
				<li>Hörsaal: {{ moderator_editor(['lectures',lecture.id,'place'], lecture.place) }} </li>
Andreas Valder's avatar
Andreas Valder committed
139
				{% endif %}
140
			</ul>
Andreas Valder's avatar
Andreas Valder committed
141
		</span>
Andreas Valder's avatar
Andreas Valder committed
142
		<div class="col-sm-4 col-xs-12">
Andreas Valder's avatar
Andreas Valder committed
143
144
			<ul class="pull-right list-inline">
				<li class="dropdown">
Andreas Valder's avatar
Andreas Valder committed
145
146
147
148
149
150
151
					{{ 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
152
153
				</li>
				<li>
154
					{{ moderator_delete(['lectures',lecture.id,'deleted']) }}
Andreas Valder's avatar
Andreas Valder committed
155
156
				</li>
				<li>
157
					{{ moderator_acleditor('lecture', lecture.id, lecture.perm, global_acls) }}
Andreas Valder's avatar
Andreas Valder committed
158
159
160
				</li>
			</ul>
		</div>
Andreas Valder's avatar
Andreas Valder committed
161
162
163
	</div>
</li>
{% endmacro %}
164

165
{% macro moderator_editor (path,value) %}
166
	{% if ismod() %}
167
	<span class="moderator_editor" data-path="{{path|join('.')}}" ><a class="moderator_editor_sign btn btn-default" tabindex="0" style="padding: 3px; margin-right: 5px;"><span class="glyphicon glyphicon-pencil"></span></a><span class="moderator_editor_value">{{ value|safe }}</span></span>
168
	{% else %}
169
		{{value|fixnl|safe}}
170
	{% endif %}
171
172
{% endmacro %}

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

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

187
{% macro moderator_acleditor(type,id,acl,global_acls) %}
Andreas Valder's avatar
Andreas Valder committed
188
	{% set tmp = global_acls.extend(acl) %}
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
	{% set permdescription = acl|permdescr %}
	{% set permlogos = '' %}

	{% if permdescription[0] == 'public' %}
		{% set permlogos = '<span class="fa fa-globe" aria-hidden="true"></span>' %}
	{% endif %}
	{% if permdescription[0] == 'password' %}
		{% set permlogos = '<span class="fa fa-lock" aria-hidden="true"></span>' %}
	{% endif %}
	{% if permdescription[0] == 'l2p' %}
		{% set permlogos %}
		<span class="fa" aria-hidden="true" style="width: 12px; height: 14px; background-size: cover;  background-image: url('/static/l2p-logo.gif');"></span>
		{% endset %}
	{% endif %}
	{% if permdescription[0] == 'rwth' %}
		{% set permlogos %}
		<span class="fa" aria-hidden="true" style="width: 25px; height: 20px; background-size: cover;  background-image: url('/static/rwth.png');"></span>
		{% endset %}
	{% endif %}

	{% if ismod() %}
210
		<button class="btn btn-default modmoderator_acleditor" data-type="{{ type }}" data-id="{{ id }}">
211
			{{ permlogos|safe }}	
212
		</button>
Andreas Valder's avatar
Andreas Valder committed
213
	{% else %}
Andreas Valder's avatar
Andreas Valder committed
214
		<span title="{{permdescription[1]}}">
215
			{{ permlogos|safe }}	
Andreas Valder's avatar
Andreas Valder committed
216
		</span>
217
	{% endif %}
Andreas Valder's avatar
Andreas Valder committed
218
	
219
{% endmacro %}
Andreas Valder's avatar
Andreas Valder committed
220
221

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