53 Commits
3.2.0 ... 3.4.0

Author SHA1 Message Date
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
24 changed files with 262 additions and 337 deletions

View File

@@ -14,16 +14,16 @@ jobs:
- win32_dyn
include:
- target: native_static
image_variant: xenial
image_variant: bionic
lib_postfix: '/x86_64-linux-gnu'
- target: native_dyn
image_variant: xenial
image_variant: bionic
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

View File

@@ -13,9 +13,9 @@ jobs:
name: Deploy kiwix-tools Docker Image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0
- name: build and publish kiwix-tools
uses: openzim/docker-publish-action@v5
uses: openzim/docker-publish-action@v9
with:
image-name: kiwix/kiwix-tools
credentials: |
@@ -33,15 +33,17 @@ jobs:
linux/arm64
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-20.04
needs: build-and-push-kiwix-tools
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0
- name: build and publish kiwix-serve
uses: openzim/docker-publish-action@v5
uses: openzim/docker-publish-action@v9
with:
image-name: kiwix/kiwix-serve
credentials: |
@@ -59,3 +61,5 @@ jobs:
linux/arm64
restrict-to: kiwix/kiwix-tools
manual-tag: ${{ github.event.inputs.version }}
repo_description: auto
repo_overview: Kiwix web-server

View File

@@ -10,7 +10,6 @@ jobs:
distro:
- ubuntu-jammy
- ubuntu-impish
- ubuntu-hirsute
- ubuntu-focal
steps:
- uses: actions/checkout@v2
@@ -50,14 +49,6 @@ jobs:
args: --no-sign
ppa: ${{ steps.ppa.outputs.ppa }}
- uses: legoktm/gh-action-build-deb@ubuntu-hirsute
if: matrix.distro == 'ubuntu-hirsute'
name: Build package for ubuntu-hirsute
id: build-ubuntu-hirsute
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

View File

@@ -1,3 +1,45 @@
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
=================
@@ -12,7 +54,7 @@ kiwix-tools 3.2.0
kiwix-serve
-----------
* Print the url on which a user can connect to on startup (@nikhil #499 #522)
* 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)

View File

@@ -4,7 +4,6 @@ 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

5
debian/control vendored
View File

@@ -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),
libkiwix-dev (>= 10.0.0~),
libzim-dev (>= 7.2.0~),
meson,
pkg-config,
Standards-Version: 4.5.0
@@ -21,6 +21,5 @@ Description: collection of Kiwix tools
over the network.
* kiwix-manage allows one to manage the content of the Kiwix library (an
XML file listing available ZIM files).
* kiwix-read allows for reading ZIM files from the command-line.
* kiwix-search allows one to find articles in a ZIM file using fulltext
search patterns.

View File

@@ -1,46 +1,18 @@
# dumb-init to use as entrypoint so it can forward signals to our CMD
FROM debian:bullseye-slim as builder
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential ca-certificates musl-tools wget unzip make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# compile dumb-init
RUN wget -nv https://github.com/Yelp/dumb-init/archive/refs/tags/v1.2.5.zip && \
unzip v1.2.5.zip && cd dumb-init-1.2.5 && CC=musl-gcc make
# declare build option ARCH if not using buildx
ARG ARCH=
# declare version to build image for
ARG VERSION=
# alpine is a multi-arch image
FROM alpine:3
FROM alpine:3.16
LABEL org.opencontainers.image.source https://github.com/openzim/kiwix-tools
# TARGETARCH is injected by buildx
ARG TARGETARCH
ARG VERSION
ARG ARCH
# copy built dumb-init
COPY --from=builder /dumb-init-1.2.5/dumb-init /usr/bin/dumb-init
# find and store arch in image, using (in this order):
# $TARGETARCH || --build-arg ARCH (not using buildx) || amd64
RUN echo "amd64" > /etc/docker_arch && \
if [ ! -z "$ARCH" ] ; then echo "$ARCH" > /etc/docker_arch ; fi && \
if [ ! -z "$TARGETARCH" ] ; then echo "$TARGETARCH" > /etc/docker_arch ; fi
# decide which kiwix arch to download later (`armhf` for all arm* and x86_64 otherwise)
RUN if [ $(cut -c 1-3 /etc/docker_arch) = "arm" ] ; then echo "armhf" > /etc/kiwix_arch ; else echo "x86_64" > /etc/kiwix_arch ; fi
# Install kiwix-tools
RUN url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$(cat /etc/kiwix_arch)-$VERSION.tar.gz" && \
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 && \
# download requested kiwix-tools version
url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$ARCH-$VERSION.tar.gz" && \
echo "URL: $url" && \
wget -q -O - $url | tar -xz && \
mv kiwix-tools*/kiwix-* /usr/local/bin && \
rm -r kiwix-tools*
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

View File

@@ -11,13 +11,13 @@ Kiwix-tools Docker image
$ docker run -it kiwix/kiwix-tools:3.1.2
Welcome to kiwix-tools! The following binaries are available:
kiwix-manage kiwix-read kiwix-search kiwix-serve
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 kiwix/kiwix-tools kiwix-read --suggest="Mali" /data/wikipedia_fr_test.zim
docker run -v $(pwd):/data -it kiwix/kiwix-tools kiwix-search /data/wikipedia_fr_test.zim "Mali"
```
## Building and reusing
@@ -29,4 +29,4 @@ docker run -v $(pwd):/data -it kiwix/kiwix-tools kiwix-read --suggest="Mali" /da
**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.
- Was also unhappy when using the mirrors so it's using `mirror.download` on purpose.

View File

@@ -5,7 +5,7 @@ FROM kiwix/kiwix-tools:$VERSION
LABEL org.opencontainers.image.source https://github.com/openzim/kiwix-tools
# expose kiwix-serve default port and workdir
EXPOSE 80
EXPOSE 8080
VOLUME /data
WORKDIR /data

View File

@@ -9,14 +9,23 @@ With local ZIM file(s)
* 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 wiktionary.zim
docker run -v /tmp/zim:/data -p 8080:8080 kiwix/kiwix-serve wikipedia.zim wiktionary.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 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 kiwix/kiwix-serve
```
ARM

View File

@@ -2,7 +2,7 @@ version: '3.3'
services:
kiwix-serve:
ports:
- 8080:80
- 8080:8080
image: kiwix/kiwix-serve
# uncomment next 4 lines to use it with local zim file in /tmp/zim
# volumes:

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

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.2.0',
version : '3.4.0',
license : 'GPL',
default_options: ['c_std=c11', 'cpp_std=c++11'])
default_options: ['c_std=c11', 'cpp_std=c++11', 'werror=true'])
compiler = meson.get_compiler('cpp')
@@ -13,8 +13,8 @@ if static_linkage
endif
thread_dep = dependency('threads')
kiwixlib_dep = dependency('kiwix', version:'>=10.0.0', static:static_linkage)
libzim_dep = dependency('libzim', version:'>=7.2.0', 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, libzim_dep]

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>

View File

@@ -1,18 +0,0 @@
.TH KIWIX-READ "1" "July 2020" "kiwix-tools" "User Commands"
.SH NAME
kiwix-read \- Read ZIM file content
.SH SYNOPSIS
\fBkiwix-read\fR [\-\-verbose] [\-\-version] \-\-suggest=PATTERN ZIM\fR
.SH DESCRIPTION
.TP
ZIM
ZIM file to search
.TP
\fB\-\-verbose\fR
Enable extra output
.TP
\fB\-\-version\fR
print software version
.TP
\fB\-\-suggest=PATTERN\fR
Get search suggestions for the provided pattern

View File

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

View File

@@ -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,7 +254,7 @@ int main(int argc, char** argv)
/* Print usage)) if necessary */
if (libraryPath == "" || action == NONE) {
usage();
exit(1);
return -1;
}
/* Try to read the file */
@@ -259,7 +262,12 @@ int main(int argc, char** argv)
? 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;
kiwix::SuggestionsList_t suggestions;
reader->searchSuggestionsSmart(pattern, 10, suggestions);
for (auto& suggestion: suggestions) {
std::cout << suggestion.getTitle() << 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,11 +18,16 @@
*/
#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
@@ -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,47 +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();
bool contians_FTIndex=searcher->add_reader(reader);
if(!contians_FTIndex){
std::cerr << "The Zim file does not contain a full-text index." << std::endl;
if(suggestionFlag){
exit(0);
}
exit(1);
}
} 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>
*
@@ -49,31 +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 << 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\t\tmonitor the XML library file and reload it automatically" << 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
<< "\t-b, --blockexternal\tprevent users from directly accessing external links" << 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-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-c, --customIndex\tadd path to custom index.html for welcome page" << 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
@@ -82,24 +85,34 @@ void usage()
<< std::endl;
}
string loadCustomTemplate (string customIndexPath) {
std::string loadCustomTemplate (std::string customIndexPath) {
customIndexPath = kiwix::isRelativePath(customIndexPath) ?
kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), customIndexPath) :
customIndexPath;
if (!kiwix::fileReadable(customIndexPath)) {
throw runtime_error("No such file exist (or file is not readable) " + customIndexPath);
throw std::runtime_error("No such file exist (or file is not readable) " + customIndexPath);
}
if (kiwix::getMimeTypeForFile(customIndexPath) != "text/html") {
throw runtime_error("Invalid File Mime Type " + kiwix::getMimeTypeForFile(customIndexPath));
throw std::runtime_error("Invalid File Mime Type " + kiwix::getMimeTypeForFile(customIndexPath));
}
string indexTemplateString = kiwix::getFileContent(customIndexPath);
std::string indexTemplateString = kiwix::getFileContent(customIndexPath);
if (indexTemplateString.empty()) {
throw runtime_error("Unreadable or empty file " + customIndexPath);
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;
@@ -137,7 +150,7 @@ void setup_sighandlers()
uint64_t fileModificationTime(const std::string& path)
{
#if defined(_WIN32)
#if defined(_WIN32) && !defined(stat)
#define stat _stat
#endif
struct stat fileStatData;
@@ -183,15 +196,15 @@ int main(int argc, char** argv)
setup_sighandlers();
#endif
std::string rootLocation = "";
std::string rootLocation = "/";
kiwix::Library library;
unsigned int nb_threads = DEFAULT_THREADS;
vector<string> zimPathes;
string libraryPath;
string rootPath;
string address;
string customIndexPath="";
string indexTemplateString="";
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;
@@ -202,6 +215,8 @@ int main(int argc, char** argv)
bool isVerboseFlag = false;
bool monitorLibrary = false;
unsigned int PPID = 0;
int ipConnectionLimit = 0;
int searchLimit = 0;
static struct option long_options[]
= {{"daemon", no_argument, 0, 'd'},
@@ -220,15 +235,23 @@ int main(int argc, char** argv)
{"urlRootLocation", required_argument, 0, 'r'},
{"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, "hzmnbdvVla:p:f:t:r:i:c:M", 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();
@@ -264,20 +287,29 @@ int main(int argc, char** argv)
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 = string(optarg);
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) {
@@ -300,7 +332,7 @@ int main(int argc, char** argv)
/* Setup the library manager and get the list of books */
kiwix::Manager manager(&library);
vector<string> libraryPaths;
std::vector<std::string> libraryPaths;
if (libraryFlag) {
libraryPaths = kiwix::split(libraryPath, ";");
if ( !reloadLibrary(manager, libraryPaths) ) {
@@ -309,15 +341,15 @@ int main(int argc, char** argv)
/* 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);
}
}
@@ -364,15 +396,17 @@ int main(int argc, char** argv)
server.setTaskbar(!noSearchBarFlag, !noLibraryButtonFlag);
server.setBlockExternalLinks(blockExternalLinks);
server.setIndexTemplateString(indexTemplateString);
server.setIpConnectionLimit(ipConnectionLimit);
server.setMultiZimSearchLimit(searchLimit);
if (! server.start()) {
exit(1);
}
std::string url = "http://" + server.getAddress() + ":" + std::to_string(server.getPort()) + "/" + rootLocation;
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) */
waiting = true;
do {
@@ -395,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/" + std::to_string(PPID);
std::string procPath = "/proc/" + std::to_string(PPID);
if (access(procPath.c_str(), F_OK) != -1) {
#endif
} else {

View File

@@ -26,6 +26,7 @@
#include <kiwix/version.h>
#include <zim/version.h>
#include <iostream>
void version()
{