summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/__init__.py1
-rw-r--r--askbot/doc/source/changelog.rst1
-rw-r--r--askbot/doc/source/contributors.rst1
-rw-r--r--askbot/media/js/post.js4
-rw-r--r--askbot/media/js/utils.js13
-rw-r--r--askbot/media/js/wmd/showdown.js2
-rw-r--r--askbot/setup_templates/settings.py15
-rw-r--r--askbot/skins/loaders.py15
-rw-r--r--askbot/startup_procedures.py109
-rw-r--r--askbot/templates/base.html5
-rw-r--r--askbot/templates/main_page/javascript.html9
-rw-r--r--askbot/templates/meta/bottom_scripts.html75
-rw-r--r--askbot/templates/meta/editor_data.html14
-rw-r--r--askbot/templates/meta/html_head_javascript.html20
-rw-r--r--askbot/templates/meta/html_head_stylesheets.html23
-rw-r--r--askbot/templates/question.html37
-rw-r--r--askbot/templates/question/javascript.html69
-rw-r--r--askbot/templatetags/extra_filters_jinja.py6
-rw-r--r--askbot_requirements_dev.txt2
19 files changed, 278 insertions, 143 deletions
diff --git a/askbot/__init__.py b/askbot/__init__.py
index 59c4ab5e..25057b43 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/changelog.rst b/askbot/doc/source/changelog.rst
index eea65ede..24b72181 100644
--- a/askbot/doc/source/changelog.rst
+++ b/askbot/doc/source/changelog.rst
@@ -3,6 +3,7 @@ Changes in Askbot
Development version
-------------------
+* Some support for the media compression (Tyler Mandry)
* Allowed to enable and disable question scopes on the main page
* Added full text support for some languages with Postgresql:
Danish, Dutch, English, Finnish, French, German, Hungarian,
diff --git a/askbot/doc/source/contributors.rst b/askbot/doc/source/contributors.rst
index bd637270..3fa086df 100644
--- a/askbot/doc/source/contributors.rst
+++ b/askbot/doc/source/contributors.rst
@@ -43,6 +43,7 @@ Programming, bug fixes and documentation
* `Paul Backhouse <https://github.com/powlo>`_
* `jtrain <https://github.com/jtrain>`_
* Niki Rocco
+* `Tyler Mandry <https://github.com/tmandry>`_
* `Jorge López Pérez <https://github.com/adobo>`_
Translations
diff --git a/askbot/media/js/post.js b/askbot/media/js/post.js
index fb9f991d..5b9bf4ee 100644
--- a/askbot/media/js/post.js
+++ b/askbot/media/js/post.js
@@ -1006,7 +1006,7 @@ var Vote = function(){
questionId = qId;
questionSlug = qSlug;
questionAuthorId = questionAuthor;
- currentUserId = userId;
+ currentUserId = '' + userId;//convert to string
bindEvents();
},
@@ -1840,7 +1840,7 @@ Comment.prototype.getElement = function(){
Comment.superClass_.getElement.call(this);
if (this.isBlank() && this.hasContent()){
this.setContent();
- if (enableMathJax === true){
+ if (askbot['settings']['mathjaxEnabled'] === true){
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
}
}
diff --git a/askbot/media/js/utils.js b/askbot/media/js/utils.js
index 304caa8b..21fb9467 100644
--- a/askbot/media/js/utils.js
+++ b/askbot/media/js/utils.js
@@ -1,4 +1,3 @@
-//var $, scriptUrl, askbotSkin
/**
* attention - this function needs to be retired
* as it cannot accurately give url to the media file
@@ -65,6 +64,18 @@ var joinAsPhrase = function(values) {
}
};
+/**
+ * @return {boolean}
+ */
+var inArray = function(item, itemsList) {
+ for (var i = 0; i < itemsList.length; i++) {
+ if (item === itemsList[i]) {
+ return true;
+ }
+ }
+ return false;
+};
+
var showMessage = function(element, msg, where) {
var div = $('<div class="vote-notification"><h3>' + msg + '</h3>(' +
gettext('click to close') + ')</div>');
diff --git a/askbot/media/js/wmd/showdown.js b/askbot/media/js/wmd/showdown.js
index 257b8bd1..25872e48 100644
--- a/askbot/media/js/wmd/showdown.js
+++ b/askbot/media/js/wmd/showdown.js
@@ -155,7 +155,7 @@ var makeHtmlBase = function(text) {
}
this.makeHtml = function(text){
- if (enableMathJax === false){
+ if (askbot['settings']['mathjaxEnabled'] === false){
return makeHtmlBase(text);
}
else {
diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py
index 54c45434..3b41dfbd 100644
--- a/askbot/setup_templates/settings.py
+++ b/askbot/setup_templates/settings.py
@@ -116,6 +116,14 @@ MIDDLEWARE_CLASSES = (
'askbot.middleware.spaceless.SpacelessMiddleware',
)
+JINJA2_EXTENSIONS = (
+ 'compressor.contrib.jinja2ext.CompressorExtension',
+)
+
+COMPRESS_PRECOMPILERS = (
+ ('text/less', 'lessc {infile} {outfile}'),
+)
+
ROOT_URLCONF = os.path.basename(os.path.dirname(__file__)) + '.urls'
@@ -177,6 +185,8 @@ INSTALLED_APPS = (
'followit',
'tinymce',
#'avatar',#experimental use git clone git://github.com/ericflo/django-avatar.git$
+
+ 'compressor',
)
@@ -235,6 +245,11 @@ CSRF_COOKIE_NAME = 'askbot_csrf'
STATICFILES_DIRS = (
('default/media', os.path.join(ASKBOT_ROOT, 'media')),
)
+STATICFILES_FINDERS = (
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+ 'compressor.finders.CompressorFinder',
+)
RECAPTCHA_USE_SSL = True
diff --git a/askbot/skins/loaders.py b/askbot/skins/loaders.py
index c7854a1d..88dc2ef0 100644
--- a/askbot/skins/loaders.py
+++ b/askbot/skins/loaders.py
@@ -60,9 +60,20 @@ class SkinEnvironment(CoffinEnvironment):
or empty string - depending on the existence of file
SKIN_PATH/media/style/extra.css
"""
- url = utils.get_media_url('style/extra.css', ignore_missing = True)
+ url = None
+
+ if django_settings.ASKBOT_CSS_DEVEL is 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.css', ignore_missing=True)
+ rel = "stylesheet"
+
if url is not None:
- return '<link href="%s" rel="stylesheet" type="text/css" />' % url
+ return '<link href="%s" rel="%s" type="text/less" />' % (url, rel)
+
return ''
def load_skins():
diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py
index d728eb3f..7d2e0216 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,40 @@ 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
+ )
+
+ js_filters = getattr(django_settings, 'COMPRESS_JS_FILTERS', [])
+ if len(js_filters) > 0:
+ errors.append(
+ 'Askbot does not yet support js minification, please add to your settings.py:\n'
+ 'COMPRESS_JS_FILTERS = []'
+ )
+
+ 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 +526,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':
@@ -833,28 +907,33 @@ 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_messages_framework()
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_messages_framework()
- test_haystack()
- test_cache_backend()
- test_secret_key()
settings_tester = SettingsTester({
'CACHE_MIDDLEWARE_ANONYMOUS_ONLY': {
'value': True,
@@ -891,10 +970,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/base.html b/askbot/templates/base.html
index 6c162057..80230b26 100644
--- a/askbot/templates/base.html
+++ b/askbot/templates/base.html
@@ -1,3 +1,4 @@
+{% load compress %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@@ -12,7 +13,7 @@
{% endif %}
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="shortcut icon" href="{{ settings.SITE_FAVICON|media }}" />
- <link
+ <link
rel="alternate"
type="application/rss+xml"
title="{% trans site_title=settings.APP_SHORT_NAME %}RSS feed from {{ site_title }}{% endtrans %}"
@@ -20,7 +21,7 @@
/>
{% block before_css %}{% endblock %}
{% include "meta/html_head_stylesheets.html" %}
- {% include "meta/fonts.html" %}
+ {% include "meta/fonts.html" %} {# may contain external files #}
{% block forestyle %}{% endblock %}
{% include "meta/html_head_javascript.html" %}
{% block forejs %}{% endblock %}
diff --git a/askbot/templates/main_page/javascript.html b/askbot/templates/main_page/javascript.html
index 55b31d00..dc6bdc94 100644
--- a/askbot/templates/main_page/javascript.html
+++ b/askbot/templates/main_page/javascript.html
@@ -1,6 +1,10 @@
<script type="text/javascript">
+ {# cant cache this #}
+ askbot['settings']['showSortByRelevance'] = {{ show_sort_by_relevance|as_js_bool }};
+</script>
+{% compress js %}
+<script type="text/javascript">
/*<![CDATA[*/
- askbot['settings']['showSortByRelevance'] = {% if show_sort_by_relevance %}true{% else %}false{% endif %};
$(document).ready(function(){
/*var on_tab = '#nav_questions';
$(on_tab).attr('className','on');*/
@@ -40,6 +44,5 @@
/*]]>*/
</script>
<script type='text/javascript' src='{{"/js/editor.js"|media}}'></script>
-{% if request.user.is_authenticated() %}
<script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
-{% endif %}
+{% endcompress %}
diff --git a/askbot/templates/meta/bottom_scripts.html b/askbot/templates/meta/bottom_scripts.html
index 1a910672..805974cc 100644
--- a/askbot/templates/meta/bottom_scripts.html
+++ b/askbot/templates/meta/bottom_scripts.html
@@ -13,11 +13,8 @@
noscript.style.backgroundColor = 'transparent';
</script>
</div>
+{# this section cannot be compressed because lots of data is runtime #}
<script type="text/javascript">
- var i18nLang = '{{ language_code }}';
- var scriptUrl = '/{{settings.ASKBOT_URL}}'
- var askbotSkin = '{{settings.ASKBOT_DEFAULT_SKIN}}';
- var enableMathJax = {% if settings.ENABLE_MATHJAX %}true{% else %}false{% endif %};
askbot['urls']['mark_read_message'] = '{% url "read_message" %}';
askbot['urls']['get_tags_by_wildcard'] = '{% url "get_tags_by_wildcard" %}';
askbot['urls']['get_tag_list'] = '{% url "get_tag_list" %}';
@@ -28,24 +25,29 @@
askbot['urls']['titleSearch'] = '{% url "title_search" %}';
askbot['urls']['ask'] = '{% url "ask" %}';
askbot['urls']['questions'] = '{% url "questions" %}';
+ askbot['settings']['groupsEnabled'] = {{ settings.GROUPS_ENABLED|as_js_bool }};
askbot['settings']['static_url'] = '{{ settings.STATIC_URL }}';
askbot['settings']['minSearchWordLength'] = {{ settings.MIN_SEARCH_WORD_LENGTH }};
+ askbot['settings']['mathjaxEnabled'] = {{ settings.ENABLE_MATHJAX|as_js_bool }};
askbot['settings']['sharingSuffixText'] = '{{ settings.SHARING_SUFFIX_TEXT|escape }}';
-</script>
-<script
- type="text/javascript"
- {% if settings.DEBUG %}
- src="{{"/js/jquery-1.7.2.min.js"|media}}"
+ askbot['data']['haveFlashNotifications'] = {{ user_messages|as_js_bool }};
+ askbot['data']['activeTab'] = '{{ active_tab }}';
+ {% if search_state %}
+ askbot['data']['searchUrl'] = '{{ search_state.query_string()|escapejs }}';
{% else %}
- src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
+ askbot['data']['searchUrl'] = '';
{% endif %}
-></script>
+</script>
+{# everything below until the custom js and google analytics is compressable #}
+{% compress js %}
+<script type="text/javascript" src="{{"/js/jquery-1.7.2.min.js"|media}}"></script>
<script type="text/javascript" src='{{"/bootstrap/js/bootstrap.js"|media}}'></script>
<!-- History.js -->
<script type='text/javascript' src="{{"/js/jquery.history.js"|media }}"></script>
<script type='text/javascript' src="{{"/js/utils.js"|media }}"></script>
<script type="text/javascript" src="{{'/js/live_search.js'|media}}"></script>
{% if settings.ENABLE_MATHJAX %}
+ {# we don't want to load mathjax just in case, only if it is really enabled #}
<script type='text/javascript' src="{{settings.MATHJAX_BASE_URL}}/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
@@ -58,59 +60,56 @@
/*<![CDATA[*/
$(document).ready(function(){
// focus input on the search bar endcomment
- {% if active_tab in ('users', 'questions', 'tags', 'badges') %}
+ var activeTab = askbot['data']['activeTab'];
+ if (inArray(activeTab, ['users', 'questions', 'tags', 'badges'])) {
var searchInput = $('#keywords');
- {% elif active_tab == 'ask' %}
+ } else if (activeTab === 'ask') {
var searchInput = $('#id_title');
- {% else %}
+ } else {
var searchInput = undefined;
animateHashes();
- {% endif %}
+ }
if (searchInput) {
searchInput.focus();
putCursorAtEnd(searchInput);
}
- {% if active_tab in ('questions', 'badges', 'ask') %}
- if (searchInput) {
+ if (inArray(activeTab, ['questions', 'badges', 'ask']) && searchInput.length) {
var search = new FullTextSearch();
askbot['controllers'] = askbot['controllers'] || {};
askbot['controllers']['fullTextSearch'] = search;
- {% if search_state %}
- search.setSearchUrl('{{ search_state.query_string()|escapejs }}');
- {% else %}
- search.setSearchUrl('');
- {% endif %}
- {% if active_tab == 'ask' %}
+ search.setSearchUrl(askbot['data']['searchUrl']);
+ if (activeTab === 'ask') {
search.setAskButtonEnabled(false);
- {% endif %}
+ }
search.decorate(searchInput);
}
- {% endif %}
if (askbot['data']['userIsAdminOrMod']) {
$('body').addClass('admin');
}
- {%if settings.GROUPS_ENABLED %}
- askbot['urls']['add_group'] = "{% url add_group %}";
- var group_dropdown = new GroupDropdown({{group_list}});
- $('.dropdown').append(group_dropdown.getElement());
- {%if request.user.is_superuser%}
- group_dropdown.enableAddGroups();
- {%endif%}
- {% endif %}
+ if (askbot['settings']['groupsEnabled']) {
+ askbot['urls']['add_group'] = "{% url add_group %}";
+ var group_dropdown = new GroupDropdown({{ group_list }});
+ $('.dropdown').append(group_dropdown.getElement());
+ if (askbot['data']['userIsAdmin']) {
+ group_dropdown.enableAddGroups();
+ }
+ }
});
-{% if user_messages %}
- $('#validate_email_alert').click(function(){notify.close(true)})
- notify.show();
-{% endif %}
+ if (askbot['data']['haveFlashNotifications']) {
+ $('#validate_email_alert').click(function(){notify.close(true)})
+ notify.show();
+ }
$('abbr.timeago').timeago();
/*]]>*/
</script>
+{% endcompress %}
+{# stuff below should not be compressed #}
{% if settings.USE_CUSTOM_JS %}
<script
- src="{% url "custom_js"%}?v={{ settings.MEDIA_RESOURCE_REVISION }}"
+ src="{% url "custom_js" %}?v={{ settings.MEDIA_RESOURCE_REVISION }}"
type="text/javascript"
></script>
{% endif %}
diff --git a/askbot/templates/meta/editor_data.html b/askbot/templates/meta/editor_data.html
index f0402672..d7328b7d 100644
--- a/askbot/templates/meta/editor_data.html
+++ b/askbot/templates/meta/editor_data.html
@@ -1,16 +1,14 @@
<script type="text/javascript">
{# data necessary for the post editor, goes into endjs block #}
- askbot['settings']['tagsAreRequired'] =
- {% if settings.TAGS_ARE_REQUIRED %}true{% else %}false{% endif %};
- askbot['settings']['maxTagLength'] = {{settings.MAX_TAG_LENGTH}};
- "each tag must be shorter than %(max_chars)d characters",
+ askbot['settings']['tagsAreRequired'] = {{ settings.TAGS_ARE_REQUIRED|as_js_bool }}
+ askbot['settings']['maxTagLength'] = {{ settings.MAX_TAG_LENGTH }};
askbot['messages']['maxTagLength'] = "{% trans max_chars = settings.MAX_TAG_LENGTH %}each tag must be shorter that {{max_chars}} character{% pluralize %}each tag must be shorter than {{max_chars}} characters{% endtrans %}";
- askbot['settings']['maxTagsPerPost'] = {{settings.MAX_TAGS_PER_POST}};
+ askbot['settings']['maxTagsPerPost'] = {{ settings.MAX_TAGS_PER_POST }};
askbot['messages']['maxTagsPerPost'] = "{% trans tag_count = settings.MAX_TAGS_PER_POST %}please use {{tag_count}} tag{% pluralize %}please use {{tag_count}} tags or less{% endtrans %}";
askbot['messages']['tagLimits'] = "{% trans tag_count=settings.MAX_TAGS_PER_POST, max_chars=settings.MAX_TAG_LENGTH %}please use up to {{tag_count}} tags, less than {{max_chars}} characters each{% endtrans %}";
askbot['urls']['upload'] = '{% url "upload" %}';
- askbot['settings']['minTitleLength'] = {{settings.MIN_TITLE_LENGTH}};
- askbot['settings']['minQuestionBodyLength'] = {{settings.MIN_QUESTION_BODY_LENGTH}};
- askbot['settings']['minAnswerBodyLength'] = {{settings.MIN_ANSWER_BODY_LENGTH}};
+ askbot['settings']['minTitleLength'] = {{ settings.MIN_TITLE_LENGTH }};
+ askbot['settings']['minQuestionBodyLength'] = {{ settings.MIN_QUESTION_BODY_LENGTH }};
+ askbot['settings']['minAnswerBodyLength'] = {{ settings.MIN_ANSWER_BODY_LENGTH }};
askbot['settings']['tag_editor'] = '{{ tag_editor_settings|escapejs }}';
</script>
diff --git a/askbot/templates/meta/html_head_javascript.html b/askbot/templates/meta/html_head_javascript.html
index 306f325a..67f0ec88 100644
--- a/askbot/templates/meta/html_head_javascript.html
+++ b/askbot/templates/meta/html_head_javascript.html
@@ -1,25 +1,18 @@
<script type="text/javascript" src="{{"/js/modernizr.custom.js"|media }}"></script>
-<script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></script>
<script type="text/javascript">
var askbot = {};
askbot['data'] = {};
+ askbot['data']['userIsAuthenticated'] = {{ request.user.is_authenticated()|as_js_bool }};
{% if request.user.is_authenticated() %}
- askbot['data']['userIsAuthenticated'] = true;
- askbot['data']['userId'] = {{request.user.id}};
+ askbot['data']['userId'] = {{ request.user.id }};
askbot['data']['userName'] = '{{ request.user.username }}';
- askbot['data']['userIsAdminOrMod'] = {% if
- request.user.is_administrator()
- or request.user.is_moderator()
- %}true{% else %}false{% endif %};
- askbot['data']['userIsAdmin'] = {% if
- request.user.is_administrator()
- %}true{% else %}false{% endif %};
- askbot['data']['userReputation'] = {{request.user.reputation}};
+ askbot['data']['userIsAdminOrMod'] = {{ request.user.is_administrator()|as_js_bool }};
+ askbot['data']['userIsAdmin'] = {{ request.user.is_administrator()|as_js_bool }};
+ askbot['data']['userReputation'] = {{ request.user.reputation }};
{% else %}
- askbot['data']['userIsAuthenticated'] = false;
askbot['data']['userReputation'] = 0;
{% endif %}
- askbot['data']['maxCommentLength'] = {{settings.MAX_COMMENT_LENGTH}};
+ askbot['data']['maxCommentLength'] = {{ settings.MAX_COMMENT_LENGTH }};
askbot['urls'] = {};
askbot['settings'] = {};
askbot['settings']['editorType'] = '{{ settings.EDITOR_TYPE }}';
@@ -32,4 +25,5 @@
{% endif %}
askbot['messages'] = {};
</script>
+<script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></script>
{# avoid adding javascript here so that pages load faster #}
diff --git a/askbot/templates/meta/html_head_stylesheets.html b/askbot/templates/meta/html_head_stylesheets.html
index 23750239..20551315 100644
--- a/askbot/templates/meta/html_head_stylesheets.html
+++ b/askbot/templates/meta/html_head_stylesheets.html
@@ -1,17 +1,18 @@
-{%if settings.GROUPS_ENABLED%}
-<link href="{{'/bootstrap/css/bootstrap.css'|media}}" rel="stylesheet" type="text/css" />
-{% endif %}
-{% if settings.ASKBOT_CSS_DEVEL == False %}
-
-<link href="{{"/style/style.css"|media }}" rel="stylesheet" type="text/css" />
+{% if settings.ASKBOT_CSS_DEVEL %}
+ <link href="{{"/style/style.less"|media }}" rel="stylesheet/less" type="text/css" />
+ {{ skin.get_extra_css_link() }}
+ <script type="text/javascript" src="{{"/js/less.min.js"|media}}"></script>
+ <link href="{{'/bootstrap/css/bootstrap.css'|media}}" rel="stylesheet" type="text/css" />
{% else %}
-<link href="{{"/style/style.less"|media }}" rel="stylesheet/less" type="text/css" />
-<script type="text/javascript" src="{{"/js/less.min.js"|media}}"></script>
+ {% compress css %}
+ <link href="{{"/style/style.css"|media }}" rel="stylesheet" type="text/less" />
+ {{ skin.get_extra_css_link() }}
+ <link href="{{'/bootstrap/css/bootstrap.css'|media}}" rel="stylesheet" type="text/css" />
+ {% endcompress %}
{% endif %}
-<link href="{{'/bootstrap/css/bootstrap.css'|media}}" rel="stylesheet" type="text/css" />
-{{ skin.get_extra_css_link() }}
{% if settings.USE_CUSTOM_CSS %}
- <link
+ {# can't compress yet because this comes from live settings #}
+ <link
href="{% url "custom_css" %}?v={{settings.MEDIA_RESOURCE_REVISION}}"
rel="stylesheet"
type="text/css"
diff --git a/askbot/templates/question.html b/askbot/templates/question.html
index 429cf38d..482f5e72 100644
--- a/askbot/templates/question.html
+++ b/askbot/templates/question.html
@@ -8,7 +8,6 @@
{% block forestyle %}
<link rel="canonical" href="{{settings.APP_URL|strip_path}}{{question.get_absolute_url()}}" />
<link rel="stylesheet" type="text/css" href="{{'/js/wmd/wmd.css'|media}}" />
- <link href="{{'/bootstrap/css/bootstrap.css'|media}}" rel="stylesheet" type="text/css" />
{% endblock %}
{% block forejs %}
<script type="text/javascript">
@@ -281,10 +280,46 @@
{% include "question/sidebar.html" %}
{% endblock %}
{% block endjs %}
+ <script type='text/javascript'>
+ {# not compressable #}
+ {% if settings.ENABLE_MATHJAX or settings.MARKUP_CODE_FRIENDLY %}
+ var codeFriendlyMarkdown = true;
+ {% else %}
+ var codeFriendlyMarkdown = false;
+ {% endif %}
+ var maxCommentLength = {{settings.MAX_COMMENT_LENGTH}};
+ askbot['urls']['postComments'] = '{% url post_comments %}';
+ askbot['urls']['editComment'] = '{% url edit_comment %}';
+ askbot['urls']['deleteComment'] = '{% url delete_comment %}';
+ askbot['urls']['convertComment'] = '{% url comment_to_answer %}';
+ askbot['urls']['getComment'] = '{% url get_comment %}';
+ askbot['urls']['saveDraftAnswer'] = '{% url save_draft_answer %}';
+ askbot['urls']['vote_url'] = '{% url vote question.id %}';
+ askbot['urls']['user_signin'] = '{{ settings.LOGIN_URL }}';
+ askbot['urls']['swap_question_with_answer'] = '{% url swap_question_with_answer %}';
+ askbot['urls']['upvote_comment'] = '{% url upvote_comment %}';
+ askbot['urls']['delete_post'] = '{% url delete_post %}';
+ askbot['urls']['get_html_template'] = '{% url get_html_template %}';
+ askbot['urls']['getGroupsList'] = '{% url get_groups_list %}';
+ askbot['urls']['publishAnswer'] = '{% url publish_answer %}';
+ askbot['data']['userIsThreadModerator'] = {{ user_is_thread_moderator|as_js_bool }};
+ askbot['data']['questionAuthorId'] = {{ question.author_id }};
+ askbot['data']['threadIsClosed'] = {{ thread.closed|as_js_bool }};
+ askbot['data']['answersSortTab'] = '{{ tab_id }}';
+ askbot['data']['questionId'] = {{ question.id }};
+ askbot['data']['threadSlug'] = '{{ thread.title|slugify }}';
+ askbot['messages']['addComment'] = '{% trans %}post a comment{% endtrans %}';
+ askbot['settings']['saveCommentOnEnter'] = {{ settings.SAVE_COMMENT_ON_ENTER|as_js_bool }};
+ askbot['settings']['tagSource'] = '{{ settings.TAG_SOURCE }}';
+ askbot['settings']['enableSharingGoogle'] = {{ settings.ENABLE_SHARING_GOOGLE|as_js_bool }};
+ </script>
+ {% include "meta/editor_data.html" %}
+ {% compress js %}
{% include "question/javascript.html" %}
{% if settings.TAG_SOURCE == 'category-tree' %}
{% include "meta/category_tree_js.html" %}
{% endif %}
+ {% endcompress %}
{#
<script type="text/javascript">
var messages = askbot['messages'];
diff --git a/askbot/templates/question/javascript.html b/askbot/templates/question/javascript.html
index edd7ead7..d32e14c5 100644
--- a/askbot/templates/question/javascript.html
+++ b/askbot/templates/question/javascript.html
@@ -1,66 +1,44 @@
<script type='text/javascript' src='{{"/js/editor.js"|media}}'></script>
-<script type='text/javascript'>
- {% if settings.ENABLE_MATHJAX or settings.MARKUP_CODE_FRIENDLY %}
- var codeFriendlyMarkdown = true;
- {% else %}
- var codeFriendlyMarkdown = false;
- {% endif %}
- var maxCommentLength = {{settings.MAX_COMMENT_LENGTH}};
- askbot['urls']['postComments'] = '{% url post_comments %}';
- askbot['urls']['editComment'] = '{% url edit_comment %}';
- askbot['urls']['deleteComment'] = '{% url delete_comment %}';
- askbot['urls']['convertComment'] = '{% url comment_to_answer %}';
- askbot['urls']['getComment'] = '{% url get_comment %}';
- askbot['urls']['saveDraftAnswer'] = '{% url save_draft_answer %}';
- askbot['urls']['vote_url'] = '{% url vote question.id %}';
- askbot['urls']['user_signin'] = '{{ settings.LOGIN_URL }}';
- askbot['urls']['swap_question_with_answer'] = '{% url swap_question_with_answer %}';
- askbot['urls']['upvote_comment'] = '{% url upvote_comment %}';
- askbot['urls']['delete_post'] = '{% url delete_post %}';
- askbot['urls']['get_html_template'] = '{% url get_html_template %}';
- askbot['urls']['getGroupsList'] = '{% url get_groups_list %}';
- askbot['urls']['publishAnswer'] = '{% url publish_answer %}';
- askbot['data']['userIsThreadModerator'] = {% if user_is_thread_moderator %}true{% else %}false{% endif %};
- askbot['messages']['addComment'] = '{% trans %}post a comment{% endtrans %}';
- {% if settings.SAVE_COMMENT_ON_ENTER %}
- askbot['settings']['saveCommentOnEnter'] = true;
- {% else %}
- askbot['settings']['saveCommentOnEnter'] = false;
- {% endif %}
- askbot['settings']['tagSource'] = '{{ settings.TAG_SOURCE }}';
-</script>
<script type="text/javascript" src='{{"/bootstrap/js/bootstrap.js"|media}}'></script>
-{% if settings.EDITOR_TYPE == 'markdown' %}
- <script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
- <script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
-{% endif %}
+<script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
+<script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/jquery.validate.min.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/post.js"|media}}'></script>
<script type="text/javascript">
// define reputation needs for comments
- var repNeededForComments = 50;
$(document).ready(function(){
$("#nav_questions").attr('className',"on");
- var answer_sort_tab = "{{ tab_id }}";
- $("#" + answer_sort_tab).attr('className',"on");
+ $("#" + askbot['data']['answersSortTab']).attr('className',"on");
- Vote.init({{ question.id }}, '{{ thread.title|slugify }}', '{{ question.author_id }}','{{ request.user.id }}');
+ Vote.init(
+ askbot['data']['questionId'],
+ askbot['data']['threadSlug'],
+ askbot['data']['questionAuthorId'],
+ askbot['data']['userId']
+ );
- {% if not thread.closed and request.user.is_authenticated %}initEditor();{% endif %}
+ if ((askbot['data']['threadIsClosed'] === false) && askbot['data']['userIsAuthenticated']) {
+ initEditor();
+ }
lanai.highlightSyntax();
- $('#btLogin').bind('click', function(){window.location.href='{{ settings.LOGIN_URL }}'; } )
+ $('#btLogin').bind('click', function(){
+ window.location.href='{{ settings.LOGIN_URL }}';
+ });
if (window.location.hash === 'fmanswer'){
$('#fmanswer textarea').focus();
}
- {% if settings.ENABLE_SHARING_GOOGLE %}$.getScript("//apis.google.com/js/plusone.js"){% endif %}
- {% if request.user.id == question.author_id %}
+ if (askbot['settings']['enableSharingGoogle']) {
+ $.getScript("//apis.google.com/js/plusone.js");
+ }
+
+ if (askbot['data']['userId'] === askbot['data']['questionAuthorId']) {
$("#fmanswer_button").click(function() {
$("#fmanswer").show();
$("#fmanswer_button").hide();
});
- {%endif%}
+ }
if (askbot['data']['userIsAuthenticated']) {
var draftHandler = new DraftAnswer();
@@ -76,7 +54,9 @@
if (id_value != ""){
var previous_color = $(id_value).css('background-color');
$(id_value).css('backgroundColor', '#FFF8C6');
- $(id_value).animate({backgroundColor: '#ff7f2a'}, 1000).animate({backgroundColor: '#FFF8C6'}, 1000, function(){
+ $(id_value).animate(
+ {backgroundColor: '#ff7f2a'}, 1000
+ ).animate({backgroundColor: '#FFF8C6'}, 1000, function(){
$(id_value).css('backgroundColor', previous_color);
});
}
@@ -105,4 +85,3 @@
);
}
</script>
-{% include "meta/editor_data.html" %}
diff --git a/askbot/templatetags/extra_filters_jinja.py b/askbot/templatetags/extra_filters_jinja.py
index 7549555a..6fd12aab 100644
--- a/askbot/templatetags/extra_filters_jinja.py
+++ b/askbot/templatetags/extra_filters_jinja.py
@@ -39,6 +39,12 @@ def add_tz_offset(datetime_object):
return str(datetime_object) + ' ' + TIMEZONE_STR
@register.filter
+def as_js_bool(some_object):
+ if bool(some_object):
+ return 'true'
+ return 'false'
+
+@register.filter
def is_current_language(lang):
return lang == django_get_language()
diff --git a/askbot_requirements_dev.txt b/askbot_requirements_dev.txt
index 1fbd064c..b88592cf 100644
--- a/askbot_requirements_dev.txt
+++ b/askbot_requirements_dev.txt
@@ -8,6 +8,8 @@ oauth2
Lamson
markdown2
html5lib==0.90
+django-appconf
+django-compressor==1.2
django-keyedcache
django-threaded-multihost
django-robots