home » zplus/freepost.git
Author zPlus <zplus@peers.community> 2019-02-08 20:42:45
Committer zPlus <zplus@peers.community> 2019-02-08 20:42:45
Commit 375a757 (patch)
Tree d85dc9f
Parent(s)

Fix #56 Show Markdown text for all posts/comments


commits diff: 63f6d10..375a757
3 files changed, 28 insertions, 4 deletionsdownload


Diffstat
-rwxr-xr-x freepost/__init__.py 4
-rwxr-xr-x freepost/static/stylus/reset.styl 4
-rwxr-xr-x freepost/templates/post.html 24

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+4/-0 M   freepost/__init__.py
index ba8b3ff..bc930f5
old size: 27K - new size: 27K
@@ -507,6 +507,9 @@ def post_thread (hash_id):
507 507
508 508 comments = children ()
509 509
510 + # Show posts/comments Markdown instead of rendered text
511 + show_source = 'source' in request.query
512 +
510 513 # Disable browser caching
511 514 # Fix issue: https://notabug.org/zPlus/freepost/issues/80
512 515 response.set_header('cache-control', 'no-cache, no-store, must-revalidate')
@@ -517,6 +520,7 @@ def post_thread (hash_id):
517 520 'post.html',
518 521 post=post,
519 522 comments=comments,
523 + show_source=show_source,
520 524 votes = {
521 525 'post': {},
522 526 'comment': {}

+4/-0 M   freepost/static/stylus/reset.styl
index e388903..576df43
old size: 6K - new size: 6K
@@ -210,6 +210,10 @@ pre.new_year
210 210 white-space -moz-pre-wrap
211 211 white-space -o-pre-wrap
212 212
213 + /* A <div> that respects \n without converting to <br> */
214 + div.pre
215 + white-space pre
216 +
213 217 select
214 218 -webkit-appearance none
215 219 -moz-appearance none

+20/-4 M   freepost/templates/post.html
index fb3ca1b..06a0a58
old size: 4K - new size: 4K
@@ -36,15 +36,27 @@
36 36 <em>{{ post.created|ago }}</em>
37 37 </time>
38 38
39 - — {{ post.vote }} votes, <a href="#comments">{{ post.commentsCount }} comments</a>
39 +
40 +
41 + {{ post.vote }} votes, <a href="#comments">{{ post.commentsCount }} comments</a>
42 +
43 +
44 +
45 + {% if not show_source %}
46 + <a href="{{ url ('post', hash_id=post.hashId) }}?source" title="Show unrendered text">Source</a>
47 + {% endif%}
40 48
41 49 {% if user and post.userId == user.id %}
42 - — <a href="{{ url ('edit_post', hash_id=post.hashId) }}">Edit</a>
50 + <a href="{{ url ('edit_post', hash_id=post.hashId) }}" title="Edit post">Edit</a>
43 51 {% endif %}
44 52 </div>
45 53
46 54 <div class="text">
47 - {{ post.text|md2html|safe }}
55 + {% if show_source %}
56 + <div class="pre">{{ post.text }}</div>
57 + {% else %}
58 + {{ post.text|md2html|safe }}
59 + {% endif %}
48 60 </div>
49 61
50 62 {# "shortcut-submit" is a class used exclusively from javascript
@@ -94,7 +106,11 @@
94 106 </div>
95 107
96 108 <div class="text">
97 - {{ comment.text|md2html|safe }}
109 + {% if show_source %}
110 + <div class="pre">{{ comment.text }}</div>
111 + {% else %}
112 + {{ comment.text|md2html|safe }}
113 + {% endif %}
98 114 </div>
99 115 </div>
100 116 {% endfor %}