Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63ec03a3d4 | ||
|
|
e2f7c7a0ac | ||
|
|
a14cd5de23 | ||
|
|
06c31430c5 | ||
|
|
8ffff9cd47 | ||
|
|
ef0fc514ad | ||
|
|
6c1739d4cd | ||
|
|
cd44ba53a5 | ||
|
|
d82f9e7d5e | ||
|
|
720a319d53 | ||
|
|
2426c35547 | ||
|
|
794f63e22b | ||
|
|
79a64d5af3 | ||
|
|
2ef160bcad | ||
|
|
817a5d4847 | ||
|
|
2c3882671b | ||
|
|
7e2c5bda03 | ||
|
|
59281bf496 | ||
|
|
ee9ae0e81f | ||
|
|
2dbe0a0016 | ||
|
|
64717c2124 | ||
|
|
fc1eb3c282 | ||
|
|
e31c1cd9a3 | ||
|
|
e897dd4e59 | ||
|
|
7db7d2a2ab | ||
|
|
5b612e67bd | ||
|
|
df047588a9 | ||
|
|
9dede26717 | ||
|
|
a22ae3d467 | ||
|
|
ea93a8a195 | ||
|
|
0a7f375f3a | ||
|
|
66c35b7b3e | ||
|
|
bad7f2ddf1 | ||
|
|
758014a5ba | ||
|
|
4fd961a761 | ||
|
|
c063587a69 | ||
|
|
9b24676b02 | ||
|
|
fc5572f495 | ||
|
|
a1b3f46e4e | ||
|
|
e0177c4923 | ||
|
|
a365c1e720 | ||
|
|
3e97352128 | ||
|
|
78d2530878 | ||
|
|
d09f481b47 | ||
|
|
e0f07086d5 | ||
|
|
bbff57e6aa | ||
|
|
3c24d0a026 | ||
|
|
6107bad17e | ||
|
|
5931ac45c4 | ||
|
|
4de8623a52 | ||
|
|
6eace310a2 | ||
|
|
c6499ad5c6 | ||
|
|
34ceaf37f2 | ||
|
|
f05096e2ce | ||
|
|
3864b2404c | ||
|
|
4cd74dca4b | ||
|
|
88cea54520 | ||
|
|
3061c8bba3 | ||
|
|
2774eb9529 | ||
|
|
77dc2ef2ed | ||
|
|
17d11f9772 | ||
|
|
68ac06c397 | ||
|
|
99f6941614 | ||
|
|
848d058610 | ||
|
|
cdb9b28d35 | ||
|
|
43e1740d52 | ||
|
|
7e8d02990e | ||
|
|
c337cf174e | ||
|
|
8a64083d5b | ||
|
|
d0687e40a6 | ||
|
|
14b0b901f1 | ||
|
|
336cbe691d | ||
|
|
26b4dd5f57 | ||
|
|
8882a716a0 | ||
|
|
fede5ef9b6 | ||
|
|
c5b293c6f3 | ||
|
|
d57a37cde6 | ||
|
|
7d2bec3e39 | ||
|
|
472de06e6d | ||
|
|
51a4a4e8ef | ||
|
|
6e310c7147 | ||
|
|
790bd03bd7 | ||
|
|
15c6252db4 | ||
|
|
6fd22dec61 | ||
|
|
c332c123fe | ||
|
|
e4eafd7459 | ||
|
|
16a29127a1 | ||
|
|
7fa0579ea1 | ||
|
|
978dc47865 | ||
|
|
b7793f6e75 | ||
|
|
8095ae9ea8 | ||
|
|
286f599b3e | ||
|
|
174b236312 | ||
|
|
c7e9d44b38 | ||
|
|
3a80951c23 | ||
|
|
ffaecb5389 | ||
|
|
7b25308248 | ||
|
|
7ac14aa64f | ||
|
|
3c8da8c74c | ||
|
|
9ed3fc353b | ||
|
|
51051752f1 | ||
|
|
4e8a8533c4 | ||
|
|
fd2a0decd3 | ||
|
|
624fb32091 | ||
|
|
067a40a156 | ||
|
|
cfa22365fe | ||
|
|
d5066ba6bf | ||
|
|
f1ec1ec182 | ||
|
|
d1802c52a2 |
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: https://kiwix.org/support-us/
|
||||
27
.github/move.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# Configuration for Move Issues - https://github.com/dessant/move-issues
|
||||
|
||||
# Delete the command comment when it contains no other content
|
||||
deleteCommand: true
|
||||
|
||||
# Close the source issue after moving
|
||||
closeSourceIssue: true
|
||||
|
||||
# Lock the source issue after moving
|
||||
lockSourceIssue: false
|
||||
|
||||
# Mention issue and comment authors
|
||||
mentionAuthors: true
|
||||
|
||||
# Preserve mentions in the issue content
|
||||
keepContentMentions: true
|
||||
|
||||
# Move labels that also exist on the target repository
|
||||
moveLabels: true
|
||||
|
||||
# Set custom aliases for targets
|
||||
# aliases:
|
||||
# r: repo
|
||||
# or: owner/repo
|
||||
|
||||
# Repository to extend settings from
|
||||
# _extends: repo
|
||||
@@ -1,6 +1,6 @@
|
||||
language: cpp
|
||||
dist: trusty
|
||||
sudo: required
|
||||
dist: xenial
|
||||
sudo: true
|
||||
cache: ccache
|
||||
install: travis/install_deps.sh
|
||||
script: travis/compile.sh
|
||||
|
||||
99
Changelog
@@ -1,3 +1,102 @@
|
||||
kiwix-tools 3.0.0
|
||||
=================
|
||||
|
||||
* Move kiwix-serve implementation in kiwix-lib.
|
||||
|
||||
kiwix-tools 2.1.0
|
||||
=================
|
||||
|
||||
* Fix few compilation errors.
|
||||
|
||||
kiwix-serve
|
||||
-----------
|
||||
|
||||
* Use new api to filter the library.
|
||||
* Mobile friendly top bar.
|
||||
* Add notag parameter to be able to exclude tags from the zim search.
|
||||
|
||||
|
||||
kiwix-tools 2.0.0
|
||||
=================
|
||||
|
||||
kiwix-manage
|
||||
-----------
|
||||
|
||||
* Better usage()
|
||||
* Adding multiple files bug fix
|
||||
* Remove download command.
|
||||
|
||||
kiwix-serve
|
||||
-----------
|
||||
|
||||
* Better usage()
|
||||
* Display properly welcome page on 3 columns
|
||||
* New welcome page footer "Powered by Kiwix"
|
||||
|
||||
kiwix-tools 1.2.1
|
||||
=================
|
||||
|
||||
kiwix-serve
|
||||
-----------
|
||||
|
||||
* Always use POLL when avaible.
|
||||
|
||||
kiwix-tools 1.2.0
|
||||
=================
|
||||
|
||||
* Remove rpath for installed binaries.
|
||||
|
||||
kiwix-serve
|
||||
-----------
|
||||
|
||||
* New Dockerfile of kiwix-serve
|
||||
* New --nodatealiases option
|
||||
* Do not use POLL on windows
|
||||
|
||||
kiwix-manage
|
||||
------------
|
||||
|
||||
* Do not show all books if book ids has been provided.
|
||||
* Be able to add several zim files in the same time in a library.
|
||||
|
||||
kiwix-tools 1.1.0
|
||||
=================
|
||||
|
||||
kiwix-serve
|
||||
-----------
|
||||
|
||||
* Fix bug about handling of absolute url in old zim file.
|
||||
* All the catalog to be searched by tags.
|
||||
|
||||
kiwix-tools 1.0.0
|
||||
=================
|
||||
|
||||
* [CI] Use the new deps archive xz
|
||||
* Move version 1.0.0. There is no need to stay in pre 1.0 version.
|
||||
|
||||
kiwix-serve
|
||||
-----------
|
||||
|
||||
* Correctly implement redirection.
|
||||
kiwix-serve now return a 302 http status code instead of resolving the
|
||||
redirection internally and return the content.
|
||||
|
||||
|
||||
kiwix-tools 0.9.0
|
||||
=================
|
||||
|
||||
* Update README
|
||||
* Update man pages
|
||||
* Remove support of external indexes (manage, search, serve)
|
||||
* Update build system as we don't use ctpp2 anymore
|
||||
* Update to last kiwix-lib API.
|
||||
|
||||
kiwix-manage
|
||||
------------
|
||||
|
||||
* Update usage.
|
||||
|
||||
|
||||
kiwix-tools 0.8.0
|
||||
=================
|
||||
|
||||
|
||||
29
README.md
@@ -1,7 +1,11 @@
|
||||
Kiwix tools
|
||||
===========
|
||||
|
||||
The Kiwix tools is a collection of Kiwix related command line tools.
|
||||
The Kiwix tools is a collection of Kiwix 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
|
||||
|
||||
Disclaimer
|
||||
----------
|
||||
@@ -16,7 +20,7 @@ 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 though for GNU/Linux systems and has been tested
|
||||
ones. It is primarly thought for GNU/Linux systems and has been tested
|
||||
on recent releases of Ubuntu and Fedora.
|
||||
|
||||
Dependencies
|
||||
@@ -26,14 +30,9 @@ 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 Ubuntu)
|
||||
* CTPP2 ..................................... http://ctpp.havoc.ru/en/
|
||||
(package libctpp2-dev on Ubuntu)
|
||||
* Zlib .......................................... http://www.zlib.net/
|
||||
(package zlib1g-dev on Ubuntu)
|
||||
* [Kiwix lib](https://github.com/kiwix/kiwix-lib) (no package so far)
|
||||
* [Libmicrohttpd](https://www.gnu.org/software/libmicrohttpd/) (package libmicrohttpd-dev on Ubuntu)
|
||||
* [Zlib](https://www.zlib.net/) (package zlib1g-dev on 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
|
||||
@@ -46,7 +45,7 @@ If you want to install these dependencies locally, then use the
|
||||
kiwix-tools directory as install prefix.
|
||||
|
||||
If you want to compile Kiwix tools statically, the dependencies should
|
||||
be compile statically (provide a lib...a library), for example by
|
||||
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
|
||||
@@ -57,7 +56,7 @@ Environment
|
||||
-------------
|
||||
|
||||
The Kiwix tools build using [Meson](http://mesonbuild.com/) version
|
||||
0.39 or higher. Meson relies itself on Ninja, pkg-config and few other
|
||||
0.43 or higher. Meson relies itself on Ninja, pkg-config and few other
|
||||
compilation tools. Install them first:
|
||||
* Meson
|
||||
* Ninja
|
||||
@@ -106,6 +105,12 @@ ninja -C build uninstall
|
||||
Like for the installation, you might need to run the command as root
|
||||
(or using 'sudo').
|
||||
|
||||
Docker
|
||||
------
|
||||
|
||||
An official Docker image of `kiwix-serve` can be found at
|
||||
https://hub.docker.com/r/kiwix/kiwix-serve.
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
|
||||
15
docker/server/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM alpine:latest
|
||||
LABEL maintainer Emmanuel Engelhart <kelson@kiwix.org>
|
||||
|
||||
# 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-1.2.1.tar.gz | tar -xz && \
|
||||
mv kiwix-tools*/kiwix-serve /usr/local/bin && \
|
||||
rm -r kiwix-tools*
|
||||
|
||||
# Run kiwix-serve
|
||||
EXPOSE 80
|
||||
VOLUME /data
|
||||
WORKDIR /data
|
||||
ENTRYPOINT ["/usr/local/bin/kiwix-serve", "--port", "80"]
|
||||
13
docker/server/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
kiwix-serve Docker image
|
||||
========================
|
||||
|
||||
* Download a ZIM file from <https://wiki.kiwix.org/wiki/Content>
|
||||
|
||||
* Given `wikipedia.zim` resides in `/tmp/zim/`, execute the following:
|
||||
|
||||
```
|
||||
docker run -v /tmp/zim:/data -p 8080:80 kiwix/kiwix-serve wikipedia.zim
|
||||
```
|
||||
|
||||

|
||||

|
||||
BIN
docker/server/pictures/screenshot_1.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
docker/server/pictures/screenshot_2.png
Normal file
|
After Width: | Height: | Size: 199 KiB |
@@ -1,5 +1,5 @@
|
||||
project('kiwix-tools', 'cpp',
|
||||
version : '0.8.0',
|
||||
version : '3.0.0',
|
||||
license : 'GPL',
|
||||
default_options: ['c_std=c11', 'cpp_std=c++11', 'werror=true'])
|
||||
|
||||
@@ -11,7 +11,7 @@ if static_linkage
|
||||
endif
|
||||
|
||||
thread_dep = dependency('threads')
|
||||
kiwixlib_dep = dependency('kiwix', version:'>=3.0.0', static:static_linkage)
|
||||
kiwixlib_dep = dependency('kiwix', version:'>=6.0.0', static:static_linkage)
|
||||
microhttpd_dep = dependency('libmicrohttpd', static:static_linkage)
|
||||
z_dep = dependency('zlib', static:static_linkage)
|
||||
|
||||
@@ -25,5 +25,4 @@ if static_linkage
|
||||
endif
|
||||
|
||||
#subdir('include')
|
||||
subdir('static')
|
||||
subdir('src')
|
||||
|
||||
@@ -15,12 +15,12 @@ kiwix\-manage LIBRARY_PATH add ZIM_PATH ...
|
||||
.PP
|
||||
\fBkiwix\-manage\fP tool for managing a kiwix library.
|
||||
.PP
|
||||
Allows one to manage the content of the kiwix library. Library file is an XML flat file
|
||||
listing ZIM files with all necessary information like favicon, date, creator,
|
||||
description, indexpath, filepath, title, source/metalink etc.
|
||||
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 http://www.kiwix.org/library\.xml
|
||||
Example library file can be found at https://www.kiwix.org/library\.xml
|
||||
.br
|
||||
.TP
|
||||
\fBadd\fR
|
||||
@@ -55,7 +55,7 @@ Path to full-text index for that ZIM file.
|
||||
Set the content location of the ZIM file over the network for in\-kiwix download.
|
||||
|
||||
.SH SEE ALSO
|
||||
kiwix(1) kiwix\-install(1) kiwix\-serve(1)
|
||||
kiwix(1) kiwix\-serve(1)
|
||||
.SH AUTHOR
|
||||
Emmanuel Engelhart <kelson@kiwix.org>
|
||||
.br
|
||||
|
||||
@@ -9,7 +9,7 @@ kiwix\-serve [\-\-index=INDEX_PATH] [\-\-port=PORT] [\-\-verbose] [\-\-daemon] [
|
||||
kiwix\-serve \-\-library [\-\-port=PORT] [\-\-verbose] [\-\-daemon] [\-\-attachToProcess=PID] LIBRARY_PATH
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
Stand\-alone HTTP server for serving ZIM content over the network.
|
||||
Stand\-alone HTTP server for serving ZIM contents over the network.
|
||||
|
||||
.TP
|
||||
\fB\-\-index=INDEX_PATH\fR
|
||||
@@ -27,7 +27,7 @@ Enable verbose output.
|
||||
|
||||
.TP
|
||||
\fB\-\-daemon\fR
|
||||
Run the server as a daemon
|
||||
Run the server as a daemon.
|
||||
|
||||
.TP
|
||||
\fB\-\-attachToProcess=PID\fR
|
||||
@@ -49,12 +49,11 @@ Serves the contents of a library file instead of a single ZIM file.
|
||||
\fBLIBRARY_PATH\fR
|
||||
Kiwix library file path.
|
||||
.br
|
||||
Library is XML file created using \fBkiwix-manage\fB.
|
||||
Library is an XML file created using \fBkiwix-manage\fB.
|
||||
|
||||
.SH SEE ALSO
|
||||
kiwix(1) kiwix\-manage(1)
|
||||
.br
|
||||
kiwix\-install(1)
|
||||
|
||||
.SH AUTHOR
|
||||
Emmanuel Engelhart <kelson@kiwix.org>
|
||||
.br
|
||||
|
||||
@@ -17,34 +17,22 @@
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <getopt.h>
|
||||
#include <kiwix/common/pathTools.h>
|
||||
#include <kiwix/common/stringTools.h>
|
||||
#include <kiwix/tools/stringTools.h>
|
||||
#include <kiwix/manager.h>
|
||||
#include <kiwix/downloader.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum supportedAction { NONE, ADD, SHOW, REMOVE, DOWNLOAD };
|
||||
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
||||
|
||||
void show(kiwix::Library* library)
|
||||
void show(kiwix::Library* library, const std::string& bookId)
|
||||
{
|
||||
auto booksIds = library->getBooksIds();
|
||||
unsigned int inc = 1;
|
||||
for(auto& id: booksIds) {
|
||||
auto& book = library->getBookById(id);
|
||||
std::cout << "#" << inc++ << std::endl
|
||||
<< "id:\t\t" << book.getId() << std::endl
|
||||
try {
|
||||
auto& book = library->getBookById(bookId);
|
||||
std::cout << "id:\t\t" << book.getId() << std::endl
|
||||
<< "path:\t\t" << book.getPath() << std::endl
|
||||
<< "indexpath:\t" << book.getIndexPath() << std::endl
|
||||
<< "url:\t\t" << book.getUrl() << std::endl
|
||||
<< "title:\t\t" << book.getTitle() << std::endl
|
||||
<< "name:\t\t" << book.getName() << std::endl
|
||||
@@ -54,116 +42,151 @@ void show(kiwix::Library* library)
|
||||
<< "date:\t\t" << book.getDate() << std::endl
|
||||
<< "articleCount:\t" << book.getArticleCount() << std::endl
|
||||
<< "mediaCount:\t" << book.getMediaCount() << std::endl
|
||||
<< "size:\t\t" << book.getSize() << " KB" << std::endl
|
||||
<< std::endl;
|
||||
<< "size:\t\t" << book.getSize() << " KB" << std::endl;
|
||||
} catch (std::out_of_range&) {
|
||||
std::cout << "No book " << bookId << " in the library" << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
/* Print correct console usage options */
|
||||
void usage()
|
||||
{
|
||||
cerr << "Usage:" << endl;
|
||||
cerr << "\tkiwix-manage LIBRARY_PATH add ZIM_PATH "
|
||||
"[--zimPathToSave=../content/foobar.zim] [--current] "
|
||||
"[--indexBackend=xapian] [--indexPath=FULLTEXT_IDX_PATH] "
|
||||
"[--url=http://...metalink]"
|
||||
<< endl;
|
||||
cerr << "\tkiwix-manage LIBRARY_PATH show [CONTENTID1] [CONTENTID2] ... "
|
||||
"(show everything if no param.)"
|
||||
<< endl;
|
||||
cerr << "\tkiwix-manage LIBRARY_PATH remove CONTENTID1 [CONTENTID2]" << endl;
|
||||
std::cout << "Usage:" << std::endl
|
||||
<< "\tkiwix-manage LIBRARY_PATH add ZIM_PATH [OPTIONS]" << std::endl
|
||||
<< "\tkiwix-manage LIBRARY_PATH remove ZIM_ID [ZIM_ID]..." << std::endl
|
||||
<< "\tkiwix-manage LIBRARY_PATH show [ZIM_ID]..." << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "Purpose:" << std::endl
|
||||
<< "\tManipulates the Kiwix library XML file"
|
||||
<< std::endl << std::endl
|
||||
|
||||
<< "Arguments:" << std::endl
|
||||
<< "\tLIBRARY_PATH\tis the XML library file path."
|
||||
<< std::endl << std::endl
|
||||
<< "\tACTION\t\tis the pre-defined string to specify the action to run on the XML library file."
|
||||
<< std::endl << std::endl
|
||||
<< "\t\t\tMust be one of the following values:" << std::endl
|
||||
<< "\t\t\t* add: add a ZIM file to the library" << std::endl
|
||||
<< "\t\t\t* remove: remove a ZIM file from the library" << std::endl
|
||||
<< "\t\t\t* show: show the content of the library"
|
||||
<< std::endl << std::endl
|
||||
<< "\tZIM_ID\t\tZIM file unique ID"
|
||||
<< std::endl << std::endl
|
||||
<< "\tOPTIONS\t\tCustom options for \"add\" action:" << std::endl
|
||||
<< "\t\t\t--zimPathToSave=CUSTOM_ZIM_PATH to replace the current ZIM file path" << std::endl
|
||||
<< "\t\t\t--url=HTTP_ZIM_URL to create an \"url\" attribute for the online version of the ZIM file" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "Examples:" << std::endl
|
||||
<< "\tAdd ZIM files to library: kiwix-manage my_library.xml add first.zim second.zim" << std::endl
|
||||
<< "\tRemove ZIM files from library: kiwix-manage my_library.xml remove e5c2c003-b49e-2756-5176-5d9c86393dd9" << std::endl
|
||||
<< "\tShow all library ZIM files: kiwix-manage my_library.xml show" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "Documentation:" << std::endl
|
||||
<< "\tSource code\thttps://github.com/kiwix/kiwix-tools" << std::endl
|
||||
<< "\tMore info\thttps://wiki.kiwix.org/wiki/Kiwix-manage" << std::endl
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
bool handle_show(kiwix::Library* library, const std::string& libraryPath,
|
||||
int handle_show(kiwix::Library* library, const std::string& libraryPath,
|
||||
int argc, char* argv[])
|
||||
{
|
||||
show(library);
|
||||
if (argc > 3 ) {
|
||||
for(auto i=3; i<argc; i++) {
|
||||
std::string bookId = argv[i];
|
||||
show(library, bookId);
|
||||
}
|
||||
} else {
|
||||
auto booksIds = library->getBooksIds();
|
||||
for(auto& bookId: booksIds) {
|
||||
show(library, bookId);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
bool handle_add(kiwix::Library* library, const std::string& libraryPath,
|
||||
int handle_add(kiwix::Library* library, const std::string& libraryPath,
|
||||
int argc, char* argv[])
|
||||
{
|
||||
string zimPath;
|
||||
string zimPathToSave = ".";
|
||||
string indexPath;
|
||||
string url;
|
||||
string origID = "";
|
||||
int option_index = 0;
|
||||
int c = 0;
|
||||
bool resultCode = 0;
|
||||
int resultCode = 0;
|
||||
|
||||
if (argc > 3) {
|
||||
zimPath = argv[3];
|
||||
if (argc <= 3) {
|
||||
std::cerr << "Path to zim file to add is missing in the command line" << std::endl;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Options parsing */
|
||||
optind = 2;
|
||||
while (42) {
|
||||
static struct option long_options[]
|
||||
= {{"url", required_argument, 0, 'u'},
|
||||
{"origId", required_argument, 0, 'o'},
|
||||
{"indexPath", required_argument, 0, 'i'},
|
||||
{"zimPathToSave", required_argument, 0, 'z'},
|
||||
{0, 0, 0, 0}};
|
||||
optind = 3;
|
||||
static struct option long_options[] = {
|
||||
{"url", required_argument, 0, 'u'},
|
||||
{"origId", required_argument, 0, 'o'},
|
||||
{"zimPathToSave", required_argument, 0, 'z'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "cz:u:i:", long_options, &option_index);
|
||||
|
||||
if (c != -1) {
|
||||
switch (c) {
|
||||
case 'u':
|
||||
url = optarg;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
origID = optarg;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
indexPath = optarg;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
zimPathToSave = optarg;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
bool has_option = false;
|
||||
while (true) {
|
||||
c = getopt_long(argc, argv, "cz:u:", long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
has_option = true;
|
||||
switch (c) {
|
||||
case 'u':
|
||||
url = optarg;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
origID = optarg;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
zimPathToSave = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!zimPath.empty()) {
|
||||
kiwix::Manager manager(library);
|
||||
zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
|
||||
string bookId = manager.addBookFromPathAndGetId(
|
||||
zimPath, zimPathToSave, url, false);
|
||||
if (!bookId.empty()) {
|
||||
/* Save the index infos if necessary */
|
||||
if (!indexPath.empty()) {
|
||||
if (isRelativePath(indexPath)) {
|
||||
indexPath = computeAbsolutePath(indexPath, getCurrentDirectory());
|
||||
}
|
||||
library->getBookById(bookId).setIndexPath(indexPath);
|
||||
}
|
||||
} else {
|
||||
cerr << "Unable to build or save library file '" << libraryPath << "'"
|
||||
<< endl;
|
||||
if (optind >= argc) {
|
||||
std::cerr << "Path to zim file to add is missing in the command line" << std::endl;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (has_option && argc-optind > 1) {
|
||||
std::cerr << "You cannot give option and several zim files to add" << std::endl;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
kiwix::Manager manager(library);
|
||||
|
||||
for(auto i=optind; i<argc; i++) {
|
||||
std::string zimPath = argv[i];
|
||||
if (!zimPath.empty()) {
|
||||
auto _zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
|
||||
manager.addBookFromPathAndGetId(zimPath, _zimPathToSave, url, false);
|
||||
} else {
|
||||
std::cerr << "Invalid zim file path" << std::endl;
|
||||
resultCode = 1;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Invalid zim file path" << std::endl;
|
||||
resultCode = 1;
|
||||
}
|
||||
|
||||
return(resultCode);
|
||||
}
|
||||
|
||||
bool 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);
|
||||
bool exitCode = 0;
|
||||
int exitCode = 0;
|
||||
|
||||
if (argc <= 3) {
|
||||
std::cerr << "BookId to remove missing in the command line" << std::endl;
|
||||
@@ -188,62 +211,6 @@ bool handle_remove(kiwix::Library* library, const std::string& libraryPath,
|
||||
return(exitCode);
|
||||
}
|
||||
|
||||
bool handle_download(kiwix::Library* library, const std::string& libraryPath,
|
||||
int argc, char* argv[])
|
||||
{
|
||||
std::string bookId;
|
||||
bool exitCode = false;
|
||||
|
||||
if (argc > 3) {
|
||||
bookId = argv[3];
|
||||
}
|
||||
|
||||
auto& book = library->getBookById(bookId);
|
||||
auto did = book.getDownloadId();
|
||||
kiwix::Downloader downloader;
|
||||
kiwix::Download* download = nullptr;
|
||||
if (!did.empty()) {
|
||||
std::cout << "try resume " << did << std::endl;
|
||||
try {
|
||||
download = downloader.getDownload(did);
|
||||
} catch(...) {}
|
||||
}
|
||||
if (nullptr == download || download->getStatus() == kiwix::Download::K_UNKNOWN) {
|
||||
download = downloader.startDownload(book.getUrl());
|
||||
book.setDownloadId(download->getDid());
|
||||
}
|
||||
int step = 60*5;
|
||||
while (step--) {
|
||||
download->updateStatus();
|
||||
if (download->getStatus() == kiwix::Download::K_COMPLETE) {
|
||||
auto followingId = download->getFollowedBy();
|
||||
if (followingId.empty()) {
|
||||
book.setPath(download->getPath());
|
||||
book.setDownloadId("");
|
||||
std::cout << "File downloaded to " << book.getPath() << std::endl;
|
||||
break;
|
||||
} else {
|
||||
download = downloader.getDownload(followingId);
|
||||
}
|
||||
} else if (download->getStatus() == kiwix::Download::K_ACTIVE) {
|
||||
std::cout << download->getDid() << " : "
|
||||
<< kiwix::beautifyFileSize(download->getCompletedLength()) << "/"
|
||||
<< kiwix::beautifyFileSize(download->getTotalLength())
|
||||
<< " (" << kiwix::beautifyFileSize(download->getDownloadSpeed()) << "/s) "
|
||||
<< " [" << kiwix::beautifyFileSize(download->getVerifiedLength()) << "]"
|
||||
<< "[" << step << "] \n" << std::flush;
|
||||
} else if (download->getStatus() == kiwix::Download::K_ERROR) {
|
||||
std::cout << "File Error" << std::endl;
|
||||
exitCode = true;
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
downloader.close();
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
string libraryPath = "";
|
||||
@@ -261,8 +228,6 @@ int main(int argc, char** argv)
|
||||
action = SHOW;
|
||||
else if (actionString == "remove" || actionString == "delete")
|
||||
action = REMOVE;
|
||||
else if (actionString == "download")
|
||||
action = DOWNLOAD;
|
||||
}
|
||||
|
||||
/* Print usage)) if necessary */
|
||||
@@ -279,7 +244,7 @@ int main(int argc, char** argv)
|
||||
manager.readFile(libraryPath, false);
|
||||
|
||||
/* SHOW */
|
||||
bool exitCode = 0;
|
||||
int exitCode = 0;
|
||||
switch (action) {
|
||||
case SHOW:
|
||||
exitCode = handle_show(&library, libraryPath, argc, argv);
|
||||
@@ -290,15 +255,12 @@ int main(int argc, char** argv)
|
||||
case REMOVE:
|
||||
exitCode = handle_remove(&library, libraryPath, argc, argv);
|
||||
break;
|
||||
case DOWNLOAD:
|
||||
exitCode = handle_download(&library, libraryPath, argc, argv);
|
||||
break;
|
||||
case NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Rewrite the library file */
|
||||
if (action == REMOVE || action == ADD || action == DOWNLOAD) {
|
||||
if (action == REMOVE || action == ADD) {
|
||||
library.writeToFile(libraryPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
executable('kiwix-manage', ['kiwix-manage.cpp'],
|
||||
dependencies:all_deps,
|
||||
install:true,
|
||||
install_rpath: join_paths(get_option('prefix'), get_option('libdir')))
|
||||
install:true)
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <getopt.h>
|
||||
#include <kiwix/reader.h>
|
||||
#include <unistd.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
executable('kiwix-read', ['kiwix-read.cpp'],
|
||||
dependencies:all_deps,
|
||||
install:true,
|
||||
install_rpath: join_paths(get_option('prefix'), get_option('libdir')))
|
||||
install:true)
|
||||
|
||||
@@ -20,15 +20,13 @@
|
||||
#include <getopt.h>
|
||||
#include <kiwix/reader.h>
|
||||
#include <kiwix/searcher.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
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
|
||||
<< " ZIM is the full path of the ZIM file. This can also be a disctinct fulltext" << endl
|
||||
<< " index directory (usually distributed with the *.idx extension)." << 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
|
||||
<< " -v, --verbose\t\tGive details about the search process" << endl;
|
||||
@@ -100,14 +98,10 @@ int main(int argc, char** argv)
|
||||
|
||||
if (reader) {
|
||||
searcher = new kiwix::Searcher();
|
||||
searcher->add_reader(reader, "");
|
||||
searcher->add_reader(reader);
|
||||
} else {
|
||||
try {
|
||||
searcher = new kiwix::Searcher(zimPath, NULL, "");
|
||||
} catch (...) {
|
||||
cerr << "Unable to search through zim '" << zimPath << "'." << endl;
|
||||
exit(1);
|
||||
}
|
||||
cerr << "Unable to search through zim '" << zimPath << "'." << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Start the indexing */
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
executable('kiwix-search', ['kiwix-search.cpp'],
|
||||
dependencies:all_deps,
|
||||
install:true,
|
||||
install_rpath: join_paths(get_option('prefix'), get_option('libdir')))
|
||||
install:true)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
sources = ['kiwix-serve.cpp', 'request_context.cpp']
|
||||
sources += server_resources
|
||||
sources = ['kiwix-serve.cpp']
|
||||
|
||||
executable('kiwix-serve', sources,
|
||||
dependencies:all_deps,
|
||||
install:true,
|
||||
install_rpath: join_paths(get_option('prefix'), get_option('libdir')))
|
||||
install:true)
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009-2016 Emmanuel Engelhart <kelson@kiwix.org>
|
||||
* Copyright 2017 Matthieu Gautier<mgautier@kymeria.fr>
|
||||
*
|
||||
* 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 "request_context.h"
|
||||
#include <string.h>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
|
||||
RequestContext::RequestContext(struct MHD_Connection* connection,
|
||||
std::string rootLocation,
|
||||
const std::string& _url,
|
||||
const std::string& method,
|
||||
const std::string& version) :
|
||||
full_url(_url),
|
||||
url(_url),
|
||||
valid_url(true),
|
||||
version(version),
|
||||
acceptEncodingDeflate(false),
|
||||
accept_range(false),
|
||||
range_pair(0, -1)
|
||||
{
|
||||
if (method == "GET") {
|
||||
this->method = RequestMethod::GET;
|
||||
} else if (method == "HEAD") {
|
||||
this->method = RequestMethod::HEAD;
|
||||
} else if (method == "POST") {
|
||||
this->method = RequestMethod::POST;
|
||||
} else if (method == "PUT") {
|
||||
this->method = RequestMethod::PUT;
|
||||
} else if (method == "DELETE") {
|
||||
this->method = RequestMethod::DELETE_;
|
||||
} else if (method == "CONNECT") {
|
||||
this->method = RequestMethod::CONNECT;
|
||||
} else if (method == "OPTIONS") {
|
||||
this->method = RequestMethod::OPTIONS;
|
||||
} else if (method == "TRACE") {
|
||||
this->method = RequestMethod::TRACE;
|
||||
} else if (method == "PATCH") {
|
||||
this->method = RequestMethod::PATCH;
|
||||
} else {
|
||||
this->method = RequestMethod::OTHER;
|
||||
}
|
||||
|
||||
MHD_get_connection_values(connection, MHD_HEADER_KIND, &RequestContext::fill_header, this);
|
||||
MHD_get_connection_values(connection, MHD_GET_ARGUMENT_KIND, &RequestContext::fill_argument, this);
|
||||
|
||||
valid_url = true;
|
||||
if (rootLocation.empty()) {
|
||||
// nothing special to handle.
|
||||
url = full_url;
|
||||
} else {
|
||||
if (full_url.size() > rootLocation.size() &&
|
||||
full_url.substr(0, rootLocation.size()+1) == rootLocation + "/") {
|
||||
url = full_url.substr(rootLocation.size());
|
||||
} else {
|
||||
valid_url = false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
acceptEncodingDeflate =
|
||||
(get_header(MHD_HTTP_HEADER_ACCEPT_ENCODING).find("deflate") != std::string::npos);
|
||||
} catch (const std::out_of_range&) {}
|
||||
|
||||
/*Check if range is requested. */
|
||||
try {
|
||||
auto range = get_header(MHD_HTTP_HEADER_RANGE);
|
||||
int start = 0;
|
||||
int end = -1;
|
||||
std::istringstream iss(range);
|
||||
char c;
|
||||
|
||||
iss >> start >> c;
|
||||
if (iss.good() && c=='-') {
|
||||
iss >> end;
|
||||
if (iss.fail()) {
|
||||
// Something went wrong will extracting.
|
||||
end = -1;
|
||||
}
|
||||
if (iss.eof()) {
|
||||
accept_range = true;
|
||||
range_pair = std::pair<int, int>(start, end);
|
||||
}
|
||||
}
|
||||
} catch (const std::out_of_range&) {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
RequestContext::~RequestContext()
|
||||
{}
|
||||
|
||||
|
||||
int RequestContext::fill_header(void *__this, enum MHD_ValueKind kind,
|
||||
const char *key, const char *value)
|
||||
{
|
||||
RequestContext *_this = static_cast<RequestContext*>(__this);
|
||||
_this->headers[key] = value;
|
||||
return MHD_YES;
|
||||
}
|
||||
|
||||
int RequestContext::fill_argument(void *__this, enum MHD_ValueKind kind,
|
||||
const char *key, const char* value)
|
||||
{
|
||||
RequestContext *_this = static_cast<RequestContext*>(__this);
|
||||
_this->arguments[key] = value == nullptr ? "" : value;
|
||||
return MHD_YES;
|
||||
}
|
||||
|
||||
void RequestContext::print_debug_info() {
|
||||
printf("method : %s (%d)\n", method==RequestMethod::GET ? "GET" :
|
||||
method==RequestMethod::POST ? "POST" :
|
||||
"OTHER", (int)method);
|
||||
printf("version : %s\n", version.c_str());
|
||||
printf("headers :\n");
|
||||
for (auto it=headers.begin(); it!=headers.end(); it++) {
|
||||
printf(" - %s : '%s'\n", it->first.c_str(), it->second.c_str());
|
||||
}
|
||||
printf("arguments :\n");
|
||||
for (auto it=arguments.begin(); it!=arguments.end(); it++) {
|
||||
printf(" - %s : '%s'\n", it->first.c_str(), it->second.c_str());
|
||||
}
|
||||
printf("Parsed : \n");
|
||||
printf("url : %s\n", url.c_str());
|
||||
printf("acceptEncodingDeflate : %d\n", acceptEncodingDeflate);
|
||||
printf("has_range : %d\n", accept_range);
|
||||
printf(".............\n");
|
||||
}
|
||||
|
||||
|
||||
RequestMethod RequestContext::get_method() {
|
||||
return method;
|
||||
}
|
||||
|
||||
std::string RequestContext::get_url() {
|
||||
return url;
|
||||
}
|
||||
|
||||
std::string RequestContext::get_url_part(int number) {
|
||||
size_t start = 1;
|
||||
while(true) {
|
||||
auto found = url.find('/', start);
|
||||
if (number == 0) {
|
||||
if (found == std::string::npos) {
|
||||
return url.substr(start);
|
||||
} else {
|
||||
return url.substr(start, found-start);
|
||||
}
|
||||
} else {
|
||||
if (found == std::string::npos) {
|
||||
throw std::out_of_range("No parts");
|
||||
}
|
||||
start = found + 1;
|
||||
number -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string RequestContext::get_full_url() {
|
||||
return full_url;
|
||||
}
|
||||
|
||||
bool RequestContext::is_valid_url() {
|
||||
return valid_url;
|
||||
}
|
||||
|
||||
bool RequestContext::has_range() {
|
||||
return accept_range;
|
||||
}
|
||||
|
||||
std::pair<int, int> RequestContext::get_range() {
|
||||
return range_pair;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string RequestContext::get_argument(const std::string& name) {
|
||||
return arguments.at(name);
|
||||
}
|
||||
|
||||
std::string RequestContext::get_header(const std::string& name) {
|
||||
return headers.at(name);
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009-2016 Emmanuel Engelhart <kelson@kiwix.org>
|
||||
* Copyright 2017 Matthieu Gautier<mgautier@kymeria.fr>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef REQUEST_CONTEXT_H
|
||||
#define REQUEST_CONTEXT_H
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
|
||||
extern "C" {
|
||||
#include <microhttpd.h>
|
||||
}
|
||||
|
||||
enum class RequestMethod {
|
||||
GET,
|
||||
HEAD,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE_,
|
||||
CONNECT,
|
||||
OPTIONS,
|
||||
TRACE,
|
||||
PATCH,
|
||||
OTHER
|
||||
};
|
||||
|
||||
class KeyError : public std::runtime_error {};
|
||||
class IndexError: public std::runtime_error {};
|
||||
|
||||
|
||||
class RequestContext {
|
||||
public:
|
||||
RequestContext(struct MHD_Connection* connection,
|
||||
std::string rootLocation,
|
||||
const std::string& url,
|
||||
const std::string& method,
|
||||
const std::string& version);
|
||||
~RequestContext();
|
||||
|
||||
void print_debug_info();
|
||||
|
||||
bool is_valid_url();
|
||||
|
||||
std::string get_header(const std::string& name);
|
||||
template<typename T=std::string>
|
||||
T get_argument(const std::string& name) {
|
||||
std::istringstream stream(arguments.at(name));
|
||||
T v;
|
||||
stream >> v;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
RequestMethod get_method();
|
||||
std::string get_url();
|
||||
std::string get_url_part(int part);
|
||||
std::string get_full_url();
|
||||
|
||||
bool has_range();
|
||||
std::pair<int, int> get_range();
|
||||
|
||||
bool can_compress() { return acceptEncodingDeflate; }
|
||||
|
||||
// [TODO] Move this to the response builder
|
||||
int httpResponseCode;
|
||||
|
||||
private:
|
||||
std::string full_url;
|
||||
std::string url;
|
||||
bool valid_url;
|
||||
RequestMethod method;
|
||||
std::string version;
|
||||
|
||||
bool acceptEncodingDeflate;
|
||||
|
||||
bool accept_range;
|
||||
std::pair<int, int> range_pair;
|
||||
std::map<std::string, std::string> headers;
|
||||
std::map<std::string, std::string> arguments;
|
||||
|
||||
static int fill_header(void *, enum MHD_ValueKind, const char*, const char*);
|
||||
static int fill_argument(void *, enum MHD_ValueKind, const char*, const char*);
|
||||
};
|
||||
|
||||
template<> std::string RequestContext::get_argument(const std::string& name);
|
||||
|
||||
|
||||
#endif //REQUEST_CONTEXT_H
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
res_compiler = find_program('kiwix-compile-resources', 'compile_resources.py')
|
||||
|
||||
subdir('server')
|
||||
@@ -1,13 +0,0 @@
|
||||
<span class="kiwix">
|
||||
<span id="kiwixtoolbar" class="ui-widget-header">
|
||||
<div class="kiwix_centered">
|
||||
<div class="kiwix_searchform">
|
||||
<form class="kiwixsearch" method="GET" action="__ROOT_LOCATION__/search" id="kiwixsearchform">
|
||||
<input autocomplete="off" class="ui-autocomplete-input" id="kiwixsearchbox" name="pattern" type="text">
|
||||
<input type="submit" value="🔍">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</span>
|
||||
<div style="display: block; height: 5em;"></div>
|
||||
@@ -1,55 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Welcome to Kiwix Server</title>
|
||||
<script type="text/javascript" src="__ROOT_LOCATION__/skin/jquery-ui/external/jquery/jquery.js"></script>
|
||||
<script type="text/javascript" src="__ROOT_LOCATION__/skin/jquery-ui/jquery-ui.min.js"></script>
|
||||
<link type="text/css" href="__ROOT_LOCATION__/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
|
||||
<link type="text/css" href="__ROOT_LOCATION__/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
|
||||
<style>
|
||||
body {
|
||||
background:
|
||||
radial-gradient(#EEEEEE 15%, transparent 16%) 0 0,
|
||||
radial-gradient(#EEEEEE 15%, transparent 16%) 8px 8px,
|
||||
radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 0 1px,
|
||||
radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 8px 9px;
|
||||
background-color:#E8E8E8;
|
||||
background-size:16px 16px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 65.8em;
|
||||
}
|
||||
.book__list { text-align: center; }
|
||||
.book {
|
||||
display: inline-block; vertical-align: bottom; margin: 8px; padding: 12px 15px; width: 300px;
|
||||
border: 1px solid #ccc; border-radius: 8px;
|
||||
text-align: left; color: #000; font-family: sans-serif; font-size: 13px;
|
||||
background-color:#F1F1F1;
|
||||
box-shadow: 2px 2px 5px 0px #ccc;
|
||||
}
|
||||
.book:hover { background-color: #F9F9F9; box-shadow: none;}
|
||||
.book__background { background-repeat: no-repeat; background-size: auto; background-position: top right; }
|
||||
.book__title {
|
||||
padding: 0 55px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
font-size: 18px; color: #0645ad;
|
||||
}
|
||||
.book__description {
|
||||
padding: 5px 55px 5px 0px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
font-size: 15px;
|
||||
}
|
||||
.book__info { line-height: 18px; color: #777; font-weight: bold; font-size: 13px; }
|
||||
</style>
|
||||
<script>
|
||||
$(function() {
|
||||
$( "#accordion" ).accordion();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body class="kiwix">
|
||||
|
||||
<div class="kiwix">
|
||||
__BOOKS__
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,27 +0,0 @@
|
||||
<link type="text/css" href="__ROOT_LOCATION__/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
|
||||
<link type="text/css" href="__ROOT_LOCATION__/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
|
||||
<link type="text/css" href="__ROOT_LOCATION__/skin/taskbar.css" rel="Stylesheet" />
|
||||
<script type="text/javascript" src="__ROOT_LOCATION__/skin/jquery-ui/external/jquery/jquery.js"></script>
|
||||
<script type="text/javascript" src="__ROOT_LOCATION__/skin/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script>
|
||||
var jk = jQuery.noConflict();
|
||||
jk(function() {
|
||||
jk( "#kiwixsearchbox" ).autocomplete({
|
||||
|
||||
source: "__ROOT_LOCATION__/suggest?content=__CONTENT_ESCAPED__",
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
|
||||
select: function(event, ui) {
|
||||
jk( "#kiwixsearchbox" ).val(ui.item.value);
|
||||
jk( "#kiwixsearchform" ).submit();
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
/* cybook hack */
|
||||
if (navigator.userAgent.indexOf("bookeen/cybook") != -1) {
|
||||
jk("html").addClass("cybook");
|
||||
}
|
||||
</script>
|
||||
9789
static/server/jquery-ui/external/jquery/jquery.js
vendored
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 208 B |
|
Before Width: | Height: | Size: 335 B |
|
Before Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 332 B |
|
Before Width: | Height: | Size: 280 B |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
7
static/server/jquery-ui/jquery-ui.min.css
vendored
13
static/server/jquery-ui/jquery-ui.min.js
vendored
@@ -1,8 +0,0 @@
|
||||
|
||||
server_resources = custom_target('resources',
|
||||
input: 'resources_list.txt',
|
||||
output: ['server-resources.cpp', 'server-resources.h'],
|
||||
command:[res_compiler, '--cxxfile', '@OUTPUT0@', '--hfile', '@OUTPUT1@', '@INPUT@'],
|
||||
build_always: true
|
||||
)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||
<ShortName>Zim catalog search</ShortName>
|
||||
<Description>Search zim files in the catalog.</Description>
|
||||
<Url type="application/atom+xml;profile=opds-catalog"
|
||||
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
indexOffset="0"
|
||||
template="/__ROOT_LOCATION__/catalog/search?q={searchTerms}&lang={language}&count={count}&start={startIndex}"/>
|
||||
</OpenSearchDescription>
|
||||
@@ -1,25 +0,0 @@
|
||||
jquery-ui/jquery-ui.structure.min.css
|
||||
jquery-ui/jquery-ui.min.js
|
||||
jquery-ui/external/jquery/jquery.js
|
||||
jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png
|
||||
jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png
|
||||
jquery-ui/images/ui-icons_222222_256x240.png
|
||||
jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png
|
||||
jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
||||
jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png
|
||||
jquery-ui/images/ui-icons_2e83ff_256x240.png
|
||||
jquery-ui/images/ui-icons_cd0a0a_256x240.png
|
||||
jquery-ui/images/ui-icons_888888_256x240.png
|
||||
jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png
|
||||
jquery-ui/images/animated-overlay.gif
|
||||
jquery-ui/images/ui-bg_glass_75_dadada_1x400.png
|
||||
jquery-ui/images/ui-icons_454545_256x240.png
|
||||
jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png
|
||||
jquery-ui/jquery-ui.theme.min.css
|
||||
jquery-ui/jquery-ui.min.css
|
||||
home.html.tmpl
|
||||
include.html.part
|
||||
taskbar.css
|
||||
taskbar.html.part
|
||||
global_taskbar.html.part
|
||||
opensearchdescription.xml
|
||||
@@ -1,88 +0,0 @@
|
||||
#kiwixtoolbar {
|
||||
position: fixed;
|
||||
padding: .5em;
|
||||
left:0;
|
||||
right:0;
|
||||
top: 0;
|
||||
z-index:100;
|
||||
}
|
||||
|
||||
#kiwixtoolbar > a {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.height_separator {
|
||||
height: 3em;
|
||||
}
|
||||
|
||||
#kiwixsearchbox {
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
.kiwix .kiwix_centered {
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.kiwix .kiwix_button_wrapper {
|
||||
float: left;
|
||||
}
|
||||
.kiwix .kiwix_searchform {
|
||||
float: right;
|
||||
}
|
||||
.kiwix #kiwixtoolbar button,
|
||||
.kiwix #kiwixtoolbar input[type="submit"] {
|
||||
box-sizing: border-box !important;
|
||||
height: 26px !important;
|
||||
line-height: 20px !important;
|
||||
margin-right: 5px !important;
|
||||
padding: 2px 6px !important;
|
||||
border: 1px solid #999 !important;
|
||||
border-radius: 3px !important;
|
||||
background-color: #ededed !important;
|
||||
font-weight: normal !important;
|
||||
cursor: pointer !important;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
.kiwix #kiwixtoolbar a {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.kiwix #kiwixtoolbar #kiwixsearchform input[type='text'] {
|
||||
box-sizing: border-box !important;
|
||||
height: 26px !important;
|
||||
line-height: 20px !important;
|
||||
border: 1px solid #999 !important;
|
||||
border-radius: 3px !important;
|
||||
background-color: #fff !important;
|
||||
padding: 2px 2px 2px 3px !important;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
|
||||
/* Try to fix buggy stuff in jquery-ui autocomplete */
|
||||
#ui-id-1, .ui-autocomplete {
|
||||
background: white !important;
|
||||
border: solid 1px grey !important;
|
||||
}
|
||||
|
||||
li.ui-state-focus {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.kiwixsearch {
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 645px) {
|
||||
.kiwixsearch {
|
||||
float: none;
|
||||
}
|
||||
#kiwixsearchbox {
|
||||
width: 65%;
|
||||
}
|
||||
#kiwixsearchform input[type="submit"] {
|
||||
width: 28%;
|
||||
}
|
||||
.height_separator {
|
||||
height: 6em;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<span class="kiwix">
|
||||
<span id="kiwixtoolbar" class="ui-widget-header">
|
||||
<div class="kiwix_centered">
|
||||
<div class="kiwix_button_wrapper">
|
||||
<a id="kiwix_serve_taskbar_library_button" href="__ROOT_LOCATION__/"><button>🏠</button></a>
|
||||
<a id="kiwix_serve_taskbar_home_button" href="__ROOT_LOCATION__/__CONTENT__/"><button>__ZIM_TITLE__</button></a>
|
||||
<a id="kiwix_serve_taskbar_random_button" href="__ROOT_LOCATION__/random?content=__CONTENT_ESCAPED__"><button>🎲</button></a>
|
||||
</div>
|
||||
<div class="kiwix_searchform">
|
||||
<form class="kiwixsearch" method="GET" action="__ROOT_LOCATION__/search" id="kiwixsearchform">
|
||||
<input type="hidden" name="content" value="__CONTENT__" />
|
||||
<input autocomplete="off" class="ui-autocomplete-input" id="kiwixsearchbox" name="pattern" type="text">
|
||||
<input type="submit" value="🔍">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</span>
|
||||
<div style="display: block; height: 5em;"></div>
|
||||
@@ -24,6 +24,6 @@ esac
|
||||
cd ${TRAVIS_BUILD_DIR}
|
||||
export PKG_CONFIG_PATH=${INSTALL_DIR}/lib/x86_64-linux-gnu/pkgconfig
|
||||
export PATH=${INSTALL_DIR}/bin:$PATH
|
||||
meson . build -Dctpp2-install-prefix=${INSTALL_DIR} ${MESON_OPTION}
|
||||
meson . build ${MESON_OPTION}
|
||||
cd build
|
||||
ninja
|
||||
|
||||
@@ -3,33 +3,36 @@
|
||||
set -e
|
||||
|
||||
REPO_NAME=${TRAVIS_REPO_SLUG#*/}
|
||||
ARCHIVE_NAME=deps_${TRAVIS_OS_NAME}_${PLATFORM}_${REPO_NAME}.tar.gz
|
||||
ARCHIVE_NAME=deps_linux_xenial_${PLATFORM}_${REPO_NAME}.tar.xz
|
||||
|
||||
# Packages.
|
||||
case ${PLATFORM} in
|
||||
"native_static")
|
||||
PACKAGES="gcc cmake libbz2-dev ccache zlib1g-dev uuid-dev libctpp2-dev"
|
||||
PACKAGES="gcc python3.5 cmake libbz2-dev ccache zlib1g-dev uuid-dev"
|
||||
;;
|
||||
"native_dyn")
|
||||
PACKAGES="gcc cmake libbz2-dev ccache zlib1g-dev uuid-dev libctpp2-dev libmicrohttpd-dev"
|
||||
PACKAGES="gcc python3.5 cmake libbz2-dev ccache zlib1g-dev uuid-dev libmicrohttpd-dev"
|
||||
;;
|
||||
"win32_static")
|
||||
PACKAGES="g++-mingw-w64-i686 gcc-mingw-w64-i686 gcc-mingw-w64-base mingw-w64-tools ccache"
|
||||
PACKAGES="g++-mingw-w64-i686 gcc-mingw-w64-i686 gcc-mingw-w64-base mingw-w64-tools ccache python3.5"
|
||||
;;
|
||||
"win32_dyn")
|
||||
PACKAGES="g++-mingw-w64-i686 gcc-mingw-w64-i686 gcc-mingw-w64-base mingw-w64-tools ccache"
|
||||
PACKAGES="g++-mingw-w64-i686 gcc-mingw-w64-i686 gcc-mingw-w64-base mingw-w64-tools ccache python3.5"
|
||||
;;
|
||||
"android_arm")
|
||||
PACKAGES="gcc cmake ccache"
|
||||
PACKAGES="gcc python3.5 cmake ccache"
|
||||
;;
|
||||
"android_arm64")
|
||||
PACKAGES="gcc cmake ccache"
|
||||
PACKAGES="gcc python3.5 cmake ccache"
|
||||
;;
|
||||
esac
|
||||
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -qq python3-pip ${PACKAGES}
|
||||
sudo pip3 install meson==0.43.0
|
||||
wget https://bootstrap.pypa.io/get-pip.py
|
||||
python3.5 get-pip.py --user
|
||||
python3.5 -m pip install --user --upgrade pip
|
||||
python3.5 -m pip install --user meson==0.49.2
|
||||
|
||||
# Ninja
|
||||
cd $HOME
|
||||
@@ -43,3 +46,4 @@ sudo cp ninja /bin
|
||||
cd ${HOME}
|
||||
wget http://tmp.kiwix.org/ci/${ARCHIVE_NAME}
|
||||
tar xf ${HOME}/${ARCHIVE_NAME}
|
||||
sudo ln -s travis ../ci_builder
|
||||
|
||||