Markdown support
This commit is contained in:
parent
8230e83528
commit
d7e7d5dc2c
@ -2,6 +2,7 @@
|
|||||||
{% block title %}
|
{% block title %}
|
||||||
{{board.title}} - {{show.name}} Discussions - Episodes.Community
|
{{board.title}} - {{show.name}} Discussions - Episodes.Community
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
{% load markdown %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container mb-5 mt-5">
|
<div class="container mb-5 mt-5">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
@ -37,9 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col border-left d-flex flex-column">
|
<div class="col border-left d-flex flex-column">
|
||||||
<p class="timestamp text-muted font-weight-light">Submitted {{board.timestamp}}</p>
|
<p class="timestamp text-muted font-weight-light">Submitted {{board.timestamp}}</p>
|
||||||
<div class="user-content mb-auto">
|
<div class="user-content mb-auto">{{reply.body|markdown|safe}}</div>
|
||||||
{{reply.body}}
|
|
||||||
</div>
|
|
||||||
<div class="actions d-flex flex-row-reverse">
|
<div class="actions d-flex flex-row-reverse">
|
||||||
<div class="vote-btns">
|
<div class="vote-btns">
|
||||||
<form method="POST" class="d-inline" action="/show/{{show.abbr}}/discuss/vote/{{reply.id}}/1">
|
<form method="POST" class="d-inline" action="/show/{{show.abbr}}/discuss/vote/{{reply.id}}/1">
|
||||||
@ -106,6 +105,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-primary">Reply</button>
|
<button type="submit" class="btn btn-primary">Reply</button>
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var simplemde = new SimpleMDE({ element: document.getElementById("id_body"), forceSync: true });
|
||||||
|
</script>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var simplemde = new SimpleMDE({ element: document.getElementById("id_body"), forceSync: true });
|
||||||
|
</script>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-primary">Create</button>
|
<button type="submit" class="btn btn-primary">Create</button>
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var simplemde = new SimpleMDE({ element: document.getElementById("id_body"), forceSync: true });
|
||||||
|
</script>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
28
Discussions/templatetags/markdown.py
Normal file
28
Discussions/templatetags/markdown.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Episodes.Community - Community-Driven TV Show Episode Link Sharing Site
|
||||||
|
# Copyright (C) 2017 Evert "Diamond" Prants <evert@lunasqu.ee>, Taizo "Tsa6" Simpson <taizo@tsa6.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
import bleach
|
||||||
|
import markdown as md
|
||||||
|
import re
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
def markdown(value):
|
||||||
|
return md.markdown(re.sub(r'\>\;', '>', bleach.clean(value)), output_format="html5")
|
||||||
|
|
||||||
|
register.filter('markdown', markdown)
|
@ -226,6 +226,7 @@ def BoardReplyForm(req, abbr, bid):
|
|||||||
|
|
||||||
if err_res:
|
if err_res:
|
||||||
return render(req, "board_reply.html", ctx)
|
return render(req, "board_reply.html", ctx)
|
||||||
|
print(form_data['body'])
|
||||||
|
|
||||||
new_reply = form.save(commit=False)
|
new_reply = form.save(commit=False)
|
||||||
new_reply.user = user
|
new_reply.user = user
|
||||||
|
@ -210,6 +210,11 @@ footer .logo .part1 {
|
|||||||
.user-content {
|
.user-content {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
blockquote {
|
||||||
|
padding-left: 16px;
|
||||||
|
border-left: 5px solid #ddd;
|
||||||
}
|
}
|
||||||
@media all and (max-width: 800px) {
|
@media all and (max-width: 800px) {
|
||||||
.logo {
|
.logo {
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
<link rel='stylesheet' type='text/css' href='{% static 'css/style.css' %}'>
|
<link rel='stylesheet' type='text/css' href='{% static 'css/style.css' %}'>
|
||||||
<link rel='stylesheet' type='text/css' href='{% static 'css/footer.css' %}'>
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
|
||||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
||||||
|
@ -4,3 +4,5 @@ dj-database-url==0.4.2
|
|||||||
requests==2.18.4
|
requests==2.18.4
|
||||||
django-guardian==1.4.9
|
django-guardian==1.4.9
|
||||||
django-widget-tweaks==1.4.1
|
django-widget-tweaks==1.4.1
|
||||||
|
markdown==2.6.11
|
||||||
|
bleach==2.1.2
|
||||||
|
Reference in New Issue
Block a user