24 Commits
1.2.0 ... 2.0.0

Author SHA1 Message Date
Matthieu Gautier
a365c1e720 Merge pull request #297 from kiwix/new_version
New version 2.0.0
2019-05-29 12:00:23 +02:00
Matthieu Gautier
3e97352128 [CI] Build on xenial. 2019-05-29 11:52:03 +02:00
Matthieu Gautier
78d2530878 New version 2.0.0 2019-05-29 11:52:03 +02:00
Kelson
d09f481b47 Merge pull request #298 from kiwix/better_usage
Small updates of the README
2019-05-29 10:37:27 +02:00
Emmanuel Engelhart
e0f07086d5 Small updates of the README 2019-05-29 10:29:48 +02:00
Kelson
bbff57e6aa Merge pull request #290 from kiwix/add_footer
Add footer
2019-05-14 13:29:47 +02:00
Kelson
3c24d0a026 Add kiwix-serve welcome page footer 2019-05-04 14:09:26 +02:00
Kelson
6107bad17e Remove deprecated js code 2019-05-04 13:44:06 +02:00
Kelson
5931ac45c4 Merge pull request #289 from kiwix/fix_multiple_add
Correctly set the zimPathToSave if there are several zim file to add.
2019-05-03 12:50:19 +02:00
Matthieu Gautier
4de8623a52 Correctly set the zimPathToSave if there are several zim file to add.
The variable `zimPathToSave` is used to store the option passed by the
user.
If we reuse this variable to store the real path to use for the first
zim file, then we will mess the path to save of other zim files.

Let's use a local variable here.

Fix #288
2019-05-03 12:09:23 +02:00
Kelson
6eace310a2 Merge pull request #284 from kiwix/better_kiwix-serve_usage
Better kiwix-serve usage()
2019-05-03 11:49:58 +02:00
Kelson
c6499ad5c6 Fix typo in kiwix-manage usage() 2019-05-03 11:41:18 +02:00
Emmanuel Engelhart
34ceaf37f2 Better kiwix-serve usage() 2019-05-03 11:38:35 +02:00
Kelson
f05096e2ce Merge pull request #282 from kiwix/better_usage
Better kiwix-manage usage()
2019-05-03 11:31:48 +02:00
Emmanuel Engelhart
3864b2404c Better kiwix-manage usage() 2019-05-03 11:23:53 +02:00
Kelson
4cd74dca4b Merge pull request #283 from kiwix/remove_download_action
Remove kiwix-manage download action
2019-05-03 10:50:11 +02:00
Kelson
88cea54520 Revert "[kiwix-manage] Add a download command to kiwix-manage."
This reverts commit c1e635bd4e.
2019-05-03 10:42:14 +02:00
Matthieu Gautier
3061c8bba3 Merge pull request #281 from kiwix/thread_win
Do not use this_thread::sleep or thread::hardware_concurrency.
2019-04-17 17:57:03 +02:00
Matthieu Gautier
2774eb9529 Do not use this_thread::sleep or thread::hardware_concurrency.
Mingw doesn't implement them. So, we should not use it.
I suppose that it was working before because mingw package for debian trusty
simply no provides a "thread" header.
We may face to include the native "thread" header.
2019-04-17 15:48:33 +00:00
Kelson
77dc2ef2ed Merge pull request #280 from kiwix/3_columns_fix
Display cards in 3 columns properly
2019-04-17 16:44:18 +02:00
Emmanuel Engelhart
17d11f9772 Display cards in 3 columns properly 2019-04-17 09:12:23 +02:00
Matthieu Gautier
68ac06c397 Merge pull request #278 from kiwix/fix_server
Fix server
2019-04-16 14:37:58 +02:00
Matthieu Gautier
99f6941614 New version 1.2.1 2019-04-16 14:30:54 +02:00
Matthieu Gautier
848d058610 Always use POLL wen possible.
SELECT works only with fd < 1024. If we've got "too many" zim files,
the fd of the socket is > 1024 and we cannot create the daemon.

Also add the MHD_USE_DEBUG flag when we are verbose.

Fix #277
2019-04-16 14:29:06 +02:00
10 changed files with 141 additions and 120 deletions

View File

@@ -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

View File

@@ -1,3 +1,28 @@
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
=================

View File

@@ -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

View File

@@ -4,7 +4,7 @@ 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.1.0.tar.gz | tar -xz && \
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*

View File

@@ -1,5 +1,5 @@
project('kiwix-tools', 'cpp',
version : '1.2.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:'>=4.1.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)

View File

@@ -21,19 +21,14 @@
#include <unistd.h>
#endif
#include <getopt.h>
#include <kiwix/tools/pathTools.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, const std::string& bookId)
{
@@ -57,19 +52,47 @@ void show(kiwix::Library* library, const std::string& bookId)
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] "
"[--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[])
@@ -150,8 +173,8 @@ bool handle_add(kiwix::Library* library, const std::string& libraryPath,
for(auto i=optind; i<argc; i++) {
std::string zimPath = argv[i];
if (!zimPath.empty()) {
zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
manager.addBookFromPathAndGetId(zimPath, zimPathToSave, url, false);
auto _zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
manager.addBookFromPathAndGetId(zimPath, _zimPathToSave, url, false);
} else {
std::cerr << "Invalid zim file path" << std::endl;
resultCode = 1;
@@ -191,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 = "";
@@ -264,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 */
@@ -293,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);
}

View File

@@ -67,7 +67,6 @@ extern "C" {
#include <iostream>
#include <map>
#include <sstream>
#include <thread>
#include <string>
#include <vector>
#include "server-resources.h"
@@ -106,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) {
@@ -937,6 +937,42 @@ bool hasHumanReadableIdCollision(const string &humanReadableId,
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;
@@ -949,7 +985,6 @@ 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'},
@@ -1034,20 +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] [--nodatealiases] [--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] [--nodatealiases] [--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;
usage();
exit(1);
}
@@ -1270,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,
@@ -1285,7 +1310,15 @@ int main(int argc, char** argv)
#endif
} else {
daemon = MHD_start_daemon(MHD_USE_SELECT_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,

View File

@@ -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>

View File

@@ -11,6 +11,11 @@
float: left;
}
#kiwixfooter {
text-align: center;
margin-top: 1em;
}
.height_separator {
height: 3em;
}

View File

@@ -3,7 +3,7 @@
set -e
REPO_NAME=${TRAVIS_REPO_SLUG#*/}
ARCHIVE_NAME=deps_${TRAVIS_OS_NAME}_${PLATFORM}_${REPO_NAME}.tar.xz
ARCHIVE_NAME=deps_linux_xenial_${PLATFORM}_${REPO_NAME}.tar.xz
# Packages.
case ${PLATFORM} in
@@ -46,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