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 deletions
—
download
Diffstat
Diff options
+4/-0
M freepost/__init__.py
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
|
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
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
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
|
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 %}
|