From 353afcad0f2a6802719eb987be6de861de3e2e8e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 10 Oct 2024 11:39:50 +0200 Subject: WIP. display fediverse account of link authors if available. --- lisp/mastodon-tl.el | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2e0588f..3f06756 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -875,17 +875,46 @@ links in the text. If TOOT is nil no parsing occurs." 0 (- (window-width) 3))))) (shr-render-region (point-min) (point-max))) - ;; Make all links a tab stop recognized by our own logic, make things point - ;; to our own logic (e.g. hashtags), and update keymaps where needed: + ;; Make all links a tab stop recognized by our own logic, make + ;; things point to our own logic (e.g. hashtags), and update keymaps + ;; where needed: (when toot (let (region) (while (setq region (mastodon-tl--find-property-range 'shr-url (or (cdr region) (point-min)))) (mastodon-tl--process-link toot (car region) (cdr region) - (get-text-property (car region) 'shr-url))))) + (get-text-property (car region) 'shr-url)) + (when (proper-list-p toot) ;; not on profile fields cons cells + (let* ((card (alist-get 'card toot)) + (card-url (alist-get 'url card)) + (authors (alist-get 'authors card)) + (url (buffer-substring (car region) (cdr region))) + (url-no-query (car (split-string url "?")))) + (when (and (string= url-no-query card-url) + ;; only if we have an account's data: + (alist-get 'account (car authors))) + (goto-char (point-max)) ;;(cdr region)) + (mastodon-tl--insert-card-authors authors))))))) (buffer-string)))) +(defun mastodon-tl--insert-card-authors (authors) + "Insert a string of card AUTHORS." + (insert + (concat + "\n(Authors: " + (cl-loop for x in authors + concat + (mastodon-tl--format-card-author x)) + ")\n"))) + +(defun mastodon-tl--format-card-author (data) + "Render card author DATA." + ;; FIXME: update as needed, data contains "name" "url" and "account" + (let-alist data + (when .account + (mastodon-search--propertize-user .account)))) + (defun mastodon-tl--process-link (toot start end url) "Process link URL in TOOT as hashtag, userhandle, or normal link. START and END are the boundaries of the link in the toot." @@ -1553,7 +1582,7 @@ NO-BYLINE means just insert toot body, used for folding." (propertize ;; body only: (concat "\n" - ;; relpy symbol (broken): + ;; relpy symbol: (when (and after-reply-status-p thread) (concat (mastodon-tl--symbol 'replied) "\n")) -- cgit v1.2.3 From 11fc4f01c4934e5d687382f3ccb301cb8343a6d9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 13 Oct 2024 17:01:32 +0200 Subject: re-do display of card (link) author. #596 --- lisp/mastodon-tl.el | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3f06756..c4abbf0 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -886,6 +886,7 @@ links in the text. If TOOT is nil no parsing occurs." (car region) (cdr region) (get-text-property (car region) 'shr-url)) (when (proper-list-p toot) ;; not on profile fields cons cells + ;; render card author maybe: (let* ((card (alist-get 'card toot)) (card-url (alist-get 'url card)) (authors (alist-get 'authors card)) @@ -894,7 +895,7 @@ links in the text. If TOOT is nil no parsing occurs." (when (and (string= url-no-query card-url) ;; only if we have an account's data: (alist-get 'account (car authors))) - (goto-char (point-max)) ;;(cdr region)) + (goto-char (point-max)) (mastodon-tl--insert-card-authors authors))))))) (buffer-string)))) @@ -903,17 +904,30 @@ links in the text. If TOOT is nil no parsing occurs." (insert (concat "\n(Authors: " - (cl-loop for x in authors - concat - (mastodon-tl--format-card-author x)) + (mapconcat #'mastodon-tl--format-card-author authors "\n") ")\n"))) (defun mastodon-tl--format-card-author (data) "Render card author DATA." ;; FIXME: update as needed, data contains "name" "url" and "account" - (let-alist data - (when .account - (mastodon-search--propertize-user .account)))) + (when (alist-get 'account data) ;.account + (let-alist (alist-get 'account data) ;.account + ;; FIXME: replace with refactored handle render fun + ;; in byline refactor branch: + (concat + (propertize .username + 'face 'mastodon-display-name-face + 'byline t + 'item-type 'user + 'item-id .id) + " " + (propertize (concat "@" .acct) + 'face 'mastodon-handle-face + 'mouse-face 'highlight + 'mastodon-tab-stop 'user-handle + 'keymap mastodon-tl--link-keymap + 'mastodon-handle (concat "@" .acct) + 'help-echo (concat "Browse user profile of @" .acct)))))) (defun mastodon-tl--process-link (toot start end url) "Process link URL in TOOT as hashtag, userhandle, or normal link. -- cgit v1.2.3 From 8b4d1cbf0727879e5cbeb2f8af985cea1683c771 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 10:04:52 +0200 Subject: no byline prop for card author --- lisp/mastodon-tl.el | 1 - 1 file changed, 1 deletion(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index c4abbf0..b32fe70 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -917,7 +917,6 @@ links in the text. If TOOT is nil no parsing occurs." (concat (propertize .username 'face 'mastodon-display-name-face - 'byline t 'item-type 'user 'item-id .id) " " -- cgit v1.2.3 From 652c17da292065d760d8ad455dba9dd26ac49ba1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 14 Oct 2024 13:26:29 +0200 Subject: card authors tiny clean up. #596. --- lisp/mastodon-tl.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index b32fe70..e2cba94 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -901,17 +901,18 @@ links in the text. If TOOT is nil no parsing occurs." (defun mastodon-tl--insert-card-authors (authors) "Insert a string of card AUTHORS." - (insert - (concat - "\n(Authors: " - (mapconcat #'mastodon-tl--format-card-author authors "\n") - ")\n"))) + (let ((authors-str (format "Author%s: " + (if (< 1 (length authors)) "s" "")))) + (insert + (concat + "\n(" authors-str + (mapconcat #'mastodon-tl--format-card-author authors "\n") + ")\n")))) (defun mastodon-tl--format-card-author (data) "Render card author DATA." - ;; FIXME: update as needed, data contains "name" "url" and "account" - (when (alist-get 'account data) ;.account - (let-alist (alist-get 'account data) ;.account + (when-let ((account (alist-get 'account data))) ;.account + (let-alist account ;.account ;; FIXME: replace with refactored handle render fun ;; in byline refactor branch: (concat -- cgit v1.2.3