Commit b0c95fed authored by fred's avatar fred

force absolute URLs in feeds

parent 3ce828e3
...@@ -360,3 +360,10 @@ def image_file(page): ...@@ -360,3 +360,10 @@ def image_file(page):
except Topik.DoesNotExist: except Topik.DoesNotExist:
pass pass
return None return None
@register.filter
def set_absolute_urls(text):
text = text.replace('src="/', 'src="%s' % settings.WEBSITE_BASE_URL)
text = text.replace('href="/', 'href="%s' % settings.WEBSITE_BASE_URL)
return text
...@@ -230,6 +230,8 @@ TEMPLATE_VARS = {} ...@@ -230,6 +230,8 @@ TEMPLATE_VARS = {}
COMBO_DASHBOARD_ENABLED = False COMBO_DASHBOARD_ENABLED = False
WEBSITE_BASE_URL = 'http://www.radiopanik.org/'
try: try:
from local_settings import * from local_settings import *
except ImportError, e: except ImportError, e:
......
{% load thumbnail %} {% load paniktags thumbnail %}
{% if obj.image %} {% if obj.image %}
{% thumbnail obj.image "320x240" crop="50% 25%" as im %} {% thumbnail obj.image "320x240" crop="50% 25%" as im %}
<img src="{{im.url}}"/> <img src="{{im.url}}"/>
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
{% endif %} {% endif %}
{% autoescape off %} {% autoescape off %}
{{ obj.text }} {{ obj.text|set_absolute_urls }}
{% endautoescape %} {% endautoescape %}
{% load thumbnail %} {% load paniktags thumbnail %}
{% if obj.episode.image %} {% if obj.episode.image %}
{% thumbnail obj.episode.image "320x240" crop="50% 25%" as im %} {% thumbnail obj.episode.image "320x240" crop="50% 25%" as im %}
<img src="{{im.url}}"/> <img src="{{im.url}}"/>
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
{% endif %} {% endif %}
{% autoescape off %} {% autoescape off %}
{{ obj.episode.text }} {{ obj.episode.text|set_absolute_urls }}
{% endautoescape %} {% endautoescape %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment