From ab0e57d06ba77fabad2424dabb0b1028abf0b28f Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 23 Mar 2013 01:23:23 -0400 Subject: some additional work on the compressor branch --- askbot/__init__.py | 1 + askbot/doc/source/contributors.rst | 1 + askbot/skins/loaders.py | 11 ++- askbot/startup_procedures.py | 100 +++++++++++++++++++---- askbot/templates/meta/html_head_stylesheets.html | 2 +- 5 files changed, 96 insertions(+), 19 deletions(-) diff --git a/askbot/__init__.py b/askbot/__init__.py index cf850e33..8cbc9790 100644 --- a/askbot/__init__.py +++ b/askbot/__init__.py @@ -14,6 +14,7 @@ VERSION = (0, 7, 48) REQUIREMENTS = { 'akismet': 'akismet', 'django': 'django>=1.3.1,<1.5', + 'compressor': 'django-compressor==1.2', 'jinja2': 'Jinja2', 'coffin': 'Coffin>=0.3', 'south': 'South>=0.7.1', diff --git a/askbot/doc/source/contributors.rst b/askbot/doc/source/contributors.rst index 71d942bb..b964c7dd 100644 --- a/askbot/doc/source/contributors.rst +++ b/askbot/doc/source/contributors.rst @@ -43,6 +43,7 @@ Programming, bug fixes and documentation * `Paul Backhouse `_ * `jtrain `_ * Niki Rocco +* `Tyler Mandry `_ Translations ------------ diff --git a/askbot/skins/loaders.py b/askbot/skins/loaders.py index f46f0f07..eb72cf09 100644 --- a/askbot/skins/loaders.py +++ b/askbot/skins/loaders.py @@ -57,17 +57,22 @@ class SkinEnvironment(CoffinEnvironment): def get_extra_css_link(self): """returns either the link tag (to be inserted in the html head element) or empty string - depending on the existence of file - SKIN_PATH/media/style/extra.less + SKIN_PATH/media/style/extra.css """ url = None + if django_settings.ASKBOT_CSS_DEVEL is True: - url = utils.get_media_url('style/extra.less', ignore_missing = True) + url = utils.get_media_url('style/extra.less', ignore_missing=True) rel = "stylesheet/less" + + #second try - if there is no extra.less in devel mode - try css if url is None: - url = utils.get_media_url('style/extra.less', ignore_missing = True) + url = utils.get_media_url('style/extra.css', ignore_missing=True) rel = "stylesheet" + if url is not None: return '' % (url, rel) + return '' def load_skins(): diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index f3597820..53162421 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -108,6 +108,26 @@ def test_askbot_url(): msg = 'if ASKBOT_URL setting is not empty, ' + \ 'it must not start with /' + +def test_jinja2(): + """tests Jinja2 settings""" + compressor_ext = 'compressor.contrib.jinja2ext.CompressorExtension' + ext_list = getattr(django_settings, 'JINJA2_EXTENSIONS', None) + errors = list() + if ext_list is None: + errors.append( + "Please add the following line to your settings.py:\n" + "JINJA2_EXTENSIONS = ('%s',)" % compressor_ext + ) + elif compressor_ext not in ext_list: + errors.append( + "Please add to the JINJA2_EXTENSIONS list an item:\n" + "'%s'," % compressor_ext + ) + + print_errors(errors) + + def test_middleware(): """Checks that all required middleware classes are installed in the django settings.py file. If that is not the @@ -287,6 +307,33 @@ def test_celery(): "in your settings.py file" ) +def test_compressor(): + """test settings for django compressor""" + precompilers = getattr(django_settings, 'COMPRESS_PRECOMPILERS', None) + errors = list() + lessc_item = ('text/less', 'lessc {infile} {outfile}') + if precompilers is None: + errors.append( + 'Please add to your settings.py file: \n' + 'COMPRESS_PRECOMPILERS = (\n' + " ('%s', '%s'),\n" + ')' % lessc_item + ) + else: + if lessc_item not in precompilers: + errors.append( + 'Please add to the COMPRESS_PRECOMPILERS the following item:\n' + "('%s', '%s')," % lessc_item + ) + + if 'compressor' not in django_settings.INSTALLED_APPS: + errors.append( + 'add to the INSTALLED_APPS the following entry:\n' + " 'compressor'," + ) + + print_errors(errors) + def test_media_url(): """makes sure that setting `MEDIA_URL` has leading slash""" @@ -472,6 +519,26 @@ def test_staticfiles(): ' python manage.py collectstatic\n' ) + required_finders = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + 'compressor.finders.CompressorFinder', + ) + + finders = getattr(django_settings, 'STATICFILES_FINDERS', None) + + missing_finders = list() + for finder in required_finders: + if finder not in finders: + missing_finders.append(finder) + + if missing_finders: + errors.append( + 'Please make sure that the following items are \n' + \ + 'part of the STATICFILES_FINDERS tuple, create this tuple, if it is missing:\n' + + ' "' + '",\n "'.join(missing_finders) + '",\n' + ) + print_errors(errors) if django_settings.STATICFILES_STORAGE == \ 'django.contrib.staticfiles.storage.StaticFilesStorage': @@ -840,27 +907,32 @@ def run_startup_tests(): """function that runs all startup tests, mainly checking settings config so far """ + #this is first because it gives good info on what to install + test_modules() #todo: refactor this when another test arrives - test_template_loader() - test_encoding() - test_modules() test_askbot_url() + test_avatar() + test_cache_backend() + test_celery() + test_compressor() + test_custom_user_profile_tab() + test_encoding() + test_group_messaging() + test_haystack() + test_jinja2() + test_longerusername() + test_new_skins() + test_media_url() #test_postgres() test_middleware() - test_celery() + test_multilingual() #test_csrf_cookie_domain() + test_secret_key() + test_staticfiles() + test_template_loader() test_template_context_processors() test_tinymce() - test_staticfiles() - test_new_skins() - test_longerusername() - test_avatar() - test_group_messaging() - test_multilingual() - test_haystack() - test_cache_backend() - test_secret_key() settings_tester = SettingsTester({ 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY': { 'value': True, @@ -897,10 +969,8 @@ def run_startup_tests(): } }) settings_tester.run() - test_media_url() if 'manage.py test' in ' '.join(sys.argv): test_settings_for_test_runner() - test_custom_user_profile_tab() @transaction.commit_manually def run(): diff --git a/askbot/templates/meta/html_head_stylesheets.html b/askbot/templates/meta/html_head_stylesheets.html index 2a2fb159..b99eeabd 100644 --- a/askbot/templates/meta/html_head_stylesheets.html +++ b/askbot/templates/meta/html_head_stylesheets.html @@ -2,7 +2,7 @@ {% endif %} {% if settings.ASKBOT_CSS_DEVEL == False %} - + {{ skin.get_extra_css_link() }} {% else %} -- cgit v1.2.3-1-g7c22