[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kiwix 12e13c8 02/18: support remote Docker service
From: |
Stefan Monnier |
Subject: |
[elpa] externals/kiwix 12e13c8 02/18: support remote Docker service |
Date: |
Wed, 4 Aug 2021 18:28:08 -0400 (EDT) |
branch: externals/kiwix
commit 12e13c8e44e5d2f965b184fadcb6639c19f4c2d1
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>
support remote Docker service
---
kiwix.el | 70 ++++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 42 insertions(+), 28 deletions(-)
diff --git a/kiwix.el b/kiwix.el
index 6b07ad6..2e1bcae 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -40,7 +40,7 @@
;; :ensure t
;; :after org
;; :bind (:map document-prefix ("w" . kiwix-at-point))
-;; :init (setq kiwix-server-use-docker t
+;; :init (setq kiwix-server-type 'docker-local
;; kiwix-server-port 8080
;; kiwix-default-library "wikipedia_zh_all_2015-11.zim"))
@@ -67,22 +67,33 @@
"Kiwix customization options."
:group 'kiwix)
-(defcustom kiwix-server-use-docker t
- "Using Docker container for kiwix-serve or not?"
- :type 'boolean
- :safe #'booleanp)
+(defcustom kiwix-zim-dir "~/.www.kiwix.org/kiwix"
+ "The kiwix ZIM files directory."
+ :type 'string
+ :safe #'stringp)
+
+(defcustom kiwix-server-type 'docker-remote
+ "Specify the kiwix-serve type.
+- remote docker service
+- local docker service
+- local kiwix-serve service"
+ :type '(choice
+ (const :tag "Remote Docker Service" docker-remote)
+ (const :tag "Local Docker Service" docker-local)
+ (const :tag "Local kiwix-serve Service" kiwix-serve-local)))
+
+(defcustom kiwix-server-url "http://127.0.0.1"
+ "Specify Kiwix server URL."
+ :type 'string
+ :safe #'stringp)
(defcustom kiwix-server-port 8000
"Specify default kiwix-serve server port."
:type 'number
:safe #'numberp)
-(defcustom kiwix-server-url "http://127.0.0.1"
- "Specify Kiwix server URL."
- :type 'string)
-
(defcustom kiwix-server-command
- (when (null kiwix-server-use-docker)
+ (when (eq kiwix-server-type 'kiwix-serve-local)
(cond
((file-executable-p "/usr/bin/kiwix-serve") "/usr/bin/kiwix-serve")
((eq system-type 'gnu/linux) "/usr/lib/kiwix/bin/kiwix-serve")
@@ -192,23 +203,26 @@ Like in function `kiwix-ajax-search-hints'.")
"Launch Kiwix server."
(interactive)
(let ((library-path kiwix-default-library-dir))
- (if kiwix-server-use-docker
- (start-process
- "kiwix-server"
- " *kiwix server*"
- "docker"
- "container" "run" "-d"
- "--name" "kiwix-serve"
- "-v" (concat (file-name-directory library-path) ":" "/data")
- "kiwix/kiwix-serve"
- "--library" "library.xml")
- (start-process
- "kiwix-server"
- " *kiwix server*"
- kiwix-server-command
- "--port" (number-to-string kiwix-server-port)
- "--daemon"
- "--library" (concat library-path "library.xml")))))
+ (cl-case kiwix-server-type
+ ('docker-remote
+ (message "kiwix-serve service is started by user manually at other
place."))
+ ('docker-local (start-process
+ "kiwix-server"
+ " *kiwix server*"
+ "docker"
+ "container" "run" "-d"
+ "--name" "kiwix-serve"
+ "-v" (concat (file-name-directory library-path) ":"
"/data")
+ "-p" (format "%s:80" kiwix-server-port)
+ "kiwix/kiwix-serve"
+ "--library" "library.xml"))
+ ('kiwix-serve-local (start-process
+ "kiwix-server"
+ " *kiwix server*"
+ kiwix-server-command
+ "--port" (number-to-string kiwix-server-port)
+ "--daemon"
+ "--library" (concat library-path "library.xml"))))))
(defun kiwix-capitalize-first (string)
"Only capitalize the first word of STRING."
@@ -235,7 +249,7 @@ Like in function `kiwix-ajax-search-hints'.")
(defun kiwix-ping-server ()
"Ping Kiwix server to set `kiwix-server-available?' global state variable."
- (and kiwix-server-use-docker
+ (and (eq kiwix-server-type 'docker-local)
(or (kiwix-docker-check)
(async-shell-command "docker pull kiwix/kiwix-serve")))
(let ((inhibit-message t))
- [elpa] externals/kiwix updated (0c5e161 -> 71e770c), Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix c273429 06/18: refactor and remove the variable `kiwix--selected-library', Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix ca03a65 01/18: use Docker server by default, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix c871bef 07/18: refactor function kiwix-at-point to separate into smaller functional functions, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix 7e0b82c 04/18: refresh ZIM libraries list once-time per package loading, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix 12e13c8 02/18: support remote Docker service,
Stefan Monnier <=
- [elpa] externals/kiwix 423f607 05/18: Concentrate all kiwix library dir variables into only one, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix 716f3c4 12/18: Add condition to detect kiwix library path exist to fix GitHub Actions, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix e191c31 09/18: improve function kiwix-get-libraries to support remote Docker server, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix 0ec84f3 03/18: use dynamic ZIM library path, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix 3330d7e 08/18: Add extra library "elquery" for parsing HTTP query HTML result, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix a33c4a2 16/18: Fix kiwix-libraries variable not initialized by function kiwix-get-libraries, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix 0f85022 17/18: Add autoload cookies and improve docstring, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix f49557d 11/18: Fix format three fields, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix f9cae99 13/18: Improve kiwix-server-type docstring, Stefan Monnier, 2021/08/04
- [elpa] externals/kiwix c0c597d 14/18: Improve package config examples on README, Stefan Monnier, 2021/08/04