Skip to content

Commit 7e6baf1

Browse files
committed
Merged in [12588] from rjsparks@nostrum.com:
Change how we display review text to follow the tecnique used with other large blocks of pasted or imported text (shepherds writeups for instance). Fixes ietf-tools#2104. - Legacy-Id: 12600 Note: SVN reference [12588] has been migrated to Git commit 7c18237
2 parents 8e98583 + 7c18237 commit 7e6baf1

4 files changed

Lines changed: 14 additions & 15 deletions

File tree

ietf/doc/utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,15 @@ def add_events_message_info(events):
297297
e.in_reply_to = e.addedmessageevent.in_reply_to
298298

299299

300-
def get_unicode_document_content(key, filename, split=True, markup=True, codec='utf-8', errors='ignore', width=None):
300+
def get_unicode_document_content(key, filename, codec='utf-8', errors='ignore'):
301301
try:
302302
with open(filename, 'rb') as f:
303303
raw_content = f.read().decode(codec,errors)
304304
except IOError:
305305
error = "Error; cannot read ("+key+")"
306306
return error
307307

308-
if markup:
309-
return markup_txt.markup_unicode(raw_content, split, width)
310-
else:
311-
return raw_content
312-
308+
return raw_content
313309

314310
def get_document_content(key, filename, split=True, markup=True):
315311
try:

ietf/doc/views_doc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,10 @@ def document_main(request, name, rev=None):
582582
if doc.type_id == "review":
583583
basename = "{}.txt".format(doc.name, doc.rev)
584584
pathname = os.path.join(doc.get_file_path(), basename)
585-
content = get_unicode_document_content(basename, pathname, split=False, width=80)
586-
585+
content = get_unicode_document_content(basename, pathname)
586+
# If we want to go back to using markup_txt.markup_unicode, call it explicitly here like this:
587+
# content = markup_txt.markup_unicode(content, split=False, width=80)
588+
587589
review_req = ReviewRequest.objects.filter(review=doc.name).first()
588590

589591
other_reviews = []

ietf/templates/doc/document_review.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@
113113
<h2>{{ doc.type.name }}<br><small>{{ doc.name }}</small></h2>
114114

115115
{% if doc.rev and content != None %}
116-
{{ content|safe|keep_spacing|sanitize_html|safe }}
116+
<pre class="pasted">{{ content|urlize|safe|sanitize_html|safe }}</pre>
117117
{% endif %}
118118
{% endblock %}

ietf/utils/markup_txt.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def markup(content, split=True, width=None):
7878
else:
7979
return "<pre>" + content + "</pre>\n"
8080

81-
def markup_unicode(content, split=True, width=None):
81+
def markup_unicode(content, split=True, width=None, container_classes=None):
8282
# normalize line endings to LF only
8383
content = content.replace("\r\n", "\n")
8484
content = content.replace("\r", "\n")
@@ -93,11 +93,12 @@ def markup_unicode(content, split=True, width=None):
9393
content = fill(content, width)
9494

9595
# expand tabs + escape
96-
content = escape(content.expandtabs())
96+
content_to_show = escape(content.expandtabs())
9797

9898
if split:
9999
n = content.find("\n", 5000)
100-
content1 = "<pre>"+content[:n+1]+"</pre>\n"
101-
return content1
102-
else:
103-
return "<pre>" + content + "</pre>\n"
100+
content_to_show = content_to_show[:n+1]
101+
102+
pre = '<pre class="%s" >' % container_classes if container_classes else '<pre>'
103+
104+
return pre+content_to_show+'</pre>\n'

0 commit comments

Comments
 (0)