Commit b102bdbf authored by Abhilash Raj's avatar Abhilash Raj

Render list info using markdown renderer.

parent 85df645f
......@@ -53,7 +53,8 @@ setup(
install_requires=[
'Django>=1.11,<2.2',
'django-mailman3>=1.2.0a1',
'mailmanclient>=3.2.3a1'
'mailmanclient>=3.2.3a1',
'readme_renderer[md]',
],
tests_require=[
"mock",
......
......@@ -25,6 +25,7 @@ along with Postorius. If not, see <http://www.gnu.org/licenses/>.
be exposed as notification to admin. (Closes #327)
* Add support for ``FILTER_VHOST`` option to filter MalingLists based on
``HOST`` header of incoming request. (Closes #330)
* List Summary page now renders List info as markdown. (Closes #244)
1.2.4
......
......@@ -2,6 +2,7 @@
{% load i18n %}
{% load bootstrap_tags %}
{% load nav_helpers %}
{% load markdown %}
{% block head_title %}
{% trans 'Info' %} | {{ list.fqdn_listname }} - {{ block.super }}
......@@ -13,7 +14,9 @@
<p>{{ list.settings.description }}</p>
{% if list.settings.info %}
<p><pre style="white-space: pre-wrap; word-break: normal; border: none; background: none;">{{ list.settings.info }}</pre></p>
{% autoescape off %}
{% markdown_value list.settings.info %}
{% endautoescape %}
{% endif %}
<p>{% trans 'To contact the list owners, use the following email address:' %} <em>{{ list.settings.owner_address }}</em></p>
......
# -*- coding: utf-8 -*-
# Copyright (C) 2019 by the Free Software Foundation, Inc.
#
# This file is part of Postorius.
#
# Postorius is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Postorius 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 General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# Postorius. If not, see <http://www.gnu.org/licenses/>.
from django import template
from readme_renderer import markdown as md_render
register = template.Library()
@register.simple_tag()
def markdown_value(value):
"""Render to HTML from Markdown."""
return md_render.render(value)
......@@ -170,3 +170,26 @@ class ListSummaryPageTest(ViewTestCase):
response = self.client.get(reverse('list_summary',
args=('foo@example.com',)))
self.assertContains(response, 'List metrics')
def test_list_info(self):
# Test that list info is rendered as markdown.
settings = self.mm_client.get_list('foo@example.com').settings
info = 'Welcome To FooList today. This is something very interesting.'
settings['info'] = info
settings.save()
response = self.client.get(reverse('list_summary',
args=('foo@example.com',)))
self.assertContains(response, info)
settings['info'] = """\
Welcome To Foolist
==================
```
def function:
print('Hello World')
```
"""
settings.save()
response = self.client.get(reverse('list_summary',
args=('foo@example.com',)))
self.assertContains(response, '<pre><code>def function:')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment