From 375a757a8dc271d3da0ab6d131fa1ba82e2708cb Mon Sep 17 00:00:00 2001 From: zPlus Date: Fri, 8 Feb 2019 21:42:45 +0100 Subject: [PATCH] Fix #56 Show Markdown text for all posts/comments --- freepost/__init__.py | 4 ++++ freepost/static/stylus/reset.styl | 4 ++++ freepost/templates/post.html | 24 ++++++++++++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/freepost/__init__.py b/freepost/__init__.py index ba8b3ff3..bc930f5b 100755 --- a/freepost/__init__.py +++ b/freepost/__init__.py @@ -507,6 +507,9 @@ def post_thread (hash_id): comments = children () + # Show posts/comments Markdown instead of rendered text + show_source = 'source' in request.query + # Disable browser caching # Fix issue: https://notabug.org/zPlus/freepost/issues/80 response.set_header('cache-control', 'no-cache, no-store, must-revalidate') @@ -517,6 +520,7 @@ def post_thread (hash_id): 'post.html', post=post, comments=comments, + show_source=show_source, votes = { 'post': {}, 'comment': {} diff --git a/freepost/static/stylus/reset.styl b/freepost/static/stylus/reset.styl index e3889035..576df430 100755 --- a/freepost/static/stylus/reset.styl +++ b/freepost/static/stylus/reset.styl @@ -210,6 +210,10 @@ pre.new_year white-space -moz-pre-wrap white-space -o-pre-wrap +/* A
that respects \n without converting to
*/ +div.pre + white-space pre + select -webkit-appearance none -moz-appearance none diff --git a/freepost/templates/post.html b/freepost/templates/post.html index fb3ca1b1..06a0a58e 100755 --- a/freepost/templates/post.html +++ b/freepost/templates/post.html @@ -36,15 +36,27 @@ {{ post.created|ago }} - — {{ post.vote }} votes, {{ post.commentsCount }} comments + — + + {{ post.vote }} votes, {{ post.commentsCount }} comments + + — + + {% if not show_source %} + Source + {% endif%} {% if user and post.userId == user.id %} - — Edit + Edit {% endif %}
- {{ post.text|md2html|safe }} + {% if show_source %} +
{{ post.text }}
+ {% else %} + {{ post.text|md2html|safe }} + {% endif %}
{# "shortcut-submit" is a class used exclusively from javascript @@ -94,7 +106,11 @@
- {{ comment.text|md2html|safe }} + {% if show_source %} +
{{ comment.text }}
+ {% else %} + {{ comment.text|md2html|safe }} + {% endif %}
{% endfor %}