[extensions-web] Don't show line numbers for image types.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Don't show line numbers for image types.
- Date: Fri, 30 Sep 2011 17:40:28 +0000 (UTC)
commit 56f1a2876ef86575bddacb16321230db8ab392fa
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Sep 27 15:32:07 2011 -0400
Don't show line numbers for image types.
sweettooth/review/views.py | 8 +++++++-
sweettooth/static/js/review.js | 25 ++++++++++++++-----------
2 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 16ac94f..8b36540 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -64,6 +64,8 @@ class AjaxGetFilesView(SingleObjectMixin, View):
zipfile = self.object.get_zipfile('r')
+ show_linenum = False
+
# filename => { raw, html, filename }
files = []
for filename in zipfile.namelist():
@@ -89,8 +91,12 @@ class AjaxGetFilesView(SingleObjectMixin, View):
lexer = pygments.lexers.get_lexer_by_name('text')
html = pygments.highlight(raw, lexer, self.formatter)
+ show_linenum = True
- files.append(dict(filename=filename, raw=raw, html=html))
+ files.append(dict(filename=filename,
+ raw=raw,
+ html=html,
+ show_linenum=show_linenum))
return HttpResponse(mark_safe(json.dumps(files)),
content_type="application/json")
diff --git a/sweettooth/static/js/review.js b/sweettooth/static/js/review.js
index c16151b..94f477a 100644
--- a/sweettooth/static/js/review.js
+++ b/sweettooth/static/js/review.js
@@ -3,19 +3,22 @@
define(['jquery'], function($) {
function createFileView(data) {
- var rawLines = data.raw.split("\n");
- var count = rawLines.length;
- if (rawLines[count-1] == "")
- count --;
- if (rawLines[0] == "")
- count --;
-
var lines = [];
- lines.push("<td class=\"linenumbers\"><pre>");
- for (var i = 1; i < (count + 1); i ++) {
- lines.push("<span rel=\"L" + i + "\">" + i + "</span>\n");
+ if (data.show_linenum) {
+ var rawLines = data.raw.split("\n");
+ var count = rawLines.length;
+
+ if (rawLines[count-1] == "")
+ count --;
+ if (rawLines[0] == "")
+ count --;
+
+ lines.push("<td class=\"linenumbers\"><pre>");
+ for (var i = 1; i < (count + 1); i ++) {
+ lines.push("<span rel=\"L" + i + "\">" + i + "</span>\n");
+ }
+ lines.push("</pre></td>");
}
- lines.push("</pre></td>");
var file = "<td width=\"100%\"><div class=\"file\">" + data.html + "</div></td>";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]