From 61c2574615e775a6d609446600eac66b1bab1b46 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Fri, 27 Aug 2010 18:30:04 -0400 Subject: added simple mathjax support --- .gitignore | 1 + askbot/conf/__init__.py | 1 + askbot/conf/optional_components.py | 54 ++++++++++++++++++++++++ askbot/const/__init__.py | 4 ++ askbot/deps/django_authopenid/views.py | 2 + askbot/skins/default/templates/base.html | 15 +++++-- askbot/skins/default/templates/base_content.html | 9 ++++ askbot/views/readers.py | 1 - 8 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 askbot/conf/optional_components.py diff --git a/.gitignore b/.gitignore index 351d1e74..37be4274 100755 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ dist build askbot/upfiles/*.jpg askbot/upfiles/*.gif +askbot/skins/common/media/mathjax/ diff --git a/askbot/conf/__init__.py b/askbot/conf/__init__.py index de52c601..3798fd3d 100644 --- a/askbot/conf/__init__.py +++ b/askbot/conf/__init__.py @@ -10,6 +10,7 @@ import askbot.conf.external_keys import askbot.conf.skin_counter_settings import askbot.conf.skin_general_settings import askbot.conf.user_settings +import askbot.conf.optional_components #import main settings object from askbot.conf.settings_wrapper import settings diff --git a/askbot/conf/optional_components.py b/askbot/conf/optional_components.py new file mode 100644 index 00000000..d029fdc6 --- /dev/null +++ b/askbot/conf/optional_components.py @@ -0,0 +1,54 @@ +""" +External service key settings +""" +from askbot.conf.settings_wrapper import settings +from askbot.deps.livesettings import ConfigurationGroup +from askbot.deps.livesettings import BooleanValue, StringValue +from django.utils.translation import ugettext as _ +import askbot +from askbot import const +import os + +OPTIONAL_COMPONENTS = ConfigurationGroup( + 'OPTIONAL_COMPONENTS', + _('Optional components') + ) + +mathjax_dir = os.path.join( + askbot.get_install_directory(), + 'skins', + 'common', + 'media' + ) + +settings.register( + BooleanValue( + OPTIONAL_COMPONENTS, + 'ENABLE_MATHJAX', + description=_('Mathjax support (rendering of LaTeX)'), + help_text=_( + 'If you enable this feature, ' + 'mathjax must be ' + 'installed in directory %(dir)s' + ) % { + 'url': const.DEPENDENCY_URLS['mathjax'], + 'dir': mathjax_dir, + }, + default = False + ) +) + +settings.register( + StringValue( + OPTIONAL_COMPONENTS, + 'MATHJAX_BASE_URL', + description=_('Base url of MathJax deployment'), + help_text=_( + 'Note - MathJax is not included with ' + 'askbot - you should deploy it yourself ' + 'and enter url pointing to the "mathjax" directory ' + '(for example: http://mysite.com/mathjax' + ), + default = '' + ) +) diff --git a/askbot/const/__init__.py b/askbot/const/__init__.py index 98852b9c..8742cf56 100644 --- a/askbot/const/__init__.py +++ b/askbot/const/__init__.py @@ -224,5 +224,9 @@ DEFAULT_USER_STATUS = 'w' #number of items to show in user views USER_VIEW_DATA_SIZE = 50 +DEPENDENCY_URLS = { + 'mathjax': 'http://www.mathjax.org/resources/docs/?installation.html', +} + #an exception import * because that file has only strings from askbot.const.message_keys import * diff --git a/askbot/deps/django_authopenid/views.py b/askbot/deps/django_authopenid/views.py index 2666d6c5..e063a35e 100644 --- a/askbot/deps/django_authopenid/views.py +++ b/askbot/deps/django_authopenid/views.py @@ -748,6 +748,8 @@ def signout(request): pass logout(request) logging.debug('user logged out') + response = HttpResponseRedirect(get_next_url(request)) + #todo: here some extra cookies may be deleted return HttpResponseRedirect(get_next_url(request)) def xrdf(request): diff --git a/askbot/skins/default/templates/base.html b/askbot/skins/default/templates/base.html index 4a36ad25..b902b752 100644 --- a/askbot/skins/default/templates/base.html +++ b/askbot/skins/default/templates/base.html @@ -27,9 +27,18 @@ var scriptUrl = '/{{settings.ASKBOT_URL}}' var askbotSkin = '{{settings.ASKBOT_DEFAULT_SKIN}}'; - - - + + + + {% if settings.ENABLE_MATHJAX %} + + {% endif %} {% if user_messages %}