]> git.0d.be Git - panikweb.git/commitdiff
add party mode
authorFrédéric Péters <fpeters@0d.be>
Sat, 2 Nov 2013 20:43:34 +0000 (21:43 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sat, 2 Nov 2013 20:43:34 +0000 (21:43 +0100)
panikweb/urls.py
panikweb/views.py
panikweb_templates/templates/party.html [new file with mode: 0644]

index 53758aca288fa64b82d9527d0ba0319c132193c8..fe18e640df765f596438bf46d28261d8214c2329 100644 (file)
@@ -25,6 +25,8 @@ urlpatterns = patterns('',
     url(r'^news/archives/$', 'panikweb.search.newsArchives', name='newsArchives'),
     url(r'^news/(?P<slug>[\w,-]+)$', 'panikweb.views.newsitemview', name='newsitem-view'),
 
+    url(r'^party', 'panikweb.views.party', name='party'),
+
     url(r'^search/', 'panikweb.search.view', name='search'),
 
     url(r'^news.rss', 'panikweb.views.rss_news_feed', name='rss-feed'),
index f5de3fc96e149c6b2f01265687a96d2997e7739c..169aa8ada40ce27a1aaefcbfa1c955f3e7bfe92c 100644 (file)
@@ -1,5 +1,6 @@
 from datetime import datetime, timedelta
 import math
+import random
 import os
 import stat
 import time
@@ -603,3 +604,31 @@ class AtomNewsFeed(RssNewsFeed):
     feed_type = Atom1Feed
 
 atom_news_feed = AtomNewsFeed()
+
+
+
+class Party(TemplateView):
+    template_name = 'party.html'
+
+    def get_context_data(self, **kwargs):
+        context = super(Party, self).get_context_data(**kwargs)
+        t = random.choice(['newsitem']*2 + ['emission']*3 + ['soundfile']*1 + ['episode']*2)
+        focus = Focus()
+        if t == 'newsitem':
+            focus.newsitem = NewsItem.objects.exclude(
+                    image__isnull=True).exclude(image__exact='').order_by('?')[0]
+        elif t == 'emission':
+            focus.emission = Emission.objects.exclude(
+                    image__isnull=True).exclude(image__exact='').order_by('?')[0]
+        elif t == 'episode':
+            focus.episode = Episode.objects.exclude(
+                    image__isnull=True).exclude(image__exact='').order_by('?')[0]
+        elif t == 'soundfile':
+            focus.soundfile = SoundFile.objects.exclude(
+                    episode__image__isnull=True).exclude(episode__image__exact='').order_by('?')[0]
+
+        context['focus'] = focus
+
+        return context
+
+party = Party.as_view()
diff --git a/panikweb_templates/templates/party.html b/panikweb_templates/templates/party.html
new file mode 100644 (file)
index 0000000..370cba2
--- /dev/null
@@ -0,0 +1,89 @@
+{% extends "base.html" %}
+{% load thumbnails %}
+{% load paniktags %}
+{% load staticfiles %}
+{% load i18n %}
+{% block bodyID %}Party{% endblock %}
+{% block title %}Party{% endblock %}
+
+{% block extrascripts %}
+<script>
+function reload() {
+  if (location.href.indexOf('?') == -1) {
+    href = location.href;
+  } else {
+    href = location.href.substring(0, location.href.indexOf('?'));
+  }
+  href = href + '?' + new Date().getTime()
+  $('#Changing').fadeOut();
+
+  $('#Changing').load(href + " #Changing>*", null, function() {$('#Changing').fadeIn();});
+}
+
+$(function() {
+  timer = setInterval(reload, 10000);
+});
+</script>
+{% endblock %}
+
+{% block main %}
+
+<div id="party" class="news">
+
+  <div class="content content-inline cf special">
+    <a class="block cf" href="{{ focus|get_focus_url}}">
+      {% if focus.content_category_title %}
+        <div class="label labels absolute">
+          <span class="item inBlock">{{ focus.content_category_title }}</span>
+        </div>
+      {% endif %}
+      <div class="logo">
+        <img class="normal" src="{{ focus.content_image|thumbnail:'500x375' }}"/>
+      </div>
+      <div class="title"><div>{{ focus.focus_title }}</div></div>
+    </a>
+  </div>
+
+  <style>
+#metaNav, #Footer, .metas { display: none; }
+.special .title {
+       opacity:0.9;
+        width: 482px;
+        background: black;
+        color: white;
+        position: absolute;
+        bottom: 0;
+       font-family: "RegloBold";
+        padding: 10px;
+}
+
+body {
+        height: 90%;
+        overflow: hidden;
+}
+
+#Changing,
+#Commons {
+        float: none;
+        height: 200px;
+        width: 500px;
+        margin: 0 auto 0 auto;
+}
+#backgroundBox {
+        margin: auto 0;
+}
+
+#Commons > .wrapper {
+        position: relative;
+}
+
+#Player {
+        width: 200px;
+        position: absolute;
+        top: 50px;
+        left: 200px;
+}
+
+  </style>
+
+{% endblock %}