mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-26 09:27:36 +01:00
- added command to switch fediverse account at runtime;
- removed hardcoded string constants.
This commit is contained in:
parent
8d03f38b4c
commit
02e0a21707
@ -151,6 +151,8 @@
|
|||||||
|
|
||||||
(define-key ">" #'open-net-address)
|
(define-key ">" #'open-net-address)
|
||||||
|
|
||||||
|
(define-key "S a" #'switch-fediverse-account)
|
||||||
|
|
||||||
(define-key "?" #'print-quick-help)
|
(define-key "?" #'print-quick-help)
|
||||||
|
|
||||||
(define-key "C d" #'clear-cache)
|
(define-key "C d" #'clear-cache)
|
||||||
@ -216,7 +218,6 @@
|
|||||||
|
|
||||||
(define-key "q" #'confirm-and-clean-close-program)
|
(define-key "q" #'confirm-and-clean-close-program)
|
||||||
|
|
||||||
|
|
||||||
;; follow requests keymap
|
;; follow requests keymap
|
||||||
|
|
||||||
(define-key "C-J" #'process-follow-requests *follow-requests-keymap*)
|
(define-key "C-J" #'process-follow-requests *follow-requests-keymap*)
|
||||||
|
@ -185,7 +185,8 @@
|
|||||||
(write-shell-array options))))))
|
(write-shell-array options))))))
|
||||||
|
|
||||||
(defun fediverse-account-parameters ()
|
(defun fediverse-account-parameters ()
|
||||||
(when-let ((splitted (cl-ppcre:split "@" *fediverse-account*)))
|
(when-let ((splitted (cl-ppcre:split +fediverse-account-name-server-separator+
|
||||||
|
*fediverse-account*)))
|
||||||
(values (elt splitted 0)
|
(values (elt splitted 0)
|
||||||
(elt splitted 1))))
|
(elt splitted 1))))
|
||||||
|
|
||||||
|
@ -277,6 +277,9 @@ list af all possible candidates for completion."
|
|||||||
(with-simple-complete language-codes
|
(with-simple-complete language-codes
|
||||||
(lambda () constants:+language-codes+))
|
(lambda () constants:+language-codes+))
|
||||||
|
|
||||||
|
(with-simple-complete fediverse-account
|
||||||
|
(lambda () (swconf:all-fediverse-accounts)))
|
||||||
|
|
||||||
(defun quote-hint (a)
|
(defun quote-hint (a)
|
||||||
(cl-ppcre:quote-meta-chars a))
|
(cl-ppcre:quote-meta-chars a))
|
||||||
|
|
||||||
|
@ -179,6 +179,8 @@ General Public License for more details."
|
|||||||
|
|
||||||
(define-constant +internal-path-gemlogs+ "gemlog" :test #'string=)
|
(define-constant +internal-path-gemlogs+ "gemlog" :test #'string=)
|
||||||
|
|
||||||
|
(define-constant +fediverse-account-name-server-separator+ "@" :test #'string=)
|
||||||
|
|
||||||
(define-constant +language-codes+ '("ab"
|
(define-constant +language-codes+ '("ab"
|
||||||
"aar"
|
"aar"
|
||||||
"af"
|
"af"
|
||||||
|
@ -195,9 +195,10 @@ etc.) happened"
|
|||||||
(ui:display-latest-visited-urls)
|
(ui:display-latest-visited-urls)
|
||||||
(ui:focus-to-message-window))
|
(ui:focus-to-message-window))
|
||||||
(ui:focus-to-thread-window))
|
(ui:focus-to-thread-window))
|
||||||
;; now init the client we do not check for empty server name as
|
;; now init the client; we do not check for empty server name
|
||||||
;; the length of server-nems and usernames must be the same (this
|
;; list, as the length of server-names and usernames must be the
|
||||||
;; rule is enforced by 'swconf:trivial-configuration-checks')
|
;; same (this rule is enforced by
|
||||||
|
;; 'swconf:trivial-configuration-checks')
|
||||||
(when (not (or *gemini-full-screen-mode*
|
(when (not (or *gemini-full-screen-mode*
|
||||||
(null (swconf::config-username))))
|
(null (swconf::config-username))))
|
||||||
(client:init)
|
(client:init)
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
:+internal-scheme+
|
:+internal-scheme+
|
||||||
:+internal-path-bookmark+
|
:+internal-path-bookmark+
|
||||||
:+internal-path-gemlogs+
|
:+internal-path-gemlogs+
|
||||||
|
:+fediverse-account-name-server-separator+
|
||||||
:+language-codes+
|
:+language-codes+
|
||||||
;; GUI
|
;; GUI
|
||||||
:+minimum-padding+
|
:+minimum-padding+
|
||||||
@ -1443,6 +1444,7 @@
|
|||||||
:config-notification-icon
|
:config-notification-icon
|
||||||
:current-username
|
:current-username
|
||||||
:current-server-name
|
:current-server-name
|
||||||
|
:all-fediverse-accounts
|
||||||
:set-current-username-and-server
|
:set-current-username-and-server
|
||||||
:config-password-echo-character
|
:config-password-echo-character
|
||||||
:config-win-focus-mark
|
:config-win-focus-mark
|
||||||
@ -1629,6 +1631,7 @@
|
|||||||
:complete-always-empty
|
:complete-always-empty
|
||||||
:bookmark-section-complete
|
:bookmark-section-complete
|
||||||
:bookmark-description-complete-clsr
|
:bookmark-description-complete-clsr
|
||||||
|
:fediverse-account
|
||||||
:language-codes))
|
:language-codes))
|
||||||
|
|
||||||
(defpackage :program-events
|
(defpackage :program-events
|
||||||
@ -3199,7 +3202,8 @@
|
|||||||
:print-mentions
|
:print-mentions
|
||||||
:delete-notifications
|
:delete-notifications
|
||||||
:show-announcements
|
:show-announcements
|
||||||
:show-parent-post))
|
:show-parent-post
|
||||||
|
:switch-fediverse-account))
|
||||||
|
|
||||||
(defpackage :scheduled-events
|
(defpackage :scheduled-events
|
||||||
(:use
|
(:use
|
||||||
|
@ -1123,6 +1123,14 @@
|
|||||||
(gen-simple-access (username)
|
(gen-simple-access (username)
|
||||||
+key-username+)
|
+key-username+)
|
||||||
|
|
||||||
|
(defun all-fediverse-accounts ()
|
||||||
|
(loop for username in (config-username)
|
||||||
|
for server-name in (config-server-name)
|
||||||
|
collect
|
||||||
|
(text-utils:strcat username
|
||||||
|
+fediverse-account-name-server-separator+
|
||||||
|
server-name)))
|
||||||
|
|
||||||
(defun current-username ()
|
(defun current-username ()
|
||||||
*current-username*)
|
*current-username*)
|
||||||
|
|
||||||
|
@ -3610,3 +3610,28 @@ gemini client certificates!)."
|
|||||||
"Delete all the password for TLS certificates that has been cached in memory."
|
"Delete all the password for TLS certificates that has been cached in memory."
|
||||||
(gemini-client:clear-cache-certificate-password)
|
(gemini-client:clear-cache-certificate-password)
|
||||||
(info-message (_ "Cache for TLS passord cleared")))
|
(info-message (_ "Cache for TLS passord cleared")))
|
||||||
|
|
||||||
|
(defun switch-fediverse-account ()
|
||||||
|
"Switch to a different fediverse account (if defined in the configuration file)"
|
||||||
|
(flet ((on-input-complete (account)
|
||||||
|
(if (find account (swconf:all-fediverse-accounts) :test #'string=)
|
||||||
|
(with-enqueued-process ()
|
||||||
|
(db::close-db)
|
||||||
|
(setf command-line::*fediverse-account* account)
|
||||||
|
(multiple-value-bind (command-line-username command-line-server-name)
|
||||||
|
(command-line:fediverse-account-parameters)
|
||||||
|
(swconf:set-current-username-and-server command-line-username
|
||||||
|
command-line-server-name)
|
||||||
|
(main::init-db)
|
||||||
|
(client:init)
|
||||||
|
(client:authorize)
|
||||||
|
(line-oriented-window:resync-rows-db *thread-window* :redraw t)
|
||||||
|
(line-oriented-window:resync-rows-db *tags-window* :redraw t)
|
||||||
|
(line-oriented-window:resync-rows-db *conversations-window* :redraw t)
|
||||||
|
(win-clear *main-window* :redraw t)))
|
||||||
|
(error-message (format nil
|
||||||
|
(_ "Unable to find the account ~a in the configuration file")
|
||||||
|
account)))))
|
||||||
|
(ask-string-input #'on-input-complete
|
||||||
|
:prompt (_ "Switch to account: ")
|
||||||
|
:complete-fn #'complete:fediverse-account)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user