From 3c40f6dbb855fb4a3100f1822c4d2a29c29737a2 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 27 Aug 2022 11:21:24 +0200 Subject: readme CI status --- README.org | 2 ++ 1 file changed, 2 insertions(+) (limited to 'README.org') diff --git a/README.org b/README.org index 53bfc3c..f8e3af4 100644 --- a/README.org +++ b/README.org @@ -1,5 +1,7 @@ #+OPTIONS: toc:nil +[[https://ci.codeberg.org/api/badges/martianh/mastodon.el/status.svg]] + * README =mastodon.el= is an Emacs client for the Mastodon and Pleroma social networks. For info see https://joinmastodon.org/. -- cgit v1.2.3 From 6f7c564d90b7d477ef600a9ffb742faaaf38d3fb Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 31 Aug 2022 14:31:14 +0200 Subject: readme clean up --- README.org | 5 ----- 1 file changed, 5 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 3b91224..baa7dfa 100644 --- a/README.org +++ b/README.org @@ -216,12 +216,7 @@ See =M-x customize-group RET mastodon= to view all customize options. - Enable image caching - Compose options: - - Default toot visibility, using =mastodon-toot--default-visibility= variable. Valid values are ="public"=, ="unlisted"=, ="private"=, or =direct=. -<<<<<<< HEAD - - Completions for user mentions -======= - Completion for mentions and tags ->>>>>>> develop - Enable custom emoji *** live-updating timelines: =mastodon-async-mode= -- cgit v1.2.3 From 889e7079efe2ea266491dc383491a8a3dfb6ca94 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 31 Aug 2022 15:32:27 +0200 Subject: readme contributors --- README.org | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index baa7dfa..b950681 100644 --- a/README.org +++ b/README.org @@ -219,7 +219,7 @@ See =M-x customize-group RET mastodon= to view all customize options. - Completion for mentions and tags - Enable custom emoji -*** live-updating timelines: =mastodon-async-mode= +*** Live-updating timelines: =mastodon-async-mode= (code taken from https://github.com/alexjgriffith/mastodon-future.el.) @@ -232,7 +232,7 @@ To enable, it, add =(require 'mastodon-async)= to your =init.el=. Then you can view a timeline with one of the commands that begin with =mastodon-async--stream-=. -*** translating toots +*** Translating toots You can translate toots with =mastodon-toot--translate-toot-text=. At the moment this requires [[https://codeberg.org/martianh/lingva.el][lingva.el]], a little interface I wrote to https://lingva.ml, to @@ -255,7 +255,7 @@ to your translator function as its text argument. Here's what (message "No toot to translate?")))) #+end_src -** dependencies +** Dependencies This version depends on the library =request= (for uploading attachments). You can install it from MELPA, or https://github.com/tkf/emacs-request. @@ -281,3 +281,15 @@ PRs, issues, and feature requests are very welcome! 1. In an [[https://github.com/jdenen/mastodon.el/issues][issue]], let me know that you're working to fix it. 2. Fork the repository and create a branch off of =develop=. 3. Create a pull request referencing the issue from step 1. + +** Contributors: + +=mastodon.el= is a the work of a number of people. + +Some significant contributors are: + +- https://github.com/jdenen [original author] +- http://atomized.org +- https://alexjgriffith.itch.io +- https://github.com/hdurer +- https://codeberg.org/Red_Starfish -- cgit v1.2.3 From ee35f8c94d6ee76d75bdf85f2b495df4ce6c5a94 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 1 Sep 2022 11:04:25 +0200 Subject: readme account settings funcs --- README.org | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'README.org') diff --git a/README.org b/README.org index b950681..d9e0b39 100644 --- a/README.org +++ b/README.org @@ -219,6 +219,13 @@ See =M-x customize-group RET mastodon= to view all customize options. - Completion for mentions and tags - Enable custom emoji +*** Account settings: + +- =mastodon-profile-update-display-name=: Update the display name for your account. +- =mastodon-profile-set-default-toot-visibility=: Set the default visibility for your toots. +- =mastodon-profile-account-locked-toggle=: Toggle the locked status of your account. Locked accounts have to manually approve follow requests. +- =mastodon-profile-account-discoverable-toggle=: Toggle the discoverable status of your account. Non-discoverable accounts are not listed in the profile directory. + *** Live-updating timelines: =mastodon-async-mode= (code taken from https://github.com/alexjgriffith/mastodon-future.el.) -- cgit v1.2.3 From c6aa74e6942f5156e43a027c54862bfd68270911 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Thu, 1 Sep 2022 14:19:03 +0200 Subject: melpa badge --- README.org | 1 + 1 file changed, 1 insertion(+) (limited to 'README.org') diff --git a/README.org b/README.org index d9e0b39..815e99f 100644 --- a/README.org +++ b/README.org @@ -1,6 +1,7 @@ #+OPTIONS: toc:nil [[https://ci.codeberg.org/api/badges/martianh/mastodon.el/status.svg]] +https://melpa.org/packages/mastodon-badge.svg * README -- cgit v1.2.3 From 3ec2f7814aa11f860658e4e995ea4f8accc9499a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 2 Sep 2022 08:33:04 +0200 Subject: work on printing instance details more work on printing instance details readme - instance description more more work on printing instance details more more more work on printing instance details --- README.org | 18 ++++--- lisp/mastodon-tl.el | 141 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 122 insertions(+), 37 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 815e99f..a2b047a 100644 --- a/README.org +++ b/README.org @@ -99,7 +99,7 @@ restart Emacs and follow the steps again. =M-x mastodon= -Opens a =*mastodon-home*= buffer in the major mode and displays toots. You +Opens a =*mastodon-home*= buffer in the major mode and displays toots. If your credentials are not yet saved, you will be prompted for email and password. The app registration process will take place if your =mastodon-token-file= does not contain =:client_id= and =:client_secret=. @@ -204,6 +204,15 @@ You can download and use your instance's custom emoji | =C-c C-e= | add emoji (if =emojify= installed) | |---------+----------------------------------| +*** Other commands and account settings: + +- =mastodon-tl-view-instance-description=: View information about the instance that the author of the toot at point is on. + +- =mastodon-profile-update-display-name=: Update the display name for your account. +- =mastodon-profile-set-default-toot-visibility=: Set the default visibility for your toots. +- =mastodon-profile-account-locked-toggle=: Toggle the locked status of your account. Locked accounts have to manually approve follow requests. +- =mastodon-profile-account-discoverable-toggle=: Toggle the discoverable status of your account. Non-discoverable accounts are not listed in the profile directory. + *** Customization See =M-x customize-group RET mastodon= to view all customize options. @@ -220,13 +229,6 @@ See =M-x customize-group RET mastodon= to view all customize options. - Completion for mentions and tags - Enable custom emoji -*** Account settings: - -- =mastodon-profile-update-display-name=: Update the display name for your account. -- =mastodon-profile-set-default-toot-visibility=: Set the default visibility for your toots. -- =mastodon-profile-account-locked-toggle=: Toggle the locked status of your account. Locked accounts have to manually approve follow requests. -- =mastodon-profile-account-discoverable-toggle=: Toggle the discoverable status of your account. Non-discoverable accounts are not listed in the profile directory. - *** Live-updating timelines: =mastodon-async-mode= (code taken from https://github.com/alexjgriffith/mastodon-future.el.) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d74f003..7092352 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -34,7 +34,7 @@ (require 'shr) (require 'thingatpt) ; for word-at-point (require 'time-date) -(require 'cl-lib) ; for cl-mapcar +(require 'cl-lib) (require 'mpv nil :no-error) @@ -1363,8 +1363,26 @@ RESPONSE is the JSON returned by the server." (message "Looks like there's no toot or user at point?") ,@body)) -(defun mastodon-tl-view-instance-description () - "View the details of the instance the current post's author is on." +(defun mastodon-tl-view-own-instance (&optional brief) + "View details of your own instance. +BRIEF means show fewer details." + (interactive) + (mastodon-tl-view-instance-description :user brief)) + +(defun mastodon-tl-view-own-instance-brief () + "View brief details of your own instance." + (interactive) + (mastodon-tl-view-instance-description :user :brief)) + +(defun mastodon-tl-view-instance-description-brief () + "View brief details of the instance the current post's author is on." + (interactive) + (mastodon-tl-view-instance-description nil :brief)) + +(defun mastodon-tl-view-instance-description (&optional user brief) + "View the details of the instance the current post's author is on. +USER means to show the instance details for the logged in user. +BRIEF means to show fewer details." (interactive) (mastodon-tl--do-if-toot (let* ((toot (mastodon-tl--property 'toot-json)) @@ -1378,41 +1396,106 @@ RESPONSE is the JSON returned by the server." (string-remove-prefix (concat username "@") acct))) (response (mastodon-http--get-json - (concat instance - "/api/v1/instance")))) + (if user + (mastodon-http--api "instance") + (concat instance + "/api/v1/instance"))))) (when response - (let ((buf (get-buffer-create "*mastodon-preferences*"))) + (let ((buf (get-buffer-create "*mastodon-instance*"))) (with-current-buffer buf - ;; (setq masto-test-inst-json response) (switch-to-buffer-other-window buf) (let ((inhibit-read-only t)) (erase-buffer) (special-mode) + (when brief + (setq response + (list (assoc 'uri response) + (assoc 'title response) + (assoc 'short_description response) + (assoc 'email response) + (cons 'contact_account + (list + (assoc 'username + (assoc 'contact_account response)))) + (assoc 'rules response) + (assoc 'stats response)))) (mastodon-tl--print-json-keys response) (goto-char (point-min))))))))) -(defun mastodon-tl--print-json-keys (response) - "Print the JSON keys and values in RESPONSE." - (while response - (let ((el (pop response))) - (if (equal (type-of (cdr el)) 'cons) - (progn - (setq-local left-margin 4) - (insert - (mastodon-tl--render-text - (format "%-20s: " - (prin1-to-string (car el))) - nil) - "\n") - (indent-to-left-margin) - (mastodon-tl--print-json-keys (cdr el))) - (insert - (mastodon-tl--render-text - (format "%-20s: %s" - (prin1-to-string (car el)) - (prin1-to-string (cdr el))) - nil) - "\n"))))) +(defun mastodon-tl--format-key (el pad) + "Format a key of element EL, a cons, with PAD padding." + (format (concat "%-" + (number-to-string pad) + "s: ") + (prin1-to-string (car el)))) + +(defun mastodon-tl--print-json-keys (response &optional ind) + "Print the JSON keys and values in RESPONSE. +IND is the optional indentation level to print at." + (let* ((cars (mapcar + (lambda (x) (symbol-name (car x))) + response)) + (pad (1+ (cl-reduce #'max (mapcar #'length cars))))) + (while response + (let ((el (pop response))) + (cond + ;; vector of alists (fields, instance rules): + ((and (equal (type-of (cdr el)) 'vector) + (not (seq-empty-p (cdr el))) + (equal (type-of (seq-elt (cdr el) 0)) 'cons)) + (insert + (mastodon-tl--format-key el pad) + "\n\n") + (seq-do #'mastodon-tl--print-instance-rules-or-fields (cdr el)) + (insert "\n")) + ;; vector of strings (media types): + ((and (equal (type-of (cdr el)) 'vector) + (not (seq-empty-p (cdr el))) + (< 1 (seq-length (cdr el))) + (equal (type-of (seq-elt (cdr el) 0)) 'string)) + (when ind (indent-to ind)) + (insert + (mastodon-tl--format-key el pad) + "\n" + (seq-mapcat + (lambda (x) (concat x ", ")) + (cdr el) 'string) + "\n\n")) + ;; basic nesting: + ((equal (type-of (cdr el)) 'cons) + (when ind (indent-to ind)) + (insert + (mastodon-tl--format-key el pad) + "\n\n") + (mastodon-tl--print-json-keys + (cdr el) (if ind (+ ind 4) 4))) + (t + (when ind (indent-to ind)) + (insert (mastodon-tl--format-key el pad) + " " + (mastodon-tl--newline-if-long el) + (mastodon-tl--render-text + (prin1-to-string (cdr el))) + "\n"))))))) + +(defun mastodon-tl--print-instance-rules-or-fields (alist) + "Print ALIST of instance rules or contact account fields." + (let ((key (if (alist-get 'id alist) 'id 'name)) + (value (if (alist-get 'id alist) 'text 'value))) + (indent-to 4) + (insert (format "%-5s: " + (alist-get key alist)) + (mastodon-tl--newline-if-long (assoc value alist)) + (format "%s" (mastodon-tl--render-text + (alist-get value alist))) + "\n"))) + +(defun mastodon-tl--newline-if-long (el) + "Return a newline string if the cdr of EL is over 50 characters long." + (if (and (sequencep (cdr el)) + (< 50 (length (cdr el)))) + "\n" + "")) (defun mastodon-tl--follow-user (user-handle &optional notify) "Query for USER-HANDLE from current status and follow that user. -- cgit v1.2.3