diff --git a/server.py b/server.py index 6e6a01759a9ed9837626a8da0e9c3527ecd6edc6..c374cc71096ad4725bfbcc9fd99dd9ee77e27b9a 100644 --- a/server.py +++ b/server.py @@ -376,6 +376,21 @@ def index(): if item['param'] not in ['title', 'semester', 'organizer', 'subject']: continue item['courses'] = query('SELECT * FROM courses WHERE (visible AND listed) AND `%s` = ? ORDER BY `%s`'%(item['param'], item['param']), item['param2']) + elif item['type'] == 'video': + item['lecture'] = {'id': item['param']} + livestreams = query('''SELECT streams.handle AS livehandle, streams.lecture_id, "formats" AS sep, formats.* + FROM streams + JOIN lectures ON lectures.id = streams.lecture_id + JOIN formats ON formats.keywords = "hls" + WHERE streams.active AND streams.visible AND lectures.id = ? + ''', item['param']) + item['videos'] = query(''' + SELECT videos.*, "formats" AS sep, formats.* + FROM videos + JOIN formats ON (videos.video_format = formats.id) + WHERE videos.lecture_id = ? AND videos.visible + ORDER BY formats.prio DESC + ''', item['param'])+genlive(livestreams) return render_template('index.html', latestvideos=livestreams+latestvideos, upcomming=upcomming, featured=featured) @app.route('/courses') diff --git a/templates/index.html b/templates/index.html index 60e282695d1d90f3240f998f38b9116b0ace0ebe..d4b054bb560885ad695f1e14779218dbee9c8bfa 100644 --- a/templates/index.html +++ b/templates/index.html @@ -59,6 +59,7 @@ <ul class="dropdown-menu"> <li><a href="{{ url_for('create', table='featured', title='Neues Panel', type='plain', ref=request.url) }}">Nur Text</a></li> <li><a href="{{ url_for('create', table='featured', title='Neues Panel', type='image', ref=request.url) }}">Text mit Bild</a></li> + <li><a href="{{ url_for('create', table='featured', title='Neues Panel', type='video', ref=request.url) }}">Text mit Video</a></li> <li><a href="{{ url_for('create', table='featured', title='Neues Panel', type='courses', param='semester', param2='', ref=request.url) }}">Veranstaltungsliste</a></li> </ul> </div> diff --git a/templates/macros.html b/templates/macros.html index 6280ddbcefba5119b077a67b52dd670348b3df14..bdaed3effee4e63bbd8a54fcb5c3bda5dd063393 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -48,7 +48,7 @@ {% endmacro %} -{% macro player(lecture, videos, msgs) %} +{% macro player(lecture, videos, msgs=[], autoplay=True) %} <video id="videoplayer" style="width: 100%" class="video-js vjs-default-skin vjs-big-play-centered" width="640" height="320" controls data-wasnotplayed="1" data-setup='{ "language":"de", "plugins" : {"hotkeys": {"seekStep": 15, "enableVolumeScroll": false, "alwaysCaptureHotkeys": true}, "videoJsResolutionSwitcher": { "ui": true, "default": "720p", "dynamicLabel": false } }, "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] }'> {% for v in videos|sort(attribute='formats.player_prio', reverse=True) %} <source type="{{ v.formats.mimetype }}" src="{{ config.VIDEOPREFIX }}/{{ v.path }}" data-label="{{ v.formats.description }}" data-res="{{v.formats.resolution}}" data-aspect="{{v.formats.aspect}}" data-player_prio="{{v.formats.player_prio}}"/> @@ -90,10 +90,12 @@ $(function() { $('#videoplayer').data("wasnotplayed","0"); } }; + {% if autoplay %} $(window).focus(playerplay); if (document.hasFocus()) { playerplay(); } + {% endif %} // errors as modal dialog videojs("videoplayer").on("error", function() { var modals = []; @@ -401,6 +403,17 @@ $('#embedcodebtn').popover( {% endif %} Die vollständige Liste findest du <a href="{{ url_for('courses') }}">hier</a>. </div> + {% elif item.type == 'video' %} + <div class="panel-body"> + <div>{{ moderator_editor(('featured',item.id,'text'), item.text) }}</div> + {% if item.videos %} + {{ player(item.lecture, item.videos, autoplay=False)}} + {% endif %} + {% if ismod() %} + <div>ID des Videos: {{ moderator_editor(('featured',item.id,'param'), item.param) }}</div> + {% endif %} + <div>{{ moderator_editor(('featured',item.id,'param2'), item.param2) }}</div> + </div> {% else %} {% if item.text or ismod() %} <div class="panel-body">{{ moderator_editor(('featured',item.id,'text'), item.text) }}</div>