diff options
Diffstat (limited to 'askbot/templatetags/extra_filters_jinja.py')
-rw-r--r-- | askbot/templatetags/extra_filters_jinja.py | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/askbot/templatetags/extra_filters_jinja.py b/askbot/templatetags/extra_filters_jinja.py index ba13166b..146de6d1 100644 --- a/askbot/templatetags/extra_filters_jinja.py +++ b/askbot/templatetags/extra_filters_jinja.py @@ -14,6 +14,7 @@ from askbot import exceptions as askbot_exceptions from askbot.conf import settings as askbot_settings from django.conf import settings as django_settings from askbot.skins import utils as skin_utils +from askbot.utils.html import absolutize_urls from askbot.utils import functions from askbot.utils import url_utils from askbot.utils.slug import slugify @@ -24,22 +25,7 @@ from django_countries import settings as countries_settings register = coffin_template.Library() -@register.filter -def absolutize_urls(text): - #temporal fix for bad regex with wysiwyg editor - url_re1 = re.compile(r'(?P<prefix><img[^<]+src=)"(?P<url>[/\..][^"]+)"', re.I) - url_re2 = re.compile(r"(?P<prefix><img[^<]+src=)'(?P<url>[/\..][^']+)'", re.I) - url_re3 = re.compile(r'(?P<prefix><a[^<]+href=)"(?P<url>/[^"]+)"', re.I) - url_re4 = re.compile(r"(?P<prefix><a[^<]+href=)'(?P<url>/[^']+)'", re.I) - img_replacement = '\g<prefix>"%s/\g<url>" style="max-width:500px;"' % askbot_settings.APP_URL - replacement = '\g<prefix>"%s\g<url>"' % askbot_settings.APP_URL - text = url_re1.sub(img_replacement, text) - text = url_re2.sub(img_replacement, text) - text = url_re3.sub(replacement, text) - #temporal fix for bad regex with wysiwyg editor - return url_re4.sub(replacement, text).replace('%s//' % askbot_settings.APP_URL, - '%s/' % askbot_settings.APP_URL) - +absolutize_urls = register.filter(absolutize_urls) TIMEZONE_STR = pytz.timezone( django_settings.TIME_ZONE |