summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiskvorky <radimrehurek@seznam.cz>2011-12-07 02:21:06 +0100
committerpiskvorky <radimrehurek@seznam.cz>2011-12-07 02:27:57 +0100
commit0118be48b0272147aa63fd8910b99acbfaa52102 (patch)
tree627e03f80a78257b5239d671ecca848173c892de
parenta0ef331191fa8e1c7a7a9816f1cf35ed6b9bfe59 (diff)
downloadaskbot-0118be48b0272147aa63fd8910b99acbfaa52102.tar.gz
askbot-0118be48b0272147aa63fd8910b99acbfaa52102.tar.bz2
askbot-0118be48b0272147aa63fd8910b99acbfaa52102.zip
added support for django.contrib.staticfiles
* staticfiles used to be a separate Python package, before being integrated into django 1.3 * this patch ignores the legacy package and references only the built-in django.contrib.staticfiles, so it requires django >= 1.3 * with staticfiles, serving media in development (runserver) vs. production is handled automatically, so i completely removed the /m/ media view.
-rw-r--r--askbot/setup_templates/settings.py21
-rw-r--r--askbot/skins/utils.py9
-rw-r--r--askbot/urls.py5
-rw-r--r--askbot_requirements.txt2
4 files changed, 23 insertions, 14 deletions
diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py
index 9e847eba..7964368b 100644
--- a/askbot/setup_templates/settings.py
+++ b/askbot/setup_templates/settings.py
@@ -5,7 +5,8 @@ import sys
import askbot
#this line is added so that we can import pre-packaged askbot dependencies
-sys.path.append(os.path.join(os.path.dirname(askbot.__file__), 'deps'))
+ASKBOT_ROOT = os.path.abspath(os.path.dirname(askbot.__file__))
+sys.path.append(os.path.join(ASKBOT_ROOT, 'deps'))
DEBUG = False#set to True to enable debugging
TEMPLATE_DEBUG = False#keep false when debugging jinja2 templates
@@ -222,3 +223,21 @@ djcelery.setup_loader()
CSRF_COOKIE_NAME = 'askbot_csrf'
CSRF_COOKIE_DOMAIN = ''#enter domain name here - e.g. example.com
+
+# === Settings for django.contrib.staticfiles
+STATIC_ROOT = os.path.join(PROJECT_ROOT, "site_media", "static")
+
+STATIC_URL = "/site_media/static/"
+
+# Additional directories which hold static files
+STATICFILES_DIRS = [
+ os.path.join(PROJECT_ROOT, "static"),
+ os.path.join(ASKBOT_ROOT, 'skins'),
+]
+
+STATICFILES_FINDERS = [
+ "django.contrib.staticfiles.finders.FileSystemFinder",
+ "django.contrib.staticfiles.finders.AppDirectoriesFinder",
+# "django.contrib.staticfiles.finders.LegacyAppDirectoriesFinder",
+ "compressor.finders.CompressorFinder",
+]
diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py
index da3a8a06..64f11c75 100644
--- a/askbot/skins/utils.py
+++ b/askbot/skins/utils.py
@@ -149,13 +149,8 @@ def get_media_url(url, ignore_missing = False):
logging.critical(log_message)
return None
- url = use_skin + '/media/' + url
- url = '///' + django_settings.ASKBOT_URL + 'm/' + url
- url = os.path.normpath(url).replace(
- '\\', '/'
- ).replace(
- '///', '/'
- )
+ url = django_settings.STATIC_URL + use_skin + '/media/' + url
+ url = os.path.normpath(url).replace('\\', '/')
if resource_revision:
url += '?v=%d' % resource_revision
diff --git a/askbot/urls.py b/askbot/urls.py
index 2c3d143d..235973d0 100644
--- a/askbot/urls.py
+++ b/askbot/urls.py
@@ -37,11 +37,6 @@ urlpatterns = patterns('',
name='sitemap'
),
url(
- r'^m/(?P<skin>[^/]+)/media/(?P<resource>.*)$',
- views.meta.media,
- name='askbot_media',
- ),
- url(
r'^%s(?P<path>.*)$' % settings.ASKBOT_UPLOADED_FILES_URL,
'django.views.static.serve',
{'document_root': os.path.join(
diff --git a/askbot_requirements.txt b/askbot_requirements.txt
index fc11d9d1..6f7a170c 100644
--- a/askbot_requirements.txt
+++ b/askbot_requirements.txt
@@ -1,5 +1,5 @@
akismet
-django>=1.1.2
+django>=1.3
Jinja2
Coffin>=0.3
South>=0.7.1