[extensions-web] Show only the first line of the description in the list view
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Show only the first line of the description in the list view
- Date: Tue, 6 Dec 2011 03:01:35 +0000 (UTC)
commit a7b369678713fb5d489dd0b06209c800ffda5730
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Dec 5 22:00:43 2011 -0500
Show only the first line of the description in the list view
sweettooth/extensions/models.py | 5 +++++
.../templates/extensions/detail_edit.html | 3 ++-
.../extensions/templates/extensions/list.html | 2 +-
sweettooth/static/js/main.js | 7 ++++---
4 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 3f44363..a574ebf 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -92,6 +92,11 @@ class Extension(models.Model):
return True
return False
+ def first_line_of_description(self):
+ if not self.description:
+ return ""
+ return self.description.splitlines()[0]
+
def clean(self):
from django.core.exceptions import ValidationError
diff --git a/sweettooth/extensions/templates/extensions/detail_edit.html b/sweettooth/extensions/templates/extensions/detail_edit.html
index a4fb58a..c1be95c 100644
--- a/sweettooth/extensions/templates/extensions/detail_edit.html
+++ b/sweettooth/extensions/templates/extensions/detail_edit.html
@@ -121,7 +121,8 @@
{% endblock %}
{% block document-ready %}{{ block.super }}
- $("#extension_name, #extension_description, #extension_url").csrfEditable("{% url extensions-ajax-inline pk=extension.pk %}");
+ $("#extension_name, #extension_url").csrfEditable("{% url extensions-ajax-inline pk=extension.pk %}");
+ $("#extension_description").csrfEditable("{% url extensions-ajax-inline pk=extension.pk %}", {"type": "textarea"});
require(['uploader'], function() {
$(".screenshot.upload").uploadify("{% url extensions-ajax-screenshot pk=extension.pk %}?geometry=300x200");
$(".icon.upload").uploadify("{% url extensions-ajax-icon pk=extension.pk %}");
diff --git a/sweettooth/extensions/templates/extensions/list.html b/sweettooth/extensions/templates/extensions/list.html
index 06c2fdf..ef5692d 100644
--- a/sweettooth/extensions/templates/extensions/list.html
+++ b/sweettooth/extensions/templates/extensions/list.html
@@ -14,7 +14,7 @@
<h3 class="extension-name"><a href="{% url extensions-detail pk=extension.pk %}" class="title-link"><img src="{{ extension.icon.url }}" class="icon">{{ extension.name }}</a></h3>
<span class="author">by <a href="{% url auth-profile user=extension.creator.username %}">{{ extension.creator }}</a></span>
<p class="description">
- {{ extension.description }}
+ {{ extension.first_line_of_description }}
</p>
</li>
{% endfor %}
diff --git a/sweettooth/static/js/main.js b/sweettooth/static/js/main.js
index 9de56cd..165e193 100644
--- a/sweettooth/static/js/main.js
+++ b/sweettooth/static/js/main.js
@@ -8,7 +8,7 @@ require(['jquery', 'messages', 'extensions',
$.ajaxSettings.headers['X-CSRFToken'] = $.cookie('csrftoken');
- $.fn.csrfEditable = function(url) {
+ $.fn.csrfEditable = function(url, options) {
return $(this).each(function() {
var $elem = $(this);
@@ -18,14 +18,15 @@ require(['jquery', 'messages', 'extensions',
}
}
- $elem.editable(url, { select: true,
+ $elem.editable(url, $.merge(options,
+ { select: true,
ajaxoptions: { error: error, dataType: 'json' },
callback: function(result, settings) {
elem.text(result);
},
data: function(string, settings) {
return $.trim(string);
- }});
+ }}));
$elem.addClass("editable");
});
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]