diff options
-rw-r--r-- | askbot/__init__.py | 1 | ||||
-rw-r--r-- | askbot/forms.py | 27 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py | 27 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py.mustache | 27 | ||||
-rw-r--r-- | askbot/skins/common/templates/widgets/edit_post.html | 5 | ||||
-rw-r--r-- | askbot/skins/default/templates/meta/bottom_scripts.html | 1 | ||||
-rw-r--r-- | askbot/skins/default/templates/meta/html_head_javascript.html | 1 | ||||
-rw-r--r-- | askbot/skins/default/templates/meta/tinymce.html | 4 | ||||
-rw-r--r-- | askbot_requirements.txt | 1 |
9 files changed, 81 insertions, 13 deletions
diff --git a/askbot/__init__.py b/askbot/__init__.py index 859b2695..c51becac 100644 --- a/askbot/__init__.py +++ b/askbot/__init__.py @@ -35,6 +35,7 @@ REQUIREMENTS = { 'pystache': 'pystache==0.3.1', 'lamson': 'Lamson', 'pytz': 'pytz', + 'tinymce': 'django-tinymce', } #necessary for interoperability of django and coffin diff --git a/askbot/forms.py b/askbot/forms.py index b3ee4463..11f001e6 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -13,6 +13,7 @@ from askbot.mail import extract_first_email_address from recaptcha_works.fields import RecaptchaField from askbot.conf import settings as askbot_settings from askbot.conf import get_tag_display_filter_strategy_choices +from tinymce.widgets import TinyMCE import logging def cleanup_dict(dictionary, key, empty_value): @@ -207,7 +208,11 @@ class EditorField(forms.CharField): def __init__(self, *args, **kwargs): super(EditorField, self).__init__(*args, **kwargs) self.required = True - self.widget = forms.Textarea(attrs={'id':'editor'}) + widget_attrs = {'id': 'editor'} + if askbot_settings.EDITOR_TYPE == 'markdown': + self.widget = forms.Textarea(attrs=widget_attrs) + elif askbot_settings.EDITOR_TYPE == 'tinymce': + self.widget = TinyMCE(attrs=widget_attrs) self.label = _('content') self.help_text = u'' self.initial = '' @@ -684,9 +689,8 @@ class AskForm(PostPrivatelyForm): in the cleaned data, and will evaluate to False if the settings forbids anonymous asking """ - title = TitleField() - text = QuestionEditorField() - tags = TagNamesField() + title = TitleField() + tags = TagNamesField() wiki = WikiField() ask_anonymously = forms.BooleanField( label = _('ask anonymously'), @@ -703,6 +707,8 @@ class AskForm(PostPrivatelyForm): def __init__(self, *args, **kwargs): super(AskForm, self).__init__(*args, **kwargs) + #it's important that this field is set up dynamically + self.fields['text'] = QuestionEditorField() #hide ask_anonymously field if askbot_settings.ALLOW_ASK_ANONYMOUSLY == False: self.hide_field('ask_anonymously') @@ -798,7 +804,6 @@ class AskByEmailForm(forms.Form): return self.cleaned_data['subject'] class AnswerForm(PostPrivatelyForm): - text = AnswerEditorField() wiki = WikiField() openid = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 40, 'class':'openid-input'})) user = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) @@ -807,6 +812,8 @@ class AnswerForm(PostPrivatelyForm): def __init__(self, *args, **kwargs): super(AnswerForm, self).__init__(*args, **kwargs) self.fields['email_notify'].widget.attrs['id'] = 'question-subscribe-updates' + #it is important to add this field dynamically + self.fields['text'] = AnswerEditorField() class VoteForm(forms.Form): """form used in ajax vote view (only comment_upvote so far) @@ -854,9 +861,8 @@ class RevisionForm(forms.Form): self.fields['revision'].initial = latest_revision.revision class EditQuestionForm(PostPrivatelyForm): - title = TitleField() - text = QuestionEditorField() - tags = TagNamesField() + title = TitleField() + tags = TagNamesField() summary = SummaryField() wiki = WikiField() reveal_identity = forms.BooleanField( @@ -876,6 +882,8 @@ class EditQuestionForm(PostPrivatelyForm): self.user = kwargs['user']#preserve for superclass revision = kwargs.pop('revision') super(EditQuestionForm, self).__init__(*args, **kwargs) + #it is important to add this field dynamically + self.fields['text'] = QuestionEditorField() self.fields['title'].initial = revision.title self.fields['text'].initial = revision.text self.fields['tags'].initial = revision.tagnames @@ -971,13 +979,14 @@ class EditQuestionForm(PostPrivatelyForm): return self.cleaned_data class EditAnswerForm(PostPrivatelyForm): - text = AnswerEditorField() summary = SummaryField() wiki = WikiField() def __init__(self, answer, revision, *args, **kwargs): self.answer = answer super(EditAnswerForm, self).__init__(*args, **kwargs) + #it is important to add this field dynamically + self.fields['text'] = AnswerEditorField() self.fields['text'].initial = revision.text self.fields['wiki'].initial = answer.wiki diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index 32af9920..3e121ca6 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -229,3 +229,30 @@ CSRF_COOKIE_NAME = 'askbot_csrf' STATICFILES_DIRS = ( os.path.join(ASKBOT_ROOT, 'skins'),) RECAPTCHA_USE_SSL = True + +TINYMCE_COMPRESSOR = True +TINYMCE_SPELLCHECKER = False +TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, 'common/media/js/tinymce/') +TINYMCE_URL = STATIC_URL + 'common/media/js/tinymce/' +TINYMCE_DEFAULT_CONFIG = { + 'plugins': 'askbot_imageuploader,askbot_attachment', + 'theme': 'advanced', + 'content_css': STATIC_URL + 'default/media/style/tinymce/content.css', + 'force_br_newlines': True, + 'force_p_newlines': False, + 'forced_root_block': '', + 'mode' : 'textareas', + 'oninit': "function(){ tinyMCE.activeEditor.setContent(askbot['data']['editorContent'] || ''); }", + 'plugins': 'askbot_imageuploader,askbot_attachment', + 'theme_advanced_toolbar_location' : 'top', + 'theme_advanced_toolbar_align': 'left', + 'theme_advanced_buttons1': 'bold,italic,underline,|,bullist,numlist,|,undo,redo,|,link,unlink,askbot_imageuploader,askbot_attachment' + 'theme_advanced_buttons2': '', + 'theme_advanced_buttons3' : '', + 'theme_advanced_path': False, + 'theme_advanced_resizing': True, + 'theme_advanced_resize_horizontal': False, + 'theme_advanced_statusbar_location': 'bottom', + 'width': '723', + 'height': '250' +} diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index 3c3daaa2..820ba308 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -230,3 +230,30 @@ STATIC_ROOT = os.path.join(PROJECT_ROOT, "static") STATICFILES_DIRS = (os.path.join(ASKBOT_ROOT, 'skins'),) RECAPTCHA_USE_SSL = True + +TINYMCE_COMPRESSOR = True +TINYMCE_SPELLCHECKER = False +TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, 'common/media/js/tinymce/') +TINYMCE_URL = STATIC_URL + 'common/media/js/tinymce/' +TINYMCE_DEFAULT_CONFIG = { + 'plugins': 'askbot_imageuploader,askbot_attachment', + 'theme': 'advanced', + 'content_css': STATIC_URL + 'default/media/style/tinymce/content.css', + 'force_br_newlines': True, + 'force_p_newlines': False, + 'forced_root_block': '', + 'mode' : 'textareas', + 'oninit': "function(){ tinyMCE.activeEditor.setContent(askbot['data']['editorContent'] || ''); }", + 'plugins': 'askbot_imageuploader,askbot_attachment', + 'theme_advanced_toolbar_location' : 'top', + 'theme_advanced_toolbar_align': 'left', + 'theme_advanced_buttons1': 'bold,italic,underline,|,bullist,numlist,|,undo,redo,|,link,unlink,askbot_imageuploader,askbot_attachment' + 'theme_advanced_buttons2': '', + 'theme_advanced_buttons3' : '', + 'theme_advanced_path': False, + 'theme_advanced_resizing': True, + 'theme_advanced_resize_horizontal': False, + 'theme_advanced_statusbar_location': 'bottom', + 'width': '723', + 'height': '250' +} diff --git a/askbot/skins/common/templates/widgets/edit_post.html b/askbot/skins/common/templates/widgets/edit_post.html index 12e1d25f..a8cbbd00 100644 --- a/askbot/skins/common/templates/widgets/edit_post.html +++ b/askbot/skins/common/templates/widgets/edit_post.html @@ -13,7 +13,10 @@ {{ post_form.text }}{# this element is resizable and will be wrapped by js #} </div> {% else %} - <div class="wmd-container"><textarea name="text"></textarea></div> + <div class="wmd-container"> + {{ post_form.media }} + {{ post_form.text }} + </div> <script type="text/javascript"> {% if post_html %} askbot['data']['editorContent'] = '{{ post_html|escapejs }}'; diff --git a/askbot/skins/default/templates/meta/bottom_scripts.html b/askbot/skins/default/templates/meta/bottom_scripts.html index 40ccb15b..b7113e85 100644 --- a/askbot/skins/default/templates/meta/bottom_scripts.html +++ b/askbot/skins/default/templates/meta/bottom_scripts.html @@ -31,7 +31,6 @@ <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="{% url django.views.i18n.javascript_catalog %}"></script> <script type='text/javascript' src="{{"/js/utils.js"|media }}"></script> {% if settings.ENABLE_MATHJAX %} <script type='text/javascript' src="{{settings.MATHJAX_BASE_URL}}/MathJax.js"> diff --git a/askbot/skins/default/templates/meta/html_head_javascript.html b/askbot/skins/default/templates/meta/html_head_javascript.html index de0aee90..6f022a52 100644 --- a/askbot/skins/default/templates/meta/html_head_javascript.html +++ b/askbot/skins/default/templates/meta/html_head_javascript.html @@ -1,4 +1,5 @@ <script 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'] = {}; diff --git a/askbot/skins/default/templates/meta/tinymce.html b/askbot/skins/default/templates/meta/tinymce.html index ba14642a..1d800dcb 100644 --- a/askbot/skins/default/templates/meta/tinymce.html +++ b/askbot/skins/default/templates/meta/tinymce.html @@ -1,4 +1,4 @@ -<script type="text/javascript" src="{{ 'js/tinymce/tiny_mce.js'|media }}" ></script> +<!--script type="text/javascript" src="{{ 'js/tinymce/tiny_mce.js'|media }}" ></script> <script type="text/javascript" > tinyMCE.init({ content_css: '{{ "style/tinymce/content.css"|media }}', @@ -26,7 +26,7 @@ //theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px", //font_size_style_values : "10px,12px,13px,14px,16px,18px,20px", }); -</script> +</script--> <style type="text/css"> .defaultSkin table.mceLayout, .defaultSkin table.mceLayout tr.mceFirst td { diff --git a/askbot_requirements.txt b/askbot_requirements.txt index 7b619c36..1e851490 100644 --- a/askbot_requirements.txt +++ b/askbot_requirements.txt @@ -19,3 +19,4 @@ django-recaptcha-works python-openid pystache==0.3.1 pytz +django-tinymce |