This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@register.filter(name='twittify') | |
def twittify(value): | |
""" Replace @ and #'s with links to twitter""" | |
return mark_safe( | |
re.sub(r"#(?P<ht>([a-zA-Z0-9_])+)", r"#<a href='http://twitter.com/#!/search?q=\g<ht>' target='_blank'>\g<ht></a>", | |
re.sub(r"@(?P<un>([a-zA-Z0-9_]){1,15})", r"@<a href='http://twitter.com/\g<un>' target='_blank'>\g<un></a>", value)) | |
) | |
twittify.mark_safe=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream uwsgi { | |
ip_hash; | |
server 127.0.0.1:40000; | |
} | |
server { | |
listen 80; | |
server_name www.domain.com; | |
root /sites/mysite/; | |
access_log /sites/mysite/log/nginx/access.log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Get django-sekizai, django-compessor (and django-cms) playing nicely together | |
re: https://github.com/ojii/django-sekizai/issues/4 | |
using: https://github.com/jezdez/django_compressor.git | |
and: https://github.com/ojii/[email protected] | |
""" | |
from compressor.templatetags.compress import CompressorNode | |
from django.template.base import * | |
def compress(data, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sorl.thumbnail.engines import pil_engine | |
from sorl.thumbnail import parsers | |
class CropperEngine(pil_engine.Engine): | |
""" | |
A custom sorl.thumbnail engine (using PIL) that first crops an image according to 4 pixel/percentage | |
values in the source image, then scales that crop down to the size specified in the geometry. This is | |
in contrast to sorl.thumbnails default engine which first scales the image down to the specified geometry | |
and applies the crop afterward. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="before"> | |
An example of two inline, absolutely positioned dropdown menus that assume the width of their first element but expand in-place on hover to take the width of the largest element. | |
</div> | |
<div class="wrapper"> | |
<div>Two lists: </div> | |
<div class="dropdown first"> | |
<ul> | |
<li>Short 1st element</li> | |
<li>A bit longer 2nd element</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from semanticeditor.layout import LayoutDetailsBase | |
def num_to_word(num): | |
return ('', 'one', 'two', 'three', 'four',)[num] | |
class FoundationLayoutDetails(LayoutDetailsBase): | |
""" | |
A custom layout to use the Zurb Foundation grid. At the moment it only works for up | |
to 4 columns to avoid messy calculations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponseRedirect | |
from django.conf import settings | |
from fandjango.decorators import facebook_authorization_required | |
class ExtraFacebookMiddleware: | |
"""An extra layer of middleware on top of Fandjango to | |
enforce facebook authentication on every request. | |
This avoids having to decorate every view""" | |
def process_view(self, request, view_func, view_args, view_kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load smart_load %} | |
{% load thumbnail from sorl.thumbnail as sorl_thumbnail %} | |
{% load thumbnail from easy_thumnails as easy_thumbnail %} | |
{% sorl_thumbnail image.image "100x100" as im %} | |
<img src='{{ im.url }}' /> | |
{% endthumbnail %} | |
<img src='{% easy_thumbnail image.image "100x100" %}' /> |
OlderNewer