Mercurial > public > sg101
changeset 153:13d052fbe4f1
Fixing #28, cosmetic issues with member map. Also fixed a bug involving the smiley and markdown interactions. Single quotes were getting HTML REMOVED by markdown.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 19 Dec 2009 19:34:16 +0000 |
parents | bc657962941e |
children | 82deb8cc59e9 |
files | gpp/membermap/models.py gpp/smiley/templatetags/smiley_tags.py gpp/templates/membermap/index.html gpp/templates/membermap/markdown.html media/css/membermap.css media/js/membermap.js |
diffstat | 6 files changed, 21 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/membermap/models.py Sat Dec 19 04:59:06 2009 +0000 +++ b/gpp/membermap/models.py Sat Dec 19 19:34:16 2009 +0000 @@ -7,8 +7,9 @@ from django.template.defaultfilters import escapejs import django.utils.simplejson as json +from core.markup import site_markup -# Create your models here. + class MapEntry(models.Model): """Represents a user's entry on the map.""" user = models.ForeignKey(User) @@ -27,7 +28,10 @@ verbose_name_plural = 'map entries' def save(self, force_insert=False, force_update=False): - msg = render_to_string('membermap/markdown.html', {'entry': self}).strip() + msg = render_to_string('membermap/markdown.html', { + 'user': self.user, + 'msg': site_markup(self.message)}).strip() + self.json = json.dumps({'name': self.user.username, 'lat': '%10.6f' % self.lat, 'lon': '%10.6f' % self.lon, @@ -35,4 +39,3 @@ }) super(MapEntry, self).save(force_insert, force_update) -# vim: ts=4 sw=4
--- a/gpp/smiley/templatetags/smiley_tags.py Sat Dec 19 04:59:06 2009 +0000 +++ b/gpp/smiley/templatetags/smiley_tags.py Sat Dec 19 19:34:16 2009 +0000 @@ -22,7 +22,10 @@ @register.filter @stringfilter def smiley_markdown(value, autoescape=False): - """A filter to "smilify" text by replacing text with HTML img tags of smilies.""" + """ + A filter to "smilify" text by replacing text with Markdown image notation + for smilies. + """ from smiley import smilify_markdown return mark_safe(smilify_markdown(value, autoescape=autoescape)) smiley_markdown.needs_autoescape = True
--- a/gpp/templates/membermap/index.html Sat Dec 19 04:59:06 2009 +0000 +++ b/gpp/templates/membermap/index.html Sat Dec 19 19:34:16 2009 +0000 @@ -27,18 +27,11 @@ <div id="member_map_top"> Members on the map: <span id="member_map_count">0</span> • Recent updates: <select id="member_map_recent"><option value="0" selected="selected">(select)</option></select> + • All Members: + <select id="member_map_members"><option value="0" selected="selected">(select)</option></select> </div> {% endif %} - <div> - {% if user.is_authenticated %} - <div id="member_map_members_column"> - Members:<br /> - <select id="member_map_members" multiple="multiple"> - </select> - </div> - {% endif %} - <div id="member_map_map"> - </div> + <div id="member_map_map"> </div> <div id="member_map_info"> {% if user.is_authenticated %}
--- a/gpp/templates/membermap/markdown.html Sat Dec 19 04:59:06 2009 +0000 +++ b/gpp/templates/membermap/markdown.html Sat Dec 19 19:34:16 2009 +0000 @@ -1,4 +1,4 @@ {% load markup %} {% load smiley_tags %} {% load avatar_tags %} -{% avatar entry.user "left" %}<a href="{% url bio-view_profile username=entry.user.username %}">{{ entry.user.username }}</a>:<br />{{ entry.message|smiley_markdown|markdown:"safe" }} +{% avatar user "left" %}<a href="{% url bio-view_profile username=user.username %}">{{ user.username }}</a>:<br />{{ msg|safe }}
--- a/media/css/membermap.css Sat Dec 19 04:59:06 2009 +0000 +++ b/media/css/membermap.css Sat Dec 19 19:34:16 2009 +0000 @@ -2,10 +2,10 @@ float: left; } #member_map_map { - float: left; - width: 640px; - height: 480px; + width: 720px; + height: 540px; border: 1px solid black; + margin: 0 auto; } #member_map_info { padding-top: 1em;
--- a/media/js/membermap.js Sat Dec 19 04:59:06 2009 +0000 +++ b/media/js/membermap.js Sat Dec 19 19:34:16 2009 +0000 @@ -18,11 +18,6 @@ clear: function() { mmap.users.length = 0; }, - resizeUserList: function() { - var sel = $('#member_map_members'); - sel[0].size = Math.min(29, sel[0].length); - $('#member_map_count').html(sel[0].length); - }, selectText: "(select)", onMapDir: 'You have previously added yourself to the member map. Your information appears below. You may change ' + 'the information if you wish. To delete yourself from the map, click the Delete button.', @@ -47,6 +42,7 @@ mmap.map.clearOverlays(); var sel = $('#member_map_members'); sel[0].length = 0; + sel.append($('<option />').html(mmap.selectText)); mmap.clear(); $.each(data.users, function(i, item) { sel.append($('<option />').html(item.name)); @@ -60,7 +56,6 @@ mmap.userOnMap = true; } }); - sel[0].size = Math.min(29, data.users.length); $('#member_map_count').html(data.users.length); sel = $('#member_map_recent'); @@ -103,6 +98,7 @@ else { $('#member_map_members').append($('<option />').html(data.name)); + $('#member_map_recent').append($('<option />').html(data.name)); mmap.userOnMap = true; deleteButton.removeAttr('disabled').val('Delete'); } @@ -114,7 +110,7 @@ mmap.clickUser(mmapUser.userName); submitButton.removeAttr('disabled').val('Update'); $('#member_map_directions').html(mmap.onMapDir); - mmap.resizeUserList(); + $('#member_map_count').html($('#member_map_members')[0].length - 1); alert(wasOnMap ? "Your location has been updated!" : "You've been added to the map!"); }, @@ -146,7 +142,7 @@ deleteButton.val('Delete'); submitButton.removeAttr('disabled').val('Add'); $('#member_map_directions').html(mmap.offMapDir); - mmap.resizeUserList(); + $('#member_map_count').html($('#member_map_members')[0].length - 1); alert("You've been removed from the map."); }, error: function (xhr, textStatus, ex) {