aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/__init__.py')
-rw-r--r--youtube/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/youtube/__init__.py b/youtube/__init__.py
index 08f4f6f..3604b21 100644
--- a/youtube/__init__.py
+++ b/youtube/__init__.py
@@ -2,6 +2,7 @@ from youtube import util
from .get_app_version import app_version
import flask
from flask import request
+import jinja2
import settings
import traceback
import re
@@ -135,3 +136,17 @@ def get_css():
),
mimetype='text/css',
)
+
+
+# This is okay because the flask urlize function puts the href as the first
+# property
+YOUTUBE_LINK_RE = re.compile(r'<a href="(' + util.YOUTUBE_URL_RE_STR + ')"')
+old_urlize = jinja2.filters.urlize
+
+
+def prefix_urlize(*args, **kwargs):
+ result = old_urlize(*args, **kwargs)
+ return YOUTUBE_LINK_RE.sub(r'<a href="/\1"', result)
+
+
+jinja2.filters.urlize = prefix_urlize