From 8522172cac21c734c06b73c7447faaada0ef8899 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 29 Jul 2022 14:52:20 +0200 Subject: add single toot view - add detailed-p optional args to --byline, --insert-status --toot - for now, --byline just prints the app used if detailed-p - mastodon-tl--single-toot new fun to display --- lisp/mastodon-tl.el | 56 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 7aef0a1..77c4198 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -512,7 +512,7 @@ E.g. this could return something like \"1 min ago\", \"yesterday\", etc. TIME-STAMP is assumed to be in the past." (car (mastodon-tl--relative-time-details timestamp current-time))) -(defun mastodon-tl--byline (toot author-byline action-byline) +(defun mastodon-tl--byline (toot author-byline action-byline &optional detailed-p) "Generate byline for TOOT. AUTHOR-BYLINE is a function for adding the author portion of @@ -568,6 +568,21 @@ By default it is `mastodon-tl--byline-boosted'" 'display (if mastodon-tl--enable-relative-timestamps (mastodon-tl--relative-time-description parsed-time) parsed-time)) + (when detailed-p + (let* ((app (alist-get 'application toot)) + (app-name (alist-get 'name app)) + (app-url (alist-get 'website app))) + (when app + (concat + (propertize " via " 'face 'default) + (propertize app-name + 'face 'mastodon-display-name-face + 'follow-link t + 'mouse-face 'highlight + 'mastodon-tab-stop 'shr-url + 'shr-url app-url + 'help-echo app-url + 'keymap mastodon-tl--shr-map-replacement))))) (propertize "\n ------------\n" 'face 'default)) 'favourited-p faved 'boosted-p boosted @@ -859,7 +874,7 @@ Runs `mastodon-tl--render-text' and fetches poll or media." (mastodon-tl--get-poll toot)) (mastodon-tl--media toot)))) -(defun mastodon-tl--insert-status (toot body author-byline action-byline &optional id parent-toot) +(defun mastodon-tl--insert-status (toot body author-byline action-byline &optional id parent-toot detailed-p) "Display the content and byline of timeline element TOOT. BODY will form the section of the toot above the byline. @@ -880,7 +895,7 @@ PARENT-TOOT is the JSON of the toot responded to." (concat "\n" body " \n" - (mastodon-tl--byline toot author-byline action-byline)) + (mastodon-tl--byline toot author-byline action-byline detailed-p)) 'toot-id (or id ; for notifications (alist-get 'id toot)) 'base-toot-id (mastodon-tl--toot-id toot) @@ -1009,7 +1024,7 @@ in which case play first video or gif from current toot." (message "no moving image here?")) (message "no moving image here?")))) -(defun mastodon-tl--toot (toot) +(defun mastodon-tl--toot (toot &optional detailed-p) "Formats TOOT and insertes it into the buffer." (mastodon-tl--insert-status toot @@ -1018,7 +1033,10 @@ in which case play first video or gif from current toot." (mastodon-tl--spoiler toot) (mastodon-tl--content toot))) 'mastodon-tl--byline-author - 'mastodon-tl--byline-boosted)) + 'mastodon-tl--byline-boosted + nil + nil + detailed-p)) (defun mastodon-tl--timeline (toots) "Display each toot in TOOTS." @@ -1126,11 +1144,39 @@ webapp" (reblog (alist-get 'reblog json))) (if reblog (alist-get 'id reblog) id))) +(defun mastodon-tl--single-toot (&optional id) + "View toot at point in separate buffer. +ID is that of the toot to view." + (interactive) + (let* ((id + (or id + (if (equal (mastodon-tl--get-endpoint) "notifications") + ;; for boosts/faves: + (if (mastodon-tl--property 'parent-toot) + (mastodon-tl--as-string (mastodon-tl--toot-id + (mastodon-tl--property 'parent-toot))) + (mastodon-tl--property 'base-toot-id)) + (mastodon-tl--property 'base-toot-id)))) + (buffer (format "*mastodon-toot-%s*" id)) + (toot (mastodon-http--get-json + (mastodon-http--api (concat "statuses/" id))))) + (with-output-to-temp-buffer buffer + (switch-to-buffer buffer) + (mastodon-mode) + (setq mastodon-tl--buffer-spec + `(buffer-name ,buffer + endpoint ,(format "statuses/%s" id) + update-function + (lambda (toot) (message "END of thread.")))) + (let ((inhibit-read-only t)) + (mastodon-tl--toot toot :detailed-p))))) + (defun mastodon-tl--thread () "Open thread buffer for toot under `point'." (interactive) (let* ((id (if (equal (mastodon-tl--get-endpoint) "notifications") + ;; for boosts/faves: (if (mastodon-tl--property 'parent-toot) (mastodon-tl--as-string (mastodon-tl--toot-id (mastodon-tl--property 'parent-toot))) -- cgit v1.2.3 From d8ceb814f872d723fe40a5d252b8ab7aaafecc0a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 29 Jul 2022 17:01:36 +0200 Subject: --thread: detailed-p for current toot in thread context and load single toot if no thread --- lisp/mastodon-tl.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 77c4198..8bb034c 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1204,12 +1204,12 @@ ID is that of the toot to view." update-function (lambda (toot) (message "END of thread.")))) (let ((inhibit-read-only t)) - (mastodon-tl--timeline (vconcat - (alist-get 'ancestors context) - `(,toot) - (alist-get 'descendants context))))) + (mastodon-tl--timeline (alist-get 'ancestors context)) + (goto-char (point-max)) + (mastodon-tl--toot toot :detailed-p) + (mastodon-tl--timeline (alist-get 'descendants context)))) (mastodon-tl--goto-next-toot)) - (message "No Thread!")))) + (mastodon-tl--single-toot id)))) (defun mastodon-tl--create-filter () "Create a filter for a word. -- cgit v1.2.3