[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kiwix e49d830 002/192: temporary push a not working ver
From: |
Stefan Monnier |
Subject: |
[elpa] externals/kiwix e49d830 002/192: temporary push a not working version. |
Date: |
Sat, 19 Dec 2020 00:41:21 -0500 (EST) |
branch: externals/kiwix
commit e49d8306c5052484d0a64583fffff671c40a2393
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>
temporary push a not working version.
Hope someone can involve in to make it better.
---
kiwix.el | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/kiwix.el b/kiwix.el
new file mode 100644
index 0000000..25a2d7c
--- /dev/null
+++ b/kiwix.el
@@ -0,0 +1,77 @@
+;;; kiwix.el --- Emacs client to Kiwix.
+;;; -*- coding: utf-8 -*-
+
+;;; Commentary:
+
+
+
+;;; Code:
+
+
+(defcustom kiwix-search-command "/usr/lib/kiwix/bin/kiwix-search"
+ "The kiwix-search command path."
+ :group 'kiwix)
+(defcustom kiwix-data-profile-path "~/.www.kiwix.org/kiwix/8ip89lik.default/"
+ "The kiwix profile data directory."
+ :group 'kiwix)
+
+(defvar kiwix-data-index-path nil)
+
+(setq kiwix-data-index-path (concat kiwix-data-profile-path "data/index/"))
+
+(defun kiwix-serve-index ()
+ "Open kiwix HTTP server index page."
+ (interactive)
+ ;; (browse-url "http://127.0.0.1:8000")
+ (browse-url-conkeror "http://127.0.0.1:8000")
+ )
+
+(defun kiwix-libraries ()
+ "Get a list of dirs under a specific dir."
+ ;; ~/.www.kiwix.org/kiwix/8ip89lik.default/data/content/*.zim
+ (let ((libraries
+ ;; TODO: filter out ZIM files as libraries.
+ (mapcar #'(lambda (file)
+ (let ((zim-file (string-match-p ".*\\.zim" file)))
+ zim-file))
+ (directory-files kiwix-data-index-path)
+ )))
+ libraries))
+
+(defun kiwix-serve-search (library query)
+ "Execute shell command `kiwix-search' on `LIBRARY' with `QUERY'.
+Return a list of results."
+ (let ((search-results (shell-command
+ (concat kiwix-search-command " "
+ kiwix-data-profile-path kiwix-data-index-path
+ library " " query
+ " 2> /dev/null"))))
+ search-results)
+ )
+
+(defun kiwix-serve-query (library)
+ "Query kiwix HTTP server in a specific `LIBRARY'."
+ (interactive ; FIXME: Don't know where is wrong yet.
+ (list (completing-read
+ "Kiwix Library: "
+ (let (libraries)
+ (dolist (elt (kiwix-libraries))
+ (setq libraries (append libraries (list (car elt)))))
+ libraries))))
+
+ (let ((query (read-from-minibuffer "Kiwix Query: "))
+ (results (kiwix-search library query))
+ (result (interactive
+ (list (completing-read
+ "select a result to visit: "
+ results)))))
+ (browse-url-conkeror
+ (concat "http://127.0.0.1:8000/" library "/A/" result))
+ )
+ )
+
+
+
+(provide 'kiwix)
+
+;;; kiwix.el ends here
- [elpa] branch externals/kiwix created (now 905a413), Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 4dac833 003/192: use Org-mode format README, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 004193f 005/192: first working version, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 516f512 006/192: update defcustom properties, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 1521481 007/192: update functions, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 4701ab9 001/192: Initial commit, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix e49d830 002/192: temporary push a not working version.,
Stefan Monnier <=
- [elpa] externals/kiwix e7edd5e 004/192: rename old kiwix.el to kiwix-http.el, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 06c466e 011/192: fix Kiwix query need to capitalized, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix e54e80a 016/192: update function variables, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 06b5d36 027/192: Merge branch 'master' of github.com:stardiviner/kiwix.el, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 377f3fa 014/192: add package metadata, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix d0da8cd 017/192: make package description clear, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix bd0fe09 018/192: setq-local depend on cl-lib, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 5990cc7 022/192: improve query function to specify library, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 511a11c 025/192: Merge pull request #1 from purcell/patch-1, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix b585e25 026/192: move org-mode relative code to commentary, Stefan Monnier, 2020/12/19