Switch the cms over to using django-pipeline

This commit is contained in:
Calen Pennington
2012-06-19 14:12:03 -04:00
committed by Matthew Mongeau
parent 1898691544
commit d147638d07
12 changed files with 72 additions and 8 deletions

View File

@@ -0,0 +1,19 @@
from staticfiles.storage import staticfiles_storage
import re
PREFIX = '/static/'
STATIC_PATTERN = re.compile(r"""
(?P<quote>['"]) # the opening quotes
{prefix} # the prefix
(?P<rest>.*?) # everything else in the url
(?P=quote) # the first matching closing quote
""".format(prefix=PREFIX), re.VERBOSE)
PREFIX_LEN = len(PREFIX)
def replace(static_url):
quote = static_url.group('quote')
url = staticfiles_storage.url(static_url.group('rest'))
return "".join([quote, url, quote])
def replace_urls(text):
return STATIC_PATTERN.sub(replace, text)