mirror of
https://codeberg.org/cage/tinmop/
synced 2025-01-22 03:25:41 +01:00
- [GUI] added a command to import a bookmarks page.
This commit is contained in:
parent
a32ad1ce1c
commit
47b7ba767c
@ -235,6 +235,8 @@ keybinding.bookmark.show = "Alt-b"
|
||||
|
||||
keybinding.bookmark.export = "Alt-e"
|
||||
|
||||
keybinding.bookmark.import = "Alt-i"
|
||||
|
||||
keybinding.gemtext.scaling.increase = "Control-plus"
|
||||
|
||||
keybinding.gemtext.scaling.decrease = "Control-minus"
|
||||
@ -243,8 +245,6 @@ keybinding.gemtext.scaling.reset = "Control-0"
|
||||
|
||||
keybinding.gemtext.refresh = "Control-r"
|
||||
|
||||
|
||||
|
||||
# emphasize text
|
||||
|
||||
emphasize.wrapped.asterisk = yes
|
||||
|
@ -46,6 +46,7 @@
|
||||
up
|
||||
bookmark
|
||||
export
|
||||
import
|
||||
toggle
|
||||
show
|
||||
select
|
||||
@ -421,6 +422,13 @@
|
||||
+key-bookmark+
|
||||
+key-export+)
|
||||
|
||||
(swconf:gen-simple-access (keybinding-bookmark-import
|
||||
:transform-value-fn (lambda (a) (keybinding->tk-event a))
|
||||
:configuration-tree *client-configuration*)
|
||||
+key-keybinding+
|
||||
+key-bookmark+
|
||||
+key-import+)
|
||||
|
||||
(swconf:gen-simple-access (keybinding-gemtext-scaling-increase
|
||||
:transform-value-fn (lambda (a) (keybinding->tk-event a))
|
||||
:configuration-tree *client-configuration*)
|
||||
|
@ -271,6 +271,10 @@
|
||||
(_ "Export")
|
||||
(menu:export-bookmarks-clsr main-window)
|
||||
:accelerator (client-configuration:config-keybinding-bookmark-export))
|
||||
(gui:make-menubutton bookmarks
|
||||
(_ "Import")
|
||||
(menu:import-bookmarks-clsr main-window)
|
||||
:accelerator (client-configuration:config-keybinding-bookmark-import))
|
||||
(gui:make-menubutton bookmarks (_ "Manage") (menu:manage-bookmarks-clsr main-window))
|
||||
(gui:make-menubutton tour
|
||||
(_ "Manage")
|
||||
|
@ -80,6 +80,46 @@
|
||||
(write-sequence page stream)
|
||||
(info-operation-completed main-window)))))))
|
||||
|
||||
(defun import-bookmarks-clsr (main-window)
|
||||
(lambda ()
|
||||
(a:when-let ((file-path (gui:get-open-file :file-types (list (list (_ "Gemtext files")
|
||||
"*.gmi"))
|
||||
:title (_ "Choose file for importing…")
|
||||
:parent main-window)))
|
||||
(cond
|
||||
((fs:directory-exists-p file-path)
|
||||
(error-dialog main-window (format nil "~a is a directory" file-path)))
|
||||
((not (fs:file-exists-p file-path))
|
||||
(error-dialog main-window (format nil "file ~a does not exists" file-path)))
|
||||
(t
|
||||
(let* ((page (fs:slurp-file file-path))
|
||||
(parsed-page (cev:enqueue-request-and-wait-results :gemini-parse-string
|
||||
1
|
||||
ev:+standard-event-priority+
|
||||
page))
|
||||
(errors '()))
|
||||
(loop with current-category = (_ "Default")
|
||||
for line in parsed-page do
|
||||
(cond
|
||||
((string= (getf line :type) "h2")
|
||||
(setf current-category (getf line :line (_ "Default"))))
|
||||
((string= (getf line :type) "a")
|
||||
(let ((iri (getf line :href))
|
||||
(description (getf line :line)))
|
||||
(if (gemini-parser:gemini-iri-p iri)
|
||||
(ev:with-enqueued-process-and-unblock ()
|
||||
(comm:make-request :gemini-bookmark-delete 1 iri)
|
||||
(comm:make-request :gemini-bookmark-add
|
||||
1
|
||||
iri
|
||||
current-category
|
||||
description))
|
||||
(push (format nil "unable to parse ~a" iri) errors))))))
|
||||
(ev:with-enqueued-process-and-unblock ()
|
||||
(if errors
|
||||
(error-dialog main-window (format nil "~{~a~%~}" errors))
|
||||
(info-operation-completed main-window)))))))))
|
||||
|
||||
(defun manage-bookmarks-clsr (main-window)
|
||||
(lambda ()
|
||||
(client-bookmark-window:manage-bookmarks main-window)))
|
||||
|
@ -3400,6 +3400,7 @@
|
||||
:config-keybinding-bookmark-toggle
|
||||
:config-keybinding-bookmark-show
|
||||
:config-keybinding-bookmark-export
|
||||
:config-keybinding-bookmark-import
|
||||
:main-window-select-colors
|
||||
:emphasize-wrapped-asterisk-p
|
||||
:config-inline-scaling-ratio
|
||||
@ -3549,6 +3550,7 @@
|
||||
:show-streams
|
||||
:show-bookmarks-clsr
|
||||
:export-bookmarks-clsr
|
||||
:import-bookmarks-clsr
|
||||
:manage-bookmarks-clsr
|
||||
:show-search-frame-clsr
|
||||
:show-tour
|
||||
|
Loading…
Reference in New Issue
Block a user