theme_js (and all of theme_static) was broken because when THEME_STATIC_*
was added it was changed to *only* search the THEME_STATIC_* paths and
not fall back to STATIC_* where all the stock javascript and css are
kept. This was surprisingly subtle (since I didn't know what any of
byteflow or the themes was even supposed to look like) but did manifest
as 404s due to bad js/css paths and broken things like the comment
'preview' button.
The following patch fixes both problems.
--
Ben Jackson AD7GD
<b...@ben.com>
http://www.ben.com/
Changes default THEME_STATIC_ROOT to be the matching local path of
the URL THEME_STATIC_URL. Changes theme_static to search both
THEME_STATIC_* and STATIC_* to properly allow for theme overrides
and default files.
diff -r ca2fdf9b5e16 -r 640779799f54 apps/lib/templatetags/theme.py
--- a/apps/lib/templatetags/theme.py Fri Nov 27 13:29:25 2009 -0800
+++ b/apps/lib/templatetags/theme.py Fri Nov 27 20:38:29 2009 -0800
@@ -11,16 +11,18 @@
return strftime('%Y%m%d%H%M', time)
def theme_static(kind, filename):
- candidates = [[settings.THEME, kind, '%s.%s' % (filename, kind)],
- [kind, '%s.%s' % (filename, kind)]]
+ file = '%s.%s' % (filename, kind)
+ candidates = [[settings.THEME_STATIC_URL, settings.THEME_STATIC_ROOT, kind, file],
+ [settings.STATIC_URL, settings.STATIC_ROOT, settings.THEME, kind, file],
+ [settings.STATIC_URL, settings.STATIC_ROOT, kind, file]]
for candidate in candidates:
- full_path = join(settings.THEME_STATIC_ROOT, *candidate)
+ full_path = join(*candidate[1:])
if exists(full_path) and not isdir(full_path):
- url = '/'.join(candidate)
+ url = '/'.join(candidate[2:])
if settings.APPEND_MTIME_TO_STATIC:
url = '%s?%s' % (url, gettime(full_path))
- return {'STATIC_URL': settings.THEME_STATIC_URL, 'include': True, 'url': url}
+ return {'STATIC_URL': candidate[0], 'include': True, 'url': url}
return {'include': False}
diff -r ca2fdf9b5e16 -r 640779799f54 settings.py
--- a/settings.py Fri Nov 27 13:29:25 2009 -0800
+++ b/settings.py Fri Nov 27 20:38:29 2009 -0800
@@ -246,7 +246,7 @@
ADDITIONAL_APPS = ('pingback', 'watchlist')
if not hasattr(globals(), 'THEME_STATIC_ROOT'):
- THEME_STATIC_ROOT = STATIC_ROOT
+ THEME_STATIC_ROOT = os.path.join(STATIC_ROOT, THEME + '/')
if not hasattr(globals(), 'THEME_STATIC_URL'):
THEME_STATIC_URL = os.path.join(STATIC_URL, THEME + '/')
Thanks, pushed.
--
Alexander