216 Commits

Author SHA1 Message Date
Matthieu Gautier
ee75bc72f5 Time to switch the CI to focal. 2023-10-08 18:29:45 +02:00
Matthieu Gautier
7f0c1d8a3f Merge pull request #642 from kiwix/fix_docs 2023-10-06 15:47:10 +02:00
Matthieu Gautier
bd9e67f48e Add readthedocs configuration 2023-10-06 15:33:40 +02:00
Kelson
a4cc4ba55b Merge pull request #636 from kiwix/cpp17
Move to c++17.
2023-09-22 17:38:55 +02:00
Matthieu Gautier
1a1274012f Move to c++17.
All our compilers should handle c++17. Let's move on.
2023-08-30 17:58:40 +02:00
Kelson
74712ff022 Merge pull request #631 from kiwix/kiwix-serve-docker-readme
Dedicated Docker Compose section
2023-08-13 09:39:44 +02:00
Emmanuel Engelhart
3c6971fced Dedicated Docker Compose section 2023-08-13 09:38:59 +02:00
Kelson
7a7eaaba0e Merge pull request #626 from iArchitSharma/patch-1
Added missing parameters to kiwix-serve.1
2023-07-12 15:20:43 +02:00
Archit Sharma
d166947447 Added missing parameters to kiwix-serve.1 2023-07-12 13:38:11 +05:30
Kelson
92ee72a8f2 Merge pull request #622 from kiwix/new-archs
Docker images for new architectures
2023-06-16 18:03:35 +02:00
renaud gaudin
d0f8226f50 Docker images for new architectures
- Fixes the release filename for arm64 and armv7
- Add new architectures for i386 and armv6
2023-06-16 17:59:33 +02:00
Kelson
221055f49c Merge pull request #621 from kiwix/docker-readme-improvements
Docker readme improvements
2023-05-24 10:53:31 +03:00
Emmanuel Engelhart
a463c31a0c Add example with globbing 2023-05-24 09:51:42 +02:00
Emmanuel Engelhart
6e239d5cb6 Add link to Kiwix server container image 2023-05-24 09:51:11 +02:00
Emmanuel Engelhart
191dc95266 Fix small typo in the usage() 2023-05-23 17:05:03 +02:00
Matthieu Gautier
840f92c677 Merge pull request #618 from kiwix/fix_clone_ci 2023-05-03 16:31:10 +02:00
Matthieu Gautier
f03dc46342 Remove custom git clone
Now possible because of new Docker images and proper user/permission mgmt
within the container.
2023-05-03 15:34:41 +02:00
Kelson
a8a62aef74 Merge pull request #617 from jgmoss/main
Update docker-compose.yml to use ghcr.io image
2023-04-29 13:42:28 +02:00
Graham Moss
7f9bf58742 Update docker-compose.yml to use ghcr.io image 2023-04-28 15:01:05 -04:00
Matthieu Gautier
4cf2f4f2c9 Merge pull request #616 from kiwix/version_3.5.0 2023-04-28 11:36:55 +02:00
Matthieu Gautier
b6e7ed3443 New version 3.5.0 2023-04-28 11:07:22 +02:00
Matthieu Gautier
806747320c Merge pull request #615 from kiwix/no_static_on_macos 2023-04-28 08:20:38 +02:00
Matthieu Gautier
6765239341 Do not build with --static on maco_os. 2023-04-28 08:16:31 +02:00
Kelson
4e992a18e8 Merge pull request #608 from kiwix/ghcr
removed references to docker.io
2023-03-22 16:30:32 +01:00
renaud gaudin
3d9348092b removed references to docker.io 2023-03-22 15:23:31 +00:00
Kelson
1024360598 Merge pull request #607 from kiwix/update-ci-base-container-images
Bump-up CI container images for r36
2023-03-16 13:52:33 +01:00
Emmanuel Engelhart
cfc249b9cf Bump-up CI container images for r36 2023-03-16 13:48:43 +01:00
Kelson
688bb356ea Merge pull request #603 from kiwix/documentation
Documentation updates
2023-02-11 12:47:10 +01:00
Veloman Yunkan
d398ebdb3e Added missing information about /search endpoint 2023-02-11 12:04:18 +01:00
Veloman Yunkan
6ab6abc6d3 Noted the HTTP API type (public/private) in the docs 2023-02-11 11:20:32 +01:00
Matthieu Gautier
0059c6a213 Merge pull request #602 from kiwix/zerocount_catalog_query_doc_update 2023-02-10 19:46:51 +01:00
Veloman Yunkan
eac5898ca8 Doc update for /catalog/v2/entries?count=0 2023-02-10 19:33:10 +01:00
Kelson
edb97fb055 Merge pull request #601 from kiwix/update-ubuntu-packages
Remove PPA Impish, add Kinetic
2023-02-10 18:59:24 +01:00
Emmanuel Engelhart
e1b314267b Remove PPA Impish, add Kinetic 2023-02-10 18:56:21 +01:00
Kelson
0df6a1624b Merge pull request #599 from kiwix/documentation_of_catalog_pagination
Fixed & elaborated documentation of OPDS catalog pagination
2023-02-10 18:52:23 +01:00
Veloman Yunkan
07bc21754b Fixed & elaborated documentation of catalog pagination 2023-02-10 16:46:14 +01:00
Kelson
6f2e6ce866 Merge pull request #598 from kiwix/update-workflow-actions
Update GitHub workflow actions
2023-02-05 13:28:13 +01:00
Emmanuel Engelhart
4e8d3097b9 Update GitHub workflow actions 2023-02-05 13:25:19 +01:00
Kelson
ad58d74699 Merge pull request #597 from jacroe/docker-compose-fix-wildcard
Docker compose example: Surround wildcard statement in quotes
2023-02-02 07:13:20 +01:00
Jacob Roeland
0f25fa69d3 Surround wildcard statement in quotes 2023-02-02 00:26:46 -05:00
Matthieu Gautier
4949accdf3 Merge pull request #586 from kiwix/documentation 2023-01-04 17:56:43 +01:00
Veloman Yunkan
7c7cd42e83 Added docs badge to README 2023-01-04 19:44:49 +04:00
Veloman Yunkan
996ea031fc Documented the /search endpoint 2023-01-04 19:43:20 +04:00
Veloman Yunkan
7179244c47 Documented the /raw endpoint 2023-01-04 19:43:20 +04:00
Veloman Yunkan
68d3c9d81d Documented the /suggest endpoint 2023-01-04 19:43:20 +04:00
Veloman Yunkan
7f86317537 Documented the /catch/external endpoint 2023-01-04 19:43:20 +04:00
Veloman Yunkan
436f1b83f6 Documented library reloading via SIGHUP 2023-01-04 19:43:20 +04:00
Veloman Yunkan
490ba0f3f2 Documented the OPDS API 2023-01-04 19:43:20 +04:00
Veloman Yunkan
591a347647 Added glossary to kiwix-serve's documentation 2023-01-04 19:43:20 +04:00
Veloman Yunkan
ecf5e67759 Documented the --library option 2023-01-04 19:43:20 +04:00
Veloman Yunkan
ec2effe257 Cross-referenced a few options 2023-01-04 19:43:20 +04:00
Veloman Yunkan
244009f3b1 Marked options with directives
This will enable cross-referencing them.
2023-01-04 19:43:20 +04:00
Veloman Yunkan
11ef036174 Documented the /random endpoint 2023-01-04 19:43:20 +04:00
Veloman Yunkan
7b5b0cd7f7 Documented the /skin endpoint 2023-01-04 19:43:20 +04:00
Veloman Yunkan
2aef2d4a92 Expanded the /catalog endpoint 2023-01-04 19:43:20 +04:00
Veloman Yunkan
76023e9231 Started documenting kiwix-serve HTTP API 2023-01-04 19:43:20 +04:00
Veloman Yunkan
614f15913f Added introduction to kiwix-serve's documentation 2023-01-04 19:43:20 +04:00
Veloman Yunkan
6957a8cb1e Enter docs/
This commit introduces an embryo of sphinx-based documentation. The
content of documentation in this commit is limited to the command line
options of kiwix-serve.
2023-01-04 19:43:20 +04:00
Kelson
c6b6a47711 "main" is the new git default branch 2022-12-27 14:16:58 +01:00
Kelson
9f93677b66 "main" is the new git default branch 2022-12-27 14:10:56 +01:00
Matthieu Gautier
756d5b4a04 Merge pull request #585 from kiwix/version_3.4.0 2022-11-30 18:09:14 +01:00
Matthieu Gautier
0f81dad6a4 New version 3.4.0
* Remove last reference to kiwix-read tool (@legoktm #569)

kiwix-serve
-----------

 * Fix broken indentation in usage (@kelson42 #560)
 * Exit if wrong arguments are passed (@kelson42 #567)
 * Do not allow multiple values for same option (@juuz0 #564)
 * Fix default location of "rootLocation" (@rgaudin #571)
 * [DOCKER] Change default port to 8080 (@neyder #581)
 * [DOCKER] Simplify dockerfile (@rgaudin #582)

kiwix-manage
------------

 * Fix man page (@kelson42 #576)
2022-11-30 18:04:27 +01:00
Kelson
252e3bc962 Merge pull request #582 from kiwix/simpler-dockerfile
Simpler dockerfile
2022-10-26 18:10:22 +02:00
renaud gaudin
cf6d66b2c2 Updated actions dependencies 2022-10-26 16:04:46 +00:00
renaud gaudin
a6713db7fe Simplified Dockerfile
- using alpine's dumb-init to remove builder
- simplifying arch management
- extracting to final location
2022-10-26 16:04:40 +00:00
Kelson
4137d9f517 Merge pull request #581 from neyder/master
Make kiwix-serve easily deployable on podman Openshift
2022-10-26 17:26:33 +02:00
Neyder Achahuanco Apaza
1a25b42517 Fixed README 2022-10-24 17:00:32 -05:00
Neyder Achahuanco Apaza
70c390c7d1 Modify documentation to reflect PORT variable and default to 8080 2022-10-23 09:54:46 -05:00
Neyder Achahuanco Apaza
847d1e9e76 Modify default port so it cna be used on secured kubernetes 2022-10-21 15:11:14 -05:00
Kelson
2a9378e24e Merge pull request #576 from kiwix/kiwix-manage-man-url-fix
Rewritten kiwix-manage man
2022-09-25 20:56:22 +02:00
Emmanuel Engelhart
dd53bef147 Fix: Create library file if necessary with 'add' action 2022-09-24 20:19:40 +02:00
Emmanuel Engelhart
6f0f666be5 Fix: Add actions in bold 2022-09-18 17:12:05 +02:00
Emmanuel Engelhart
0a7e91ceb7 Fix: Fix missing enclosures 2022-09-18 17:05:36 +02:00
Emmanuel Engelhart
db7f30fb81 Fix: Remove example library.xml because useless 2022-09-18 17:00:53 +02:00
Emmanuel Engelhart
3c6e8ed6c8 Fix: simple ALOS typo 2022-09-18 16:57:47 +02:00
Emmanuel Engelhart
cef30cd0b8 Rewritten kiwix-manage man page 2022-09-10 11:04:40 +02:00
Kelson
ce9e3e82e3 Merge pull request #569 from kiwix/rm-kiwix-search-man
Remove more references to kiwix-read
2022-07-31 09:45:54 +02:00
Kunal Mehta
0df3c14faa Remove more references to kiwix-read
Was removed in f9ce353ad1.
2022-07-31 09:43:53 +02:00
Kelson
092be45512 Merge pull request #571 from kiwix/rootLocation
Default kiwix-serve's rootLocation to "/"
2022-07-28 19:11:33 +02:00
renaud gaudin
442de30ff7 Normalize printed rootLocation
Reusing libkiwix's normalizeRootUrl() to display a more reliable representation of the
rootLocation the InternalServer will be using.

Can't reuse server.m_root as it is private.
2022-07-28 15:51:46 +00:00
renaud gaudin
9c16e53767 Default kiwix-serve's rootLocation to "/""
Usage mentions that the rootLocation defaults to `/` while it was not.
It defaulted to an empty string.

While it defaulting to "" or "/" has no technical consequence: libkiwix's server
normalizes the requested rootLocation ; it leads to users setting a "/"-prefixed
rootLocation when customizing it, resulting in double-slashed print of the URL
to access kiwix-serve at.

This harmonizes usage and actual default, fixing the URL print.
2022-07-28 11:30:48 +00:00
Matthieu Gautier
f9dc22a671 Merge pull request #565 from kiwix/multipleAddresses 2022-07-11 14:15:20 +02:00
Nikhil Tanwar
7526148f89 Do not allow multiple values for same option
Previously, kiwix-serve would take the last value for the same option. This was unintuitive.
This change exits the program if multiple values for the same option are found.
2022-07-11 11:21:09 +02:00
Kelson
da55468a88 Merge pull request #567 from kiwix/exit-if-argument-error
Exit if wrong argument given to kiwix-serve
2022-07-11 11:11:50 +02:00
Emmanuel Engelhart
86fac0e9af Exit if wrong argument given to kiwix-serve 2022-07-10 21:33:27 +02:00
Kelson
5709d4d489 Merge pull request #564 from kiwix/fixHeader
Add iostream header and namespace std
2022-07-07 06:34:51 +02:00
Nikhil Tanwar
8efa71d307 Use std namespace consistently
Previously, there was an inconsistent usage of no namespace vs namespace.
This change fixes that by correctly adding std:: whenever required.
Adds iostream header in src/version.h to fix cout/cerr problems.
2022-07-06 20:55:44 +05:30
Kelson
3f076c2b27 Merge pull request #560 from kiwix/fix-identation
Fix broken indentation in usage()
2022-06-23 10:30:47 +02:00
Emmanuel Engelhart
6266c3baa8 Fix broken indentation in usage() 2022-06-23 10:26:43 +02:00
Matthieu Gautier
b2bc6cead2 Merge pull request #559 from kiwix/version_3.3.0 2022-06-15 14:46:15 +02:00
Matthieu Gautier
b7a6f78150 New version 3.3.0 2022-06-15 14:25:48 +02:00
Kelson
9e3d4c9615 Merge pull request #558 from kiwix/limit_books_search
Add a option to limit the number of zim in a fulltext multizim search.
2022-06-14 11:03:14 +02:00
Matthieu Gautier
472ff19861 [CI] Use last docker image (and dependencies) 2022-06-14 10:49:46 +02:00
Matthieu Gautier
97aa28c74d Add a option to limit the number of zim in a fulltext multizim search. 2022-06-14 10:41:31 +02:00
Kelson
2c40d23991 Merge pull request #555 from kiwix/manager_add_no_library
It is ok to not be able to read library if we ADD book to non existant library
2022-06-06 17:37:24 +02:00
Matthieu Gautier
ca8d6e570c It is ok to not be able to read library if we ADD book to non existant lib 2022-06-03 10:54:43 +02:00
Matthieu Gautier
78887d6815 Merge pull request #553 from kiwix/manager_return_code 2022-06-03 09:11:59 +02:00
Matthieu Gautier
643a07f653 Make kiwix-manage return with something !0 if something went wrong 2022-06-02 23:01:58 +02:00
Matthieu Gautier
9a07dd8314 Merge pull request #546 from kiwix/fix_win_cross_compilation 2022-03-11 14:45:04 +01:00
Matthieu Gautier
bdd36f0379 Do not define stat if not necessary.
On recent mingw compiler, `stat` is already defined the same way we do.
So we don't need to do it.
2022-03-11 14:41:47 +01:00
Kelson
62195c788e Merge pull request #541 from kiwix/ci_fix 2022-02-14 10:34:52 +01:00
Veloman Yunkan
fa7948abbe Fixed armhf_static CI build 2022-02-14 11:17:37 +04:00
Kelson
2c701cb260 Merge pull request #535 from kiwix/saying_no_to_deprecated_libkiwix_api
Removed the usage of libkiwix deprecated API
2022-02-10 10:34:32 +01:00
Veloman Yunkan
8b36e94d50 Now kiwix-tools is built with werror=true 2022-02-10 13:13:11 +04:00
Veloman Yunkan
f9ce353ad1 Goodbye kiwix-read
`kiwix-read` was a confusing tool. It was a loose equivalent of
`kiwix-search --suggest` also able to work on old ZIM archives that didn't
contain a title index. Its existence is not justified.
2022-02-10 13:13:10 +04:00
Veloman Yunkan
2bb080ee3b Cleared kiwix-search of libkiwix deprecated API 2022-02-10 13:13:10 +04:00
Kelson
dd5aa33775 Merge pull request #534 from kiwix/ipLimit
Add ip connection limit option
2022-02-06 15:23:39 +01:00
Emmanuel Engelhart
0ed608f5c2 Cosmetic changes in kiwix-serve usage() 2022-02-06 15:22:09 +01:00
Nikhil Tanwar
8f4758a6a9 Add ip connection limit option
Adds --ipConnectionLimit/-L option to change MHD_OPTION_PER_IP_CONNECTION_LIMIT by calling server.setIpConnectionLimit()
2022-02-05 18:31:01 +05:30
Kelson
b10f2ed1a1 Merge pull request #530 from kiwix/legoktm-patch-1
PPA: Remove Ubuntu Hirsute, EOL
2022-02-01 08:29:22 +01:00
Kunal Mehta
94549828cb PPA: Remove Ubuntu Hirsute, EOL 2022-01-31 23:13:46 -08:00
Kelson
f342bd5e24 Merge pull request #526 from kiwix/legoktm-patch-1 2022-01-24 06:42:36 +01:00
Kunal Mehta
f316bb14a2 PPA: Fix libzim-dev and libkiwix-dev dependencies
Our libzim packages are "7.2.0~focal" but the ~ means that "7.2.0" is greater than
"7.2.0~focal" so the dependency can't be satisfied. Depending on "7.2.0~" will
allow "7.2.0~focal" to satisfy the dependency. Same for libkiwix.
2022-01-23 20:31:31 -08:00
Matthieu Gautier
ea44dc76f6 Merge pull request #525 from kiwix/version_3.2.0 2022-01-20 14:38:07 +01:00
Matthieu Gautier
6dfdcea5ce New version 3.2.0 2022-01-19 17:03:14 +01:00
Matthieu Gautier
0ef85944b8 Update dependencies.
zlib and microhttpd are used by libkiwix, not kiwix-tools.

We indeed need libzim, but we use no feature related to xapian so no
need to mark it as mandatory.
(Libkiwix needs it and the check is there)
2022-01-19 17:03:14 +01:00
Kelson
04ac15508f New deps needed (#523)
* kiwix-tools need libkiwix 10.0.0

* Compilation requires libzim 7.2.0 now
2022-01-19 13:04:25 +01:00
rgaudin
eeb41d8047 Merge pull request #524 from OlegSmelov/fix/dockerfile
Fix dumb-init HTTPS download in Dockerfile
2022-01-17 09:00:28 +00:00
Oleg Smelov
85a3093df3 Fix dumb-init HTTPS download in Dockerfile 2022-01-16 20:39:19 +02:00
Kelson
2c435926ca Merge pull request #522 from kiwix/showCustomRoot
Add root location in startup message
2022-01-14 16:18:34 +01:00
Nikhil Tanwar
b8c4791dd0 Add root location in startup message 2022-01-14 17:41:34 +05:30
Kelson
701541aa2f Merge pull request #520 from kiwix/no_werror
Do not compile with `werror=true`.
2022-01-12 19:20:17 +01:00
Matthieu Gautier
527981ba66 Do not compile with werror=true.
We are using `kiwix::Reader` and `kiwix::Searcher` which are now
deprecated.
Remove `werror` until we fix this.
2022-01-12 18:22:46 +01:00
Kelson
d8ed915c80 Merge pull request #517 from kiwix/fileExists
Change kiwix::fileExists to kiwix::fileReadable
2022-01-09 20:17:26 +01:00
Nikhil Tanwar
74d3bffde0 Change kiwix::fileExists to kiwix::fileReadable 2022-01-09 20:10:45 +01:00
Kelson
b974e121b4 Merge pull request #516 from kiwix/dependences_version
Print dependence versions
2022-01-03 09:02:58 +01:00
Emmanuel Engelhart
d2bb9d123e Print dependence versions 2022-01-03 08:54:38 +01:00
Kelson
9b158360a6 Merge pull request #499 from kiwix/startup-message
Add startup message to provide http url to server
2021-12-22 18:38:25 +01:00
Nikhil Tanwar
7d2c67f43d Add startup message to provide http url to server 2021-12-22 18:37:13 +01:00
Kelson
a080a3137e Merge pull request #515 from kiwix/dumb-init
Fixed docker image for non-amd64 platforms
2021-12-21 12:00:29 +01:00
renaud gaudin
dedcae83cd Fixed docker image for non-amd64 platforms
PR#489 (01430603b6) introduced dumb-init for better
signals handling.
While this has the intended effect, it was done ny downloading the dumb-init static bin
into the image… only using the amd64 version.

Ever since, the image(s) have been broken for armv7 and arm64.

As dumb-init doesn't provide 32b arm binary and because it's such a simple/small code,
this fix compiles it in a builder shallow image ; ensuring we're getting an appropriate
binary for the target arch.

We are also statically linking against musl-C as this is supported by dumb-init and is
much smaller than glibc.
2021-12-21 10:27:28 +00:00
Kelson
c0fa06c931 Merge pull request #514 from kiwix/legoktm-patch-1
PPA: Reinstate Ubuntu Impish, add Jammy
2021-12-20 07:57:17 +01:00
Kunal Mehta
dbe6126496 PPA: Reinstate Ubuntu Impish, add Jammy 2021-12-19 16:47:59 -08:00
Kelson
94bf71eb82 Merge pull request #512 from kiwix/updated-kiwix-serve-usage-message 2021-12-13 19:19:17 +01:00
Veloman Yunkan
25e9941f6a Mentioned --monitorLibrary in the help message 2021-12-13 22:16:47 +04:00
Kelson
81d8ad964a Merge pull request #511 from kiwix/kiwix-serve-help-option 2021-12-13 17:16:19 +01:00
Emmanuel Engelhart
9a49623879 Add -h/--help option to kiwix-serve 2021-12-13 15:48:42 +01:00
Kelson
f7f10597eb Merge pull request #504 from fazlerabbi37/feature-docker-compose
Add docker-compose for kiwix-server
2021-12-11 05:13:30 +01:00
Fazle Rabbi
c8be7c47ca Modify README.md to link to docker-compose doc 2021-12-10 21:09:14 +06:00
Fazle Rabbi
f356587b23 Add docker-compose for kiwix-server
added docker-compose for kiwix-server via docker-compose.yml.example which supports both local and remote zim file.
updated README.md to update about docker-compose.yml.example
2021-12-09 18:16:41 +06:00
Matthieu Gautier
32432a7113 Merge pull request #503 from kiwix/automatic_library_reloading 2021-12-06 10:53:13 +01:00
Veloman Yunkan
7985ba1b0c kiwix-serve [--monitorLibrary|-M] 2021-12-05 19:53:18 +04:00
Kelson
933aa0cd63 Merge pull request #497 from kiwix/library_reloading
Library reloading on SIGHUP
2021-12-03 16:34:26 +01:00
Veloman Yunkan
098e1cfe51 Library reloading on SIGHUP
Note that this enhancement drops the --donottrustlibrary mode.
2021-12-03 18:52:34 +04:00
Kelson
43b5be179a Merge pull request #501 from kiwix/fix_option_parsing
Add missing break in the switch case.
2021-12-01 15:44:12 +01:00
Matthieu Gautier
88213b3f3b Add missing break in the switch case.
Fix #500
2021-12-01 15:41:16 +01:00
Matthieu Gautier
7659efa97c Merge pull request #488 from kiwix/kiwix-serve_sigterm_handling 2021-10-18 10:42:54 +02:00
Veloman Yunkan
4faaa978f7 Handling of SIGTERM & SIGINT in kiwix-serve 2021-10-18 00:01:25 +04:00
Matthieu Gautier
d73fcb357f Merge pull request #491 from kiwix/fix_ci_docker_version 2021-10-14 14:18:52 +02:00
Matthieu Gautier
61e82228a4 Last CI docker image is 31 2021-10-14 14:16:13 +02:00
Matthieu Gautier
01430603b6 Merge pull request #489 from kiwix/docker-signals 2021-10-14 14:12:23 +02:00
renaud gaudin
6c31d0d7b0 Fixed #482: use dumb-init in docker for signal forwarding
Following-up on discussion in #488, now using https://github.com/Yelp/dumb-init
as entrypoint so our kiwix-* tools properly receives signals
2021-10-14 09:30:04 +02:00
Kelson
c1731c9697 Merge pull request #490 from kiwix/ci-disable-impish
Disable Ubuntu Impish in CI
2021-10-14 09:29:35 +02:00
Emmanuel Engelhart
929c36c930 Disable Ubuntu Impish in CI 2021-10-14 09:26:46 +02:00
Kelson
3df4a94863 Merge pull request #477 from kiwix/kiwix-serve/issue/571
added --customIndexTemplate option
2021-10-13 06:55:12 +02:00
Emmanuel Engelhart
2cd190e965 Tune a bit an error message 2021-10-11 15:32:08 +02:00
Manan Jethwani
6a7c737d48 added --customIndexTemplate option 2021-10-11 18:55:47 +05:30
Kelson
b20e83bd0b Merge pull request #485 from karandeeppotato/issue#483 2021-09-29 18:36:25 +02:00
karandeeppotato
7a3f77dbf2 Removed a redundant error message from kiwix-serve
The error message about failing to open the specified port was produced both
by kiwix-tools/src/server/kiwix-serve.cpp and by the InternalServer
constructor (in libkiwix/src/server/internalServer.cpp).
2021-09-29 18:47:55 +05:30
Kelson
71e065312f Merge pull request #474 from kiwix/remove_groovy_package
Remove Groovy package
2021-07-28 21:38:40 +02:00
Emmanuel Engelhart
9f207a61f9 Remove Groovy package 2021-07-28 21:35:58 +02:00
Kelson
43656554f1 Merge pull request #465 from kiwix/ppa-impish
PPA: Build for Ubuntu Impish
2021-07-08 13:16:03 +02:00
Kunal Mehta
7d55c0f6ac PPA: Build for Ubuntu Impish 2021-07-08 13:13:21 +02:00
Kelson
c3721970c5 Merge pull request #468 from kiwix/new_tools_libkiwix
Adapt kiwix-tools to the new libkiwix headers.
2021-07-08 13:10:45 +02:00
Matthieu Gautier
81ac333cc9 Adapt kiwix-tools to the new libkiwix headers.
Fix #467
2021-07-08 10:09:17 +02:00
Kelson
d1edbc11d3 Merge pull request #462 from kiwix/update-readme-libkiwix
Kiwix-tools does not depend on libmicrohttpd anymore
2021-05-30 15:55:05 +02:00
Emmanuel Engelhart
47929008cf Kiwix-tools does not depend on libmicrohttpd anymore 2021-05-30 15:33:52 +02:00
Kelson
4ba79d9776 Merge pull request #459 from kiwix/update-readme-libkiwix
Update readme libkiwix
2021-05-28 14:10:45 +02:00
Emmanuel Engelhart
c1e2913f24 Kiwix-lib has been renamed to libkiwix, update README.md 2021-05-28 09:56:37 +02:00
Kelson
ac3e889388 Merge pull request #461 from kiwix/use_suggestion_class_functions
Use SuggestionItem member function getTitle()
2021-05-28 09:55:17 +02:00
Maneesh P M
6d9fa0cb45 Use SuggestionItem member function getTitle()
We have introduced a new class SuggestionItem in libkiwix, it must be
used in kiwix-tools as well for handling suggestions.
2021-05-28 12:56:22 +05:30
rgaudin
c76bbabd10 Merge pull request #455 from kiwix/kiwix-tools-docker-badge
Add kiwix-tools Docker badge
2021-05-03 07:55:06 +00:00
Kelson
a5cf735ffe Add kiwix-tools Docker badge 2021-05-02 09:50:05 +02:00
Matthieu Gautier
b064796c2d Merge branch 'arjun-369-master' 2021-04-28 14:49:20 +02:00
arjun-369
6f2316bc8a Update kiwix-search.cpp for a bug fix 2021-04-28 14:48:46 +02:00
Kelson
b2aeb08051 Merge pull request #433 from kiwix/better-pid-type-conversion
Better PID type conversion
2021-01-24 19:41:11 +01:00
luddens
17b7fb2145 Better PID type conversion 2021-01-24 11:22:57 +01:00
Kelson
36c7bf4d6f Better Docker badge 2021-01-11 10:41:38 +01:00
renaud gaudin
a3ed7ad3e1 using two jobs to isolate envs 2021-01-08 18:35:23 +00:00
rgaudin
b7d884ceb2 Merge pull request #429 from kiwix/docker
CI built docker image
2021-01-08 15:33:26 +00:00
renaud gaudin
19322958b3 Support for non-release builds
- only building on workflow_dispatch with a specified version that can be a release or release-build
2021-01-08 15:29:19 +00:00
renaud gaudin
ccb8d11dce CI built docker image
- added a new generic kiwix/kiwix-tools image
- kiwix/kiwix-serve now based on kiwix/kiwix-tools ; with its entrypoint
- both images are built with official binary distribution
- both images are built on github action and pushed to both docker.io and ghcr.io
- both images are multi-arch and support arm/v7, arm64 and amd64
- built on release published or workflow_dispatch event (to be triggered by kiwix-build)
2021-01-07 22:13:49 +00:00
Kelson
7bdbe901db Merge pull request #419 from kiwix/legoktm-patch-1
PPA: Build for Ubuntu Hirsute
2020-12-18 23:51:42 +01:00
Kunal Mehta
7e6e74330a PPA: Build for Ubuntu Hirsute 2020-12-03 22:48:19 -08:00
Matthieu Gautier
9efd18a9a4 Merge pull request #409 from kiwix/kelson42-patch-1
Add instructions to build image for ARM
2020-09-21 18:12:29 +02:00
Kelson
0e9f406180 Add instructions to build image for ARM 2020-09-19 13:55:15 +02:00
Kelson
0160f356a6 Merge pull request #405 from kiwix/multiarch-docker
Add support for ARM in Docker
2020-09-02 17:13:37 +02:00
renaud gaudin
8cc34782bc support arm arch for kiwix-serve image 2020-08-31 11:27:29 +02:00
Kelson
b2c68d7f22 Merge pull request #403 from hashworks/archCommunityPkg
Add repology package badge
2020-08-30 22:06:42 +02:00
hashworks
977cfb9887 Switch to repology package badge 2020-08-30 21:00:28 +02:00
hashworks
1671effaf4 Replace AUR shield with official Arch Linux package
I recently became an Arch Linux Trusted User and moved kiwix-tools to
the official community repository. Hence, the shield needs to be
updated.
2020-08-30 13:19:28 +02:00
Kelson
8d00e45d2a Merge pull request #398 from kiwix/ppa-sync
PPA: Drop eoan and sync with proper Debian package
2020-07-24 12:42:19 +02:00
Kunal Mehta
730f20e86f debian: Sync with proper Debian package, bump to debhelper 13 2020-07-24 03:08:53 -07:00
Kunal Mehta
ff5f1d96d2 PPA: Drop Ubuntu eoan, EOL
Launchpad no longer accepts eoan uploads.
2020-07-24 03:07:47 -07:00
Kelson
d1d72218b3 Example with multiple ZIM files 2020-07-22 16:53:31 +02:00
Matthieu Gautier
88269c1ff2 Merge pull request #394 from kiwix/ppa 2020-07-20 11:54:56 +02:00
Kunal Mehta
4ee202514e PPA: Set fail-fast: false
See discussion/rationale on <https://github.com/openzim/libzim/pull/370>.
2020-07-16 06:04:01 -07:00
Kunal Mehta
98b372ee17 Automatically build and publish packages via Github Actions
Same exact configuration as kiwix-lib.
2020-07-13 17:46:02 -07:00
Kunal Mehta
8e5df188b3 Add minimal Debianization for our PPA 2020-07-13 17:45:59 -07:00
Matthieu Gautier
ed709454bd Merge pull request #392 from kiwix/manpages
Add man pages for kiwix-read and kiwix-search
2020-07-09 10:47:06 +02:00
Kunal Mehta
f5762c72d3 Add man pages for kiwix-read and kiwix-search 2020-07-09 10:44:34 +02:00
Matthieu Gautier
1744b152ac Merge pull request #393 from kiwix/legoktm-grammar
Improve grammar in kiwix-search help
2020-07-09 10:42:20 +02:00
Kunal Mehta
7f09e55077 Improve grammar in kiwix-search help
Suggested by Debian's lintian.
2020-07-09 00:35:24 -07:00
Matthieu Gautier
fdec897bc7 Release 3.1.2 2020-07-02 15:20:01 +02:00
Matthieu Gautier
764dd8848b Merge pull request #391 from kiwix/new_kiwixlib_suggestion_api
Use new suggestion API of kiwix-lib.
2020-07-02 14:39:53 +02:00
Matthieu Gautier
4a944cc901 Use new suggestion API of kiwix-lib.
Old API is not threadsafe and is deprecated.
2020-07-01 16:51:41 +02:00
Matthieu Gautier
4120e7fd25 New version 3.1.1 2020-05-18 15:17:14 +02:00
Matthieu Gautier
8736a2f4ea Merge pull request #383 from kiwix/include_windows 2020-05-18 13:38:38 +02:00
Matthieu Gautier
00b810d649 Include missing "windows.h"
Now that libzim doesn't inculde "windows.h" in its public headers it fails
if we don't include it.
2020-05-18 13:27:14 +02:00
Matthieu Gautier
5d21baa759 Fix typo in meson.build 2020-04-09 23:51:23 +02:00
Matthieu Gautier
6ba6046850 New version 3.1.0 2020-04-08 18:01:34 +02:00
Matthieu Gautier
d24f474dda Merge pull request #367 from kiwix/block-external-links
Add support for external links blocking in kiwix-serve
2020-04-06 20:15:08 +02:00
Kelson
07de2d29c4 Merge pull request #371 from kiwix/better-ci-event
Run Github actions on any push (not only in PR)
2020-04-03 16:28:34 +02:00
Kelson
d99e5cd975 Run Github actions on any push (not only in PR) 2020-04-03 16:26:47 +02:00
Kelson
f82d5aa7e5 CI badge from Github actions (instead of Travis) 2020-04-03 16:24:04 +02:00
renaud gaudin
824aef9189 Add support for external links blocking in kiwix-serve
Add a new `-b` `--blockexternallinks` option to kiwix-serve
triggering the corresponding response taskbar option in kiwix-lib.
2020-04-02 09:10:00 +00:00
36 changed files with 1851 additions and 391 deletions

View File

@@ -1,6 +1,6 @@
name: CI
on: [pull_request]
on: [push]
jobs:
Linux:
@@ -14,49 +14,34 @@ jobs:
- win32_dyn
include:
- target: native_static
image_variant: xenial
image_variant: focal
lib_postfix: '/x86_64-linux-gnu'
- target: native_dyn
image_variant: xenial
image_variant: focal
lib_postfix: '/x86_64-linux-gnu'
- target: win32_static
image_variant: f31
image_variant: f35
lib_postfix: '64'
- target: win32_dyn
image_variant: f31
image_variant: f35
lib_postfix: '64'
env:
HOME: /home/runner
runs-on: ubuntu-latest
container:
image: "kiwix/kiwix-build_ci:${{matrix.image_variant}}-26"
image: "ghcr.io/kiwix/kiwix-build_ci_${{matrix.image_variant}}:36"
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Checkout code
shell: python
run: |
import json
from subprocess import check_call
from os import environ
with open(environ['GITHUB_EVENT_PATH'], 'r') as f:
content = f.read()
event_data = json.loads(content)
try:
branch_ref = event_data['ref'].split('/')[-1]
except KeyError:
branch_ref = event_data['pull_request']['head']['ref']
print("Cloning branch", branch_ref)
command = [
'git', 'clone',
'https://github.com/${{github.repository}}',
'--depth=1',
'--branch', branch_ref
]
check_call(command, cwd=environ['HOME'])
uses: actions/checkout@v3
- name: Install deps
shell: bash
run: |
ARCHIVE_NAME=deps2_${OS_NAME}_${{matrix.target}}_kiwix-tools.tar.xz
wget -O- http://tmp.kiwix.org/ci/${ARCHIVE_NAME} | tar -xJ -C /home/runner
wget -O- http://tmp.kiwix.org/ci/${ARCHIVE_NAME} | tar -xJ -C ${{env.HOME}}
- name: Compile
shell: bash
run: |
@@ -68,10 +53,9 @@ jobs:
if [[ ! "${{matrix.target}}" =~ native_.* ]]; then
MESON_OPTION="$MESON_OPTION --cross-file $HOME/BUILD_${{matrix.target}}/meson_cross_file.txt"
fi
cd $HOME/kiwix-tools
meson . build ${MESON_OPTION}
cd build
ninja
env:
PKG_CONFIG_PATH: "/home/runner/BUILD_${{matrix.target}}/INSTALL/lib/pkgconfig:/home/runner/BUILD_${{matrix.target}}/INSTALL/lib${{matrix.lib_postfix}}/pkgconfig"
CPPFLAGS: "-I/home/runner/BUILD_${{matrix.target}}/INSTALL/include"
PKG_CONFIG_PATH: "${{env.HOME}}/BUILD_${{matrix.target}}/INSTALL/lib/pkgconfig:${{env.HOME}}/BUILD_${{matrix.target}}/INSTALL/lib${{matrix.lib_postfix}}/pkgconfig"
CPPFLAGS: "-I${{env.HOME}}/BUILD_${{matrix.target}}/INSTALL/include"

67
.github/workflows/docker.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
name: Docker
on:
workflow_dispatch:
inputs:
version:
description: Specific version to build (overrides on-master and tag-pattern)
required: false
default: ''
jobs:
build-and-push-kiwix-tools:
name: Deploy kiwix-tools Docker Image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3.4.0
- name: build and publish kiwix-tools
uses: openzim/docker-publish-action@v10
with:
image-name: kiwix/kiwix-tools
registries: ghcr.io
credentials: |
GHCRIO_USERNAME=${{ secrets.GHCR_USERNAME }}
GHCRIO_TOKEN=${{ secrets.GHCR_TOKEN }}
context: docker
latest-on-tag: true
build-args:
VERSION={tag}
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
linux/arm/v6
linux/386
restrict-to: kiwix/kiwix-tools
manual-tag: ${{ github.event.inputs.version }}
repo_description: auto
repo_overview: Kiwix command line tools
build-and-push-kiwix-serve:
name: Deploy kiwix-serve Docker Image
runs-on: ubuntu-22.04
needs: build-and-push-kiwix-tools
steps:
- uses: actions/checkout@v3.4.0
- name: build and publish kiwix-serve
uses: openzim/docker-publish-action@v10
with:
image-name: kiwix/kiwix-serve
registries: ghcr.io
credentials: |
GHCRIO_USERNAME=${{ secrets.GHCR_USERNAME }}
GHCRIO_TOKEN=${{ secrets.GHCR_TOKEN }}
context: docker/server
latest-on-tag: true
build-args:
VERSION={tag}
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
linux/arm/v6
linux/386
restrict-to: kiwix/kiwix-tools
manual-tag: ${{ github.event.inputs.version }}
repo_description: auto
repo_overview: Kiwix web-server

82
.github/workflows/package.yml vendored Normal file
View File

@@ -0,0 +1,82 @@
name: Packages
on: [push, pull_request]
jobs:
build-deb:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distro:
- ubuntu-kinetic
- ubuntu-jammy
- ubuntu-focal
steps:
- uses: actions/checkout@v3
# Determine which PPA we should upload to
- name: PPA
id: ppa
run: |
if [[ $REF == refs/tags* ]]
then
echo "::set-output name=ppa::kiwixteam/release"
else
echo "::set-output name=ppa::kiwixteam/dev"
fi
env:
REF: ${{ github.ref }}
- uses: legoktm/gh-action-auto-dch@master
with:
fullname: Kiwix builder
email: release+launchpad@kiwix.org
distro: ${{ matrix.distro }}
- uses: legoktm/gh-action-build-deb@ubuntu-jammy
if: matrix.distro == 'ubuntu-jammy'
name: Build package for ubuntu-jammy
id: build-ubuntu-jammy
with:
args: --no-sign
ppa: ${{ steps.ppa.outputs.ppa }}
- uses: legoktm/gh-action-build-deb@ubuntu-kinetic
if: matrix.distro == 'ubuntu-kinetic'
name: Build package for ubuntu-kinetic
id: build-ubuntu-kinetic
with:
args: --no-sign
ppa: ${{ steps.ppa.outputs.ppa }}
- uses: legoktm/gh-action-build-deb@ubuntu-focal
if: matrix.distro == 'ubuntu-focal'
name: Build package for ubuntu-focal
id: build-ubuntu-focal
with:
args: --no-sign
ppa: ${{ steps.ppa.outputs.ppa }}
- uses: actions/upload-artifact@v3
with:
name: Packages for ${{ matrix.distro }}
path: output
- uses: legoktm/gh-action-dput@master
name: Upload dev package
# Only upload on pushes to git default branch
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' && startswith(matrix.distro, 'ubuntu-')
with:
gpg_key: ${{ secrets.LAUNCHPAD_GPG }}
repository: ppa:kiwixteam/dev
packages: output/*_source.changes
- uses: legoktm/gh-action-dput@master
name: Upload release package
# Only upload on pushes to master or tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && startswith(matrix.distro, 'ubuntu-')
with:
gpg_key: ${{ secrets.LAUNCHPAD_GPG }}
repository: ppa:kiwixteam/release
packages: output/*_source.changes

21
.readthedocs.yaml Normal file
View File

@@ -0,0 +1,21 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# We recommend specifying your dependencies to enable reproducible builds:
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt

101
Changelog
View File

@@ -1,7 +1,106 @@
Unreleased
==========
* Additional docker images archs for armv6 and i386.
kiwix-tools 3.5.0
=================
* Do not use `--static` option when compiling on MacOs (@mgautierfr #615)
* Move main branch from `master` to `main`.
* Fix docker image (@jacroe #597)
* Various CI improvements (@kelson42)
kiwix-serve
-----------
* Add documentation about the kiwix-serve API (@veloman-yunkan #586)
https://kiwix-tools.readthedocs.io/en/latest/kiwix-serve.html#http-api
kiwix-tools 3.4.0
=================
* Remove last reference to kiwix-read tool (@legoktm #569)
kiwix-serve
-----------
* Fix broken indentation in usage (@kelson42 #560)
* Exit if wrong arguments are passed (@kelson42 #567)
* Do not allow multiple values for same option (@juuz0 #564)
* Fix default location of "rootLocation" (@rgaudin #571)
* [DOCKER] Change default port to 8080 (@neyder #581)
* [DOCKER] Simplify dockerfile (@rgaudin #582)
kiwix-manage
------------
* Fix man page (@kelson42 #576)
kiwix-tools 3.3.0
=================
* Remove kiwix-read tool (@veloman-yunkan #535)
kiwix-serve
-----------
* Add an option to limit the number of connections for a same IP (@juuz0 #534)
* Add an option to limit the number of zim in a multizim fulltext search (@mgautierfr #558)
kiwix-search
------------
* Remove usage of libkiwix's deprecated api (@veloman-yunkan #535)
kiwix-manage
------------
* Correctly return a value !0 if something went wrong (@mgautierfr #553)
kiwix-tools 3.2.0
=================
* Print the version of all dependencies (@kelson42 #516)
* Better Docker images (@kelson42 @rgaudin)
* Update Readme (@kelson42)
* Build debian packages on CI (@legoktm #394)
* Add man pages for kiwix-read and kiwix-search (@legoktm #392)
* Various fixes (@legoktm @hashworks @mgautierfr)
kiwix-serve
-----------
* Print the url on which a user can connect to on startup (@juuz0 #499 #522)
* Reload library on SIGHUP signal (@veloman-yunkan #497)
* Add a option `--monitorLibrary` to monitor and automically reload the library
(@veloman-yunkan #503)
* Correct handling of SIGTERM and SIGINT (@veloman-yunkan #488)
* Add `--customIndexTemplate` option (@manan #477)
* Add `--help` option (@kelson42 #511)
kiwix-tools 3.1.2
=================
* Use new threadsafe API of kiwix-lib to do suggestions search.
kiwix-tools 3.1.1
=================
* Fix compilation on Windows' CI
kiwix-tools 3.1.0
=================
* [SERVER] Add option to block external links
kiwix-tools 3.0.3
=================
* [MANAGER] Fix broken --version argument parsin
* [MANAGER] Fix broken --version argument parsing
kiwix-tools 3.0.2
=================

View File

@@ -4,27 +4,19 @@ Kiwix tools
The Kiwix tools is a collection of [Kiwix](https://kiwix.org) related
command line tools:
* kiwix-manage: Manage XML based library of ZIM files
* kiwix-read: Read ZIM file content
* kiwix-search: Fulltext search in ZIM files
* kiwix-serve: HTTP daemon serving ZIM files
[![Build Status](https://travis-ci.com/kiwix/kiwix-tools.svg?branch=master)](https://travis-ci.com/kiwix/kiwix-tools)
[![latest release](https://img.shields.io/github/v/tag/kiwix/kiwix-tools?label=latest%20release&sort=semver)](https://download.kiwix.org/release/kiwix-tools/)
[![Repositories](https://img.shields.io/repology/repositories/kiwix-tools?label=repositories)](https://github.com/kiwix/kiwix-tools/wiki/Repology)
[![Docker](https://ghcr-badge.deta.dev/kiwix/kiwix-tools/latest_tag?label=docker)](https://ghcr.io/kiwix/kiwix-tools)
[![Docker](https://ghcr-badge.deta.dev/kiwix/kiwix-tools/latest_tag?label=docker%20(kiwix-serve))](https://ghcr.io/kiwix/kiwix-tools)
[![Sandstorm](https://img.shields.io/badge/Sandstorm-kiwix-blue)](https://apps.sandstorm.io/app/5uh349d0kky2zp5whrh2znahn27gwha876xze3864n0fu9e5220h)
[![Build Status](https://github.com/kiwix/kiwix-tools/workflows/CI/badge.svg?query=branch%3Amain)](https://github.com/kiwix/kiwix-tools/actions?query=branch%3Amain)
[![Doc](https://readthedocs.org/projects/kiwix-tools/badge/?style=flat)](https://kiwix-tools.readthedocs.org/en/latest/?badge=latest)
[![CodeFactor](https://www.codefactor.io/repository/github/kiwix/kiwix-tools/badge)](https://www.codefactor.io/repository/github/kiwix/kiwix-tools)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
Distribution
------------
#### Official
[![latest release](https://img.shields.io/github/v/tag/kiwix/kiwix-tools?label=latest%20release&sort=semver)](https://download.kiwix.org/release/kiwix-tools/)
[![Docker](https://img.shields.io/docker/cloud/build/kiwix/kiwix-serve)](https://hub.docker.com/r/kiwix/kiwix-serve)
#### Contribution
[![AUR](https://img.shields.io/aur/version/kiwix-tools)](https://aur.archlinux.org/packages/kiwix-tools/)
[![Sandstorm](https://img.shields.io/badge/Sandstorm-kiwix-blue)](https://apps.sandstorm.io/app/5uh349d0kky2zp5whrh2znahn27gwha876xze3864n0fu9e5220h)
Disclaimer
----------
@@ -49,10 +41,8 @@ Dependencies
The Kiwix tools rely on a few third party software libraries. They are
prerequisites to the Kiwix tools compilation. Therefore, following
libraries need to be available:
* [Kiwix lib](https://github.com/kiwix/kiwix-lib) (no package so far)
* [Libmicrohttpd](https://www.gnu.org/software/libmicrohttpd/)
(package `libmicrohttpd-dev` on Debian/Ubuntu)
* [Zlib](https://www.zlib.net/) (package `zlib1g-dev` on Debian/Ubuntu)
* [libkiwix](https://github.com/kiwix/libkiwix) (package `libkiwix` on Debian/Ubuntu)
* [libzim](https://github.com/openzim/libzim) (package `libzim` on Debian/Ubuntu)
These dependencies may or may not be packaged by your operating
system. They may also be packaged but only in an older version. They
@@ -68,10 +58,6 @@ If you want to compile Kiwix tools statically, the dependencies should
be compiled statically (provide a `lib...a` library), for example by
using `--enable-static` with `./configure`.
If you compile manually Libmicrohttpd, you might need to compile it
without GNU TLS, a bug here will empeach further compilation of Kiwix
tools otherwise.
Environment
-------------
@@ -127,7 +113,10 @@ Like for the installation, you might need to run the command as `root`
Docker
------
An official Docker image of `kiwix-serve` can be found in the [Docker Hub](https://hub.docker.com/r/kiwix/kiwix-serve).
An official Docker image of the Kiwix tools can be found on
[GHCR](https://ghcr.io/kiwix/kiwix-tools). A
`kiwix-serve` dedicated Docker image [exists
too](https://ghcr.io/kiwix/kiwix-serve).
Troubleshooting
---------------

5
debian/changelog vendored Normal file
View File

@@ -0,0 +1,5 @@
kiwix-tools (0.0.0) unstable; urgency=medium
* Initial release
-- Kunal Mehta <legoktm@debian.org> Mon, 13 Jul 2020 17:21:11 -0700

25
debian/control vendored Normal file
View File

@@ -0,0 +1,25 @@
Source: kiwix-tools
Section: utils
Priority: optional
Maintainer: Kiwix team <kiwix@kiwix.org>
Build-Depends: debhelper-compat (= 13),
libkiwix-dev (>= 10.0.0~),
libzim-dev (>= 7.2.0~),
meson,
pkg-config,
Standards-Version: 4.5.0
Homepage: https://github.com/kiwix/kiwix-tools
Rules-Requires-Root: no
Package: kiwix-tools
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: collection of Kiwix tools
kiwix-tools is a collection of various command-line tools used to help
users interact with and manage ZIM files. It includes:
* kiwix-serve is a standalone HTTP server for serving ZIM files
over the network.
* kiwix-manage allows one to manage the content of the Kiwix library (an
XML file listing available ZIM files).
* kiwix-search allows one to find articles in a ZIM file using fulltext
search patterns.

1
debian/copyright vendored Normal file
View File

@@ -0,0 +1 @@
See COPYING in the repository root.

5
debian/rules vendored Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@

1
debian/source/format vendored Normal file
View File

@@ -0,0 +1 @@
3.0 (native)

34
docker/Dockerfile Normal file
View File

@@ -0,0 +1,34 @@
FROM alpine:3.18
LABEL org.opencontainers.image.source https://github.com/openzim/kiwix-tools
# TARGETPLATFORM is injected by docker build
ARG TARGETPLATFORM
ARG VERSION
RUN set -e && \
apk --no-cache add dumb-init curl && \
echo "TARGETPLATFORM: $TARGETPLATFORM" && \
if [ "$TARGETPLATFORM" = "linux/386" ]; then ARCH="i586"; \
# linux/arm64/v8 points to linux/arm64
elif [ "$TARGETPLATFORM" = "linux/arm64/v8" \
-o "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH="aarch64"; \
# linux/arm translates to linux/arm/v7
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then ARCH="armv8"; \
elif [ "$TARGETPLATFORM" = "linux/arm/v6" ]; then ARCH="armv6"; \
elif [ "$TARGETPLATFORM" = "linux/amd64/v3" \
-o "$TARGETPLATFORM" = "linux/amd64/v2" \
-o "$TARGETPLATFORM" = "linux/amd64" ]; then ARCH="x86_64"; \
# we dont suppot any other arch so let it fail
else ARCH="unknown"; fi && \
# download requested kiwix-tools version
url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$ARCH-$VERSION.tar.gz" && \
echo "URL: $url" && \
curl -k -L $url | tar -xz -C /usr/local/bin/ --strip-components 1 && \
# only needed in dockerfile
apk del curl
# expose kiwix-serve default port
EXPOSE 80
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["/bin/sh", "-c", "echo 'Welcome to kiwix-tools! The following binaries are available:' && ls /usr/local/bin/"]

36
docker/README.md Normal file
View File

@@ -0,0 +1,36 @@
Kiwix-tools Docker image
===
- Available on [ghcr.io](https://ghcr.io/kiwix/kiwix-tools).
- multi-arch (`linux/amd64`, `linux/arm64`, `linux/arm/v7`)
- based on official `kiwix-tools` binaries.
## Usage
``` sh
$ docker run -it ghcr.io/kiwix/kiwix-tools:3.1.2
Welcome to kiwix-tools! The following binaries are available:
kiwix-manage kiwix-search kiwix-serve
```
`kiwix-tools` operates on zim files. You shall mount a volume to access the files.
```sh
docker run -v $(pwd):/data -it ghcr.io/kiwix/kiwix-tools kiwix-search /data/wikipedia_fr_test.zim "Mali"
```
## Building and reusing
- `kiwix/kiwix-tools` is multi-arch and is ideally built using `buildx`.
- requires a `--build-arg VERSION=` with the kiwix-tools release.
- can be built using `docker build` in which case it expects an additionnal `--build-arg ARCH=arm` for arm. Otherwise defaults to `amd64`.
**Notes:**
- `wget` in `alpine:3` on `arm/v7` (__inside github action only__) crashes when downloading from HTTPs locations. Keep http-only in Dockerfile.
- Was also unhappy when using the mirrors so it's using `mirror.download` on purpose.
## See also
If you are interested by a Kiwix server only container image, [here it is](server/README.md).

View File

@@ -1,18 +1,14 @@
FROM alpine:latest
LABEL maintainer Emmanuel Engelhart <kelson@kiwix.org>
ARG VERSION=latest
# Install kiwix-serve
WORKDIR /
RUN apk add --no-cache curl bzip2
RUN curl -kL https://download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-x86_64.tar.gz | tar -xz && \
mv kiwix-tools*/kiwix-serve /usr/local/bin && \
rm -r kiwix-tools*
# kiwix-tools is multi-arch
FROM ghcr.io/kiwix/kiwix-tools:$VERSION
LABEL org.opencontainers.image.source https://github.com/openzim/kiwix-tools
# Run kiwix-serve
EXPOSE 80
# expose kiwix-serve default port and workdir
EXPOSE 8080
VOLUME /data
WORKDIR /data
COPY ./start.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/start.sh"]
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/start.sh"]

View File

@@ -1,24 +1,54 @@
Kiwix serve Docker image
========================
With local ZIM file
-------------------
With local ZIM file(s)
----------------------
* Download a ZIM file from <https://wiki.kiwix.org/wiki/Content>
* Given `wikipedia.zim` resides in `/tmp/zim/`, execute the following:
* Given `wikipedia.zim` and `wiktionary.zim` reside in `/tmp/zim/`, execute the following:
```bash
docker run -v /tmp/zim:/data -p 8080:80 kiwix/kiwix-serve wikipedia.zim
docker run -v /tmp/zim:/data -p 8080:8080 ghcr.io/kiwix/kiwix-serve wikipedia.zim wiktionary.zim
```
or, if you want to load all ZIM files within a directory, then use globbing:
```bash
docker run -v /tmp/zim:/data -p 8080:8080 ghcr.io/kiwix/kiwix-serve '*.zim'
```
With remote ZIM file
--------------------
```bash
docker run -e "DOWNLOAD=https://download.kiwix.org/zim/wikipedia_bm_all.zim" -p 8080:80 kiwix/kiwix-serve
docker run -e "DOWNLOAD=https://download.kiwix.org/zim/wikipedia_bm_all.zim" -p 8080:8080 ghcr.io/kiwix/kiwix-serve
```
Change default port
-------------------
You can change port to expose with environment variable PORT, useful if running on Podman, K8s or OpenShift
```bash
podman run -e "DOWNLOAD=https://download.kiwix.org/zim/wikipedia_bm_all.zim" -e PORT=8888 -p 8080:8888 ghcr.io/kiwix/kiwix-serve
```
ARM
---
Build an image for an ARM based GNU/Linux:
```bash
docker build . -t ghcr.io/kiwix/kiwix-serve:latest --build-arg ARCH="arm32v7/"
```
Docker Compose
--------------
You can also deploy kiwix with
[`docker-compose`](https://docs.docker.com/compose/). Check out a
sample at [docker-compose.yml.example](docker-compose.yml.example).
Screenshots
-----------

View File

@@ -0,0 +1,14 @@
version: '3.3'
services:
kiwix-serve:
ports:
- 8080:8080
image: ghcr.io/kiwix/kiwix-serve:latest
# uncomment next 4 lines to use it with local zim file in /tmp/zim
# volumes:
# - /tmp/zim:/data
# command:
# - '*.zim'
# uncomment next 2 lines to use it with remote zim file
# environment:
# - 'DOWNLOAD=https://download.kiwix.org/zim/wikipedia_bm_all.zim'

View File

@@ -13,7 +13,11 @@ then
fi
fi
CMD="/usr/local/bin/kiwix-serve --port=80 $@"
if [ -z "$PORT" ]
then
PORT=8080
fi
CMD="/usr/local/bin/kiwix-serve --port=$PORT $@"
echo $CMD
$CMD

50
docs/conf.py Normal file
View File

@@ -0,0 +1,50 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'kiwix-tools'
copyright = '2022, kiwix-team'
author = 'kiwix-team'
# -- General configuration ---------------------------------------------------
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
if not on_rtd:
html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []

8
docs/index.rst Normal file
View File

@@ -0,0 +1,8 @@
Welcome to kiwix-tools' documentation!
======================================
.. toctree::
:maxdepth: 2
:caption: Contents:
kiwix-serve

835
docs/kiwix-serve.rst Normal file
View File

@@ -0,0 +1,835 @@
***********
kiwix-serve
***********
Introduction
============
``kiwix-serve`` is a tool for serving ZIM file content over HTTP. It supports
serving a library containing multiple ZIM files. In a large library served by a
``kiwix-serve`` instance clients can look up/filter ZIM files of interest by
words in their :term:`titles <ZIM title>` and/or descriptions, language, tags, etc.
``kiwix-serve`` provides a ZIM file viewer for displaying inidividual pages
from a ZIM file inside the user's web browser (without downloading the full ZIM
file).
Clients can also remotely search inside those ZIM files that contain a full-text
search database.
Usage
=====
.. code-block:: sh
kiwix-serve --library [OPTIONS] LIBRARY_FILE_PATH
kiwix-serve [OPTIONS] ZIM_FILE_PATH ...
Arguments
---------
.. _cli-arg-library-file-path:
``LIBRARY_FILE_PATH``: path of an XML library file listing ZIM files to serve.
To be used only with the :option:`--library` option. Multiple library files can
be provided as a semicolon (``;``) separated list.
``ZIM_FILE_PATH``: ZIM file path (multiple arguments are allowed).
Options
-------
.. option:: --library
By default, ``kiwix-serve`` expects a list of ZIM files as command line
arguments. Providing the :option:`--library` option tells ``kiwix-serve``
that the command line argument is rather a :ref:`library XML file
<cli-arg-library-file-path>`.
.. option:: -i ADDR, --address=ADDR
Listen only on this IP address. By default the server listens on all
available IP addresses.
.. option:: -p PORT, --port=PORT
TCP port on which to listen for HTTP requests (default: 80).
.. option:: -r ROOT, --urlRootLocation=ROOT
URL prefix on which the content should be made available (default: empty).
.. option:: -d, --daemon
Detach the HTTP server daemon from the main process.
.. option:: -a PID, --attachToProcess=PID
Exit when the process with id PID stops running.
.. option:: -M, --monitorLibrary
Monitor the XML library file and reload it automatically when it changes.
Library reloading can be forced anytime by sending a SIGHUP signal to the
``kiwix-serve`` process (this works regardless of the presence of the
:option:`--monitorLibrary`/:option:`-M` option).
.. option:: -m, --nolibrarybutton
Disable the library home button in the ZIM viewer toolbar.
.. option:: -n, --nosearchbar
Disable the searchbox in the ZIM viewer toolbar.
.. option:: -b, --blockexternal
Prevent the users from directly navigating to external resources via such
links in ZIM content.
.. option:: -t N, --threads=N
Number of threads to run in parallel (default: 4).
.. option:: -s N, --searchLimit=N
Maximum number of ZIM files in a fulltext multizim search (default: No limit).
.. option:: -z, --nodatealiases
Create URL aliases for each content by removing the date embedded in the file
name. The expected format of the date in the filename is ``_YYYY-MM``. For
example, ZIM file ``wikipedia_en_all_2020-08.zim`` will be accessible both as
``wikipedia_en_all_2020-08`` and ``wikipedia_en_all``.
.. option:: -c PATH, --customIndex=PATH
Override the welcome page with a custom HTML file.
.. option:: -L N, --ipConnectionLimit=N
Max number of (concurrent) connections per IP (default: infinite,
recommended: >= 6).
.. option:: -v, --verbose
Print debug log to STDOUT.
.. option:: -V, --version
Print the software version.
.. option:: -h, --help
Print the help text.
HTTP API
========
``kiwix-serve`` serves content at/under ``http://ADDR:PORT/ROOT`` where
``ADDR``, ``PORT`` and ``ROOT`` are the values supplied to the
:option:`--address`/:option:`-i`, :option:`--port`/:option:`-p` and
:option:`--urlRootLocation`/:option:`-r` options, respectively.
HTTP API endpoints presented below are relative to that location, i.e.
``/foo/bar`` must be actually accessed as ``http://ADDR:PORT/ROOT/foo/bar``.
.. note::
The HTTP API is documented in its entirety in order to facilitate the work of
the Kiwix development team. Note, however, that only a subset of the HTTP API
constitutes ``kiwix-serves``'s public interface.
.. _public-api-endpoint:
**Public API endpoint**
A public HTTP API endpoint is intended to serve the outside world (in
addition to ``kiwix-serve``'s front-end and other Kiwix products). The
Kiwix development team will do its best to ensure gratifying experience for
clients of public API endpoints at all stages of the endpoint lifecycle.
.. _private-api-endpoint:
**Private API endpoint**
A private API endpoint is intended to be used only by ``kiwix-serve``'s
frontend or by other products maintained solely by the Kiwix team. Private
API comes without any guaranees. It may change as frequently and as
drasticaly as the Kiwix development team sees fit.
.. _deprecation:
**Deprecation**
Public API doesn't stay frozen once and forever. As the API evolves, Kiwix
team reserves the right to drop support for certain old functionality. In
such events, an advance notice will be issued and the users will be given
enough time to prepare for the change.
Currently, public endpoints are limited to the following list:
- :ref:`OPDS API <new-opds-api>`
- ``/raw``
- ``/search`` (with ``/search/searchdescription.xml``)
.. _welcome-page:
``/``
-----
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
Welcome page is served under ``/``. By default this is the library page, where
books are listed and can be looked up/filtered interactively. However, the
welcome page can be overriden through the :option:`--customIndex`/:option:`-c`
command line option of ``kiwix-serve``.
.. _new-opds-api:
``/catalog/v2`` (OPDS API)
------------------------------
===== ===========
Type: :ref:`public <public-api-endpoint>`
===== ===========
The new OPDS API of ``kiwix-serve`` is based on the `OPDS Catalog specification
v1.2 <https://specs.opds.io/opds-1.2>`_. All of its endpoints are grouped under
``/catalog/v2``.
:ref:`Legacy OPDS API <legacy-opds-api>` is preserved for backward
compatibility.
``/catalog/v2/root.xml``
^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
The OPDS Catalog Root links to the OPDS acquisition and navigation feeds
accessible through the other endpoints of the OPDS API.
``/catalog/v2/searchdescription.xml``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
Describes the `/catalog/v2/entries`_ endpoint in `OpenSearch description format
<https://developer.mozilla.org/en-US/docs/Web/OpenSearch>`_.
``/catalog/v2/categories``
^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
Returns the full list of ZIM file categories as an `OPDS Navigation Feed
<https://specs.opds.io/opds-1.2#22-navigation-feeds>`_.
``/catalog/v2/entries``
^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
Returns a full or filtered list of ZIM files as a paginated `OPDS acquisition
feed <https://specs.opds.io/opds-1.2#23-acquisition-feeds>`_ with `complete
entries
<https://specs.opds.io/opds-1.2#512-partial-and-complete-catalog-entries>`_.
**Pagination:**
By default, no more than 10 first entries are returned from the library. To
obtain the remaining entries the URL query parameters ``start`` and/or
``count`` must be used. The output of ``/catalog/v2/entries?start=s&count=n``
will contain at most ``n`` (default value: 10) results starting from entry #
``s`` (default value: 0). ``count`` with a negative value (e.g. ``count=-1``)
removes the limit on the number of results in the output.
.. note::
Previously ``count=0`` also designated an unbounded query (i.e. worked
similarly to ``count=-1``). The response to a ``count=0`` query was changed
to consist of 0 results, as such a query/response combination is a good way
to find out the total number of results (when only that information is
needed) with minimal consumption of resources.
Examples:
.. code:: sh
# Returns the first 10 entries (internally numbered 0 through 9)
$ curl 'http://localhost:8080/catalog/v2/entries'
# Returns the next 10 entries (internally numbered 10 through 19)
$ curl 'http://localhost:8080/catalog/v2/entries?start=10'
# Returns the first 50 entries
$ curl 'http://localhost:8080/catalog/v2/entries?count=50'
# Returns 50 entries starting from entry # 100 (i.e. entries ## 100-149)
$ curl 'http://localhost:8080/catalog/v2/entries?start=100&count=50'
# Returns all entries
$ curl 'http://localhost:8080/catalog/v2/entries?count=-1'
# Returns all entries starting from entry # 100
$ curl 'http://localhost:8080/catalog/v2/entries?start=100&count=-1'
.. _library-filtering:
**Filtering:**
A filtered subset of the library can be requested by providing one or more
filtering criteria, whereupon only entries matching *all* of the criteria are
included in the response. Pagination is applied to the filtered list. The
filtering criteria must be specified via the following URL parameters:
* ``lang`` - filter by language (specified as a 3-letter language code).
* ``category`` - filter by categories associated with the library entries.
* ``tag`` - filter by tags associated with the library entries. Multiple tags
can be provided as a semicolon separated list (e.g
``tag=wikipedia;_videos:no``). The result will contain only those entries
that contain *all* of the requested tags.
* ``notag`` - filter out (exclude) entries with *any* of the specified tags
(example - ``notag=ted;youtube``).
* ``maxsize`` - include in the results only entries whose size (in bytes)
doesn't exceed the provided value.
* ``q`` - include in the results only entries that contain the specified text
in the title or description.
* ``name`` - include in the results only the entry with the specified
:term:`name <ZIM name>`.
Examples:
.. code:: sh
# List only books in Italian (lang=ita) but
# return only results ## 100-149 (start=100&count=50)
$ curl 'http://localhost:8080/catalog/v2/entries?lang=ita&start=100&count=50'
# List only books with category of 'wikipedia' AND containing the word
# 'science' in the title or description. Return only the first 10 results.
$ curl 'http://localhost:8080/catalog/v2/entries?q=science&category=wikipedia'
``/catalog/v2/entry/ZIMID``
^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
Returns full info about the library entry with :term:`UUID <ZIM UUID>`
``ZIMID``.
``/catalog/v2/illustration/ZIMID``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
**Usage:**
``/catalog/v2/illustration/ZIMID?size=N``
Returns the illustration of size ``NxN`` pixels for the library entry with
:term:`UUID <ZIM UUID>` ``ZIMID``.
If no illustration of requested size is found a HTTP 404 error is returned.
``/catalog/v2/languages``
^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
Returns the full list of ZIM file languages as an `OPDS Navigation Feed
<https://specs.opds.io/opds-1.2#22-navigation-feeds>`_.
``/catalog/v2/partial_entries``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <new-opds-api>`
===== ===========
Returns the full or filtered list of ZIM files as an `OPDS acquisition feed
<https://specs.opds.io/opds-1.2#23-acquisition-feeds>`_ with `partial entries
<https://specs.opds.io/opds-1.2#512-partial-and-complete-catalog-entries>`_.
Supported filters are the same as for the `/catalog/v2/entries`_ endpoint.
.. _legacy-opds-api:
``/catalog`` (Legacy OPDS API)
------------------------------
===== ===========
Type: :ref:`deprecated <deprecation>`
===== ===========
The legacy OPDS API is preserved for backward compatibility and is deprecated.
:ref:`New OPDS API <new-opds-api>` should be used instead.
``/catalog/root.xml``
^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`deprecated API <legacy-opds-api>`
===== ===========
Full library OPDS catalog (list of all ZIM files).
``/catalog/searchdescription.xml``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`deprecated API <legacy-opds-api>`
===== ===========
Describes the `/catalog/search`_ endpoint in `OpenSearch description format
<https://developer.mozilla.org/en-US/docs/Web/OpenSearch>`_.
``/catalog/search``
^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`deprecated API <legacy-opds-api>`
===== ===========
Returns the list of ZIM files (in OPDS catalog format) matching the
search/filtering criteria. Supported filters are the same as for the
`/catalog/v2/entries`_ endpoint.
``/catch/external``
-------------------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
**Usage:**
``/catch/external?source=URL``
Generates a HTML page with a link leading to (the decoded version of) ``URL``
and a warning that following that link will load an external (out of ZIM)
resource.
**Parameters:**
``source``: URL of the external resource (must be URL-encoded).
**Example:**
.. code:: sh
# Intercept an external link to https://example.com?query=abcd
$ curl 'http://localhost:8080/catch/external?source=https%3A%2F%2Fexample.com%3Fquery%3Dabcd'
``/content``
------------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
ZIM file content is served under the ``/content`` endpoint as described below.
``/content/ZIMNAME/PATH/IN/ZIMFILE``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
Returns the entry with path ``PATH/IN/ZIMFILE`` from ZIM file with :term:`name
<ZIM name>` ``ZIMNAME``.
``/content/ZIMNAME``
^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
``/content/ZIMNAME`` redirects to the main page of the ZIM file with :term:`name
<ZIM name>` ``ZIMNAME`` (unless that ZIM file contains an entry with an empty
path or path equal to ``/``, in which case that entry is returned).
``/random``
-----------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
**Usage:**
``/random?content=ZIMNAME``
Generates a HTTP redirect to a randomly selected article/page from the
specified ZIM file.
**Parameters:**
``content``: :term:`name <ZIM name>` of the ZIM file.
.. _raw:
``/raw``
--------
===== ===========
Type: :ref:`public <public-api-endpoint>`
===== ===========
The ``/raw`` API provides access to ZIM file data. It consists of two separate
endpoints for accessing data and metadata.
``/raw/ZIMNAME/content/PATH/IN/ZIMFILE``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <raw>`
===== ===========
Returns the entry with path ``PATH/IN/ZIMFILE`` from the ZIM file with
:term:`name <ZIM name>` ``ZIMNAME``. Currently, this endpoint almost duplicates
(with some subtle technical differences) the newer endpoint
`/content/ZIMNAME/PATH/IN/ZIMFILE`_. The important difference is that the
``/raw`` endpoint guarantees that no server-side processing will be applied to
the returned content, whereas content obtained via the ``/content`` endpoint
may in the future undergo some processing intended to improve the operation of
the viewer (e.g. compensating for certain bugs in ZIM creation). Also note that
``/raw`` is :ref:`public <public-api-endpoint>`, whereas ``/content`` is
:ref:`private <private-api-endpoint>`.
``/raw/ZIMNAME/meta/METADATAID``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
===== ===========
Type: member of a :ref:`public API <raw>`
===== ===========
Returns the metadata item ``METADATAID`` from the ZIM file with :term:`name
<ZIM name>` ``ZIMNAME``.
``/search``
-----------
===== ===========
Type: :ref:`public <public-api-endpoint>`
===== ===========
Performs a full text search on one or more ZIM files and returns an HTML page
with a list of links to matching pages along with snippets of the matching
portions of those pages.
.. _multi-zim-search-constraints:
A multi-ZIM search request must comply with the following constraints:
* the number of ZIM files participating in the search operation must not exceed
the limit imposed by the :option:`--searchLimit` option of ``kiwix-serve``.
* all of the ZIM files participating in the same search operation must be in
the same language.
**Parameters:**
ZIM file selection parameters:
At least one of the following parameters must be provided in order to
specify in which ZIM file(s) to search. Parameters appearing earlier in
below list take precedence over subsequent ones (the later ones, even if
present in the request, are simply ignored).
``content``: :term:`name <ZIM name>` of the ZIM file (for a single-ZIM
search). This is a :ref:`legacy parameter <deprecation>`. ``books.name``
should be used instead.
``books.id``: :term:`UUID <ZIM UUID>` of the ZIM file. Can be repeated for
a multi-ZIM search, however must respect the :ref:`multi-ZIM search
constraints <multi-zim-search-constraints>`.
``books.name``: :term:`name <ZIM name>` of the ZIM file. Can be repeated
for a multi-ZIM search, however must respect the :ref:`multi-ZIM search
constraints <multi-zim-search-constraints>`.
``books.filter.{criteria}``: allows to take full advantage of :ref:`library
filtering <library-filtering>` functionality of the `/catalog/v2/entries`_
endpoint (``{criteria}`` must be replaced with an attribute/filtering
criteria name supported by :ref:`library filtering <library-filtering>`).
Query parameters:
``pattern`` (optional; defaults to an empty string): text to search for.
``latitude``, ``longitude`` & ``distance`` (optional): geospatial query
parameters. If all of these are provided, then the results will be
restricted to geotagged pages that are within ``distance`` metres from the
location on Earth with coordinates ``latitude`` and ``longitude``.
Pagination parameters:
``pageLength`` (optional, default: 25): maximum number of search results in
the response. Capped at 140.
``start`` (optional, default: 1): this parameter enables pagination of
results. The response will include up to ``pageLength`` results starting
with entry # ``start`` from the full list of search results (the first
result is assumed to have index 1).
Other parameters:
``format`` (optional, default: html): format of the search results. Allowed
values are: html, xml.
Examples:
.. code:: sh
# Search for 'android' in the book with name 'scifi-library'
# Return results ## 51-60.
$ curl 'http://localhost:8080/search?pattern=android&books.name=scifi-library&start=51&pageLength=10'
# Search for 'napoli' in books in Italian
$ curl 'http://localhost:8080/search?books.filter.lang=ita&pattern=napoli'
# Search for 'chateau' in books in French that have a category of 'wikipedia'.
# Return the results as XML.
$ curl 'http://localhost:8080/search?pattern=chateau&books.filter.lang=fra&books.filter.category=wikipedia&format=xml'
``/search/searchdescription.xml``
---------------------------------
===== ===========
Type: :ref:`public <public-api-endpoint>`
===== ===========
Describes the `/search`_ endpoint in `OpenSearch description format
<https://developer.mozilla.org/en-US/docs/Web/OpenSearch>`_.
``/skin``
-----------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
Static front-end resources (such as CSS, javascript and images) are all grouped
under ``/skin``.
**Usage:**
``/skin/PATH/TO/RESOURCE[?cacheid=CACHEID]``
`Cache busting
<https://javascript.plainenglish.io/what-is-cache-busting-55366b3ac022>`_ of
static resources is supported via the optional param ``cacheid``. By default,
i.e. when the ``cacheid`` parameter is not specified while accessing the
``/skin`` endpoint, static resources are served as if they were dynamic (i.e.
could be different for an immediately repeated request). Specifying the
``cacheid`` parameter with a correct value (matching the value embedded in the
``kiwix-serve`` instance), makes the returned resource to be presented as
immutable. However, if the value of the ``cacheid`` parameter mismatches then
``kiwix-serve`` responds with a 404 HTTP error.
``kiwix-serve``'s default front-end (the :ref:`welcome page <welcome-page>` and
the :ref:`ZIM file viewer <zim-file-viewer>`) access all underlying static
resources by using explicit ``cacheid`` s.
``/suggest``
------------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
**Usage:**
``/suggest?content=ZIMNAME[&term=QUERY][&count=N][&start=S]``
Returns suggestions (in JSON format) for a text string that is assumed to be a
partially typed search for a page inside a particular ZIM file.
Suggestions are obtained as matches of the query text against the page titles
in the ZIM file using the title index database generated during the creation of
the ZIM file.
In case of a multi-word query the order of the words matters in two ways:
1. the last word is considered as partially typed, unless followed by a space;
2. ranking of the matches.
If the ZIM file doesn't contain a title index then suggestions are generated by
listing page titles starting *exactly* (in a case sensitive manner) with the
query text. Otherwise, suggestions are case-insensitive.
If the ZIM file contains a full text search index, then an extra suggestion is
added as an option to perform a full text search in the said ZIM file.
**Parameters:**
``content`` (mandatory): :term:`name <ZIM name>` of the ZIM file.
``term`` (optional; defaults to an empty string): query text.
``count`` (optional, default: 10): maximum number of page suggestions in the
response (i.e. the extra option to perform a full text search is not included
in this count).
``start`` (optional, default: 0): this parameter enables pagination of
results. The response will include up to ``count`` entries starting with
entry # ``start`` from the full list of page suggestions (the first result is
assumed to have index 0).
**Example:**
.. code:: sh
$ curl 'http://localhost/suggest?content=stackoverflow_en&term=pyth&count=50'
.. _zim-file-viewer:
``/viewer``
-----------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
ZIM file viewer. The ZIM file and entry therein must be specified via the hash
component of the URL as ``/viewer#ZIMNAME/PATH/IN/ZIMFILE``.
``/viewer_settings.js``
-----------------------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
Settings of the ZIM file viewer that are configurable via certain command line
options of ``kiwix-serve`` (e.g. ``--nolibrarybutton``).
/ANYTHING/ELSE
--------------
===== ===========
Type: :ref:`private <private-api-endpoint>`
===== ===========
Any other URL is considered as an attempt to access ZIM file content using the
legacy URL scheme and is redirected to ``/content/ANYTHING/ELSE``.
Glossary
========
.. glossary::
ZIM filename
Name of a ZIM file on the server filesystem.
ZIM name
Identifier of a ZIM file in the server's library (used for referring to a
particular ZIM file in requests).
For a ``kiwix-serve`` started with a list of ZIM files, ZIM names are
derived from the filename by dropping the extension and replacing certain
characters (spaces are replaced with underscores, and ``+`` symbols are
replaced with the text ``plus``). Presence of the
:option:`-z`/:option:`--nodatealiases` option will create additional names
(aliases) for filenames with dates.
For a ``kiwix-serve`` started with the :option:`--library` option, ZIM
names come from the library XML file.
ZIM names are expected to be unique across the library. Any name conflicts
(including those caused by the usage of the
:option:`-z`/:option:`--nodatealiases` option) are reported on STDERR but,
otherwise, are ignored.
ZIM title
Title of a ZIM file. This can be any text (with whitespace). It is never
used as a way of referring to a ZIM file.
ZIM UUID
This is a unique identifier of a ZIM file designated at its creation time
and embedded in the ZIM file. Certain ``kiwix-serve`` operations may
require that a ZIM file be referenced through its UUID rather than name.

7
docs/meson.build Normal file
View File

@@ -0,0 +1,7 @@
sphinx = find_program('sphinx-build', native:true)
sphinx_target = run_target('doc',
command: [sphinx, '-bhtml',
meson.current_source_dir(),
meson.current_build_dir()])

2
docs/requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
Sphinx==5.3.0
sphinx-rtd-theme==1.1.1

View File

@@ -3,7 +3,6 @@
files=(
"src/installer/kiwix-install.cpp"
"src/searcher/kiwix-search.cpp"
"src/reader/kiwix-read.cpp"
"src/manager/kiwix-manage.cpp"
"src/server/kiwix-serve.cpp"
)

View File

@@ -1,7 +1,7 @@
project('kiwix-tools', 'cpp',
version : '3.0.3',
version : '3.5.0',
license : 'GPL',
default_options: ['c_std=c11', 'cpp_std=c++11', 'werror=true'])
default_options: ['c_std=c11', 'cpp_std=c++17', 'werror=true'])
compiler = meson.get_compiler('cpp')
@@ -9,15 +9,17 @@ add_global_arguments('-DKIWIX_TOOLS_VERSION="@0@"'.format(meson.project_version(
static_linkage = get_option('static-linkage')
if static_linkage
add_global_link_arguments('-static-libstdc++', '--static', language:'cpp')
# Static build is not supported on MacOS
if host_machine.system() != 'darwin'
add_global_link_arguments('-static-libstdc++', '--static', language:'cpp')
endif
endif
thread_dep = dependency('threads')
kiwixlib_dep = dependency('kiwix', version:'>=9.0.0', static:static_linkage)
microhttpd_dep = dependency('libmicrohttpd', static:static_linkage)
z_dep = dependency('zlib', static:static_linkage)
kiwixlib_dep = dependency('kiwix', version:'>=12.0.0', static:static_linkage)
libzim_dep = dependency('libzim', version:'>=8.1.0', static:static_linkage)
all_deps = [thread_dep, kiwixlib_dep, microhttpd_dep, z_dep]
all_deps = [thread_dep, kiwixlib_dep, libzim_dep]
if static_linkage
librt = compiler.find_library('rt', required:false)
@@ -27,3 +29,6 @@ if static_linkage
endif
subdir('src')
if get_option('doc')
subdir('docs')
endif

View File

@@ -1,2 +1,4 @@
option('static-linkage', type : 'boolean', value : false,
description : 'Create statically linked binaries.')
option('doc', type : 'boolean', value : false,
description : 'Build the documentations.')

View File

@@ -1,62 +1,69 @@
.TH KIWIX 1 "21 May 2012"
.TH KIWIX-MANAGE 1 "21 May 2012"
.SH NAME
kiwix\-manage \- Kiwix Library Manager
.SH SYNOPSIS
.IX Header SYNOPSIS
.B kiwix\-manage
.br
kiwix\-manage LIBRARY_PATH add ZIM_PATH ...
.br
kiwix-manage LIBRARY_PATH show [CONTENTID1] [CONTENTID2] ...
.br
kiwix\-manage LIBRARY_PATH remove CONTENTID1 [CONTENTID2]
.SH DESCRIPTION
.SS kiwix\-manage
.PP
\fBkiwix\-manage\fP tool for managing a kiwix library.
.PP
Allows one to manage the content of the kiwix library. The library file is a
flat XML file listing ZIM files with all necessary information like favicon,
date, creator, description, indexpath, filepath, title, source/metalink, etc.
.
.PP
Example library file can be found at https://www.kiwix.org/library\.xml
.br
.TP
\fBadd\fR
Add \fBZIM_FILE\fP to \fBLIBRARY_FILE\fP.
\fBkiwix\-manage\fR LIBRARY_PATH \fBadd\fR ZIM_PATH ...
.TP
\fBkiwix\-manage\fR LIBRARY_PATH \fBshow\fR [ZIM_ID_1] [ZIM_ID_2] ...
.TP
\fBkiwix\-manage\fR LIBRARY_PATH \fBremove\fR ZIM_ID_1 [ZIM_ID_2] ...
.TP
\fBkiwix\-manage\fR --version
.TP
\fBkiwix\-manage\fR --help
.SH DESCRIPTION
.PP
\fBkiwix\-manage\fP is a command line tool for manipulating a Kiwix XML library.
.PP
\fBkiwix\-manage\fP allows to manage the entries of the Kiwix
library. The library file is a flat XML file listing ZIM files with
all necessary information like id, favicon, date, creator,
description, filepath, title, url, etc.
.SH ACTIONS
.TP
\fBshow\fR
Show given \fBCONTENT_ID\fP from \fBLIBRARY_FILE\fR. If no \fBCONTENT_ID\fP is given then all contents from \fBLIBRARY_FILE\fR are shown.
\fBadd\fR
Add \fBZIM_FILE\fP to \fBLIBRARY_FILE\fP. Create the library file if necessary.
.TP
\fBremove\fR
Remove the given \fBCONTENT_ID\fR from \fBLIBRARY_FILE\fR. At least one \fBCONTENT_ID\fR should be specified.
Remove the given \fBZIM_ID\fR from \fBLIBRARY_FILE\fR. At least one \fBZIM_ID\fR should be specified.
.TP
\fB\-\-zimPathToSave=\fR
Change the location reference of the ZIM file in the library.
\fBshow\fR
Show given \fBZIM_ID\fP from \fBLIBRARY_FILE\fR. If no \fBZIM_ID\fP is given then all contents from \fBLIBRARY_FILE\fR are shown.
.SH OPTIONS
.TP
Options to be used with the action \fBadd\fR:
.TP
\fB\-\-current\fR
Mark this content as the current (default) content in the library.
\fB\-\-url=HTTP_URL\fR
Set the ZIM online HTTP(S) URL
.TP
\fB\-\-backend=xapian|clucene\fR
Select an indexing backend.
\fB\-\-zimPathToSave=OTHER_FS_PATH\fR
Set an arbitrary ZIM filesystem path (instead of the ZIM_PATH)
.TP
\fB\-\-indexPath=FULLTEXT_IDX_PATH\fR
Path to full-text index for that ZIM file.
Other options (to be used alone):
.TP
\fBurl\fR
Set the content location of the ZIM file over the network for in\-kiwix download.
\fB\-\-help | \-h\fR
Display the kiwix-manage help
.TP
\fB\-\-version | \-v\fR
Display the version of kiwix-manage and all dependences
.SH SEE ALSO
kiwix(1) kiwix\-serve(1)
.SH AUTHOR
Emmanuel Engelhart <kelson@kiwix.org>
.br
Vasudev Kamath <kamathvasudev@gmail.com> (Manual)
kiwix\-serve(1)
.SH AUTHORS
Kiwix team <contact@kiwix.org>

21
src/man/kiwix-search.1 Normal file
View File

@@ -0,0 +1,21 @@
.TH KIWIX-SEARCH "1" "July 2020" "kiwix-tools" "User Commands"
.SH NAME
kiwix-search \- find articles using a fulltext search pattern
.SH SYNOPSIS
\fBkiwix-search\fR [OPTIONS] ZIM PATTERN\fR
.SH DESCRIPTION
.TP
ZIM
ZIM file to search
.TP
PATTERN
Words or parts of words to search for in the ZIM file
.TP
\fB\-s\fR, \fB\-\-suggestion\fR
Suggest article titles based on the PATTERN instead of a fulltext search
.TP
\fB\-V\fR, \fB\-\-version\fR
print software version
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Give details about the search process

View File

@@ -1,60 +1,132 @@
.TH KIWIX 1 "21 May 2012"
.TH KIWIX 1 "10 July 2023"
.SH NAME
kiwix\-serve \- Kiwix HTTP Server
kiwix-serve \- Kiwix HTTP Server
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.B kiwix-serve --library [OPTIONS] LIBRARY_FILE_PATH
.br
kiwix\-serve [\-\-index=INDEX_PATH] [\-\-port=PORT] [\-\-verbose] [\-\-daemon] [\-\-attachToProcess=PID] ZIM_PATH
.br
kiwix\-serve \-\-library [\-\-port=PORT] [\-\-verbose] [\-\-daemon] [\-\-attachToProcess=PID] LIBRARY_PATH
.B kiwix-serve [OPTIONS] ZIM_FILE_PATH ...
.SH DESCRIPTION
.PP
Stand\-alone HTTP server for serving ZIM contents over the network.
The \fBkiwix-serve\fR command is used to run a stand-alone HTTP server for serving ZIM contents over the network.
.SH ARGUMENTS
.TP
\fBLIBRARY_FILE_PATH\fR
Path of an XML library file listing ZIM files to serve. To be used only with the --library option. Multiple library files can be provided as a semicolon (;) separated list.
.TP
\fB\-\-index=INDEX_PATH\fR
Path to index folder created using \fBkiwix-install\fB.
\fBZIM_FILE_PATH ...\fR
ZIM file path(s). Multiple arguments are allowed.
.SH OPTIONS
.TP
\fB--library\fR
By default, kiwix-serve expects a list of ZIM files as command line arguments. Providing the --library option tells kiwix-serve that the command line argument is rather a library XML file.
.TP
\fB\-\-port=PORT\fR
Port number on which the server should listen.
\fB-i ADDR, --address=ADDR\fR
Listen only on this IP address. By default, the server listens on all available IP addresses.
.TP
\fB-p PORT, --port=PORT\fR
TCP port on which to listen for HTTP requests (default: 80).
.TP
\fB-r ROOT, --urlRootLocation=ROOT\fR
URL prefix on which the content should be made available (default: empty).
.TP
\fB-d, --daemon\fR
Detach the HTTP server daemon from the main process.
.TP
\fB-a PID, --attachToProcess=PID\fR
Exit when the process with id PID stops running.
.TP
\fB-M, --monitorLibrary\fR
Monitor the XML library file and reload it automatically when it changes.
Library reloading can be forced anytime by sending a SIGHUP signal to the
\*(lqkiwix-serve\*(rq process (this works regardless of the presence of the
\*(lq--monitorLibrary\*(rq/\*(lq-M\*(rq option).
.TP
\fB-m, --nolibrarybutton\fR
Disable the library home button in the ZIM viewer toolbar.
.TP
\fB-n, --nosearchbar\fR
Disable the search box in the ZIM viewer toolbar.
.TP
\fB-b, --blockexternal\fR
Prevent users from directly navigating to external resources via links in ZIM content.
.TP
\fB-t N, --threads=N\fR
Number of threads to run in parallel (default: 4).
.TP
\fB-s N, --searchLimit=N\fR
Maximum number of ZIM files in a fulltext multizim search (default: No limit).
.TP
\fB-z, --nodatealiases\fR
Create URL aliases for each content by removing the date embedded in the file name.
The expected format of the date in the filename is \*(lq_YYYY-MM\*(rq. For example, a ZIM file named \*(lqwikipedia_en_all_2020-08.zim\*(rq will be accessible both as \*(lqwikipedia_en_all_2020-08\*(rq and \*(lqwikipedia_en_all\*(rq.
.TP
\fB-c PATH, --customIndex=PATH\fR
Override the welcome page with a custom HTML file.
.TP
\fB-L N, --ipConnectionLimit=N\fR
Max number of (concurrent) connections per IP (default: infinite, recommended: >= 6).
.TP
\fB-v, --verbose\fR
Print debug log to STDOUT.
.TP
\fB-V, --version\fR
Print the software version.
.TP
\fB-h, --help\fR
Print a help message.
.SH EXAMPLES
Serve a single ZIM file:
.sp
.nf
.B kiwix-serve myzim.zim
.fi
Serve multiple ZIM files:
.sp
.nf
.B kiwix-serve zim1.zim zim2.zim zim3.zim
.fi
Serve ZIM files from a library:
.sp
.nf
.B kiwix-serve --library library.xml
.fi
.SH DOCUMENTATION
Online documentation: https://kiwix-tools.readthedocs.io/en/latest/kiwix-serve.html
.br
By default, server listens on port 80.
.TP
\fB\-\-verbose\fR
Enable verbose output.
.TP
\fB\-\-daemon\fR
Run the server as a daemon.
.TP
\fB\-\-attachToProcess=PID\fR
Shutdown the server when process numbered PID dies.
.TP
\fBZIM_PATH\fR
ZIM file of the content to serve.
Source code: https://github.com/kiwix/kiwix-tools
.br
Mandatory if not in library mode.
More info: https://wiki.kiwix.org/wiki/Kiwix-serve
.TP
\fB\-\-library\fR
Enable library mode.
.br
Serves the contents of a library file instead of a single ZIM file.
.TP
\fBLIBRARY_PATH\fR
Kiwix library file path.
.br
Library is an XML file created using \fBkiwix-manage\fB.
.SH SEE ALSO
kiwix(1) kiwix\-manage(1)
.SH AUTHOR
.SH AUTHORS
Emmanuel Engelhart <kelson@kiwix.org>
.br
Vasudev Kamath <kamathvasudev@gmail.com> (Manual)
Vasudev Kamath <kamathvasudev@gmail.com>

View File

@@ -1,3 +1,4 @@
install_man('kiwix-manage.1',
'kiwix-search.1',
'kiwix-serve.1')
subdir('fr')

View File

@@ -18,8 +18,8 @@
*/
#include <getopt.h>
#include <kiwix/tools/stringTools.h>
#include <kiwix/manager.h>
#include <kiwix/tools.h>
#include <cstdlib>
#include <iostream>
@@ -169,7 +169,10 @@ int handle_add(kiwix::Library* library, const std::string& libraryPath,
std::string zimPath = argv[i];
if (!zimPath.empty()) {
auto _zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
manager.addBookFromPathAndGetId(zimPath, _zimPathToSave, url, false);
if (manager.addBookFromPathAndGetId(zimPath, _zimPathToSave, url, false).empty()) {
std::cerr << "Cannot add zim " << zimPath << " to the library." << std::endl;
resultCode = 1;
}
} else {
std::cerr << "Invalid zim file path" << std::endl;
resultCode = 1;
@@ -251,15 +254,20 @@ int main(int argc, char** argv)
/* Print usage)) if necessary */
if (libraryPath == "" || action == NONE) {
usage();
exit(1);
return -1;
}
/* Try to read the file */
libraryPath = isRelativePath(libraryPath)
? computeAbsolutePath(getCurrentDirectory(), libraryPath)
libraryPath = kiwix::isRelativePath(libraryPath)
? kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), libraryPath)
: libraryPath;
kiwix::Manager manager(&library);
manager.readFile(libraryPath, false);
if (!manager.readFile(libraryPath, false)) {
if (kiwix::fileExists(libraryPath) || action!=ADD) {
std::cerr << "Cannot read the library " << libraryPath << std::endl;
return 1;
}
}
/* SHOW */
int exitCode = 0;
@@ -277,10 +285,18 @@ int main(int argc, char** argv)
break;
}
/* Rewrite the library file */
if (action == REMOVE || action == ADD) {
library.writeToFile(libraryPath);
if (exitCode) {
return exitCode;
}
exit(exitCode);
/* Rewrite the library file */
if (action == REMOVE || action == ADD) {
// writeToFile return true (1) if everything is ok => exitCode is 0
if (!library.writeToFile(libraryPath)) {
std::cerr << "Cannot write the library " << libraryPath << std::endl;
return 1;
}
}
return 0;
}

View File

@@ -1,6 +1,4 @@
subdir('manager')
subdir('reader')
subdir('searcher')
subdir('server')
subdir('man')

View File

@@ -1,107 +0,0 @@
/*
* Copyright 2011 Emmanuel Engelhart <kelson@kiwix.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include <getopt.h>
#include <kiwix/reader.h>
#include <map>
#include <string>
#include "../version.h"
void usage()
{
cout << "Usage: kiwix-read [--verbose] [--version] --suggest=<PATTERN> ZIM_FILE_PATH" << endl;
exit(1);
}
int main(int argc, char** argv)
{
/* Init the variables */
const char* filePath = NULL;
const char* pattern = NULL;
int option_index = 0;
int c = 0;
kiwix::Reader* reader = NULL;
/* Argument parsing */
while (42) {
static struct option long_options[]
= {{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"suggest", required_argument, 0, 's'},
{0, 0, 0, 0}};
if (c != -1) {
c = getopt_long(argc, argv, "Vvs:", long_options, &option_index);
switch (c) {
case 'v':
break;
case 'V':
version();
return 0;
case 's':
pattern = optarg;
break;
}
} else {
if (optind < argc) {
if (filePath == NULL) {
filePath = argv[optind++];
} else {
usage();
}
} else {
break;
}
}
}
/* Check if we have enough arguments */
if (filePath == NULL) {
usage();
}
/* Instanciate the reader */
reader = new kiwix::Reader(filePath);
/* Start to read an article */
if (reader != NULL) {
string content;
string contentType;
string suggestion;
if (pattern != NULL) {
std::cout << "Searching suggestions for: " << pattern << std::endl;
reader->searchSuggestionsSmart(pattern, 10);
while (reader->getNextSuggestion(suggestion)) {
std::cout << suggestion << std::endl;
}
}
delete reader;
} else {
cerr << "Unable instanciate the Kiwix reader." << endl;
exit(1);
}
exit(0);
}

View File

@@ -1,3 +0,0 @@
executable('kiwix-read', ['kiwix-read.cpp'],
dependencies:all_deps,
install:true)

View File

@@ -18,15 +18,20 @@
*/
#include <getopt.h>
#include <kiwix/reader.h>
#include <kiwix/searcher.h>
#include <zim/search.h>
#include <zim/suggestion.h>
#include <iostream>
#include "../version.h"
using namespace std;
void usage()
{
cout << "Usage: kiwix-search [OPTIONS] ZIM PATTERN" << endl << endl
<< " kiwix-search allows to find articles based on the a fulltext search pattern." << endl << endl
<< " kiwix-search allows one to find articles based on the a fulltext search pattern." << endl << endl
<< " ZIM is the full path of the ZIM file." << endl
<< " PATTERN is/are word(s) - or part of - to search in the ZIM." << endl << endl
<< " -s, --suggestion\tSuggest article titles based on the few letters of the PATTERN instead of making a fulltext search. Work a bit like a completion solution." << endl
@@ -48,9 +53,6 @@ int main(int argc, char** argv)
int option_index = 0;
int c = 0;
kiwix::Searcher* searcher = NULL;
kiwix::Reader* reader = NULL;
/* Argument parsing */
while (42) {
static struct option long_options[]
@@ -96,40 +98,24 @@ int main(int argc, char** argv)
/* Try to prepare the indexing */
try {
reader = new kiwix::Reader(zimPath);
} catch (...) {
/* Cannot open the zimPath, maybe it is a plain old xapian database
* directory */
}
zim::Archive archive(zimPath);
if (reader) {
searcher = new kiwix::Searcher();
searcher->add_reader(reader);
} else {
cerr << "Unable to search through zim '" << zimPath << "'." << endl;
exit(1);
}
/* Start the indexing */
if (searcher != NULL) {
string searchString(search);
if (suggestionFlag) {
searcher->suggestions(searchString, verboseFlag);
} else {
searcher->search(searchString, 0, 10, verboseFlag);
zim::SuggestionSearcher searcher(archive);
searcher.setVerbose(verboseFlag);
for (const auto& r : searcher.suggest(search).getResults(0, 10) ) {
cout << r.getTitle() << endl;
}
} else {
zim::Searcher searcher(archive);
searcher.setVerbose(verboseFlag);
const zim::Query query(search);
for (const auto& r : searcher.search(query).getResults(0, 10) ) {
cout << r.getTitle() << endl;
}
}
kiwix::Result* p_result;
while ((p_result = searcher->getNextResult())) {
cout << p_result->get_title() << endl;
delete p_result;
}
delete searcher;
delete reader;
// kiwix::XapianSearcher::terminate();
} else {
cerr << "Unable instanciate the Kiwix searcher." << endl;
} catch ( const std::runtime_error& err) {
cerr << err.what() << endl;
exit(1);
}

View File

@@ -1,3 +1,4 @@
/*
* Copyright 2009-2019 Emmanuel Engelhart <kelson@kiwix.org>
*
@@ -21,11 +22,15 @@
#include <kiwix/manager.h>
#include <kiwix/server.h>
#include <kiwix/name_mapper.h>
#include <kiwix/tools/otherTools.h>
#include <kiwix/tools.h>
#ifndef _WIN32
#ifdef _WIN32
# include <windows.h>
#else
# include <unistd.h>
# include <signal.h>
#endif
#include <sys/stat.h>
#ifdef __APPLE__
# import <sys/sysctl.h>
@@ -45,28 +50,33 @@ void usage()
<< std::endl
<< "Purpose:" << std::endl
<< "\tDeliver ZIM file articles via HTTP"
<< "\tDeliver ZIM file(s) articles via HTTP"
<< std::endl << std::endl
<< "Mandatory arguments:" << std::endl
<< "\tLIBRARY_PATH\t\tis the XML library file path listing ZIM file to serve. To be used only with the --library argument."
<< "\tLIBRARY_PATH\t\tXML library file path listing ZIM file to serve. To be used only with the --library argument."
<< std::endl
<< "\tZIM_PATH\t\tis the path of a ZIM file."
<< "\tZIM_PATH\t\tZIM file path(s)"
<< std::endl << std::endl
<< "Optional arguments:" << std::endl
<< "\t-a, --attachToProcess\texit if given process id is not running anymore" << std::endl
<< "\t-d, --daemon\t\tdetach the HTTP server daemon from the main process" << std::endl
<< "\t-i, --address\t\tlisten only on this ip address, all available ones otherwise" << std::endl
<< "\t-m, --nolibrarybutton\tdo not print the builtin home button in the builtin top bar overlay" << std::endl
<< "\t-n, --nosearchbar\tdo not print the builtin bar overlay on the top of each served page" << std::endl
<< "Optional arguments:" << std::endl << std::endl
<< "\t-h, --help\t\tPrint this help" << std::endl << std::endl
<< "\t-a, --attachToProcess\tExit if given process id is not running anymore" << std::endl
<< "\t-d, --daemon\t\tDetach the HTTP server daemon from the main process" << std::endl
<< "\t-i, --address\t\tListen only on this ip address, all available ones otherwise" << std::endl
<< "\t-M, --monitorLibrary\tMonitor the XML library file and reload it automatically" << std::endl
<< "\t-m, --nolibrarybutton\tDon't print the builtin home button in the builtin top bar overlay" << std::endl
<< "\t-n, --nosearchbar\tDon't print the builtin bar overlay on the top of each served page" << std::endl
<< "\t-b, --blockexternal\tPrevent users from directly accessing external links" << std::endl
<< "\t-p, --port\t\tTCP port on which to listen to HTTP requests (default: 80)" << std::endl
<< "\t-r, --urlRootLocation\tURL prefix on which the content should be made available (default: /)" << std::endl
<< "\t-t, --threads\t\tnumber of threads to run in parallel (default: " << DEFAULT_THREADS << ")" << std::endl
<< "\t-v, --verbose\t\tprint debug log to STDOUT" << std::endl
<< "\t-V, --version\t\tprint software version" << std::endl
<< "\t-z, --nodatealiases\tcreate URL aliases for each content by removing the date" << std::endl
<< "\t--donottrustlibrary\tRead the metadata from the zim file instead of trusting the library." << std::endl
<< "\t-s, --searchLimit\tMaximun number of zim in a fulltext multizim search (default: No limit)" << std::endl
<< "\t-t, --threads\t\tNumber of threads to run in parallel (default: " << DEFAULT_THREADS << ")" << std::endl
<< "\t-v, --verbose\t\tPrint debug log to STDOUT" << std::endl
<< "\t-V, --version\t\tPrint software version" << std::endl
<< "\t-z, --nodatealiases\tCreate URL aliases for each content by removing the date" << std::endl
<< "\t-c, --customIndex\tAdd path to custom index.html for welcome page" << std::endl
<< "\t-L, --ipConnectionLimit\tMax number of (concurrent) connections per IP (default: infinite, recommended: >= 6)" << std::endl
<< std::endl
<< "Documentation:" << std::endl
@@ -75,50 +85,177 @@ void usage()
<< std::endl;
}
std::string loadCustomTemplate (std::string customIndexPath) {
customIndexPath = kiwix::isRelativePath(customIndexPath) ?
kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), customIndexPath) :
customIndexPath;
if (!kiwix::fileReadable(customIndexPath)) {
throw std::runtime_error("No such file exist (or file is not readable) " + customIndexPath);
}
if (kiwix::getMimeTypeForFile(customIndexPath) != "text/html") {
throw std::runtime_error("Invalid File Mime Type " + kiwix::getMimeTypeForFile(customIndexPath));
}
std::string indexTemplateString = kiwix::getFileContent(customIndexPath);
if (indexTemplateString.empty()) {
throw std::runtime_error("Unreadable or empty file " + customIndexPath);
}
return indexTemplateString;
}
inline std::string normalizeRootUrl(std::string rootUrl)
{
while ( !rootUrl.empty() && rootUrl.back() == '/' )
rootUrl.pop_back();
while ( !rootUrl.empty() && rootUrl.front() == '/' )
rootUrl = rootUrl.substr(1);
return rootUrl.empty() ? rootUrl : "/" + rootUrl;
}
volatile sig_atomic_t waiting = false;
volatile sig_atomic_t libraryMustBeReloaded = false;
#ifndef _WIN32
void handle_sigterm(int signum)
{
if ( waiting == false ) {
_exit(signum);
}
waiting = false;
}
void handle_sighup(int signum)
{
libraryMustBeReloaded = true;
}
typedef void (*SignalHandler)(int);
void set_signal_handler(int sig, SignalHandler handler)
{
struct sigaction sa;
sigaction(sig, NULL, &sa);
sa.sa_handler = handler;
sigaction(sig, &sa, NULL);
}
void setup_sighandlers()
{
set_signal_handler(SIGTERM, &handle_sigterm);
set_signal_handler(SIGINT, &handle_sigterm);
set_signal_handler(SIGHUP, &handle_sighup);
}
#endif
uint64_t fileModificationTime(const std::string& path)
{
#if defined(_WIN32) && !defined(stat)
#define stat _stat
#endif
struct stat fileStatData;
if ( stat(path.c_str(), &fileStatData) == 0 ) {
return fileStatData.st_mtime;
}
return 0;
#ifdef _WIN32
#undef stat
#endif
}
uint64_t newestFileTimestamp(const std::vector<std::string>& paths)
{
uint64_t t = 0;
for ( const auto& p : paths ) {
t = std::max(t, fileModificationTime(p));
}
return t;
}
bool reloadLibrary(kiwix::Manager& mgr, const std::vector<std::string>& paths)
{
try {
std::cout << "Loading the library from the following files:\n";
for ( const auto& p : paths ) {
std::cout << "\t" << p << std::endl;
}
mgr.reload(paths);
std::cout << "The library was successfully loaded." << std::endl;
return true;
} catch ( const std::runtime_error& err ) {
std::cerr << "ERROR: " << err.what() << std::endl;
std::cerr << "Errors encountered while loading the library." << std::endl;
return false;
}
}
int main(int argc, char** argv)
{
std::string rootLocation = "";
#ifndef _WIN32
setup_sighandlers();
#endif
std::string rootLocation = "/";
kiwix::Library library;
unsigned int nb_threads = DEFAULT_THREADS;
vector<string> zimPathes;
string libraryPath;
string rootPath;
string address;
std::vector<std::string> zimPathes;
std::string libraryPath;
std::string rootPath;
std::string address;
std::string customIndexPath="";
std::string indexTemplateString="";
int serverPort = 80;
int daemonFlag [[gnu::unused]] = false;
int libraryFlag = false;
bool noLibraryButtonFlag = false;
bool noSearchBarFlag = false;
bool noDateAliasesFlag = false;
bool blockExternalLinks = false;
bool isVerboseFlag = false;
bool trustlibrary = true;
string PPIDString;
bool monitorLibrary = false;
unsigned int PPID = 0;
int ipConnectionLimit = 0;
int searchLimit = 0;
static struct option long_options[]
= {{"daemon", no_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"library", no_argument, 0, 'l'},
{"nolibrarybutton", no_argument, 0, 'm'},
{"nodatealiases", no_argument, 0, 'z'},
{"nosearchbar", no_argument, 0, 'n'},
{"blockexternallinks", no_argument, 0, 'b'},
{"attachToProcess", required_argument, 0, 'a'},
{"port", required_argument, 0, 'p'},
{"address", required_argument, 0, 'i'},
{"threads", required_argument, 0, 't'},
{"urlRootLocation", required_argument, 0, 'r'},
{"donottrustlibrary", no_argument, 0, 'T'},
{"customIndex", required_argument, 0, 'c'},
{"monitorLibrary", no_argument, 0, 'M'},
{"ipConnectionLimit", required_argument, 0, 'L'},
{"searchLimit", required_argument, 0, 's'},
{0, 0, 0, 0}};
std::set<int> usedOptions;
/* Argument parsing */
while (true) {
int option_index = 0;
int c
= getopt_long(argc, argv, "zmndvVla:p:f:t:r:i:", long_options, &option_index);
= getopt_long(argc, argv, "hzmnbdvVla:p:f:t:r:i:c:ML:s:", long_options, &option_index);
if (c != -1) {
auto insertRes = usedOptions.insert(c);
if (!insertRes.second) {
std::cerr << "Multiple values of same option are not allowed." << std::endl;
exit(1);
}
switch (c) {
case 'h':
usage();
return 0;
case 'd':
daemonFlag = true;
break;
@@ -134,30 +271,45 @@ int main(int argc, char** argv)
case 'n':
noSearchBarFlag = true;
break;
case 'b':
blockExternalLinks = true;
break;
case 'z':
noDateAliasesFlag = true;
break;
case 'm':
noLibraryButtonFlag = true;
break;
case 'T':
trustlibrary = false;
case 'p':
serverPort = atoi(optarg);
break;
case 'a':
PPIDString = string(optarg);
PPID = atoi(optarg);
break;
case 'i':
address = string(optarg);
address = std::string(optarg);
break;
case 't':
nb_threads = atoi(optarg);
break;
case 'r':
rootLocation = string(optarg);
rootLocation = std::string(optarg);
break;
case 'c':
customIndexPath = std::string(optarg);
break;
case 'M':
monitorLibrary = true;
break;
case 'L':
ipConnectionLimit = atoi(optarg);
break;
case 's':
searchLimit = atoi(optarg);
break;
case '?':
usage();
return 2;
}
} else {
if (optind < argc) {
@@ -180,47 +332,30 @@ int main(int argc, char** argv)
/* Setup the library manager and get the list of books */
kiwix::Manager manager(&library);
std::vector<std::string> libraryPaths;
if (libraryFlag) {
vector<string> libraryPaths = kiwix::split(libraryPath, ";");
vector<string>::iterator itr;
for (itr = libraryPaths.begin(); itr != libraryPaths.end(); ++itr) {
if (!itr->empty()) {
bool retVal = false;
try {
string libraryPath
= isRelativePath(*itr)
? computeAbsolutePath(getCurrentDirectory(), *itr)
: *itr;
retVal = manager.readFile(libraryPath, true, trustlibrary);
} catch (...) {
retVal = false;
}
if (!retVal) {
cerr << "Unable to open the XML library file '" << *itr << "'."
<< endl;
exit(1);
}
}
libraryPaths = kiwix::split(libraryPath, ";");
if ( !reloadLibrary(manager, libraryPaths) ) {
exit(1);
}
/* Check if the library is not empty (or only remote books)*/
if (library.getBookCount(true, false) == 0) {
cerr << "The XML library file '" << libraryPath
<< "' is empty (or has only remote books)." << endl;
std::cerr << "The XML library file '" << libraryPath
<< "' is empty (or has only remote books)." << std::endl;
}
} else {
std::vector<std::string>::iterator it;
for (it = zimPathes.begin(); it != zimPathes.end(); it++) {
if (!manager.addBookFromPath(*it, *it, "", false)) {
cerr << "Unable to add the ZIM file '" << *it
<< "' to the internal library." << endl;
std::cerr << "Unable to add the ZIM file '" << *it
<< "' to the internal library." << std::endl;
exit(1);
}
}
}
auto libraryFileTimestamp = newestFileTimestamp(libraryPaths);
auto curLibraryFileTimestamp = libraryFileTimestamp;
#ifndef _WIN32
/* Fork if necessary */
@@ -241,25 +376,39 @@ int main(int argc, char** argv)
}
#endif
kiwix::HumanReadableNameMapper nameMapper(library, noDateAliasesFlag);
kiwix::UpdatableNameMapper nameMapper(library, noDateAliasesFlag);
kiwix::Server server(&library, &nameMapper);
if (!customIndexPath.empty()) {
try {
indexTemplateString = loadCustomTemplate(customIndexPath);
} catch (std::runtime_error& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
exit(1);
}
}
server.setAddress(address);
server.setRoot(rootLocation);
server.setPort(serverPort);
server.setNbThreads(nb_threads);
server.setVerbose(isVerboseFlag);
server.setTaskbar(!noSearchBarFlag, !noLibraryButtonFlag);
server.setBlockExternalLinks(blockExternalLinks);
server.setIndexTemplateString(indexTemplateString);
server.setIpConnectionLimit(ipConnectionLimit);
server.setMultiZimSearchLimit(searchLimit);
if (! server.start()) {
cerr << "Unable to instantiate the HTTP daemon. The port " << serverPort
<< " is maybe already occupied or need more permissions to be open. "
"Please try as root or with a port number higher or equal to 1024."
<< endl;
exit(1);
}
std::string url = "http://" + server.getAddress() + ":" + std::to_string(server.getPort()) + normalizeRootUrl(rootLocation);
std::cout << "The Kiwix server is running and can be accessed in the local network at: "
<< url << std::endl;
/* Run endless (until PPID dies) */
bool waiting = true;
waiting = true;
do {
if (PPID > 0) {
#ifdef _WIN32
@@ -280,7 +429,7 @@ int main(int argc, char** argv)
int ret = sysctl(mib, MIBSIZE, &kp, &len, NULL, 0);
if (ret != -1 && len > 0) {
#else /* Linux & co */
string procPath = "/proc/" + string(PPIDString);
std::string procPath = "/proc/" + std::to_string(PPID);
if (access(procPath.c_str(), F_OK) != -1) {
#endif
} else {
@@ -289,6 +438,18 @@ int main(int argc, char** argv)
}
kiwix::sleep(1000);
if ( monitorLibrary ) {
curLibraryFileTimestamp = newestFileTimestamp(libraryPaths);
libraryMustBeReloaded += curLibraryFileTimestamp > libraryFileTimestamp;
}
if ( libraryMustBeReloaded && !libraryPaths.empty() ) {
libraryFileTimestamp = curLibraryFileTimestamp;
reloadLibrary(manager, libraryPaths);
nameMapper.update();
libraryMustBeReloaded = false;
}
} while (waiting);
/* Stop the daemon */

View File

@@ -24,9 +24,16 @@
#define KIWIX_TOOLS_VERSION "undefined"
#endif
#include <kiwix/version.h>
#include <zim/version.h>
#include <iostream>
void version()
{
std::cout << KIWIX_TOOLS_VERSION << std::endl;
std::cout << "kiwix-tools " << KIWIX_TOOLS_VERSION << std::endl << std::endl;
kiwix::printVersions();
std::cout << std::endl;
zim::printVersions();
}
#endif //_KIWIX_TOOLs_VERSION_H_