summaryrefslogtreecommitdiffstats
path: root/askbot/utils
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-05 02:10:45 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-05 02:10:45 -0400
commit9c56383cd0525d0e6e5463e1c8a70d2e9d66fd99 (patch)
tree9ee2d285f8b0650485c35c827a0f4375881053b6 /askbot/utils
parent54891e1576a3b8ad96fcfa159c5eaf5ab9cd2446 (diff)
downloadaskbot-9c56383cd0525d0e6e5463e1c8a70d2e9d66fd99.tar.gz
askbot-9c56383cd0525d0e6e5463e1c8a70d2e9d66fd99.tar.bz2
askbot-9c56383cd0525d0e6e5463e1c8a70d2e9d66fd99.zip
hopefully fixed the askbot site mounted at a sub-url
Diffstat (limited to 'askbot/utils')
-rw-r--r--askbot/utils/decorators.py3
-rw-r--r--askbot/utils/html.py10
2 files changed, 6 insertions, 7 deletions
diff --git a/askbot/utils/decorators.py b/askbot/utils/decorators.py
index da1cd7db..1cf20059 100644
--- a/askbot/utils/decorators.py
+++ b/askbot/utils/decorators.py
@@ -17,6 +17,7 @@ from django.utils.encoding import smart_str
from askbot import exceptions as askbot_exceptions
from askbot.conf import settings as askbot_settings
from askbot.utils import url_utils
+from askbot.utils.html import site_url
from askbot import get_version
def auto_now_timestamp(func):
@@ -204,7 +205,7 @@ def check_spam(field):
from akismet import Akismet
api = Akismet(
askbot_settings.AKISMET_API_KEY,
- smart_str(askbot_settings.APP_URL),
+ smart_str(site_url(reverse('questions'))),
"Askbot/%s" % get_version()
)
diff --git a/askbot/utils/html.py b/askbot/utils/html.py
index 9fb46337..29e8bd70 100644
--- a/askbot/utils/html.py
+++ b/askbot/utils/html.py
@@ -52,14 +52,14 @@ def absolutize_urls(html):
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
+ base_url = site_url('')#important to have this without the slash
+ img_replacement = '\g<prefix>"%s/\g<url>" style="max-width:500px;"' % base_url
+ replacement = '\g<prefix>"%s\g<url>"' % base_url
html = url_re1.sub(img_replacement, html)
html = url_re2.sub(img_replacement, html)
html = url_re3.sub(replacement, html)
#temporal fix for bad regex with wysiwyg editor
- return url_re4.sub(replacement, html).replace('%s//' % askbot_settings.APP_URL,
- '%s/' % askbot_settings.APP_URL)
+ return url_re4.sub(replacement, html).replace('%s//' % base_url, '%s/' % base_url)
def replace_links_with_text(html):
"""any absolute links will be replaced with the
@@ -131,8 +131,6 @@ def site_link(url_name, title):
todo: may be improved to process url parameters, keyword
and other arguments
"""
- from askbot.conf import settings
- base_url = urlparse(settings.APP_URL)
url = site_url(reverse(url_name))
return '<a href="%s">%s</a>' % (url, title)