Embedded schedule view

Allow the schedule to be embedded in external platforms.
Hide header and footer when embedded for easier consumption.
This commit is contained in:
Joel Addison 2021-01-22 23:22:06 +10:00
parent bf46c82fe4
commit ef420b2d43
4 changed files with 30 additions and 0 deletions

View file

@ -1 +1,8 @@
{% extends "site_base.html" %}
{% load static %}
{% block extra_script %}
<script src="{% static 'js/luxon.min.js' %}"></script>
<script src="{% static 'js/schedule.js' %}" type="text/javascript"></script>
{% endblock %}

View file

@ -103,6 +103,23 @@ $(function() {
}
}
var embeddedView = function() {
var urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('embed')) {
$('header').remove();
$('footer').remove();
$('a').each(function() {
var anchor = $(this);
var path = anchor.attr('href');
if (path.startsWith('/')) {
var separator = path.indexOf('?') === -1 ? '?' : '&';
anchor.attr('href', path + separator + 'embed')
}
})
}
}
/* Schedule Editing */
$("a.edit-slot").click(function(e) {
$("#slotEditModal").load($(this).data("action"), function() {
@ -123,6 +140,7 @@ $(function() {
});
/* Update schedule display */
embeddedView();
showCurrentTab();
updateScheduleGrid();
updatePresentationTimes();

View file

@ -6,6 +6,7 @@ from django.shortcuts import render, get_object_or_404, redirect
from django.urls import reverse
from django.template import loader, Context
from django.conf import settings
from django.views.decorators.clickjacking import xframe_options_exempt
from django.contrib.auth import get_user_model
from django.contrib import messages
@ -39,6 +40,7 @@ def fetch_schedule(slug):
return schedule
@xframe_options_exempt
def schedule_conference(request):
if request.user.is_staff:
@ -184,6 +186,7 @@ def schedule_slot_edit(request, slug, slot_pk):
return render(request, "symposion/schedule/_slot_edit.html", ctx)
@xframe_options_exempt
def schedule_presentation_detail(request, pk):
presentation = get_object_or_404(Presentation, pk=pk)

View file

@ -1,6 +1,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.http import Http404
from django.shortcuts import render, redirect, get_object_or_404
from django.views.decorators.clickjacking import xframe_options_exempt
from django.contrib import messages
from django.contrib.auth.decorators import login_required
@ -123,6 +124,7 @@ def speaker_edit(request, pk=None):
})
@xframe_options_exempt
def speaker_profile(request, pk):
speaker = get_object_or_404(Speaker, pk=pk)
presentations = speaker.all_presentations