[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mastodon 7af46336f2 42/50: add read less button to unfolde
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mastodon 7af46336f2 42/50: add read less button to unfolded long posts (read more). FIX #614 |
Date: |
Sat, 2 Nov 2024 13:00:57 -0400 (EDT) |
branch: elpa/mastodon
commit 7af46336f2dd2ed17b3aba7b0c58b029b49767cc
Author: marty hiatt <martianhiatus@disroot.org>
Commit: marty hiatt <martianhiatus@disroot.org>
add read less button to unfolded long posts (read more). FIX #614
---
lisp/mastodon-tl.el | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 3e1d49f197..87fd710e5e 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1143,7 +1143,8 @@ the toot)."
LINK-TYPE is the type of link to produce."
(let ((help-text (cond ((eq link-type 'content-warning)
"Toggle hidden text")
- ((eq link-type 'read-more)
+ ((or (eq link-type 'read-more)
+ (eq link-type 'read-less))
"Toggle full post")
(t
(error "Unknown link type %s" link-type)))))
@@ -1187,6 +1188,8 @@ Used for hitting RET on a given link."
(error "Unable to find account"))))))))
((eq link-type 'read-more)
(mastodon-tl--unfold-post))
+ ((eq link-type 'read-less)
+ (mastodon-tl--fold-post))
(t
(error "Unknown link type %s" link-type)))))
@@ -1653,7 +1656,8 @@ Runs `mastodon-tl--render-text' and fetches poll or
media."
(string= reply-to-id prev-id)))
(defun mastodon-tl--insert-status
- (toot body &optional detailed-p thread domain unfolded no-byline)
+ (toot body &optional detailed-p thread domain unfolded no-byline
+ cw-expanded)
"Display the content and byline of timeline element TOOT.
BODY will form the section of the toot above the byline.
DETAILED-P means display more detailed info. For now
@@ -1669,7 +1673,10 @@ NO-BYLINE means just insert toot body, used for folding."
;; (type (alist-get 'type toot))
(toot-foldable
(and mastodon-tl--fold-toots-at-length
- (length> body mastodon-tl--fold-toots-at-length))))
+ (length> body mastodon-tl--fold-toots-at-length)))
+ (cw-p (not
+ (string-empty-p
+ (alist-get 'spoiler_text toot)))))
(insert
(propertize ;; body + byline:
(concat
@@ -1690,7 +1697,14 @@ NO-BYLINE means just insert toot body, used for folding."
(propertize body
'line-prefix bar
'wrap-prefix bar)
- body)))
+ body))
+ (if (and toot-foldable unfolded cw-expanded)
+ (propertize (mastodon-search--format-heading
+ (mastodon-tl--make-link "READ LESS" 'read-less)
+ nil :no-newline)
+ 'mastodon-content-warning-body cw-p
+ 'invisible (not cw-expanded))
+ ""))
'toot-body t) ;; includes newlines etc. for folding
;; byline:
"\n"
@@ -1751,7 +1765,7 @@ title, and context."
(mastodon-tl--filter-by-context context filters-no-context)))
(defun mastodon-tl--toot (toot &optional detailed-p thread domain
- unfolded no-byline no-cw)
+ unfolded no-byline cw-expanded)
"Format TOOT and insert it into the buffer.
DETAILED-P means display more detailed info. For now
this just means displaying toot client.
@@ -1761,7 +1775,7 @@ UNFOLDED is a boolean meaning whether to unfold or fold
item if foldable.
NO-BYLINE means just insert toot body, used for folding.
NO-CW means treat content warnings as unfolded."
(let* ((mastodon-tl--expand-content-warnings
- (or no-cw mastodon-tl--expand-content-warnings))
+ (or cw-expanded mastodon-tl--expand-content-warnings))
(filtered (mastodon-tl--field 'filtered toot))
(filters (when filtered
(mastodon-tl--current-filters filtered)))
@@ -1775,7 +1789,7 @@ NO-CW means treat content warnings as unfolded."
(unless (and filtered (assoc "hide" filters)) ;; no insert
(mastodon-tl--insert-status
toot (mastodon-tl--clean-tabs-and-nl spoiler-or-content)
- detailed-p thread domain unfolded no-byline))))
+ detailed-p thread domain unfolded no-byline cw-expanded))))
(defun mastodon-tl--timeline (toots &optional thread domain no-byline)
"Display each toot in TOOTS.
@@ -1853,7 +1867,7 @@ FOLD means to fold it instead."
(delete-char 1) ;; prevent newlines accumulating
;; insert toot body:
(mastodon-tl--toot toot nil nil nil (not fold) :no-byline
- (unless cw-invis :no-cw)) ;; respect CW state
+ (unless cw-invis :cw-expanded)) ;; respect CW state
;; set toot-folded prop on entire toot (not just body):
(let ((toot-range ;; post fold action range:
(mastodon-tl--find-property-range 'item-json
- [nongnu] elpa/mastodon 8a8b13dc0a 21/50: --byline: pull fave/boost/edit/visibility from base toot if present, (continued)
- [nongnu] elpa/mastodon 8a8b13dc0a 21/50: --byline: pull fave/boost/edit/visibility from base toot if present, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 1bf73f2528 33/50: remove elsa from Cask, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon ee25cb9b02 41/50: update point after widget. FIX #615, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon c09935b100 37/50: tl: remove stale args to insert status, inc. action-byline arg, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon b47390993b 46/50: Merge branch 'poll-var' into develop, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 94ea642a1a 38/50: notifs: improve byline docstrings for new byline logic, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 071c33eed2 32/50: Merge branch 'develop' into non-group-notifs, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon babb3a1adf 28/50: fold-toot - respect CW state, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 1606b34c5d 45/50: Merge branch 'read-less' into develop, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 7623478121 48/50: bump, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 7af46336f2 42/50: add read less button to unfolded long posts (read more). FIX #614,
ELPA Syncer <=
- [nongnu] elpa/mastodon bf82092dde 44/50: autoload ht-get, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 639745a885 04/50: move notifs customizes into mastodon.el, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 0e75fc74ee 01/50: group-notifs custom (for servers without). #608. WIP., ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon bfb17cdf91 10/50: docstrings tl.el, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon f3602493da 03/50: fix notifs custom group, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 8446f239bb 02/50: working v1 notifications custom. #608, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon b529690f96 06/50: notifs: refactor some v1/v2 calling code, mastodon-notifiations--body-arg, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 14e3fa36cb 11/50: start on pagination for v1 notifs. #610, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 4505b4e818 05/50: index, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 1ba949586e 29/50: tl: improve ctrl flow in --spoiler + --toot. FIX #579, ELPA Syncer, 2024/11/02