clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

Download raw (1.6 KB)

from django import template

import HTMLParser
from publish.utils import typogrify as typogrify_util
from publish.models import Issue

from django.contrib.staticfiles.finders import find as find_static_file
from django.conf import settings

from import default_storage
import os.path

register = template.Library()

def times(number):
    return range(1, number + 1)

def decode_entities(text):
    html_parser = HTMLParser.HTMLParser()
    return html_parser.unescape(text)

def typogrify(html):
    return typogrify_util(html)

def pile_de_medor():
    issue = Issue.objects.order_by("-id").filter(published_online=True).first()
    return {'issue': issue}

def encode_media(path, encoding='base64', file_type='image'):
    a template tag that returns a encoded string representation of a mediafile
        {% encode_media path [encoding] %}
        <img src="{% encode_media 'path/to/img.png' %}">
    if path.startswith(settings.MEDIA_URL):
        # remove MEDIA_URL if its included in the path
        path = path.replace(settings.MEDIA_URL, '')

    with as f:
        data =

    ext = path.split('.')[-1]
    file_str = data.encode(encoding)

    return u"data:{0}/{1};{2},{3}".format(file_type, ext, encoding, file_str)