Commit 1ce354ab authored by Gijs Hendriksen's avatar Gijs Hendriksen

Created a Thabloid page viewer using FancyBox

parent 5420e848
......@@ -26,7 +26,7 @@
<h2>{{ thabloid.year }}-{{ thabloid.year|add:1 }}, #{{ thabloid.issue }}</h2>
</div>
<ul class="post-overlay-icons">
<li><span></span><a class="gallery-box overlay-icon-open" data-fancybox-type='iframe' href="{% url 'thabloid:viewer' thabloid.year thabloid.issue %}"></a></li>
<li><span></span><a class="overlay-icon-open open-thabloid" href="pages/{{ thabloid.year }}/{{ thabloid.issue }}/"></a></li>
<li><span></span><a class="overlay-icon-link" href="{{ thabloid.file.url }}" target="_blank"></a></li>
</ul>
</div>
......@@ -36,3 +36,26 @@
</ul>
</div>
{% endblock %}
{% block js_footer %}
<script>
$('.open-thabloid').on('click', function(event) {
event.preventDefault();
$.ajax(this.href).success(function(data) {
$.fancybox(data,
{
padding: 0,
loop: false,
openEffect: 'elastic',
closeEffect: 'elastic',
helpers: {
overlay: {
css: {'background-color': 'rgba(0, 0, 0, 0.9)'},
locked: true
}
}
});
});
});
</script>
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
</head>
<body>
TODO: embed a viewer that displays the page files;
<ul>
{% for page in thabloid.pages %}
<li>{{ MEDIA_URL }}{{ page }}</li>
{% endfor %}
</ul>
</body>
</html>
\ No newline at end of file
......@@ -2,9 +2,9 @@ from django.conf.urls import url
from . import views
app_name = "thabloid"
app_name='thabloid'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^(?P<year>[0-9]{4})/(?P<issue>[0-9]+)/$', views.viewer, name='viewer'),
url(r'^pages/(?P<year>[0-9]{4})/(?P<issue>[0-9]+)/$', views.pages, name='pages'),
]
from django.db.models import Max
from django.shortcuts import get_object_or_404, render
from django.db.models import Max
from django.conf import settings
from django.http import JsonResponse
from .models import Thabloid
......@@ -11,6 +13,7 @@ def index(request):
return render(request, 'thabloid/index.html', context)
def viewer(request, year, issue):
def pages(request, year, issue):
thabloid = get_object_or_404(Thabloid, year=int(year), issue=int(issue))
return render(request, 'thabloid/viewer.html', {'thabloid': thabloid})
pages = ['{}{}'.format(settings.MEDIA_URL, p) for p in thabloid.pages]
return JsonResponse(pages, safe=False)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment