You can now edit markdown in settings. #18

master
b3yond 2018-05-25 16:50:02 +02:00
parent b43779e6c8
commit 4aae0ba1df
5 changed files with 15 additions and 4 deletions

View File

@ -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:

View File

@ -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):

View File

@ -1,7 +1,7 @@
% rebase('template/wrapper.tpl')
<%
import markdown2 as md
import markdown as md
html = md.markdown(markdown)
%>

View File

@ -75,8 +75,8 @@
needs. <b>You should definitely adjust the Social Media profile links.</b> This is just the default text we
suggest:
</p>
<form action="/settings/goodlist" method="post">
<textarea id="markdown" rows="20" cols="70" name="goodlist" wrap="physical">{{markdown}}</textarea>
<form action="/settings/markdown" method="post">
<textarea id="markdown" rows="20" cols="70" name="markdown" wrap="physical">{{markdown}}</textarea>
<input name='confirm' value='Save' type='submit'/>
</form>
</div>

View File

@ -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]