diff options
author | Aaron Bentley <abentley@panoramicfeedback.com> | 2006-02-06 13:06:13 -0500 |
---|---|---|
committer | Aaron Bentley <abentley@panoramicfeedback.com> | 2006-02-06 13:06:13 -0500 |
commit | b1c1acfdb3f466fc5e385902cd915899df2970c4 (patch) | |
tree | 0a099dc79dd0fad6999c84a01a66a461ba25cfc4 /beweb | |
parent | 4b8bcd3818ee319d3ec5086b89083beb0501c784 (diff) | |
download | bugseverywhere-b1c1acfdb3f466fc5e385902cd915899df2970c4.tar.gz |
Nicer comment bodies
Diffstat (limited to 'beweb')
-rw-r--r-- | beweb/beweb/templates/edit_bug.kid | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/beweb/beweb/templates/edit_bug.kid b/beweb/beweb/templates/edit_bug.kid index 89c4208..206f4ba 100644 --- a/beweb/beweb/templates/edit_bug.kid +++ b/beweb/beweb/templates/edit_bug.kid @@ -27,6 +27,34 @@ def select_among(name, options, default, display_names=None): display_name)) output.append("</select>") return XML("".join(output)) + +def to_unix(text): + skip_newline = False + for ch in text: + if ch not in ('\r', '\n'): + yield ch + else: + if ch == '\n': + if skip_newline: + continue + else: + skip_newline = True + yield '\n' + +def soft_text(text): + translations = {'\n': '<br />\n', '&': '&', '\x3c': '<', + '\x3e': '>'} + for ch in to_unix(text): + if ch == ' ' and first_space is True: + yield ' ' + first_space = ch in (' ') + try: + yield translations[ch] + except KeyError: + yield ch +def soft_pre(text): + return XML('<div style="font-family: monospace">'+ + ''.join(soft_text(text))+'</div>') ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:extends="'master.kid'"> @@ -50,7 +78,7 @@ def select_among(name, options, default, display_names=None): <tr><td>From</td><td>${comment.From}</td></tr> <tr><td>Date</td><td>${time_to_str(comment.date)}</td></tr> </table> - <pre>${comment.body}</pre> + <div py:content="soft_pre(comment.body)" py:strip="True"></div> <a href="${comment_url(project_id, bug.uuid, comment.uuid)}">Edit</a> </insetbox> </div> |