summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/conf/skin_general_settings.py40
-rw-r--r--askbot/doc/source/customizing-skin-in-askbot.rst2
-rw-r--r--askbot/startup_procedures.py2
-rw-r--r--askbot/utils/hasher.py27
4 files changed, 49 insertions, 22 deletions
diff --git a/askbot/conf/skin_general_settings.py b/askbot/conf/skin_general_settings.py
index b90d3de5..1e488404 100644
--- a/askbot/conf/skin_general_settings.py
+++ b/askbot/conf/skin_general_settings.py
@@ -106,20 +106,7 @@ settings.register(
)
)
-settings.register(
- values.IntegerValue(
- GENERAL_SKIN_SETTINGS,
- 'MEDIA_RESOURCE_REVISION',
- default = 1,
- description = _('Skin media revision number'),
- help_text = _(
- 'Increment this number when you change '
- 'image in skin media or stylesheet. '
- 'This helps avoid showing your users '
- 'outdated images from their browser cache.'
- )
- )
-)
+
settings.register(
values.BooleanValue(
@@ -271,3 +258,28 @@ settings.register(
)
)
)
+
+settings.register(
+ values.IntegerValue(
+ GENERAL_SKIN_SETTINGS,
+ 'MEDIA_RESOURCE_REVISION',
+ default = 1,
+ description = _('Skin media revision number'),
+ help_text = _(
+ 'Will be set automatically'
+ 'but you can modify it if you desire.'
+ )
+ )
+)
+
+settings.register(
+ values.StringValue(
+ GENERAL_SKIN_SETTINGS,
+ 'MEDIA_RESOURCE_REVISION_HASH',
+ description = _('Hash to update the media revision number automatically.'),
+ default='',
+ help_text = _(
+ 'Will be set automatically, it is not necesary to modify manually.'
+ )
+ )
+)
diff --git a/askbot/doc/source/customizing-skin-in-askbot.rst b/askbot/doc/source/customizing-skin-in-askbot.rst
index 96c2ec9c..8be21ebd 100644
--- a/askbot/doc/source/customizing-skin-in-askbot.rst
+++ b/askbot/doc/source/customizing-skin-in-askbot.rst
@@ -56,7 +56,7 @@ Possible approaches to customize skins
There are several methods at your disposal,
would you like to customize askbot's appearance.
-.. note::
+.. deprecated:: 0.7.21
Whenever you change any media files on disk, it will be necessary
to increment "skin media revision number" in the
skin settings and restart the app,
diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py
index bb269600..881ef1fb 100644
--- a/askbot/startup_procedures.py
+++ b/askbot/startup_procedures.py
@@ -13,6 +13,7 @@ from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
from askbot.models import badges
from askbot.utils.loading import load_module
+from askbot.utils import hasher
PREAMBLE = """\n
************************
@@ -181,5 +182,6 @@ def run():
try:
badges.init_badges()
transaction.commit()
+ hasher.update_revision()
except:
transaction.rollback()
diff --git a/askbot/utils/hasher.py b/askbot/utils/hasher.py
index 4c68ed79..f6e23c38 100644
--- a/askbot/utils/hasher.py
+++ b/askbot/utils/hasher.py
@@ -1,9 +1,10 @@
import hashlib, os
+import logging
from askbot.conf import settings as askbot_settings
-use_skin = askbot_settings.ASKBOT_DEFAULT_SKIN
-resource_revision = askbot_settings.MEDIA_RESOURCE_REVISION
+from askbot.skins.utils import get_path_to_skin, get_skin_choices
-def GetHashofDirs(directory, verbose=0):
+
+def get_hash_of_dirs(directory):
SHAhash = hashlib.sha1()
if not os.path.exists (directory):
return -1
@@ -34,7 +35,19 @@ def GetHashofDirs(directory, verbose=0):
return SHAhash.hexdigest()
-if __name__ == '__main__':
- #directory = raw_input('directory:')
- #print GetHashofDirs(directory, 0)
- print GetHashofDirs('skins/default/media', 0)
+def update_revision(skin = None):
+ resource_revision = askbot_settings.MEDIA_RESOURCE_REVISION
+ if skin:
+ if skin in get_skin_choices():
+ skin_path = get_path_to_skin(skin)
+ else:
+ raise MediaNotFound('Skin not found')
+ else:
+ skin_path = get_path_to_skin(askbot_settings.ASKBOT_DEFAULT_SKIN)
+
+ current_hash = get_hash_of_dirs(skin_path)
+
+ if current_hash != askbot_settings.MEDIA_RESOURCE_REVISION_HASH:
+ askbot_settings.update('MEDIA_RESOURCE_REVISION', resource_revision + 1)
+ askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash)
+ logging.debug('MEDIA_RESOURCE_REVISION changed')