# HG changeset patch # User Brian Neal # Date 1258333228 0 # Node ID 2d299909e074aa2553b827a6d96b1e7f198ec65f # Parent b0d62247c3e4e1576845af68bb46add48644e333 Adding markdown help to comments and forums. Still need to add it to a few other places that use the markItUp editor. diff -r b0d62247c3e4 -r 2d299909e074 gpp/comments/forms.py --- a/gpp/comments/forms.py Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/comments/forms.py Mon Nov 16 01:00:28 2009 +0000 @@ -66,7 +66,9 @@ class Media: css = { - 'all': settings.GPP_THIRD_PARTY_CSS['markitup'], + 'all': (settings.GPP_THIRD_PARTY_CSS['markitup'] + + settings.GPP_THIRD_PARTY_CSS['jquery-ui']), } - js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ - ('js/comments.js', ) + js = (settings.GPP_THIRD_PARTY_JS['markitup'] + + settings.GPP_THIRD_PARTY_JS['jquery-ui'] + + ('js/comments.js', )) diff -r b0d62247c3e4 -r 2d299909e074 gpp/core/templatetags/script_tags.py --- a/gpp/core/templatetags/script_tags.py Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/core/templatetags/script_tags.py Mon Nov 16 01:00:28 2009 +0000 @@ -7,21 +7,22 @@ register = template.Library() @register.simple_tag -def script_tags(library): +def script_tags(libraries): s = '' - if library in settings.GPP_THIRD_PARTY_CSS: - for path in settings.GPP_THIRD_PARTY_CSS[library]: - prefix = '' - if not path.startswith('http'): - prefix = settings.MEDIA_URL - s += '' % (prefix, path) + for library in libraries.split(): + if library in settings.GPP_THIRD_PARTY_CSS: + for path in settings.GPP_THIRD_PARTY_CSS[library]: + prefix = '' + if not path.startswith('http'): + prefix = settings.MEDIA_URL + s += '' % (prefix, path) - if library in settings.GPP_THIRD_PARTY_JS: - for path in settings.GPP_THIRD_PARTY_JS[library]: - prefix = '' - if not path.startswith('http'): - prefix = settings.MEDIA_URL - s += '' % (prefix, path) + if library in settings.GPP_THIRD_PARTY_JS: + for path in settings.GPP_THIRD_PARTY_JS[library]: + prefix = '' + if not path.startswith('http'): + prefix = settings.MEDIA_URL + s += '' % (prefix, path) return s diff -r b0d62247c3e4 -r 2d299909e074 gpp/core/views.py --- a/gpp/core/views.py Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/core/views.py Mon Nov 16 01:00:28 2009 +0000 @@ -1,1 +1,17 @@ -# Create your views here. +""" +Views for the core application. These are mainly shared, common views +used by multiple applications. +""" +from django.shortcuts import render_to_response +from django.template import RequestContext +from django.contrib.auth.decorators import login_required +from django.views.decorators.http import require_GET + +@login_required +@require_GET +def markdown_help(request): + """ + This view provides the Markdown help cheat sheet. It is expected + to be called via AJAX. + """ + return render_to_response('core/markdown_help.html') diff -r b0d62247c3e4 -r 2d299909e074 gpp/forums/templatetags/forum_tags.py --- a/gpp/forums/templatetags/forum_tags.py Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/forums/templatetags/forum_tags.py Mon Nov 16 01:00:28 2009 +0000 @@ -80,3 +80,17 @@ fmt = DATE_FMT_12 return date.strftime(fmt) + + +@register.inclusion_tag('forums/show_form.html') +def show_form(legend_text, form, submit_value, is_ajax, media_url): + """ + This tag displays the common HTML for a forum form. + """ + return { + 'legend_text': legend_text, + 'form': form, + 'submit_value': submit_value, + 'is_ajax': is_ajax, + 'MEDIA_URL': media_url, + } diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/comments/comment_form.html --- a/gpp/templates/comments/comment_form.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/comments/comment_form.html Mon Nov 16 01:00:28 2009 +0000 @@ -1,8 +1,18 @@ {% if user.is_authenticated %}
{{ form.as_p }} + +More smileys + +Help
+
+Loading +
+
+Loading +
{% else %}

Please login or diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/core/markdown_help.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/core/markdown_help.html Mon Nov 16 01:00:28 2009 +0000 @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Type ThisTo See This
Paragrahs +
Paragraphs must be separated by a blank line.
+
+Here is another paragraph.
+
+

Paragraphs must be separated by a blank line.

+

Here is another paragraph.

+
Manual Line Breaks +
To insert a line break  
+end a line with two or more spaces.
+
+

To insert a line break
+ end a line with two or more spaces.

+
Emphasis +
*italic*
+_italic_
+**bold**
+__bold__
italic
+ italic
+ bold
+ bold
Inline linksA link to [Google](http://google.com).A link to Google.
Reference linksA link to [Google][id]. Then anywhere else in the + text, define the link on its own line.
+ [id]: http://google.com
A link to Google. Then + anywhere else in the text, define the link on its own line.
Inline Images![alt text](/static/icons/emoticon_smile.png "Smile").alt text
Reference Images![alt text][id]
+ [id]: /static/icons/emoticon_smile.png "Smile"
alt text
Bullet List +
* One
+* Two
+* Three
+
    +
  • One
  • +
  • Two
  • +
  • Three
  • +
+
Numbered List +
1. One
+1. Two
+1. Three
+
    +
  1. One
  2. +
  3. Two
  4. +
  5. Three
  6. +
+
Blockquotes
John said:
+> Email style angle brackets
+> are used for quotes.

John said:

+

Email-style angle brackets are used for blockquotes.

Code Spans
`<code>` spans are delimited by backticks.

<code> spans are delimited by backticks.

Code Blocks
First insert a blank line.
+
+    Then indent every line 
+    of a code block by at least
+    4 spaces. This is useful to 
+    display tablature.
+
+

First insert a blank line.

+ +
Then indent every line 
+of a code block by at least
+4 spaces. This is useful to 
+display tablature.
+
+
Header 1 +
Header 1
+========
+

Header 1

Header 2 +
Header 2
+--------
+

Header 2

Header 1
# Header 1

Header 1

Header 2
## Header 2

Header 2

Header 3
### Header 3

Header 3

Header 6
###### Header 6
Header 6
+

+More help: +

+ +

Hit ESC or click the X to close this window.

diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/downloads/download_detail.html --- a/gpp/templates/downloads/download_detail.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/downloads/download_detail.html Mon Nov 16 01:00:28 2009 +0000 @@ -8,7 +8,7 @@ {% endblock %} {% block custom_js %} -{% script_tags "markitup" %} +{% script_tags "markitup jquery-ui" %} {% endblock %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/forums/edit_post.html --- a/gpp/templates/forums/edit_post.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/forums/edit_post.html Mon Nov 16 01:00:28 2009 +0000 @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load forum_tags %} {% block title %}Forums: Edit Post{% endblock %} {% block custom_js %}{{ form.media }}{% endblock %} {% block content %} @@ -16,17 +17,6 @@ -
-
-Edit Post -{{ form.as_p }} - -More smileys - -
-
- -
-Loading +{% show_form "Edit Post" form "Update Post" 0 MEDIA_URL %}
{% endblock %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/forums/new_post.html --- a/gpp/templates/forums/new_post.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/forums/new_post.html Mon Nov 16 01:00:28 2009 +0000 @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load forum_tags %} {% block title %}Forums: New Post{% endblock %} {% block custom_js %}{{ form.media }}{% endblock %} {% block content %} @@ -13,19 +14,7 @@ {% if can_post %}
-
-
-New Post -{{ form.as_p }} - -More smileys - -
-
-
-
-Loading -
+{% show_form "New Post" form "Submit Post" 0 MEDIA_URL %} {% else %} {% if topic.locked %}

This topic is locked.

@@ -33,4 +22,5 @@

You don't have permission to post to this topic.

{% endif %} {% endif %} + {% endblock %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/forums/new_topic.html --- a/gpp/templates/forums/new_topic.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/forums/new_topic.html Mon Nov 16 01:00:28 2009 +0000 @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load forum_tags %} {% block title %}Forums: New Topic{% endblock %} {% block custom_js %}{{ form.media }}{% endblock %} {% block content %} @@ -9,15 +10,5 @@ {{ forum.name }} -
-{{ form.as_p }} - -More smileys - -
- -
-Loading -
- +{% show_form "New Topic" form "Submit" 0 MEDIA_URL %} {% endblock %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/forums/show_form.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/forums/show_form.html Mon Nov 16 01:00:28 2009 +0000 @@ -0,0 +1,17 @@ +
+
+{{ legend_text }} +{{ form.as_p }} + +More smileys + +Help + +
+
+
+Loading +
+
+Loading +
diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/forums/topic.html --- a/gpp/templates/forums/topic.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/forums/topic.html Mon Nov 16 01:00:28 2009 +0000 @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load forum_tags %} {% block title %}Forums: {{ topic.name }}{% endblock %} {% block custom_js %}{{ form.media }}{% endblock %} {% block content %} @@ -54,18 +55,7 @@ {% if last_page and can_reply %} -
-
-Reply to "{{ topic.name }}" -{{ form.as_p }} - -More smileys - -
-
-
-Loading -
+{% show_form "Reply to Topic" form "Submit Reply" 1 MEDIA_URL %} {% endif %} {% endblock %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/news/story.html --- a/gpp/templates/news/story.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/news/story.html Mon Nov 16 01:00:28 2009 +0000 @@ -8,7 +8,7 @@ {% endblock %} {% block custom_js %} {% if story.can_comment_on %} -{% script_tags "markitup" %} +{% script_tags "markitup jquery-ui" %} {% endif %} {% endblock %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/polls/poll_results.html --- a/gpp/templates/polls/poll_results.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/polls/poll_results.html Mon Nov 16 01:00:28 2009 +0000 @@ -8,7 +8,7 @@ {% endblock %} {% block custom_js %} {% if poll.is_open %} -{% script_tags "markitup" %} +{% script_tags "markitup jquery-ui" %} {% endif %} {% endblock %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/templates/potd/view.html --- a/gpp/templates/potd/view.html Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/templates/potd/view.html Mon Nov 16 01:00:28 2009 +0000 @@ -7,7 +7,7 @@ {% endblock %} {% block custom_js %} -{% script_tags "markitup" %} +{% script_tags "markitup jquery-ui" %} {% endblock %} {% block content %} diff -r b0d62247c3e4 -r 2d299909e074 gpp/urls.py --- a/gpp/urls.py Sat Nov 14 20:30:31 2009 +0000 +++ b/gpp/urls.py Mon Nov 16 01:00:28 2009 +0000 @@ -17,6 +17,7 @@ (r'^calendar/', include('gcalendar.urls')), (r'^comments/', include('comments.urls')), (r'^contact/', include('contact.urls')), + (r'^core/', include('core.urls')), (r'^donations/', include('donations.urls')), (r'^downloads/', include('downloads.urls')), url(r'^feeds/(?P.*)/$', diff -r b0d62247c3e4 -r 2d299909e074 media/icons/help.png Binary file media/icons/help.png has changed diff -r b0d62247c3e4 -r 2d299909e074 media/js/comments.js --- a/media/js/comments.js Sat Nov 14 20:30:31 2009 +0000 +++ b/media/js/comments.js Mon Nov 16 01:00:28 2009 +0000 @@ -62,4 +62,54 @@ return false; }); postText.markItUp(mySettings); + + $('#smileys_dialog').dialog({autoOpen:false}); + var firstTime = true; + $('#more_smileys').click(function () { + $('#smileys_dialog').dialog('open'); + var postBox = $('#id_comment')[0]; + if (firstTime) { + $.ajax({ + url: '/smiley/farm/extra/', + type: 'GET', + dataType: 'html', + success: function(data, textStatus) { + var img = $('#smiley_busy'); + img.hide(); + img.after(data); + $('#smileys_dialog .smiley_farm img').click(function() { + postBox.value += ' ' + this.alt + ' '; + postBox.focus(); + }); + firstTime = false; + }, + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); + } + }); + } + return false; + }); + $('#markdown_help_dialog').dialog({autoOpen: false, width: 720, height: 600}); + var firstTimeMd = true; + $('#markdown_help').click(function () { + $('#markdown_help_dialog').dialog('open'); + if (firstTimeMd) { + $.ajax({ + url: '/core/markdown_help/', + type: 'GET', + dataType: 'html', + success: function(data, textStatus) { + var img = $('#markdown_busy'); + img.hide(); + img.after(data); + firstTimeMd = false; + }, + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); + } + }); + } + return false; + }); }); diff -r b0d62247c3e4 -r 2d299909e074 media/js/forums.js --- a/media/js/forums.js Sat Nov 14 20:30:31 2009 +0000 +++ b/media/js/forums.js Mon Nov 16 01:00:28 2009 +0000 @@ -110,4 +110,26 @@ } return false; }); + $('#markdown_help_dialog').dialog({autoOpen: false, width: 720, height: 600}); + var firstTimeMd = true; + $('#markdown_help').click(function () { + $('#markdown_help_dialog').dialog('open'); + if (firstTimeMd) { + $.ajax({ + url: '/core/markdown_help/', + type: 'GET', + dataType: 'html', + success: function(data, textStatus) { + var img = $('#markdown_busy'); + img.hide(); + img.after(data); + firstTimeMd = false; + }, + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); + } + }); + } + return false; + }); });