1
0
Fork 0
mirror of https://github.com/Kunsi/pretalx-plugin-broadcast-tools synced 2025-04-28 23:10:57 +00:00

initial commit

This commit is contained in:
Franzi 2021-11-20 09:05:08 +01:00
commit bdf7281b74
Signed by: kunsi
GPG key ID: 12E3D2136B818350
21 changed files with 563 additions and 0 deletions

View file

@ -0,0 +1,17 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy
class PluginApp(AppConfig):
name = "pretalx_lower_thirds"
verbose_name = "Lower Thirds"
class PretalxPluginMeta:
name = gettext_lazy("Lower Thirds")
author = "kunsi"
description = gettext_lazy("Creates lower thirds from your current schedule. Will show speaker names and talk title using the configured track and event colours.")
visible = True
version = "0.0.0"
def ready(self):
from . import signals # NOQA

View file

@ -0,0 +1 @@
# Register your receivers here

View file

@ -0,0 +1,30 @@
* {
margin: 0;
padding: 0;
line-height: 1.2em;
}
#box {
width: 1020px;
position: absolute;
bottom: 80px;
left: 50%;
margin-left: -510px;
color: white;
font-family: "Muli","Open Sans","OpenSans","Helvetica Neue",Helvetica,Arial,sans-serif;
padding: 15px;
box-shadow: 5px 5px 10px 0px rgba(50, 50, 50, 0.75);
}
#title {
font-size: 30px;
font-weight: 500;
margin-bottom: 15px;
}
#speaker {
font-size: 20px;
}

View file

@ -0,0 +1,70 @@
schedule = null;
room_name = null;
$(function() {
$('#speaker').text('Content will appear soon.');
});
function update_lower_third() {
current_time = new Date(Date.now()).getTime()
try {
hash = decodeURIComponent(window.location.hash.substring(1));
room_name = hash;
} catch (e) {
console.error(e);
return
}
if (!schedule) {
console.warn("There's no schedule yet, exiting ...");
return
}
if (schedule['rooms'].length > 1 && !schedule['rooms'].includes(room_name)) {
$('#title').text('Error')
$('#speaker').text('Invalid room_name. Valid names: ' + schedule['rooms'].join(', '));
return
}
current_talk = null;
for (talk_i in schedule['talks']) {
talk = schedule['talks'][talk_i]
if (schedule['rooms'].length > 1 && talk['room'] != room_name) {
// not in this room
continue;
}
talk_start = new Date(talk['start']).getTime();
talk_end = new Date(talk['end']).getTime();
if (talk_start < current_time && talk_end > current_time) {
current_talk = talk;
}
}
if (current_talk) {
$('#title').text(current_talk['title']);
$('#speaker').text(current_talk['persons'].join(', '));
$('#box').css('border-bottom', '10px solid ' + current_talk['track']['color']);
} else {
$('#title').text('Currently no talk');
$('#speaker').text('');
$('#box').css('border-bottom', 'none');
}
}
window.setInterval(update_lower_third, 1000);
function update_schedule() {
$.getJSON('schedule.json', function(data) {
console.info('schedule updated with ' + data['talks'].length + ' talks in ' + data['rooms'].length + ' rooms');
schedule = data;
window.setTimeout(update_schedule, 30000);
});
}
update_schedule();

View file

@ -0,0 +1,25 @@
{% load static %}
{% load compress %}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html" charset="UTF-8">
<title>{{ request.event.name }} lower thirds</title>
{% compress js %}
<script src="{% static "vendored/jquery-3.1.1.js" %}"></script>
{% endcompress %}
<script src="{% static "pretalx_lower_thirds/update.js" %}"></script>
<link rel="stylesheet" href="{% static "pretalx_lower_thirds/frontend.css" %}" />
<style type="text/css">
#box {
background-color: {{ request.event.primary_color }};
}
</style>
</head>
<body>
<div id="box">
<p id="title">Loading ...</p>
<p id="speaker">Content should appear soon. If not, please verify you have Javascript enabled.</p>
</div>
</body>
</html>

View file

@ -0,0 +1,18 @@
from django.urls import re_path
from pretalx.event.models.event import SLUG_CHARS
from . import views
urlpatterns = [
re_path(
f"^(?P<event>[{SLUG_CHARS}]+)/p/lower-thirds/$",
views.LowerThirdsView.as_view(),
name="lowerthirds",
),
re_path(
f"^(?P<event>[{SLUG_CHARS}]+)/p/lower-thirds/schedule.json$",
views.ScheduleView.as_view(),
name="schedule",
),
]

View file

@ -0,0 +1,71 @@
import datetime as dt
import json
import pytz
import random
from django.contrib import messages
from django.db.models import Case, OuterRef, Subquery, When
from django.http import Http404, JsonResponse
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from django.views.generic.base import TemplateView
from django_context_decorator import context
from pretalx.agenda.views.schedule import ScheduleMixin
from pretalx.common.mixins.views import EventPermissionRequired
from pretalx.common.signals import register_data_exporters
from pretalx.schedule.exporters import ScheduleData
class LowerThirdsView(TemplateView):
template_name = "pretalx_lower_thirds/lower_thirds.html"
class ScheduleView(EventPermissionRequired, ScheduleMixin, TemplateView):
permission_required = "agenda.view_schedule"
def get(self, request, *args, **kwargs):
schedule = ScheduleData(
event=self.request.event,
schedule=self.schedule,
)
tz = pytz.timezone(schedule.event.timezone)
return JsonResponse(
{
"conference": {
"slug": schedule.event.slug,
"name": str(schedule.event.name),
},
"rooms": sorted({
str(room["name"])
for day in schedule.data
for room in day["rooms"]
}),
"talks": [
{
"id": talk.submission.id,
"start": talk.start.astimezone(tz).isoformat(),
"end": (talk.start + dt.timedelta(minutes=talk.duration)).astimezone(tz).isoformat(),
"slug": talk.frab_slug,
"title": talk.submission.title,
"persons": sorted({
person.get_display_name() for person in talk.submission.speakers.all()
}),
"track": {
"color": talk.submission.track.color,
"name": str(talk.submission.track.name),
} if talk.submission.track else None,
"room": str(room["name"]),
}
for day in schedule.data
for room in day["rooms"]
for talk in room["talks"]
],
},
json_dumps_params={
"indent": 4,
},
)