From 983cea631b2acd8920bd91b5ad4eea9952a0cc61 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson <frjo@xdeb.org> Date: Tue, 13 Nov 2018 15:31:06 +0100 Subject: [PATCH] Implement markdown filter and editor for submission comments. --- opentech/apply/activity/forms.py | 3 +++ .../activity/include/listing_base.html | 6 +++--- .../applicationsubmission_admin_detail.html | 1 + .../funds/applicationsubmission_detail.html | 1 + .../src/sass/apply/components/_editor.scss | 18 +++++++++++++++--- .../src/sass/apply/components/_feed.scss | 9 +++++++++ 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/opentech/apply/activity/forms.py b/opentech/apply/activity/forms.py index 904fde0e6..720706827 100644 --- a/opentech/apply/activity/forms.py +++ b/opentech/apply/activity/forms.py @@ -2,6 +2,8 @@ from django import forms from django.core.exceptions import ValidationError from django.utils.safestring import mark_safe +from pagedown.widgets import PagedownWidget + from .models import Activity, VISIBILILTY_HELP_TEXT, VISIBILITY @@ -15,6 +17,7 @@ class CommentForm(forms.ModelForm): } widgets = { 'visibility': forms.RadioSelect(), + 'message': PagedownWidget(), } def __init__(self, *args, user=None, **kwargs): diff --git a/opentech/apply/activity/templates/activity/include/listing_base.html b/opentech/apply/activity/templates/activity/include/listing_base.html index 15ff754d5..e76d3ec02 100644 --- a/opentech/apply/activity/templates/activity/include/listing_base.html +++ b/opentech/apply/activity/templates/activity/include/listing_base.html @@ -1,4 +1,4 @@ -{% load activity_tags %} +{% load activity_tags bleach_tags markdown_tags %} <div class="feed__item feed__item--{{ activity.type }}"> <div class="feed__pre-content"> <p class="feed__label feed__label--{{ activity.type }}">{{ activity.type|capfirst }}</p> @@ -19,13 +19,13 @@ updated <a href="{{ activity.submission.get_absolute_url }}">{{ activity.submission.title }}</a> {% endif %} - {{ activity.message|linebreaksbr }} + {{ activity.message|markdown|bleach }} {% if not submission_title and activity|user_can_see_related:request.user %} {% with url=activity.related_object.get_absolute_url %} {% if url %} <a href="{{ url }}" class="feed__related-item"> - <svg><use xlink:href="#arrow-head-pixels--solid"></use></svg> + {{ activity.related_object }} <svg><use xlink:href="#arrow-head-pixels--solid"></use></svg> </a> {% endif %} {% endwith %} diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html index 5cc8cc9b0..e0a41610a 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_admin_detail.html @@ -38,6 +38,7 @@ {% block extra_js %} {{ reviewer_form.media.js }} + {{ comment_form.media.js }} <script src="//cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.1/jquery.fancybox.min.js"></script> <script src="{% static 'js/apply/fancybox-global.js' %}"></script> <script src="{% static 'js/apply/tabs.js' %}"></script> diff --git a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html index ab0d66ee8..43041ef7a 100644 --- a/opentech/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/opentech/apply/funds/templates/funds/applicationsubmission_detail.html @@ -130,6 +130,7 @@ {% endblock %} {% block extra_js %} + {{ comment_form.media.js }} <script src="{% static 'js/apply/tabs.js' %}"></script> <script src="{% static 'js/apply/submission-text-cleanup.js' %}"></script> {% endblock %} diff --git a/opentech/static_src/src/sass/apply/components/_editor.scss b/opentech/static_src/src/sass/apply/components/_editor.scss index 22affba70..7c1c0639d 100644 --- a/opentech/static_src/src/sass/apply/components/_editor.scss +++ b/opentech/static_src/src/sass/apply/components/_editor.scss @@ -1,14 +1,26 @@ .wmd-panel { } -.wmd-button-bar { -} - .wmd-input { } .wmd-preview { background-color: $color--sky-blue; + padding: .1px 10px; + width: 100%; + + ul { + padding-left: 20px; + list-style: outside disc; + } + + ol { + list-style: inside decimal; + } + + @include media-query(tablet-portrait) { + max-width: 70%; + } } .wmd-button-row { diff --git a/opentech/static_src/src/sass/apply/components/_feed.scss b/opentech/static_src/src/sass/apply/components/_feed.scss index a3862c226..2ab489a4b 100644 --- a/opentech/static_src/src/sass/apply/components/_feed.scss +++ b/opentech/static_src/src/sass/apply/components/_feed.scss @@ -15,6 +15,15 @@ max-height: 300px; overflow: hidden; } + + ul { + padding-left: 20px; + list-style: outside disc; + } + + ol { + list-style: inside decimal; + } } &__label { -- GitLab