Commit a24403c0 authored by Simon Daron's avatar Simon Daron

New files (archives)

parent 948f94f2
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://test-web.radiopanik.org:8985/solr/panik'
},
}
import re
import urllib2
import uuid
from django import template
from django.db.models.query import QuerySet
register = template.Library()
@register.filter(name='zip')
def zip_lists(a, b):
return zip(a, b)
@register.inclusion_tag('includes/audio.html', takes_context=True)
def audio(context, sound=None):
return {
'episode': context.get('episode'),
'sound': sound
}
@register.inclusion_tag('episodes/resume.html', takes_context=True)
def episode_resume(context, date=None, model=None, klass=None):
return {
'model': model,
'class': klass,
'episode': context.get('episode'),
'date': date,
}
@register.inclusion_tag('emissions/detail.html', takes_context=True)
def emission_detail(context, date=None):
return {
'emission': context.get('emission'),
'schedules': context.get('schedules'),
}
@register.inclusion_tag('includes/player.html', takes_context=False)
def player():
return {'unique': uuid.uuid4()}
@register.inclusion_tag('includes/metaNav.html', takes_context=False)
def metanav():
return {}
@register.inclusion_tag('news/inline.html', takes_context=False)
def news_inline(content=None, klass=None, logo=None):
return {
'content': content,
'class': klass,
'logo': logo
}
@register.filter
def jsonify(object):
if isinstance(object, QuerySet):
return serialize('json', object)
return simplejson.dumps(object)
@register.filter
def remove_tag_facet(url, facet):
facet = urllib2.quote(facet.encode('utf-8'), safe='')
return re.sub(r'&page=\d+', '', url.replace('&selected_facets=tags_exact:%s' % facet, ''))
@register.filter
def remove_category_facet(url, facet):
facet = urllib2.quote(facet.encode('utf-8'), safe='')
return re.sub(r'&page=\d+', '', url.replace('&selected_facets=categories_exact:%s' % facet, ''))
@register.filter
def append_tag_facet(url, facet):
facet = urllib2.quote(facet.encode('utf-8'), safe='')
return re.sub(r'&page=\d+', '', url + '&selected_facets=tags_exact:%s' % facet)
@register.filter
def append_category_facet(url, facet):
facet = urllib2.quote(facet.encode('utf-8'), safe='')
return re.sub(r'&page=\d+', '', url + '&selected_facets=categories_exact:%s' % facet)
@register.tag
def search_result_template(parser, token):
try:
tag_name, result_str = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError("%r tag requires exactly one argument" % token.contents.split()[0])
return FormatSearchResultNode(result_str)
class FormatSearchResultNode(template.Node):
def __init__(self, result_str):
self.result_var = template.Variable(result_str)
def render(self, context):
result = self.result_var.resolve(context)
dir_mapping = {
'newsitem': 'news',
'emission': 'emissions',
'episode': 'episodes'
}
t = template.loader.get_template('%s/search_result.html' % dir_mapping.get(result.model_name))
return t.render(template.context.Context({'result': result}, autoescape=context.autoescape))
# initiated from http://djangosnippets.org/snippets/2145/
import os
import re
from PIL import Image
from django.db.models.signals import post_save, pre_delete
from django.template import Library
register = Library()
def thumbnail(image, size='100x100'):
# defining the size
x, y = [int(x) for x in size.split('x')]
# defining the filename and the miniature filename
filehead, filetail = os.path.split(image.path)
basename, format = os.path.splitext(filetail)
miniature = basename + '_' + size + format
filename = image.path
miniature_filename = os.path.join(filehead, miniature)
filehead, filetail = os.path.split(image.url)
miniature_url = filehead + '/' + miniature
if os.path.exists(miniature_filename) and \
os.path.getmtime(filename) > os.path.getmtime(miniature_filename):
os.unlink(miniature_filename)
# if the image wasn't already resized, resize it
if not os.path.exists(miniature_filename):
image = Image.open(filename)
if abs( (1.0*x/y) - (1.0*image.size[0]/image.size[1]) ) > 0.1:
# aspect ratio change, crop the image first
if image.size[0] > image.size[1]: # landscape
box = [0, 0, int(image.size[1] * (1.0*x/y)), image.size[1]]
box[0] = (image.size[0] - box[2]) / 2 # keep the middle
else:
box = [0, 0, image.size[0], int(image.size[0] * (1.0*x/y))]
box[1] = (image.size[1] - box[3]) / 4 # keep mostly the top
image = image.crop(box)
image = image.resize([x, y], Image.ANTIALIAS)
try:
image.save(miniature_filename, image.format, quality=90, optimize=1)
except:
image.save(miniature_filename, image.format, quality=90)
return miniature_url
register.filter(thumbnail)
def clean_thumb(sender, instance, **kwargs):
if not hasattr(instance, 'image'):
return
name, ext = os.path.splitext(os.path.basename(instance.image.name))
exp = '^%s_\d+x\d+x[0-1]{1}\%s' % (name, ext)
for file_path in os.listdir(settings.MEDIA_ROOT):
if re.search(exp, file_path):
os.unlink(settings.MEDIA_ROOT + file_path)
post_save.connect(clean_thumb)
pre_delete.connect(clean_thumb)
from django.conf.urls import patterns, include, url
from django.conf import settings
from django.views.generic import RedirectView
from django.core.urlresolvers import reverse_lazy
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'panikweb.views.home', name='home'),
url(r'^onair.json$', 'panikweb.views.onair', name='onair'),
url(r'^program$', 'panikweb.views.program', name='program'),
url(r'^grid$', 'panikweb.views.grid', name='grid'),
url(r'^emissions/$', 'panikweb.views.emissions', name='emissions'),
url(r'^emissions/', include('emissions.urls')),
url(r'^ckeditor/', include('ckeditor.urls')),
url(r'^get$', 'panikweb.views.get', name='get'),
url(r'^listen$', 'panikweb.views.listen', name='listen'),
url(r'^news/$', 'panikweb.views.news', name='news'),
url(r'^news/(?P<slug>[\w,-]+)$', 'panikweb.views.newsitem', name='news-view'),
url(r'^search/', 'panikweb.search.view', name='search'),
(r'^api/v2/', include('fiber.rest_api.urls')),
(r'^admin/fiber/', include('fiber.admin_urls')),
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': ('fiber',),}),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
)
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += patterns('',
(r'', 'fiber.views.page'),
)
try:
from local_urls import *
except ImportError, e:
pass
This diff is collapsed.
@font-face {
font-family: 'RegloNormal';
src: url('../reglo/RE01.otf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'RegloMedium';
src: url('../reglo/RE02-Medium.otf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'RegloBold';
src: url('../reglo/RE03-Bold.otf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'RE04';
src: url('../reglo/RE04-Bold.otf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'RE05';
src: url('../reglo/RE05-Bold.otf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'RegloSymbol';
src: url('../reglo/RE06.otf');
font-weight: normal;
font-style: normal;
line-height: 0 !important;
}
@font-face {
font-family: 'Reglo';
src: url('../reglo/Reglo-Bold.otf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Symbols';
src: url('../reglo/RESYMBOL.otf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'RegloScale';
src: url('../reglo/RegloScaleBold.otf');
font-weight: normal;
font-style: normal;
}
[class^="icon-"],
[class*=" icon-"]{
/*font-size:1.3em;*/
}
.resymbol{
vertical-align:middle !important;
display:inline-block !important;
font-family: 'Symbols' !important;
line-height:50% !important;
font-size:2em;
}
.resymbol.big, .icons.big{
font-size:5em;
}
.resymbol.huge, .icons.huge{
font-size:8em;
}
.info:before,.warning:before,.error:before{
font-family: FontAwesome;
display:inline-block;
margin-right:0.2em;
}
.info:before {
content: "\f05a";
}
.warning:before {
content: "\f071";
}
.error:before {
content: "\f056 ";
}
.checked:before {
content: "\f056 ";
}
{% extends "emissions.html" %}
{% load paniktags %}
{% block bodyID %}Emissions{% endblock %}
{% block title %}Archives{% endblock %}
{% block nav %}
{% emission_nav with klass="archives" %}
{% endblock %}
{% extends "emissions/emission_detail.html" %}
{% load paniktags %}
{% block nav %}
{% emission_nav klass "episodes" %}
{% endblock %}
{% block main %}
<form method="get" action="." class="padded center" id="search-form">
<div class="big ">
<label for="id_q">Rechercher:</label>
<input id="id_q" name="q" type="text" {% if search_query %}value="{{ search_query }}{% endif %}">
<button class="icon-search"></button>
</div>
</form>
<div class="wrapper {% if episodes %}sided{% endif %}">
{% if search_query and not episodes %}
<div class="big error padded center">Sorry, no result with your query!</div>
{% endif %}
<div id="Emission-container" class="emission padded">
{% if episodes %}
{% with episodes as episodes %}
{% regroup episodes by first_diffusion|date:"F Y"|capfirst as month_list %}
<div>
{% for month in month_list %}
<div class="monthGroup {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}">
<div
class="legend button"
onclick="$('#{{ month.grouper|slugify }}').toggle();"
>{{ month.grouper }}</div>
<ul class="custom list" id="{{ month.grouper|slugify }}"
{% if forloop.counter >= 3 %}style="display:none;"{% endif %}
>
{% for episode in month.list %}
<li>{% episode_resume model="inline" date="daytime" %}</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
{% endwith %}
{% endif %}
</div>
</div>
{% endblock %}
{% extends "listen.html" %}
{% load paniktags %}
{% block title %}Listen - Archives{% endblock %}
{% block nav %}
{% listen_nav with klass="archives" %}
<form method="get" action="." class="padded center" id="search-form">
<div class="big ">
<label for="id_q">Rechercher:</label>
<input id="id_q" name="q" type="text" {% if search_query %}value="{{ search_query }}{% endif %}">
<button class="icon-search"></button>
</div>
</form>
{% endblock %}
{% block main %}
{% endblock %}
{% load paniktags %}
<div class="wrapper">
<nav>
<ul class="inline padded">
<li><a href="{% url 'listen' %}" class="{% if class != "archives" %}active{% endif %}">
<span class="icon-bolt" ></span>
<span class="iconLabel">Dernières</span>
</a></li>
<li><a href="{% url 'listenArchives' %}" class="{% if class = "archives" %}active{% endif %}">
<span class="icon-archive" ></span>
<span class="iconLabel">Archives</span>
</a></li>
</ul>
</nav>
</div>
<div class="wrapper">
{% if categories and class != "archives" %}
<nav id="gridNav" class="checkable">
<ul class="by{{ categories.count }}">
<li><button class="check icon-check" data-about="#Main" data-toggle=".nocat">?</button></li>
{% for category in categories %}
<li><button class="check icon-check" data-about="#Main" data-toggle=".{{ category|slugify }}">{{ category }}</button></li>
{% endfor %}
</ul>
</nav>
{% endif %}
</div>
{% extends "news.html" %}
{% load thumbnails %}
{% load paniktags %}
{% block title %}News - Archives{% endblock %}
{% block nav %}
{% news_nav with klass="archives" %}
<form method="get" action="." class="padded center" id="search-form">
<div class="big ">
<label for="id_q">Rechercher:</label>
<input id="id_q" name="q" type="text" {% if search_query %}value="{{ search_query }}{% endif %}">
<button class="icon-search"></button>
</div>
</form>
{% endblock %}
{% block main %}
{% endblock %}
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