From cd5eeb39178427bdff3e46a7bb2a881deeed150d Mon Sep 17 00:00:00 2001
From: b3yond
Date: Fri, 25 May 2018 16:50:02 +0200
Subject: [PATCH] You can now edit markdown in settings. #18
---
README.md | 2 +-
frontend.py | 7 +++++++
template/city.tpl | 2 +-
template/settings.tpl | 4 ++--
user.py | 4 ++++
5 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 28d553b..2bdc8d7 100644
--- a/README.md
+++ b/README.md
@@ -91,7 +91,7 @@ virtualenv -p python3 .
Install the dependencies:
```shell
-pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt markdown2
+pip install tweepy pytoml Mastodon.py bottle pyjwt pylibscrypt Markdown
```
Configure the bot:
diff --git a/frontend.py b/frontend.py
index 07aff7f..a3ae423 100755
--- a/frontend.py
+++ b/frontend.py
@@ -93,6 +93,13 @@ def settings(user):
return user.state()
+@post('/settings/markdown')
+@view('template/settings.tpl')
+def update_markdown(user):
+ user.set_markdown(request.forms['markdown'])
+ return user.state()
+
+
@post('/settings/goodlist')
@view('template/settings.tpl')
def update_trigger_patterns(user):
diff --git a/template/city.tpl b/template/city.tpl
index 200fb39..7953c52 100644
--- a/template/city.tpl
+++ b/template/city.tpl
@@ -1,7 +1,7 @@
% rebase('template/wrapper.tpl')
<%
-import markdown2 as md
+import markdown as md
html = md.markdown(markdown)
%>
diff --git a/template/settings.tpl b/template/settings.tpl
index ddaa161..cd7e524 100644
--- a/template/settings.tpl
+++ b/template/settings.tpl
@@ -75,8 +75,8 @@
needs. You should definitely adjust the Social Media profile links. This is just the default text we
suggest:
-
diff --git a/user.py b/user.py
index 9cbea03..95b0a92 100644
--- a/user.py
+++ b/user.py
@@ -227,6 +227,10 @@ schlitz
"VALUES(?, ?, ?, ?);", (self.uid, access_token, instance_id, 1))
db.commit()
+ def set_markdown(self, markdown):
+ db.execute("UPDATE cities SET markdown = ? WHERE user_id = ?;",
+ (markdown, self.uid))
+
def get_city(self):
db.execute("SELECT city FROM cities WHERE user_id == ?;", (self.uid, ))
return db.cur.fetchone()[0]