mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2026-01-17 18:37:44 -05:00
Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
38088ee321 | ||
|
|
0f445e9791 | ||
|
|
1032a46c57 |
@@ -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
|
||||
|
||||
89
Changelog
89
Changelog
@@ -1,3 +1,92 @@
|
||||
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
|
||||
=================
|
||||
|
||||
kiwix-manage
|
||||
------------
|
||||
|
||||
* Be able to remove several books from the library in one command.
|
||||
|
||||
kiwix-tools 0.7.0
|
||||
=================
|
||||
|
||||
|
||||
23
README.md
23
README.md
@@ -16,7 +16,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 +26,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 +41,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 +52,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 +101,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
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
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
BIN
docker/server/pictures/screenshot_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
docker/server/pictures/screenshot_2.png
Normal file
BIN
docker/server/pictures/screenshot_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 199 KiB |
@@ -1,5 +1,5 @@
|
||||
project('kiwix-tools', 'cpp',
|
||||
version : '0.7.0',
|
||||
version : '2.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:'>=5.1.0', static:static_linkage)
|
||||
microhttpd_dep = dependency('libmicrohttpd', static:static_linkage)
|
||||
z_dep = dependency('zlib', static:static_linkage)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,30 +21,21 @@
|
||||
#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,30 +45,69 @@ 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 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);
|
||||
}
|
||||
|
||||
@@ -86,73 +116,69 @@ bool handle_add(kiwix::Library* library, const std::string& libraryPath,
|
||||
{
|
||||
string zimPath;
|
||||
string zimPathToSave = ".";
|
||||
string indexPath;
|
||||
string url;
|
||||
string origID = "";
|
||||
int option_index = 0;
|
||||
int c = 0;
|
||||
bool 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);
|
||||
@@ -165,19 +191,22 @@ bool handle_remove(kiwix::Library* library, const std::string& libraryPath,
|
||||
const unsigned int totalBookCount = library->getBookCount(true, true);
|
||||
bool exitCode = 0;
|
||||
|
||||
if (argc > 3) {
|
||||
bookId = argv[3];
|
||||
if (argc <= 3) {
|
||||
std::cerr << "BookId to remove missing in the command line" << std::endl;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (!library->removeBookById(bookId)) {
|
||||
if (totalBookCount > 0) {
|
||||
std::cerr
|
||||
<< "Invalid book id." << std::endl;
|
||||
exitCode = 1;
|
||||
} else {
|
||||
std::cerr
|
||||
<< "Invalid book id. Library is empty, no book to delete."
|
||||
<< std::endl;
|
||||
if (!totalBookCount) {
|
||||
std::cerr << "Library is empty, no book to delete."
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i = 3; i<argc; i++) {
|
||||
bookId = argv[i];
|
||||
|
||||
if (!library->removeBookById(bookId)) {
|
||||
std::cerr << "Invalid book id '" << bookId << "'." << std::endl;
|
||||
exitCode = 1;
|
||||
}
|
||||
}
|
||||
@@ -185,62 +214,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 = "";
|
||||
@@ -258,8 +231,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 */
|
||||
@@ -287,15 +258,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -27,8 +27,7 @@ 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;
|
||||
@@ -102,12 +101,8 @@ int main(int argc, char** argv)
|
||||
searcher = new kiwix::Searcher();
|
||||
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)
|
||||
|
||||
@@ -44,10 +44,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <getopt.h>
|
||||
#include <kiwix/common/otherTools.h>
|
||||
#include <kiwix/common/pathTools.h>
|
||||
#include <kiwix/common/regexTools.h>
|
||||
#include <kiwix/common/stringTools.h>
|
||||
#include <kiwix/tools/otherTools.h>
|
||||
#include <kiwix/tools/pathTools.h>
|
||||
#include <kiwix/tools/regexTools.h>
|
||||
#include <kiwix/tools/stringTools.h>
|
||||
#include <kiwix/manager.h>
|
||||
#include <kiwix/reader.h>
|
||||
#include <kiwix/searcher.h>
|
||||
@@ -67,7 +67,6 @@ extern "C" {
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "server-resources.h"
|
||||
@@ -93,6 +92,7 @@ using namespace std;
|
||||
|
||||
static bool noLibraryButtonFlag = false;
|
||||
static bool noSearchBarFlag = false;
|
||||
static bool noDateAliasesFlag = false;
|
||||
static string welcomeHTML;
|
||||
static string catalogOpenSearchDescription;
|
||||
static std::atomic_bool isVerbose(false);
|
||||
@@ -105,6 +105,7 @@ static kiwix::Library library;
|
||||
static pthread_mutex_t searchLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t compressorLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t regexLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static unsigned int nb_threads = 4;
|
||||
|
||||
std::pair<kiwix::Reader*, kiwix::Searcher*>
|
||||
get_from_humanReadableBookId(const std::string& humanReadableBookId) {
|
||||
@@ -538,9 +539,9 @@ static struct MHD_Response* handle_search(RequestContext* request)
|
||||
|
||||
/* Retrive geo search */
|
||||
bool has_geo_query = false;
|
||||
float latitude;
|
||||
float longitude;
|
||||
float distance;
|
||||
float latitude = 0;
|
||||
float longitude = 0;
|
||||
float distance = 0;
|
||||
try {
|
||||
latitude = request->get_argument<float>("latitude");
|
||||
longitude = request->get_argument<float>("longitude");
|
||||
@@ -698,6 +699,7 @@ static struct MHD_Response* handle_catalog(RequestContext* request)
|
||||
} else if (url == "search") {
|
||||
std::string query;
|
||||
std::string language;
|
||||
std::vector<std::string> tags;
|
||||
size_t count(10);
|
||||
size_t startIndex(0);
|
||||
try {
|
||||
@@ -712,13 +714,19 @@ static struct MHD_Response* handle_catalog(RequestContext* request)
|
||||
try {
|
||||
startIndex = stoul(request->get_argument("start"));
|
||||
} catch (...) {}
|
||||
try {
|
||||
tags.push_back(request->get_argument("tag"));
|
||||
} catch (...) {}
|
||||
opdsDumper.setTitle("Search result for " + query);
|
||||
uuid = zim::Uuid::generate();
|
||||
bookIdsToDump = library.listBooksIds(
|
||||
kiwix::VALID|kiwix::LOCAL|kiwix::REMOTE,
|
||||
kiwix::UNSORTED,
|
||||
query,
|
||||
language);
|
||||
language,
|
||||
"", // creator
|
||||
"", // publisher
|
||||
tags);
|
||||
auto totalResults = bookIdsToDump.size();
|
||||
bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+startIndex);
|
||||
if (count>0 && bookIdsToDump.size() > count) {
|
||||
@@ -766,10 +774,22 @@ static struct MHD_Response* handle_content(RequestContext* request)
|
||||
}
|
||||
|
||||
auto urlStr = request->get_url().substr(humanReadableBookId.size()+1);
|
||||
if (urlStr[0] == '/') {
|
||||
urlStr = urlStr.substr(1);
|
||||
}
|
||||
|
||||
try {
|
||||
entry = reader->getEntryFromPath(urlStr);
|
||||
entry = entry.getFinalEntry();
|
||||
if (entry.isRedirect() || urlStr.empty()) {
|
||||
// If urlStr is empty, we want to mainPage.
|
||||
// We must do a redirection to the real page.
|
||||
entry = entry.getFinalEntry();
|
||||
std::string httpRedirection = (
|
||||
rootLocation + "/" + humanReadableBookId + "/" +
|
||||
kiwix::urlEncode(entry.getPath()));
|
||||
request->httpResponseCode = MHD_HTTP_FOUND;
|
||||
return build_response("", 0, httpRedirection, "", false, false);
|
||||
}
|
||||
} catch(kiwix::NoEntry& e) {
|
||||
if (isVerbose.load())
|
||||
printf("Failed to find %s\n", urlStr.c_str());
|
||||
@@ -797,7 +817,6 @@ static struct MHD_Response* handle_content(RequestContext* request)
|
||||
/* Special rewrite URL in case of ZIM file use intern *asbolute* url like
|
||||
* /A/Kiwix */
|
||||
if (mimeType.find("text/html") != string::npos) {
|
||||
baseUrl = "/" + entry.getPath();
|
||||
pthread_mutex_lock(®exLock);
|
||||
content = replaceRegex(content,
|
||||
"$1$2" + rootLocation + "/" + humanReadableBookId + "/$3/",
|
||||
@@ -805,10 +824,6 @@ static struct MHD_Response* handle_content(RequestContext* request)
|
||||
content = replaceRegex(content,
|
||||
"$1$2" + rootLocation + "/" + humanReadableBookId + "/$3/",
|
||||
"(@import[ ]+)([\"|\']{0,1})/([A-Z|\\-])/");
|
||||
content = replaceRegex(
|
||||
content,
|
||||
"<head><base href=\"" + rootLocation + "/" + humanReadableBookId + baseUrl + "\" />",
|
||||
"<head>");
|
||||
pthread_mutex_unlock(®exLock);
|
||||
introduceTaskbar(content, humanReadableBookId);
|
||||
} else if (mimeType.find("text/css") != string::npos) {
|
||||
@@ -909,12 +924,60 @@ static int accessHandlerCallback(void* cls,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool hasHumanReadableIdCollision(const string &humanReadableId,
|
||||
const string &zimPath)
|
||||
{
|
||||
if (readers.find(humanReadableId) != readers.end()) {
|
||||
cerr << "Path collision: " << readers[humanReadableId]->getZimFilePath()
|
||||
<< " and " << zimPath << " can't share the same URL path /"
|
||||
<< humanReadableId << "/. Therefore, only "
|
||||
<< zimPath << " will be served." << endl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
std::cout << "Usage:" << std::endl
|
||||
<< "\tkiwix-serve [OPTIONS] ZIM_PATH+" << std::endl
|
||||
<< "\tkiwix-serve --library [OPTIONS] LIBRARY_PATH" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "Purpose:" << std::endl
|
||||
<< "\tDeliver ZIM file 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."
|
||||
<< std::endl
|
||||
<< "\tZIM_PATH\t\tis the path of a ZIM file."
|
||||
<< std::endl << std::endl
|
||||
|
||||
<< "Optional arguments:" << std::endl
|
||||
<< "\t-a, --attachToProcess\texit if given process id is not running anymore" << std::endl
|
||||
<< "\t-d, --daemon\t\tdetach the HTTP server daemon from the main process" << std::endl
|
||||
<< "\t-f, --interface\t\tlisten only on this interface, all available ones otherwise (POSIX only)" << 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-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: " << nb_threads << ")" << std::endl
|
||||
<< "\t-v, --verbose\t\tprint debug log to STDOUT" << std::endl
|
||||
<< "\t-z, --nodatealiases\tcreate URL aliases for each content by removing the date" << std::endl
|
||||
<< std::endl
|
||||
|
||||
<< "Documentation:" << std::endl
|
||||
<< "\tSource code\t\thttps://github.com/kiwix/kiwix-tools" << std::endl
|
||||
<< "\tMore info\t\thttps://wiki.kiwix.org/wiki/Kiwix-serve" << std::endl
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct MHD_Daemon* daemon;
|
||||
vector<string> zimPathes;
|
||||
string libraryPath;
|
||||
string indexPath;
|
||||
string rootPath;
|
||||
string interface;
|
||||
int serverPort = 80;
|
||||
@@ -922,15 +985,14 @@ int main(int argc, char** argv)
|
||||
int libraryFlag = false;
|
||||
string PPIDString;
|
||||
unsigned int PPID = 0;
|
||||
unsigned int nb_threads = std::thread::hardware_concurrency();
|
||||
|
||||
static struct option long_options[]
|
||||
= {{"daemon", no_argument, 0, 'd'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"library", no_argument, 0, 'l'},
|
||||
{"nolibrarybutton", no_argument, 0, 'm'},
|
||||
{"nodatealiases", no_argument, 0, 'z'},
|
||||
{"nosearchbar", no_argument, 0, 'n'},
|
||||
{"index", required_argument, 0, 'i'},
|
||||
{"attachToProcess", required_argument, 0, 'a'},
|
||||
{"port", required_argument, 0, 'p'},
|
||||
{"interface", required_argument, 0, 'f'},
|
||||
@@ -942,7 +1004,7 @@ int main(int argc, char** argv)
|
||||
while (true) {
|
||||
int option_index = 0;
|
||||
int c
|
||||
= getopt_long(argc, argv, "mndvli:a:p:f:t:r:", long_options, &option_index);
|
||||
= getopt_long(argc, argv, "mndvla:p:f:t:r:", long_options, &option_index);
|
||||
|
||||
if (c != -1) {
|
||||
switch (c) {
|
||||
@@ -958,12 +1020,12 @@ int main(int argc, char** argv)
|
||||
case 'n':
|
||||
noSearchBarFlag = true;
|
||||
break;
|
||||
case 'z':
|
||||
noDateAliasesFlag = true;
|
||||
break;
|
||||
case 'm':
|
||||
noLibraryButtonFlag = true;
|
||||
break;
|
||||
case 'i':
|
||||
indexPath = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
serverPort = atoi(optarg);
|
||||
break;
|
||||
@@ -1007,25 +1069,7 @@ int main(int argc, char** argv)
|
||||
|
||||
/* Print usage)) if necessary */
|
||||
if (zimPathes.empty() && libraryPath.empty()) {
|
||||
cerr << "Usage: kiwix-serve [--index=INDEX_PATH] [--port=PORT] [--verbose] "
|
||||
"[--nosearchbar] [--nolibrarybutton] [--daemon] "
|
||||
"[--attachToProcess=PID] [--interface=IF_NAME] "
|
||||
"[--urlRootLocation=/URL_ROOT] "
|
||||
"[--threads=NB_THREAD(" << nb_threads << ")] ZIM_PATH+"
|
||||
<< endl;
|
||||
cerr << " kiwix-serve --library [--port=PORT] [--verbose] [--daemon] "
|
||||
"[--nosearchbar] [--nolibrarybutton] [--attachToProcess=PID] "
|
||||
"[--interface=IF_NAME] [--urlRootLocation=/URL_ROOT] "
|
||||
"[--threads=NB_THREAD(" << nb_threads << ")] LIBRARY_PATH "
|
||||
<< endl;
|
||||
cerr << "\n If you set more than one ZIM_PATH, you cannot set a "
|
||||
"INDEX_PATH."
|
||||
<< endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((zimPathes.size() > 1) && !indexPath.empty()) {
|
||||
cerr << "You cannot set a indexPath if you also set several zimPathes";
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1071,12 +1115,6 @@ int main(int argc, char** argv)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (!indexPath.empty()) {
|
||||
if (isRelativePath(indexPath)) {
|
||||
indexPath = computeAbsolutePath(indexPath, getCurrentDirectory());
|
||||
}
|
||||
library.getBookById(library.getBooksIds()[0]).setIndexPath(indexPath);
|
||||
}
|
||||
}
|
||||
|
||||
/* Instance the readers and searcher and build the corresponding maps */
|
||||
@@ -1087,7 +1125,6 @@ int main(int argc, char** argv)
|
||||
for (auto& bookId: booksIds) {
|
||||
auto& currentBook = library.getBookById(bookId);
|
||||
auto zimPath = currentBook.getPath();
|
||||
auto indexPath = currentBook.getIndexPath();
|
||||
|
||||
/* Instanciate the ZIM file handler */
|
||||
kiwix::Reader* reader = NULL;
|
||||
@@ -1099,6 +1136,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
auto humanReadableId = currentBook.getHumanReadableIdFromPath();
|
||||
hasHumanReadableIdCollision(humanReadableId, currentBook.getPath());
|
||||
readers[humanReadableId] = reader;
|
||||
|
||||
if (reader->hasFulltextIndex()) {
|
||||
@@ -1108,19 +1146,16 @@ int main(int argc, char** argv)
|
||||
searcher->add_reader(reader, humanReadableId);
|
||||
globalSearcher->add_reader(reader, humanReadableId);
|
||||
searchers[humanReadableId] = searcher;
|
||||
} else if ( !indexPath.empty() ) {
|
||||
try {
|
||||
kiwix::Searcher* searcher = new kiwix::Searcher(indexPath, reader, humanReadableId);
|
||||
searcher->setProtocolPrefix(rootLocation + "/");
|
||||
searcher->setSearchProtocolPrefix(rootLocation + "/" + "search?");
|
||||
searchers[humanReadableId] = searcher;
|
||||
} catch (...) {
|
||||
cerr << "Unable to open the search index '" << indexPath << "'."
|
||||
<< endl;
|
||||
searchers[humanReadableId] = nullptr;
|
||||
}
|
||||
} else {
|
||||
searchers[humanReadableId] = nullptr;
|
||||
searchers[humanReadableId] = nullptr;
|
||||
}
|
||||
|
||||
/* Deal with noDateAliases */
|
||||
if (noDateAliasesFlag) {
|
||||
string alias = replaceRegex(humanReadableId, "", "_[[:digit:]]{4}-[[:digit:]]{2}$");
|
||||
hasHumanReadableIdCollision(alias, currentBook.getPath());
|
||||
readers[alias] = readers[humanReadableId];
|
||||
searchers[alias] = searchers[humanReadableId];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1257,7 +1292,10 @@ int main(int argc, char** argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
daemon = MHD_start_daemon(MHD_USE_POLL_INTERNALLY,
|
||||
int flags = MHD_USE_POLL_INTERNALLY;
|
||||
if (isVerbose.load())
|
||||
flags |= MHD_USE_DEBUG;
|
||||
daemon = MHD_start_daemon(flags,
|
||||
serverPort,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -1272,7 +1310,15 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
} else {
|
||||
daemon = MHD_start_daemon(MHD_USE_POLL_INTERNALLY,
|
||||
#ifdef _WIN32
|
||||
int flags = MHD_USE_SELECT_INTERNALLY;
|
||||
#else
|
||||
int flags = MHD_USE_POLL_INTERNALLY;
|
||||
#endif
|
||||
if (isVerbose.load())
|
||||
flags |= MHD_USE_DEBUG;
|
||||
|
||||
daemon = MHD_start_daemon(flags,
|
||||
serverPort,
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
@@ -4,5 +4,4 @@ sources += server_resources
|
||||
|
||||
executable('kiwix-serve', sources,
|
||||
dependencies:all_deps,
|
||||
install:true,
|
||||
install_rpath: join_paths(get_option('prefix'), get_option('libdir')))
|
||||
install:true)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
background-size:16px 16px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 65.8em;
|
||||
max-width: 1100px;
|
||||
}
|
||||
.book__list { text-align: center; }
|
||||
.book {
|
||||
@@ -40,16 +40,16 @@
|
||||
}
|
||||
.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>
|
||||
|
||||
<div id="kiwixfooter">
|
||||
Powered by <a href="https://kiwix.org">Kiwix</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
float: left;
|
||||
}
|
||||
|
||||
#kiwixfooter {
|
||||
text-align: center;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.height_separator {
|
||||
height: 3em;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user