mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2026-01-10 06:58:00 -05:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcbb4a56bc | ||
|
|
e37af51dd4 | ||
|
|
43704c6154 | ||
|
|
d25fda82be | ||
|
|
279cdcda0b | ||
|
|
331743ea29 | ||
|
|
19f11d8777 | ||
|
|
3377f9e8bb | ||
|
|
930c8321ca | ||
|
|
a3239ea8bc | ||
|
|
456c77d8fd | ||
|
|
7913b6a4f0 | ||
|
|
027f7d6620 | ||
|
|
18b532a923 | ||
|
|
21a145d999 | ||
|
|
be89de2bbe | ||
|
|
433010a900 | ||
|
|
dd14e02741 | ||
|
|
8ea12b2ce5 | ||
|
|
67c0ebd6ad | ||
|
|
c5197ceb51 | ||
|
|
98b4fb3cdf | ||
|
|
33bdf56bdd | ||
|
|
4556262c87 | ||
|
|
cb2159b114 | ||
|
|
5b45e1898b | ||
|
|
f6128b9079 | ||
|
|
ba64c1637e | ||
|
|
3a0e87d8ea | ||
|
|
9ca2b9fc16 | ||
|
|
f5932bf5d3 | ||
|
|
018df0d563 | ||
|
|
76ac5ce93f | ||
|
|
d0847525c6 | ||
|
|
7f0c1d8a3f | ||
|
|
bd9e67f48e | ||
|
|
a4cc4ba55b | ||
|
|
1a1274012f | ||
|
|
74712ff022 | ||
|
|
3c6971fced | ||
|
|
7a7eaaba0e | ||
|
|
d166947447 | ||
|
|
92ee72a8f2 | ||
|
|
d0f8226f50 | ||
|
|
221055f49c | ||
|
|
a463c31a0c | ||
|
|
6e239d5cb6 | ||
|
|
191dc95266 | ||
|
|
840f92c677 | ||
|
|
f03dc46342 | ||
|
|
a8a62aef74 | ||
|
|
7f9bf58742 |
30
.github/workflows/ci.yml
vendored
30
.github/workflows/ci.yml
vendored
@@ -14,10 +14,10 @@ jobs:
|
||||
- win32_dyn
|
||||
include:
|
||||
- target: native_static
|
||||
image_variant: bionic
|
||||
image_variant: focal
|
||||
lib_postfix: '/x86_64-linux-gnu'
|
||||
- target: native_dyn
|
||||
image_variant: bionic
|
||||
image_variant: focal
|
||||
lib_postfix: '/x86_64-linux-gnu'
|
||||
- target: win32_static
|
||||
image_variant: f35
|
||||
@@ -36,22 +36,11 @@ jobs:
|
||||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
||||
id: extract_branch
|
||||
- name: Checkout code
|
||||
shell: python
|
||||
run: |
|
||||
from subprocess import check_call
|
||||
from os import environ
|
||||
command = [
|
||||
'git', 'clone',
|
||||
'https://github.com/${{github.repository}}',
|
||||
'--depth=1',
|
||||
'--branch', '${{steps.extract_branch.outputs.branch}}'
|
||||
]
|
||||
check_call(command, cwd=environ['HOME'])
|
||||
- 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
|
||||
uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
uses: kiwix/kiwix-build/actions/dl_deps_archive@main
|
||||
with:
|
||||
target_platform: ${{ matrix.target }}
|
||||
- name: Compile
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -63,10 +52,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"
|
||||
|
||||
8
.github/workflows/docker.yml
vendored
8
.github/workflows/docker.yml
vendored
@@ -28,8 +28,10 @@ jobs:
|
||||
VERSION={tag}
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm/v7
|
||||
linux/arm64
|
||||
linux/arm/v7
|
||||
linux/arm/v6
|
||||
linux/386
|
||||
restrict-to: kiwix/kiwix-tools
|
||||
manual-tag: ${{ github.event.inputs.version }}
|
||||
repo_description: auto
|
||||
@@ -55,8 +57,10 @@ jobs:
|
||||
VERSION={tag}
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm/v7
|
||||
linux/arm64
|
||||
linux/arm/v7
|
||||
linux/arm/v6
|
||||
linux/386
|
||||
restrict-to: kiwix/kiwix-tools
|
||||
manual-tag: ${{ github.event.inputs.version }}
|
||||
repo_description: auto
|
||||
|
||||
9
.github/workflows/package.yml
vendored
9
.github/workflows/package.yml
vendored
@@ -8,7 +8,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
distro:
|
||||
- ubuntu-kinetic
|
||||
- ubuntu-jammy
|
||||
- ubuntu-focal
|
||||
steps:
|
||||
@@ -41,14 +40,6 @@ jobs:
|
||||
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
|
||||
|
||||
21
.readthedocs.yaml
Normal file
21
.readthedocs.yaml
Normal 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
|
||||
15
Changelog
15
Changelog
@@ -1,3 +1,18 @@
|
||||
kiwix-tools 3.7.0
|
||||
=================
|
||||
|
||||
* Fixed ZIM name vs Book name confusion in documentation (@veloman-yunkan #663)
|
||||
* Fixes compilation dependencies to rely on appropriate version (@kelson42 #667)
|
||||
* New --skipInvalid Kiwix Server command line option (@schuellerf @kelson42 #666)
|
||||
|
||||
kiwix-tools 3.6.0
|
||||
=================
|
||||
|
||||
* Improved kiwix-serve man page (@iArchitSharma #626)
|
||||
* C++17 compliant code base (@mgautierfr #636)
|
||||
* Support of libkiwix13 (@mgautierfr #633)
|
||||
* Additional docker images archs for armv6 and i386 (@rgaudin #622)
|
||||
|
||||
kiwix-tools 3.5.0
|
||||
=================
|
||||
|
||||
|
||||
10
README.md
10
README.md
@@ -4,7 +4,7 @@ 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-search: Fulltext search in ZIM files
|
||||
* kiwix-search: Full text search in ZIM files
|
||||
* kiwix-serve: HTTP daemon serving ZIM files
|
||||
|
||||
[](https://download.kiwix.org/release/kiwix-tools/)
|
||||
@@ -29,8 +29,8 @@ Preamble
|
||||
--------
|
||||
|
||||
Although the Kiwix tools can be compiled/cross-compiled on/for many
|
||||
sytems, the following documentation explains how to do it on POSIX
|
||||
ones. It is primarly thought for GNU/Linux systems and has been tested
|
||||
systems, the following documentation explains how to do it on POSIX
|
||||
ones. It is primarily thought for GNU/Linux systems and has been tested
|
||||
on recent releases of
|
||||
[Debian](https://debian.org)/[Ubuntu](https://ubuntu.com) and
|
||||
[Fedora](https://getfedora.org).
|
||||
@@ -62,7 +62,7 @@ Environment
|
||||
-------------
|
||||
|
||||
The Kiwix tools build using [Meson](http://mesonbuild.com/) version
|
||||
0.43 or higher. Meson relies itself on Ninja, pkg-config and few other
|
||||
0.43 or higher. Meson relies itself on Ninja, pkg-config and a few other
|
||||
compilation tools. Install them first:
|
||||
* [Meson](http://mesonbuild.com/)
|
||||
* [Ninja](https://ninja-build.org/)
|
||||
@@ -96,7 +96,7 @@ ninja -C build install
|
||||
```
|
||||
|
||||
You might need to run the command as `root` (or using `sudo`),
|
||||
depending where you want to install the Kiwix tools. After the
|
||||
depending on where you want to install the Kiwix tools. After the
|
||||
installation succeeded, you may need to run ldconfig (as `root`).
|
||||
|
||||
Uninstallation
|
||||
|
||||
4
debian/control
vendored
4
debian/control
vendored
@@ -3,8 +3,8 @@ 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~),
|
||||
libzim-dev (>= 9.0.0), libzim-dev (<< 10.0.0),
|
||||
libkiwix-dev (>= 13.0.0), libkiwix-dev (<< 14.0.0),
|
||||
meson,
|
||||
pkg-config,
|
||||
Standards-Version: 4.5.0
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
FROM alpine:3.16
|
||||
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 apk --no-cache add dumb-init curl && \
|
||||
ARCH=$(cat /etc/apk/arch) && \
|
||||
if [ "$ARCH" = "x86" ]; then ARCH="i586"; \
|
||||
elif [ "$ARCH" = "aarch64" ]; then ARCH="armhf"; \
|
||||
elif [ "$ARCH" = "armv7" ]; then ARCH="armhf"; fi && \
|
||||
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" && \
|
||||
|
||||
@@ -30,3 +30,7 @@ docker run -v $(pwd):/data -it ghcr.io/kiwix/kiwix-tools kiwix-search /data/wiki
|
||||
|
||||
- `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).
|
||||
@@ -12,6 +12,12 @@ With local ZIM file(s)
|
||||
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
|
||||
--------------------
|
||||
|
||||
@@ -36,7 +42,12 @@ Build an image for an ARM based GNU/Linux:
|
||||
docker build . -t ghcr.io/kiwix/kiwix-serve:latest --build-arg ARCH="arm32v7/"
|
||||
```
|
||||
|
||||
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)
|
||||
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
|
||||
-----------
|
||||
|
||||
@@ -3,7 +3,7 @@ services:
|
||||
kiwix-serve:
|
||||
ports:
|
||||
- 8080:8080
|
||||
image: kiwix/kiwix-serve
|
||||
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
|
||||
|
||||
@@ -18,7 +18,7 @@ import os
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'kiwix-tools'
|
||||
copyright = '2022, kiwix-team'
|
||||
copyright = '2024, kiwix-team'
|
||||
author = 'kiwix-team'
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
"sphinx_rtd_theme"
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
@@ -41,8 +42,7 @@ templates_path = ['_templates']
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
|
||||
if not on_rtd:
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
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,
|
||||
|
||||
@@ -339,8 +339,8 @@ filtering criteria must be specified via the following URL parameters:
|
||||
* ``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>`.
|
||||
* ``name`` - include in the results only entries with a matching
|
||||
:term:`book name <Book name>`.
|
||||
|
||||
|
||||
Examples:
|
||||
@@ -532,7 +532,7 @@ specified ZIM file.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
``content``: :term:`name <ZIM name>` of the ZIM file.
|
||||
``content``: :term:`name of the ZIM file <ZIM name>`.
|
||||
|
||||
|
||||
.. _raw:
|
||||
@@ -609,7 +609,7 @@ A multi-ZIM search request must comply with the following constraints:
|
||||
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
|
||||
``content``: :term:`name of the ZIM file <ZIM name>` (for a single-ZIM
|
||||
search). This is a :ref:`legacy parameter <deprecation>`. ``books.name``
|
||||
should be used instead.
|
||||
|
||||
@@ -617,9 +617,23 @@ A multi-ZIM search request must comply with the following constraints:
|
||||
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>`.
|
||||
.. note::
|
||||
|
||||
If any of the provided ``books.id`` values refers to a book missing
|
||||
from the library then an error is returned instead of running the
|
||||
search on the remaining (valid) entries.
|
||||
|
||||
``books.name``: :term:`name of the ZIM file <ZIM name>` (not to be confused
|
||||
with ``books.filter.name`` which selects/filters based on the :term:`book
|
||||
name <Book name>`). Can be repeated for a multi-ZIM search, however must
|
||||
respect the :ref:`multi-ZIM search constraints
|
||||
<multi-zim-search-constraints>`.
|
||||
|
||||
.. note::
|
||||
|
||||
If any of the provided ``books.name`` values refers to a book missing
|
||||
from the library then an error is returned instead of running the
|
||||
search on the remaining (valid) entries.
|
||||
|
||||
``books.filter.{criteria}``: allows to take full advantage of :ref:`library
|
||||
filtering <library-filtering>` functionality of the `/catalog/v2/entries`_
|
||||
@@ -739,7 +753,7 @@ 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.
|
||||
``content`` (mandatory): :term:`name of the ZIM file <ZIM name>`.
|
||||
|
||||
``term`` (optional; defaults to an empty string): query text.
|
||||
|
||||
@@ -799,6 +813,21 @@ Glossary
|
||||
|
||||
.. glossary::
|
||||
|
||||
Book name
|
||||
|
||||
Name of the book as specified in the ZIM file metadata (for a
|
||||
``kiwix-serve`` started *WITHOUT* the :option:`--library` option) or the
|
||||
library XML file (for a ``kiwix-serve`` started with the
|
||||
:option:`--library` option).
|
||||
|
||||
.. note::
|
||||
|
||||
Two or more books may have the same name in the library. That's not
|
||||
considered a conflict, because there may be multiple versions of the
|
||||
"same" book (differing by the settings of the scraper, date, etc).
|
||||
:ref:`Library filtering <library-filtering>` by name will return all
|
||||
matching books.
|
||||
|
||||
ZIM filename
|
||||
|
||||
Name of a ZIM file on the server filesystem.
|
||||
@@ -808,20 +837,22 @@ Glossary
|
||||
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.
|
||||
ZIM names are derived from the filenames as follows:
|
||||
|
||||
For a ``kiwix-serve`` started with the :option:`--library` option, ZIM
|
||||
names come from the library XML file.
|
||||
- file extension is removed,
|
||||
- all characters are converted to lowercase,
|
||||
- diacritics are removed,
|
||||
- spaces are replaced with underscores,
|
||||
- ``+`` symbols are replaced with the text ``plus``.
|
||||
|
||||
Presence of the :option:`-z`/:option:`--nodatealiases` option will create
|
||||
additional names (aliases) for filenames with dates.
|
||||
|
||||
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.
|
||||
otherwise, are ignored (i.e. only one of the entries can be accessed via
|
||||
the conflicting name).
|
||||
|
||||
ZIM title
|
||||
|
||||
|
||||
10
meson.build
10
meson.build
@@ -1,7 +1,7 @@
|
||||
project('kiwix-tools', 'cpp',
|
||||
version : '3.5.0',
|
||||
version : '3.7.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')
|
||||
|
||||
@@ -16,8 +16,10 @@ if static_linkage
|
||||
endif
|
||||
|
||||
thread_dep = dependency('threads')
|
||||
kiwixlib_dep = dependency('kiwix', version:'>=12.0.0', static:static_linkage)
|
||||
libzim_dep = dependency('libzim', version:'>=8.1.0', static:static_linkage)
|
||||
libzim_dep = dependency('libzim', version:'>=9.0.0', static:static_linkage)
|
||||
libzim_dep = dependency('libzim', version:'<10.0.0', static:static_linkage)
|
||||
kiwixlib_dep = dependency('kiwix', version:'>=13.0.0', static:static_linkage)
|
||||
kiwixlib_dep = dependency('kiwix', version:'<14.0.0', static:static_linkage)
|
||||
|
||||
all_deps = [thread_dep, kiwixlib_dep, libzim_dep]
|
||||
|
||||
|
||||
@@ -1,60 +1,136 @@
|
||||
.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-k, --skipInvalid\fR
|
||||
Startup even when ZIM files are invalid (those will be skipped)
|
||||
|
||||
.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>
|
||||
|
||||
@@ -29,10 +29,10 @@ using namespace std;
|
||||
|
||||
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
||||
|
||||
void show(kiwix::Library* library, const std::string& bookId)
|
||||
void show(const kiwix::Library& library, const std::string& bookId)
|
||||
{
|
||||
try {
|
||||
auto& book = library->getBookById(bookId);
|
||||
auto& book = library.getBookById(bookId);
|
||||
std::cout << "id:\t\t" << book.getId() << std::endl
|
||||
<< "path:\t\t" << book.getPath() << std::endl
|
||||
<< "url:\t\t" << book.getUrl() << std::endl
|
||||
@@ -96,7 +96,7 @@ void usage()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
int handle_show(kiwix::Library* library, const std::string& libraryPath,
|
||||
int handle_show(const kiwix::Library& library, const std::string& libraryPath,
|
||||
int argc, char* argv[])
|
||||
{
|
||||
if (argc > 3 ) {
|
||||
@@ -105,7 +105,7 @@ int handle_show(kiwix::Library* library, const std::string& libraryPath,
|
||||
show(library, bookId);
|
||||
}
|
||||
} else {
|
||||
auto booksIds = library->getBooksIds();
|
||||
auto booksIds = library.getBooksIds();
|
||||
for(auto& bookId: booksIds) {
|
||||
show(library, bookId);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ int handle_show(kiwix::Library* library, const std::string& libraryPath,
|
||||
return(0);
|
||||
}
|
||||
|
||||
int handle_add(kiwix::Library* library, const std::string& libraryPath,
|
||||
int handle_add(kiwix::LibraryPtr library, const std::string& libraryPath,
|
||||
int argc, char* argv[])
|
||||
{
|
||||
string zimPath;
|
||||
@@ -182,11 +182,11 @@ int handle_add(kiwix::Library* library, const std::string& libraryPath,
|
||||
return(resultCode);
|
||||
}
|
||||
|
||||
int handle_remove(kiwix::Library* library, const std::string& libraryPath,
|
||||
int handle_remove(kiwix::Library& library, const std::string& libraryPath,
|
||||
int argc, char* argv[])
|
||||
{
|
||||
std::string bookId;
|
||||
const unsigned int totalBookCount = library->getBookCount(true, true);
|
||||
const unsigned int totalBookCount = library.getBookCount(true, true);
|
||||
int exitCode = 0;
|
||||
|
||||
if (argc <= 3) {
|
||||
@@ -203,7 +203,7 @@ int handle_remove(kiwix::Library* library, const std::string& libraryPath,
|
||||
for (int i = 3; i<argc; i++) {
|
||||
bookId = argv[i];
|
||||
|
||||
if (!library->removeBookById(bookId)) {
|
||||
if (!library.removeBookById(bookId)) {
|
||||
std::cerr << "Invalid book id '" << bookId << "'." << std::endl;
|
||||
exitCode = 1;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
string libraryPath = "";
|
||||
supportedAction action = NONE;
|
||||
kiwix::Library library;
|
||||
auto library = kiwix::Library::create();
|
||||
|
||||
/* General argument parsing */
|
||||
static struct option long_options[] = {
|
||||
@@ -261,7 +261,7 @@ int main(int argc, char** argv)
|
||||
libraryPath = kiwix::isRelativePath(libraryPath)
|
||||
? kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), libraryPath)
|
||||
: libraryPath;
|
||||
kiwix::Manager manager(&library);
|
||||
kiwix::Manager manager(library);
|
||||
if (!manager.readFile(libraryPath, false)) {
|
||||
if (kiwix::fileExists(libraryPath) || action!=ADD) {
|
||||
std::cerr << "Cannot read the library " << libraryPath << std::endl;
|
||||
@@ -273,13 +273,13 @@ int main(int argc, char** argv)
|
||||
int exitCode = 0;
|
||||
switch (action) {
|
||||
case SHOW:
|
||||
exitCode = handle_show(&library, libraryPath, argc, argv);
|
||||
exitCode = handle_show(*library, libraryPath, argc, argv);
|
||||
break;
|
||||
case ADD:
|
||||
exitCode = handle_add(&library, libraryPath, argc, argv);
|
||||
exitCode = handle_add(library, libraryPath, argc, argv);
|
||||
break;
|
||||
case REMOVE:
|
||||
exitCode = handle_remove(&library, libraryPath, argc, argv);
|
||||
exitCode = handle_remove(*library, libraryPath, argc, argv);
|
||||
break;
|
||||
case NONE:
|
||||
break;
|
||||
@@ -292,7 +292,7 @@ int main(int argc, char** argv)
|
||||
/* Rewrite the library file */
|
||||
if (action == REMOVE || action == ADD) {
|
||||
// writeToFile return true (1) if everything is ok => exitCode is 0
|
||||
if (!library.writeToFile(libraryPath)) {
|
||||
if (!library->writeToFile(libraryPath)) {
|
||||
std::cerr << "Cannot write the library " << libraryPath << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ void usage()
|
||||
|
||||
<< "Optional arguments:" << std::endl << std::endl
|
||||
<< "\t-h, --help\t\tPrint this help" << std::endl << std::endl
|
||||
<< "\t-a, --attachToProcess\tWxit if given process id is not running anymore" << 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
|
||||
@@ -77,6 +77,7 @@ void usage()
|
||||
<< "\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
|
||||
<< "\t-k, --skipInvalid\tStartup even when ZIM files are invalid (those will be skipped)" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "Documentation:" << std::endl
|
||||
@@ -197,7 +198,7 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
std::string rootLocation = "/";
|
||||
kiwix::Library library;
|
||||
auto library = kiwix::Library::create();
|
||||
unsigned int nb_threads = DEFAULT_THREADS;
|
||||
std::vector<std::string> zimPathes;
|
||||
std::string libraryPath;
|
||||
@@ -217,6 +218,7 @@ int main(int argc, char** argv)
|
||||
unsigned int PPID = 0;
|
||||
int ipConnectionLimit = 0;
|
||||
int searchLimit = 0;
|
||||
bool skipInvalid = false;
|
||||
|
||||
static struct option long_options[]
|
||||
= {{"daemon", no_argument, 0, 'd'},
|
||||
@@ -237,6 +239,7 @@ int main(int argc, char** argv)
|
||||
{"monitorLibrary", no_argument, 0, 'M'},
|
||||
{"ipConnectionLimit", required_argument, 0, 'L'},
|
||||
{"searchLimit", required_argument, 0, 's'},
|
||||
{"skipInvalid", no_argument, 0, 'k'},
|
||||
{0, 0, 0, 0}};
|
||||
|
||||
std::set<int> usedOptions;
|
||||
@@ -307,6 +310,9 @@ int main(int argc, char** argv)
|
||||
case 's':
|
||||
searchLimit = atoi(optarg);
|
||||
break;
|
||||
case 'k':
|
||||
skipInvalid = true;
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
return 2;
|
||||
@@ -331,7 +337,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
/* Setup the library manager and get the list of books */
|
||||
kiwix::Manager manager(&library);
|
||||
kiwix::Manager manager(library);
|
||||
std::vector<std::string> libraryPaths;
|
||||
if (libraryFlag) {
|
||||
libraryPaths = kiwix::split(libraryPath, ";");
|
||||
@@ -340,7 +346,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
/* Check if the library is not empty (or only remote books)*/
|
||||
if (library.getBookCount(true, false) == 0) {
|
||||
if (library->getBookCount(true, false) == 0) {
|
||||
std::cerr << "The XML library file '" << libraryPath
|
||||
<< "' is empty (or has only remote books)." << std::endl;
|
||||
}
|
||||
@@ -348,9 +354,13 @@ int main(int argc, char** argv)
|
||||
std::vector<std::string>::iterator it;
|
||||
for (it = zimPathes.begin(); it != zimPathes.end(); it++) {
|
||||
if (!manager.addBookFromPath(*it, *it, "", false)) {
|
||||
std::cerr << "Unable to add the ZIM file '" << *it
|
||||
<< "' to the internal library." << std::endl;
|
||||
exit(1);
|
||||
if (skipInvalid) {
|
||||
std::cerr << "Skipping invalid '" << *it << "' ...continuing" << std::endl;
|
||||
} else {
|
||||
std::cerr << "Unable to add the ZIM file '" << *it
|
||||
<< "' to the internal library." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,8 +386,8 @@ int main(int argc, char** argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
kiwix::UpdatableNameMapper nameMapper(library, noDateAliasesFlag);
|
||||
kiwix::Server server(&library, &nameMapper);
|
||||
auto nameMapper = std::make_shared<kiwix::UpdatableNameMapper>(library, noDateAliasesFlag);
|
||||
kiwix::Server server(library, nameMapper);
|
||||
|
||||
if (!customIndexPath.empty()) {
|
||||
try {
|
||||
@@ -447,7 +457,7 @@ int main(int argc, char** argv)
|
||||
if ( libraryMustBeReloaded && !libraryPaths.empty() ) {
|
||||
libraryFileTimestamp = curLibraryFileTimestamp;
|
||||
reloadLibrary(manager, libraryPaths);
|
||||
nameMapper.update();
|
||||
nameMapper->update();
|
||||
libraryMustBeReloaded = false;
|
||||
}
|
||||
} while (waiting);
|
||||
|
||||
Reference in New Issue
Block a user