]> WPIA git - motion.git/commitdiff
upd: allow markdown text in motion content
authorINOPIAE <m.maengel@inopiae.de>
Wed, 19 Feb 2020 05:15:25 +0000 (06:15 +0100)
committerINOPIAE <m.maengel@inopiae.de>
Sat, 9 May 2020 13:12:39 +0000 (15:12 +0200)
Markdown is used for formatting the motion text.

README.md
motion.py
requirements.txt
templates/index.html
templates/motion.html

index 3b33b93b8964cc5634335a6856bbf219fad2c769..01406efc9962c48c8a6a706577a68ff88081ae4c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -14,3 +14,9 @@ LANG=C.UTF-8 FLASK_DEBUG=1 FLASK_APP=motion.py flask run
 ```
 
 The database schema is automatically installed when the table "schema_version" does not exist and the application is started.
+
+# Usage
+
+Within the motion content markdown can be used for formatting e.g. 
+* To add a line break add two lines
+* to enter a link use `[text](https//domain.tld/link)`
index eb04effb9844d7734e69549b93532a265110b391..f6ddf1344004ee30bd5bbb40d096eadcd33cea90 100644 (file)
--- a/motion.py
+++ b/motion.py
@@ -4,6 +4,8 @@ from flask import render_template, redirect
 from flask import request
 import postgresql
 import filters
+from flaskext.markdown import Markdown
+from markdown.extensions import Extension
 
 def get_db():
     db = getattr(g, '_database', None)
@@ -15,6 +17,13 @@ def get_db():
 app = Flask(__name__)
 app.register_blueprint(filters.blueprint)
 
+class EscapeHtml(Extension):
+    def extendMarkdown(self, md, md_globals):
+        del md.preprocessors['html_block']
+        del md.inlinePatterns['html']
+
+md = Markdown(app, extensions=[EscapeHtml()])
+
 # Load config
 app.config.from_pyfile('config.py')
 
index e3bed75d65bfa63f4708330b42eb505e02b854aa..7bfcb1f7c2fe01cbdc7b0bce1d3887dd00b4d3a6 100644 (file)
@@ -5,3 +5,4 @@ Jinja2==2.10
 MarkupSafe==1.0
 py-postgresql==1.2.1
 Werkzeug==0.12.2
+Flask-Markdown==0.3
index 4ff3a44b90083c456cfe03eca077f9ffa7f3652d..125dc7c07fc7ac9fa26a90fae7140be85731323e 100644 (file)
@@ -29,6 +29,8 @@ User: {{g.user}}
   </div>
   <div class="panel-body">
     <textarea class="form-control" placeholder="Motion content" name="content" rows="8" cols="70"></textarea><br>
+    Editing note: Markdown is used formatting.<br>
+    To add a line break add two lines, to enter a link use [text](https//domain.tld/link)<br>
     <button class="btn btn-primary" type="submit">Submit Motion</button>
   </div>
 </div>
index eac27bda134706da79bfe157ad45f4d4e3d5c242..87b3e417e636bd4a5c2748ad7b4b1572a5be9a8f 100644 (file)
@@ -17,7 +17,7 @@
 {%- endif %}
   </div>
   <div class="panel-body">
-    <p>{{motion.content}}</p>
+    <p>{{motion.content|markdown}}</p>
 {%- if motion.yes or motion.no or motion.abstain %}
     <p>
 {%- for vote in ['yes', 'no', 'abstain'] %}