Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Fix formatting problem with redrafts and tags
Browse files Browse the repository at this point in the history
Plus misc. redraft problems
  • Loading branch information
jfmcbrayer committed Sep 7, 2018
1 parent 3407aa8 commit ccb21b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ six = "*"
webencodings = "*"
Django = "*"
django-html_sanitizer = "*"
inscriptis = "*"
lxml = "*"

[dev-packages]

Expand Down
3 changes: 2 additions & 1 deletion brutaldon/templates/main/toot_partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
ic-get-from="{% url "redraft" toot.id %}"
ic-indicator="#page-load-indicator"
ic-target="#main"
ic-select-from-response="#main">
ic-select-from-response="#main"
ic-push-url="true">
redraft
</a>
<a class="level-item" href="{% url "delete" toot.id %}"
Expand Down
6 changes: 4 additions & 2 deletions brutaldon/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
from mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonAPIError
from urllib import parse
from pdb import set_trace
from bs4 import BeautifulSoup
from inscriptis import get_text
from time import sleep
import re

class NotLoggedInException(Exception):
pass
Expand Down Expand Up @@ -436,7 +437,8 @@ def redraft(request, id):
if request.method == 'GET':
account, mastodon = get_usercontext(request)
toot = mastodon.status(id)
toot_content = BeautifulSoup(toot.content).get_text("\n")
toot_content = get_text(toot.content)
toot_content = re.sub("(^\n)|(\n$)", '', re.sub("\n\n", "\n", toot_content))
form = PostForm({'status': toot_content,
'visibility': toot.visibility,
'spoiler_text': toot.spoiler_text,
Expand Down

0 comments on commit ccb21b0

Please sign in to comment.