# HG changeset patch # User Brian Neal # Date 1239757997 0 # Node ID f408971657b9788644f90f9c3c128f0816779f3a # Parent cc8eb028def1063c55c43cd33f0f24a67a10730d Changed the shoutbox: posts are now made by Ajax. The smiley farm is loaded only on demand. jQuery is now in the base template. May add scrolling later. diff -r cc8eb028def1 -r f408971657b9 gpp/bio/forms.py --- a/gpp/bio/forms.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/bio/forms.py Wed Apr 15 01:13:17 2009 +0000 @@ -43,8 +43,7 @@ 'all': settings.GPP_THIRD_PARTY_CSS['markitup'] + \ settings.GPP_THIRD_PARTY_CSS['jquery-ui'] } - js = settings.GPP_THIRD_PARTY_JS['jquery'] + \ - settings.GPP_THIRD_PARTY_JS['markitup'] + \ + js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ settings.GPP_THIRD_PARTY_JS['jquery-ui'] + \ ('js/bio.js', ) diff -r cc8eb028def1 -r f408971657b9 gpp/comments/forms.py --- a/gpp/comments/forms.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/comments/forms.py Wed Apr 15 01:13:17 2009 +0000 @@ -68,6 +68,5 @@ css = { 'all': settings.GPP_THIRD_PARTY_CSS['markitup'], } - js = settings.GPP_THIRD_PARTY_JS['jquery'] + \ - settings.GPP_THIRD_PARTY_JS['markitup'] + \ + js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ ('js/comments.js', ) diff -r cc8eb028def1 -r f408971657b9 gpp/core/widgets.py --- a/gpp/core/widgets.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/core/widgets.py Wed Apr 15 01:13:17 2009 +0000 @@ -13,8 +13,7 @@ css = { 'all': settings.GPP_THIRD_PARTY_CSS['jquery-autocomplete'], } - js = settings.GPP_THIRD_PARTY_JS['jquery'] + \ - settings.GPP_THIRD_PARTY_JS['jquery-autocomplete'] + js = settings.GPP_THIRD_PARTY_JS['jquery-autocomplete'] def render(self, name, value, attrs=None): url = reverse('messages-ajax_users') diff -r cc8eb028def1 -r f408971657b9 gpp/downloads/forms.py --- a/gpp/downloads/forms.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/downloads/forms.py Wed Apr 15 01:13:17 2009 +0000 @@ -37,7 +37,6 @@ css = { 'all': settings.GPP_THIRD_PARTY_CSS['markitup'], } - js = settings.GPP_THIRD_PARTY_JS['jquery'] + \ - settings.GPP_THIRD_PARTY_JS['markitup'] + \ + js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ ('js/downloads/add.js', ) diff -r cc8eb028def1 -r f408971657b9 gpp/gcalendar/forms.py --- a/gpp/gcalendar/forms.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/gcalendar/forms.py Wed Apr 15 01:13:17 2009 +0000 @@ -85,8 +85,7 @@ settings.GPP_THIRD_PARTY_CSS['jquery-ui'] + \ ('css/gcalendar.css', ) } - js = settings.GPP_THIRD_PARTY_JS['jquery'] + \ - settings.GPP_THIRD_PARTY_JS['markitup'] + \ + js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ settings.GPP_THIRD_PARTY_JS['jquery-ui'] + \ ('js/gcalendar.js', ) diff -r cc8eb028def1 -r f408971657b9 gpp/shoutbox/templatetags/shoutbox_tags.py --- a/gpp/shoutbox/templatetags/shoutbox_tags.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/shoutbox/templatetags/shoutbox_tags.py Wed Apr 15 01:13:17 2009 +0000 @@ -12,4 +12,5 @@ return { 'shouts': shouts, 'user': context['user'], + 'MEDIA_URL': context['MEDIA_URL'], } diff -r cc8eb028def1 -r f408971657b9 gpp/shoutbox/views.py --- a/gpp/shoutbox/views.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/shoutbox/views.py Wed Apr 15 01:13:17 2009 +0000 @@ -10,6 +10,7 @@ from django.http import HttpResponseForbidden from django.http import HttpResponseRedirect from django.contrib.auth.decorators import login_required +from django.views.decorators.http import require_POST from core.paginator import DiggPaginator from shoutbox.forms import ShoutBoxForm @@ -18,14 +19,18 @@ SHOUTS_PER_PAGE = 10 @login_required +@require_POST def shout(request): - if request.method == 'POST': - msg = request.POST.get('msg', '').strip() - if msg != '': - shout = Shout(user=request.user, shout=msg) - shout.save() - - return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) + msg = request.POST.get('msg', '').strip() + if msg == '': + return HttpResponse('') + + shout = Shout(user=request.user, shout=msg) + shout.save() + return render_to_response('shoutbox/shout.html', { + 'shout': shout, + }, + context_instance = RequestContext(request)) def view(request, page=1): @@ -101,3 +106,5 @@ return HttpResponse(id) return HttpResponseForbidden() + +# vim: ts=4 sw=4 diff -r cc8eb028def1 -r f408971657b9 gpp/smiley/urls.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/smiley/urls.py Wed Apr 15 01:13:17 2009 +0000 @@ -0,0 +1,9 @@ +""" +Urls for the Smiley application. +""" + +from django.conf.urls.defaults import * + +urlpatterns = patterns('smiley.views', + url(r'^farm/$', 'farm', name='smiley-farm'), +) diff -r cc8eb028def1 -r f408971657b9 gpp/smiley/views.py --- a/gpp/smiley/views.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/smiley/views.py Wed Apr 15 01:13:17 2009 +0000 @@ -1,1 +1,19 @@ -# Create your views here. +""" +Views for the Smiley application. +""" +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 + +from smiley.models import Smiley + +@login_required +@require_GET +def farm(request): + return render_to_response('smiley/smiley_farm.html', { + 'smilies': Smiley.objects.get_smilies(), + }, + context_instance = RequestContext(request)) + +# vim: ts=4 sw=4 diff -r cc8eb028def1 -r f408971657b9 gpp/templates/base.html --- a/gpp/templates/base.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/base.html Wed Apr 15 01:13:17 2009 +0000 @@ -6,6 +6,7 @@ {% load irc_tags %} {% load potd_tags %} {% load messages_tags %} +{% load script_tags %} SurfGuitar101.com | {% block title %}{% endblock %} @@ -19,10 +20,13 @@ - +{% script_tags "jquery" %} {% block custom_head %}{% endblock %} {% block custom_css %}{% endblock %} {% block custom_js %}{% endblock %} +{% if user.is_authenticated %} + +{% endif %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/downloads/download_comments.html --- a/gpp/templates/downloads/download_comments.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/downloads/download_comments.html Wed Apr 15 01:13:17 2009 +0000 @@ -8,7 +8,6 @@ {% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {% script_tags "markitup" %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/downloads/download_list.html --- a/gpp/templates/downloads/download_list.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/downloads/download_list.html Wed Apr 15 01:13:17 2009 +0000 @@ -1,6 +1,5 @@ {% extends 'base.html' %} {% load downloads_tags %} -{% load script_tags %} {% block title %}Downloads: {{ category.title }}{% endblock %} {% block custom_css %} @@ -8,7 +7,6 @@ {% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {% endblock %} {% block content %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/downloads/download_summary.html --- a/gpp/templates/downloads/download_summary.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/downloads/download_summary.html Wed Apr 15 01:13:17 2009 +0000 @@ -1,12 +1,10 @@ {% extends 'base.html' %} {% load downloads_tags %} -{% load script_tags %} {% block title %}{{ title }}{% endblock %} {% block custom_css %} {% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {% endblock %} {% block content %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/downloads/search_results.html --- a/gpp/templates/downloads/search_results.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/downloads/search_results.html Wed Apr 15 01:13:17 2009 +0000 @@ -1,6 +1,5 @@ {% extends 'base.html' %} {% load downloads_tags %} -{% load script_tags %} {% block title %}Downloads: Search Results{% endblock %} {% block custom_css %} @@ -8,7 +7,6 @@ {% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {% endblock %} {% block content %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/gcalendar/edit.html --- a/gpp/templates/gcalendar/edit.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/gcalendar/edit.html Wed Apr 15 01:13:17 2009 +0000 @@ -1,8 +1,6 @@ {% extends 'base.html' %} -{% load script_tags %} {% block title %}Edit Calendar Events{% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {% endblock %} {% block content %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/membermap/index.html --- a/gpp/templates/membermap/index.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/membermap/index.html Wed Apr 15 01:13:17 2009 +0000 @@ -1,8 +1,6 @@ {% extends 'base.html' %} -{% load script_tags %} {% block title %}Member Map{% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {{ form.media }} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/news/story.html --- a/gpp/templates/news/story.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/news/story.html Wed Apr 15 01:13:17 2009 +0000 @@ -8,7 +8,6 @@ {% endblock %} {% block custom_js %} {% if story.can_comment_on %} -{% script_tags "jquery" %} {% script_tags "markitup" %} {% endif %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/polls/poll_results.html --- a/gpp/templates/polls/poll_results.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/polls/poll_results.html Wed Apr 15 01:13:17 2009 +0000 @@ -8,7 +8,6 @@ {% endblock %} {% block custom_js %} {% if poll.is_open %} -{% script_tags "jquery" %} {% script_tags "markitup" %} {% endif %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/potd/view.html --- a/gpp/templates/potd/view.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/potd/view.html Wed Apr 15 01:13:17 2009 +0000 @@ -7,7 +7,6 @@ {% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {% script_tags "markitup" %} {% endblock %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/shoutbox/shout.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/shoutbox/shout.html Wed Apr 15 01:13:17 2009 +0000 @@ -0,0 +1,6 @@ +{% load smiley_tags %} +

+{{ shout.user.username }}: +{{ shout.shout|smilify|urlizetrunc:15 }} +{{ shout.shout_date|date:"D M d Y H:i:s" }} +

diff -r cc8eb028def1 -r f408971657b9 gpp/templates/shoutbox/shoutbox.html --- a/gpp/templates/shoutbox/shoutbox.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/shoutbox/shoutbox.html Wed Apr 15 01:13:17 2009 +0000 @@ -2,11 +2,7 @@ {% load smiley_tags %} {% block block_title %}Shoutbox{% endblock %} {% block block_content %} -{% if shouts %} - -
- - {# for shout in shouts reversed #} +
{% for shout in shouts %}

{{ shout.user.username }}: @@ -14,20 +10,18 @@ {{ shout.shout_date|date:"D M d Y H:i:s" }}

{% endfor %} -
-{% endif %}
Shout History
{% if user.is_authenticated %}

- - + +
{% else %} diff -r cc8eb028def1 -r f408971657b9 gpp/templates/shoutbox/view.html --- a/gpp/templates/shoutbox/view.html Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/templates/shoutbox/view.html Wed Apr 15 01:13:17 2009 +0000 @@ -7,7 +7,6 @@ {% endblock %} {% block custom_js %} -{% script_tags "jquery" %} {% script_tags "jquery-jeditable" %} {% endblock %} diff -r cc8eb028def1 -r f408971657b9 gpp/urls.py --- a/gpp/urls.py Tue Apr 14 02:35:35 2009 +0000 +++ b/gpp/urls.py Wed Apr 15 01:13:17 2009 +0000 @@ -32,6 +32,7 @@ (r'^potd/', include('potd.urls')), (r'^profile/', include('bio.urls')), (r'^shout/', include('shoutbox.urls')), + (r'^smiley/', include('smiley.urls')), ) if settings.DEBUG: diff -r cc8eb028def1 -r f408971657b9 media/css/shoutbox.css --- a/media/css/shoutbox.css Tue Apr 14 02:35:35 2009 +0000 +++ b/media/css/shoutbox.css Wed Apr 15 01:13:17 2009 +0000 @@ -21,7 +21,7 @@ cursor: pointer; } -#marqueecontainer { +#shoutbox-shout-container { position: relative; width: 142; /*marquee width */ height: 200px; /*marquee height */ diff -r cc8eb028def1 -r f408971657b9 media/icons/ajax_busy.gif Binary file media/icons/ajax_busy.gif has changed diff -r cc8eb028def1 -r f408971657b9 media/js/shoutbox.js --- a/media/js/shoutbox.js Tue Apr 14 02:35:35 2009 +0000 +++ b/media/js/shoutbox.js Wed Apr 15 01:13:17 2009 +0000 @@ -1,53 +1,40 @@ -/*********************************************** -* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com) -* This notice MUST stay intact for legal use -* Visit http://www.dynamicdrive.com/ for this script and 100s more. -***********************************************/ - -var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds) -var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10) -var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)? - -////NO NEED TO EDIT BELOW THIS LINE//////////// - -var copyspeed=marqueespeed -var pausespeed=(pauseit==0)? copyspeed: 0 -var actualheight='' - -function scrollmarquee(){ -if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) -cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px" -else -cross_marquee.style.top=parseInt(marqueeheight)+8+"px" -} - -function initializemarquee(){ -cross_marquee=document.getElementById("vmarquee") -cross_marquee.style.top=0 -marqueeheight=document.getElementById("marqueecontainer").offsetHeight -actualheight=cross_marquee.offsetHeight -if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit -cross_marquee.style.height=marqueeheight+"px" -cross_marquee.style.overflow="scroll" -return -} -setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll) -} - -if (window.addEventListener) -window.addEventListener("load", initializemarquee, false) -else if (window.attachEvent) -window.attachEvent("onload", initializemarquee) -else if (document.getElementById) -window.onload=initializemarquee - -/////////////////////////////// - -function sb_toggle_smilies() -{ - var d = document.getElementById("shoutbox-smiley-frame"); - d.style.display = d.style.display == "none" ? "block" : "none"; -} +$(document).ready(function() { + var submit = $('#shoutbox-submit'); + submit.click(function () { + var input = $('#shoutbox-smiley-input'); + var msg = input.val(); + msg = msg.replace(/^\s+/, ''); + msg = msg.replace(/\s+$/, ''); + if (msg.length == 0) { + return false; + } + submit.attr('disabled', 'disabled'); + $.post('/shout/shout/', { + msg: msg + }, + function (data, textStatus) { + input.val(''); + if (data != '') { + $('#shoutbox-shout-container').prepend(data); + $('#shoutbox-shout-container p:first').fadeIn(2500); + } + submit.removeAttr('disabled'); + }, + 'html'); + return false; + }); + var smilies_loaded = false; + var smiley_frame = $('#shoutbox-smiley-frame'); + $('#shoutbox-smilies').click(function () { + smiley_frame.toggle(); + if (!smilies_loaded) { + smiley_frame.load('/smiley/farm/', function () { + $('#shoutbox-busy-icon').hide(); + smilies_loaded = true; + }); + } + }); +}); function sb_smiley_click(code) {