-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tui: allow editing toots #451
Conversation
Thanks! This requires more brain cells than I'm willing to invest today. I'll leave the review for next year. :) |
I suggest we don't strip the HTML when editing the toot. Rather, convert it to markdown, edit, then convert back to HTML. #427 gives the required support libraries to reliably do HTML>markdown conversion (if you're willing to put up with the pandoc+pypandoc dependencies, it really does a better job than the alternatives.) I think those libraries will do markdown>HTML conversion as well, but will have to check. |
i had a look at another library, Mastodon.py, and found it implements an endpoint called according to a brief note, this only works for local toots, but only local toots can be edited, so this is fine. hopefully, this means we don't need to do any conversion ourselves or use Pandoc, although i only use Mastodon so i don't know how this works on other implementations; presumably implementations that support Markdown will return the Markdown source. |
Good find! Was not aware of that. It's been a while since I read through the whole API docs to see what's new. |
d999639
to
8633ede
Compare
unless there are any other comments, the only thing left to land this is support for editing polls. |
As a first implementation this would be fine; we can't author rich text statuses in toot yet anyway. |
i noticed there's no support for composing polls to begin with, so now it just copies the poll from the original status (if there is one). |
fixed an issue where editing a toot without a poll would fail (because the 'poll' key is still in the status dict, it's just set to null). |
i've just noticed the issue where the updated status content isn't shown until refresh is still there. i'll add something to fix that, it looks fairly straightforward. |
Add new [E]dit command to the timeline: opens an existing toot to allow editing it. Since this is more or less the same operation as posting a new toot, extend the StatusComposer view to support this rather than implementing a new view. Add a new api method, fetch_status_source(), to implement the /api/v1/statuses/{id}/source endpoint used to fetch the original post text.
fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, tested it a bit and seems to work fine.
Interesting discovery- when editing toots containing rich text (html) on a glitch-doc server, the API call you're using automatically translates the html into markdown server-side. And reverses the translation when you submit the edit. At least this was my experience. I'll do some more testing. Unexpected and nice benefit. |
Add new [E]dit command to the timeline: opens an existing toot to allow editing it. Since this is more or less the same operation as posting a new toot, extend the StatusComposer view to support this rather than implementing a new view.
this is a draft PR because of a significant unsolved issue: the Mastodon API returns toots as HTML, not plain text, so we would need to strip the HTML from the toot before displaying it in StatusComposer. this is particularly difficult for toots with links or embeds. i'm wondering if the API provides a better way to do this, but i couldn't find anything obvious in the docs.aside from that, not all of the toot options are copied to the edited toot right now (i'll fix this), and it could also do with more testing.also, the edited toot currently doesn't show up on the timeline without a refresh.