83 Commits
r0.1 ... 0.3.0

Author SHA1 Message Date
Matthieu Gautier
b1d2a1378b Merge pull request #90 from kiwix/new_release
Release of kiwix-tools 0.3.0.
2017-10-24 11:29:34 +02:00
Matthieu Gautier
df7d44128c Release of kiwix-tools 0.3.0. 2017-10-23 11:40:00 +02:00
Matthieu Gautier
ee5333bb91 Merge pull request #86 from kiwix/swiftugandan_root
Swiftugandan root
2017-10-17 16:21:04 +02:00
Philip Munaawa
871d8f4a51 disable caching for the welcome page 2017-10-17 15:46:55 +02:00
Philip Munaawa
9280d519f5 Adding support for relative url location 2017-10-17 15:46:11 +02:00
Matthieu Gautier
540fcd3be9 Merge pull request #84 from kiwix/byte_range
Byte range
2017-10-11 17:14:01 +02:00
Matthieu Gautier
ad7238b0c9 Stop refusing the first connection.
I don't know why we are refusing the first connection.

It seems to work without this.
Moreover, this is not thread safe and it would be pretty complex to
make it thread safe.
2017-10-11 17:00:55 +02:00
Matthieu Gautier
b5c91417ff Better debug information of each request. 2017-10-11 17:00:55 +02:00
Matthieu Gautier
b638df81fa Implement response to bytes range request.
Handle bytes range request http header.
Do not read the full buffer but try to stream it as far as possible.
2017-10-11 17:00:55 +02:00
Matthieu Gautier
58f0a716a6 Correctly return 404 if asked skin is not existing.
Fix #83
2017-10-10 17:02:15 +02:00
Matthieu Gautier
a2324b5e8b Use a structure RequestContext to pass all the context of a request.
This simplifies the code and avoid to pass a lot of arguments to
each function.
2017-10-10 16:59:45 +02:00
Matthieu Gautier
c2ac40d4f5 Merge pull request #82 from kiwix/multi_thread
Make kiwix-server multi-threaded.
2017-10-10 14:43:50 +02:00
Matthieu Gautier
4534b51f5e Use printf instead of cout.
`std::cout` stream is not thread safe at all.
Printing from different threads can lead to corrupted stream (and no
output working).

Using `printf` may still lead to interleaved output but nothing will broke.
2017-10-10 14:39:42 +02:00
Matthieu Gautier
0364951f75 Make kiwix-server multi-threaded. 2017-10-03 16:35:03 +02:00
Matthieu Gautier
a2627e81c4 Merge pull request #78 from kiwix/patch-1
Look for renamed kiwix-compile-resources script as well
2017-09-27 19:15:57 +02:00
Kunal Mehta
cd72a2d73c Look for renamed kiwix-compile-resources script as well
See https://github.com/kiwix/kiwix-lib/pull/76
2017-09-27 19:10:57 +02:00
Matthieu Gautier
fa3f33d3c7 Use sudo to install pip dependencies in travis 2017-09-27 19:03:11 +02:00
Matthieu Gautier
a210cb3a4b Merge pull request #68 from kiwix/css_taskbar
Css taskbar
2017-08-15 15:51:09 -04:00
Matthieu Gautier
63cb47247b Serve the taskbar css as separated file.
For firefox, the file encoding must be specified in the first 1024 bytes.
If it is not, firefox will reload the page when it founds it.

By inserting the taskbar's css directly in the html, we are "moving" down
the encoding of the page, and the encoding is not inside the first 1024
bytes.

This also improve a bit the performance as the browser can cache the css
file and it's avoid us to send the css in earch html file.
2017-08-15 15:15:26 -04:00
Matthieu Gautier
3220ee1276 Move <link> tag in <head> tag.
In html, the link tag should be in head tag, not in the body tag.
2017-08-15 15:08:56 -04:00
Matthieu Gautier
4a1b9cbfa9 Merge pull request #67 from kiwix/no_globalsearch_on_zim
Do not do globalSearch if the zim file has no full text index.
2017-08-15 14:54:35 -04:00
Matthieu Gautier
f2b5904221 Do not do globalSearch if the zim file has no full text index.
Global search is made only on the global task bar.
Task bar display in the article should provide full text search only
if the zim file has associated full text index.

This is done by having a `NULL` searcher. However, commit `558a0375`
return the globalSearcher if no searcher is associated to a zim.

This commit associate a `NULL` searcher to the zim, so we will not use
the globalSearcher.
2017-08-13 11:35:57 -04:00
Matthieu Gautier
f44722fbbc Merge pull request #64 from kiwix/fix_protocol
Correctly set ProtocolPrefix and SearchProtocolPrefix for searcher.
2017-08-11 00:44:28 -04:00
Matthieu Gautier
0cfcc59437 Update to new kiwix-lib API about Searcher instantiation.
`kiwix-lib` remove `setContentHumanReadableId` method in favour of
specifying directly it in the constructor.
2017-08-10 09:45:08 -04:00
Matthieu Gautier
7776eafbfc Correctly set ProtocolPrefix and SearchProtocolPrefix for searcher.
Default `protocolPrefix` for the kiwix-lib searcher is `zim:://`.
We have to change it to `/` for all searcher we create else the search's
results will have a `zim://...` url, which will obviously won't work.
2017-08-09 20:20:56 -04:00
Matthieu Gautier
5989146931 Merge pull request #49 from kiwix/globalSearch
Global search
2017-07-19 09:54:31 +02:00
Matthieu Gautier
ea088b21a4 Introduce a global taskbar on the welcomeHTML page to allow global search.
Global search is a search on all zims.
2017-07-17 18:24:27 +02:00
Matthieu Gautier
558a0375b0 Use a globalSearcher to do multi search on all zims. 2017-07-17 18:23:12 +02:00
Matthieu Gautier
5f0a05e8d8 Add a global_taskbar.html.part file to be use as taskbar in library home.
This is a simplified version of taskbar.html.part without the buttons
(specific to the current read zim)
2017-07-17 18:20:55 +02:00
Matthieu Gautier
4b9dc39c49 Use only one lock to acces zim library.
Search can now use reader. So there is no need to have to different locks.
2017-07-17 18:17:33 +02:00
Matthieu Gautier
08f2373360 Merge pull request #48 from kiwix/no_use_of_tree_h
Remove use of tree.h
2017-07-12 14:45:38 +02:00
Matthieu Gautier
82fb6bc4d0 Remove use of tree.h
All code using tree.h where commented.
As tree.h where install by kiwix-lib and we removed it there, let's remove
its use here.
2017-07-12 10:28:40 +02:00
Matthieu Gautier
17eceeff5b Merge pull request #46 from kiwix/format_code
Format code
2017-07-12 10:06:46 +02:00
Matthieu Gautier
aef20d6c96 Move to C++11.
Code and kiwix-lib are C++11. So compile using C++11.
2017-07-12 10:01:25 +02:00
Matthieu Gautier
4e3ff03059 Format all the code using clang-format.
Add a script `format_code.sh` to easily format the code.
2017-07-05 15:52:32 +02:00
Matthieu Gautier
856bfc675a Bump-up the version to 0.2.
Time to make a new release.
2017-06-27 15:22:33 +02:00
Kelson
7850e79eab Merge pull request #44 from kiwix/custom_welcome_css
custom welcome page css
2017-06-08 13:21:01 +02:00
Emmanuel Engelhart
62769aed57 custom welcome page css 2017-06-08 13:12:31 +02:00
Kelson
29e281209d Merge pull request #43 from Skylsmoi/335/rewrite_welcome_page
rewrite welcome page (fixed histo)
2017-06-08 12:47:55 +02:00
Skylsmoi
0f480d9fb8 fixed boxes size with ellipsis + moved style tag to template + reduced margin/padding 2017-06-08 09:55:11 +02:00
Skylsmoi
1aeeaa2c3b rewrite welcome page 2017-06-07 11:48:21 +02:00
Matthieu Gautier
2fe1a9443c Merge pull request #39 from kiwix/t38
Add --nolibrarybutton option refs #38
2017-06-06 14:40:07 +02:00
Emmanuel Engelhart
569b4d946e Add --nolibrarybutton option 2017-06-04 18:49:55 +02:00
Matthieu Gautier
e51539d161 Merge pull request #36 from kiwix/new_api
Adapt to new kiwix-lib search API.
2017-05-28 23:15:27 +02:00
Matthieu Gautier
f12a731939 Adapt to new kiwix-lib search API. 2017-05-28 23:11:02 +02:00
Matthieu Gautier
d94423964e Merge pull request #34 from kiwix/full_html_document
ZIM/libzim/libkiwix should provide full HTML DOM
2017-05-22 16:00:51 +02:00
Emmanuel Engelhart
af10b665a9 ZIM/libzim/libkiwix should provide full HTML DOM 2017-05-19 20:37:21 +02:00
Kelson
c2d29376d9 Merge pull request #32 from Skylsmoi/336/fix_display_taskbar_save
336/fix display taskbar save
2017-05-16 14:11:28 +02:00
Skylsmoi
fd9c63c76a Merge branch '336/fix_display_taskbar_save' of github.com:Skylsmoi/kiwix-tools into 336/fix_display_taskbar_save 2017-05-16 11:16:26 +02:00
Skylsmoi
4cc46685f7 fix breakpoint for cybook 2017-05-16 11:16:04 +02:00
Kelson
e30da0c0cd Merge pull request #29 from Skylsmoi/336/fix_display_taskbar_save
css rules for taskbar are now more strict
2017-05-07 10:06:27 +02:00
Kelson
70a652e020 Merge branch 'master' into 336/fix_display_taskbar_save 2017-05-06 21:08:38 +02:00
Skylsmoi
97f0c8ec5b added important rules to set the taskbar design 2017-05-02 16:20:59 +02:00
Matthieu Gautier
da83027710 Merge pull request #26 from kiwix/no_ssh_key
Get dependencies from http server, not from ssh.
2017-04-24 17:20:37 +02:00
Matthieu Gautier
ef9b48682b Get dependencies from http server, not from ssh.
`kiwix-build` now publish intermediate dependencies archives in a
http accessible location.

Let's use this location instead of `scp` the archives.
2017-04-24 17:13:42 +02:00
Kelson
e26244687d Merge pull request #24 from Skylsmoi/336/fix_display_taskbar_save
336/fix display taskbar save
2017-04-23 15:43:22 +02:00
Skylsmoi
2634167f41 fix taskbar design for iOS 2017-04-21 15:00:57 +02:00
Skylsmoi
7edc49c4eb Merge branch 'master' of github.com:kiwix/kiwix-tools into 336/fix_display_taskbar_save 2017-04-20 17:37:03 +02:00
Skylsmoi
36225207c0 force custom design to override rules from libraries 2017-04-20 17:35:12 +02:00
Emmanuel Engelhart
1d61e270fb Add CTPP2 link in README 2017-04-16 20:37:01 +02:00
Kelson
5aecb4231d Merge pull request #20 from Skylsmoi/336/fix_display_taskbar
#336 taskbar is now responsive
2017-04-16 11:06:47 +02:00
Skylsmoi
126781bbb5 removed calc() 2017-04-13 11:52:27 +02:00
Skylsmoi
f045590243 #336 taskbar is now responsive 2017-04-13 11:52:27 +02:00
Matthieu Gautier
f46e560d7f Merge pull request #22 from kiwix/search_in_libzim
Search in libzim
2017-04-11 14:02:21 +02:00
Matthieu Gautier
643293c7df Try to link with uuid only if xapian is present. 2017-04-10 14:47:19 +02:00
Matthieu Gautier
799a47142b Adapt kiwix-tools to last kiwix-lib API (Xapian in zimlib). 2017-04-10 14:47:19 +02:00
Matthieu Gautier
79fdee1df2 Merge pull request #23 from kiwix/travisci
Travisci
2017-04-10 14:46:22 +02:00
Matthieu Gautier
ab623b7176 Add TravisCI.
Now the project is build on every PR using TravisCI.

The project dependencies are get from the archive generated by kiwix-build.
2017-04-10 14:42:41 +02:00
Matthieu Gautier
208050df4b Merge pull request #21 from kiwix/no_indexer
Remove indexer and indexing functionality from installer.
2017-04-06 15:39:07 +02:00
Matthieu Gautier
9ead431b3f Remove indexer and indexing functionality from installer.
This is handled by zimwriterfs now (and zimlib itself later on).
2017-04-06 15:37:39 +02:00
Julian Harty
1e6353330d Please discount (ignore) my last commit, it was intended for the kiwix-apache repo. 2017-04-06 00:05:08 +01:00
Julian Harty
482577fd53 You're welcome... and here's the starting point to encourage you to get involved. 2017-04-06 00:02:27 +01:00
Matthieu Gautier
856b487007 Merge pull request #18 from kiwix/snippets
Update to the new API of kiwix-lib.
2017-03-28 11:37:58 +02:00
Matthieu Gautier
cb20e719ee Update to the new API of kiwix-lib. 2017-03-21 16:33:57 +01:00
Matthieu Gautier
25091c320b Merge pull request #16 from kiwix/kiwix-serve.bugfix
Kiwix serve.bugfix
2017-03-20 11:05:21 +01:00
Matthieu Gautier
35b83144c6 Do not compress only if the content is small.
We do not need the test "contentLength < COMPRESSOR_BUFFER_SIZE" to know
if we compress the content or not.

This is a non sens, we WANT to compress the content if it is big.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
063e9ba80d Use compressBound function to reserve the right amount of space.
compressBound function give the upper bound of space needed to
reserve to the compression buffer. Use it instead of using a define.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
e27ce444c6 Correctly check that compress gone well before using the result buffer.
We need to check the return code of compress.
Compress may fail for different reason, one being that the compr_buffer
is not large enough.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
3592cd84c6 Do not modify the compr buffer pointer.
The compr pointer points to the allocated memory. We must not modify
it value.
If we advance the pointer by two bytes each time we compress an answer
we will end to write in some random memory and segfault.

Now, we use a std::vector to correctly handle allocation
(and deallocation!) of the memory.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
a27010c247 Correctly change the compression buffer we send.
For ie browser, we need to remove the two first bytes.
If we make our buffer start two bytes after, we also need to reduce the
size of the buffer by two bytes. Else we will read and send two extra
junk bytes.

Fix #15
2017-03-20 10:08:14 +01:00
Matthieu Gautier
0c01ec5bb5 Cleanup a bit kiwix-serve.cpp
- Remove spaces at end of lines
- Remove unused variables.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
a3a0127edb Do not try to discover ctpp2 ourselves.
Kiwixlib now exports ctpp2 link/cflags in its pkg-config file.
So we don't have to check to ctpp2 here.
2017-02-22 12:10:47 +01:00
Matthieu Gautier
ad7d30cc4f Do not link with iconv when cross-compilating to windows.
Ideally we should check if iconv is present to know if ctpp2 has been
build with iconv.
This may be a bit too complex for our present case. As we know our
cross-compilation environment. It is better to remove the use of iconv
everywhere for now.
2017-02-07 12:25:43 +01:00
24 changed files with 1255 additions and 1034 deletions

12
.clang-format Normal file
View File

@@ -0,0 +1,12 @@
BasedOnStyle: Google
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Linux
DerivePointerAlignment: false
SpacesInContainerLiterals: false
Standard: Cpp11
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false

11
.travis.yml Normal file
View File

@@ -0,0 +1,11 @@
language: cpp
dist: trusty
sudo: required
cache: ccache
install: travis/install_deps.sh
script: travis/compile.sh
env:
- PLATFORM="native_static"
- PLATFORM="native_dyn"
- PLATFORM="win32_static"
- PLATFORM="win32_dyn"

43
Changelog Normal file
View File

@@ -0,0 +1,43 @@
kiwix-tools 0.3.0
=================
* Move to C++11
kiwix-serve
-----------
* Add a global taskbar in the welcome page to search in all zims (#49)
* Serve the taskbar as css file instead of including it in the html (#68):
* Better client caching
* The html encoding is now in the first 1024 bytes and firefox correctly
detect the encoding
* Make kiwix-server multi-threaded (#82)
* Correctly return 404 instead of crashing when request inexistant skin file
(#83)
* Correctly respond to bytes-range requests.(#84)
* Directly respond to first request for a url instead of refusing the first
connexion
* Add support to relative url location. (#86)
* Remove caching (on client side) for the welcome page. (#86)
kiwix-tools 0.2.0
=================
* Remove indexer tools
kiwix-serve
-----------
* Correctly fix the deflate data we send over http. (#15)
* Update in the taskbar (or topbar):
* Taskbar is responsive (github.com/kiwix/kiwix/issues/336)
* Force css rules for the taskbar (and not be impacted by content's css)
* Add `--nolibrarybutton` to hide the library button from the taskbar.
* Rewrite of the welcome page.
kiwix-installer
---------------
* Remove indexing functionnality

View File

@@ -30,6 +30,7 @@ libraries need to be available:
(no package for now)
* 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)

15
format_code.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/bash
files=(
"src/installer/kiwix-install.cpp"
"src/searcher/kiwix-search.cpp"
"src/reader/kiwix-read.cpp"
"src/manager/kiwix-manage.cpp"
"src/server/kiwix-serve.cpp"
)
for i in "${files[@]}"
do
echo $i
clang-format -i -style=file $i
done

View File

@@ -1,4 +1,7 @@
project('kiwix-tools', 'cpp')
project('kiwix-tools', 'cpp',
version : '0.3.0',
license : 'GPL',
default_options: ['c_std=c11', 'cpp_std=c++11'])
compiler = meson.get_compiler('cpp')
@@ -8,53 +11,10 @@ if static_linkage
endif
thread_dep = dependency('threads')
kiwixlib_dep = dependency('kiwix', static:static_linkage)
kiwixlib_dep = dependency('kiwix', version:'>=1.0.0', static:static_linkage)
microhttpd_dep = dependency('libmicrohttpd', static:static_linkage)
z_dep = dependency('zlib', static:static_linkage)
# Idealy we should not have more dependency, however :
# We should declare we use ctpp2 in kiwixlib in the pkg-config file.
# But there is no pkg-config file for ctpp2. Once one exists, no need to
# declare the dependency here
ctpp2_prefix_install = get_option('ctpp2-install-prefix')
find_library_in_compiler = meson.version().version_compare('>=0.31.0')
if ctpp2_prefix_install == ''
if not compiler.has_header('ctpp2/CTPP2Logger.hpp')
error('ctpp2/CTPP2Logger.hppnot found')
endif
if find_library_in_compiler
ctpp2_lib = compiler.find_library('ctpp2')
else
ctpp2_lib = find_library('ctpp2')
endif
link_args = ['-lctpp2']
if meson.is_cross_build()
if host_machine.system() == 'windows'
link_args += ['-liconv']
endif
endif
ctpp2_dep = declare_dependency(link_args:link_args)
else
if not find_library_in_compiler
error('For custom ctpp2_prefix_install you need a meson version >=0.31.0')
endif
ctpp2_include_path = ctpp2_prefix_install + '/include'
ctpp2_include_args = ['-I'+ctpp2_include_path]
if not compiler.has_header('ctpp2/CTPP2Logger.hpp', args:ctpp2_include_args)
error('ctpp2/CTPP2Logger.hpp not found')
endif
ctpp2_include_path = include_directories(ctpp2_include_path, is_system:true)
ctpp2_lib_path = ctpp2_prefix_install+'/lib'
ctpp2_lib = compiler.find_library('ctpp2', dirs:ctpp2_lib_path)
link_args = ['-L'+ctpp2_lib_path, '-lctpp2']
if meson.is_cross_build()
if host_machine.system() == 'windows'
link_args += ['-liconv']
endif
endif
ctpp2_dep = declare_dependency(include_directories:ctpp2_include_path, link_args:link_args)
endif
# This is a temporary workaround until xapian fix it's xapian-core.pc
# For a correct dependency checking we should test if uuid is really installed
# but for a workaround, we assume that in xapian is installed, uuid also.
@@ -62,10 +22,15 @@ if meson.is_cross_build() and host_machine.system() == 'windows'
# xapian doesn't use uuid on windows.
uuid_dep = declare_dependency()
else
uuid_dep = declare_dependency(link_args:['-luuid', '-lrt'])
xapian_dep = dependency('xapian-core', required : false)
if xapian_dep.found()
uuid_dep = declare_dependency(link_args:['-luuid', '-lrt'])
else
uuid_dep = declare_dependency()
endif
endif
all_deps = [thread_dep, kiwixlib_dep, microhttpd_dep, ctpp2_dep, z_dep, uuid_dep]
all_deps = [thread_dep, kiwixlib_dep, microhttpd_dep, z_dep, uuid_dep]
#subdir('include')
subdir('static')

View File

@@ -1,4 +1,2 @@
option('static-linkage', type : 'boolean', value : false,
description : 'Create statically linked binaries.')
option('ctpp2-install-prefix', type : 'string', value : '',
description : 'Prefix where ctpp libs has been installed')

View File

@@ -1,107 +0,0 @@
/*
* Copyright 2009-2013 Emmanuel Engelhart <kelson@kiwix.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include <kiwix/xapianIndexer.h>
#include <getopt.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
void usage() {
cout << "Usage: kiwix-index [--verbose] ZIM_PATH INDEX_PATH" << endl;
exit(1);
}
int main(int argc, char **argv) {
/* Init the variables */
char *zimFilePath = NULL;
char *indexPath = NULL;
bool verboseFlag = false;
int option_index = 0;
int c = 0;
kiwix::XapianIndexer *indexer = NULL;
/* Argument parsing */
while (42) {
static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
if (c != -1) {
c = getopt_long(argc, argv, "v", long_options, &option_index);
switch (c) {
case 'v':
verboseFlag = true;
break;
}
} else {
if (optind < argc) {
if (zimFilePath == NULL) {
zimFilePath = argv[optind++];
} else if (indexPath == NULL) {
indexPath = argv[optind++];
} else {
usage();
}
} else {
break;
}
}
}
/* Check if we have enough arguments */
if (zimFilePath == NULL || indexPath == NULL) {
usage();
}
/* Try to prepare the indexing */
try {
indexer = new kiwix::XapianIndexer();
} catch (...) {
cerr << "Unable to index '" << zimFilePath << "'." << endl;
exit(1);
}
/* Start the indexing */
if (indexer != NULL) {
indexer->setVerboseFlag(verboseFlag);
indexer->start(zimFilePath, indexPath);
while (indexer->isRunning()) {
if (verboseFlag)
cout << indexer->getProgression() << "% of all the articles indexed..." << endl;
kiwix::sleep(1000);
}
if (verboseFlag)
cout << "100% of the articles were successfuly indexed..." << endl;
delete indexer;
} else {
cerr << "Unable instanciate the Kiwix indexer." << endl;
exit(1);
}
exit(0);
}

View File

@@ -1,3 +0,0 @@
executable('kiwix-index', ['kiwix-index.cpp'],
dependencies:all_deps,
install:true)

View File

@@ -19,64 +19,57 @@
#include <getopt.h>
#include <kiwix/common/pathTools.h>
#include <kiwix/xapianIndexer.h>
#include <kiwix/reader.h>
#include <kiwix/manager.h>
#include <kiwix/reader.h>
enum supportedAction { NONE, ADDCONTENT };
void usage() {
cout << "Usage: kiwix-install [--verbose] [--buildIndex] addcontent ZIM_PATH KIWIX_PATH" << endl;
exit(1);
void usage()
{
cout << "Usage: kiwix-install [--verbose] addcontent ZIM_PATH KIWIX_PATH"
<< endl;
exit(1);
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
/* Init the variables */
const char *contentPath = NULL;
const char *kiwixPath = NULL;
const char* contentPath = NULL;
const char* kiwixPath = NULL;
supportedAction action = NONE;
bool verboseFlag = false;
bool buildIndexFlag = false;
int option_index = 0;
int c = 0;
/* Argument parsing */
while (42) {
static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'},
{"buildIndex", no_argument, 0, 'i'},
{0, 0, 0, 0}
};
static struct option long_options[]
= {{"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0}};
if (c != -1) {
c = getopt_long(argc, argv, "vi", long_options, &option_index);
switch (c) {
case 'v':
verboseFlag = true;
break;
case 'i':
buildIndexFlag = true;
break;
case 'v':
verboseFlag = true;
break;
}
} else {
if (optind < argc) {
if (action == NONE) {
string actionString = argv[optind++];
if (actionString == "addcontent" || actionString == "ADDCONTENT") {
action = ADDCONTENT;
}
} else if (contentPath == NULL) {
contentPath = argv[optind++];
} else if (kiwixPath == NULL) {
kiwixPath = argv[optind++];
} else {
usage();
}
if (action == NONE) {
string actionString = argv[optind++];
if (actionString == "addcontent" || actionString == "ADDCONTENT") {
action = ADDCONTENT;
}
} else if (contentPath == NULL) {
contentPath = argv[optind++];
} else if (kiwixPath == NULL) {
kiwixPath = argv[optind++];
} else {
usage();
}
} else {
break;
break;
}
}
}
@@ -88,38 +81,48 @@ int main(int argc, char **argv) {
/* Make the action */
if (action == ADDCONTENT) {
/* Check if the content path exists and is readable */
if (verboseFlag) { std::cout << "Check if the ZIM file exists..." << std::endl; }
if (verboseFlag) {
std::cout << "Check if the ZIM file exists..." << std::endl;
}
if (!fileExists(contentPath)) {
cerr << "The content path '" << contentPath << "' does not exist or is not readable." << endl;
cerr << "The content path '" << contentPath
<< "' does not exist or is not readable." << endl;
exit(1);
}
/* Check if this is a ZIM file */
try {
if (verboseFlag) { std::cout << "Check if the ZIM file is valid..." << std::endl; }
kiwix::Reader *reader = new kiwix::Reader(contentPath);
if (verboseFlag) {
std::cout << "Check if the ZIM file is valid..." << std::endl;
}
kiwix::Reader* reader = new kiwix::Reader(contentPath);
delete reader;
} catch (exception &e) {
cerr << "The content available at '" << contentPath << "' is not a ZIM file." << endl;
} catch (exception& e) {
cerr << "The content available at '" << contentPath
<< "' is not a ZIM file." << endl;
exit(1);
}
string contentFilename = getLastPathElement(contentPath);
/* Check if kiwixPath/kiwix/kiwix.exe exists */
if (verboseFlag) { std::cout << "Check if the Kiwix path is valid..." << std::endl; }
if (verboseFlag) {
std::cout << "Check if the Kiwix path is valid..." << std::endl;
}
string kiwixBinaryPath = computeAbsolutePath(kiwixPath, "kiwix/kiwix.exe");
if (!fileExists(kiwixBinaryPath)) {
kiwixBinaryPath = computeAbsolutePath(kiwixPath, "kiwix/kiwix");
if (!fileExists(kiwixBinaryPath)) {
cerr << "Unable to find the Kiwix binary at '" << kiwixBinaryPath << "[.exe]'." << endl;
exit(1);
cerr << "Unable to find the Kiwix binary at '" << kiwixBinaryPath
<< "[.exe]'." << endl;
exit(1);
}
}
/* Check if the directory "data" structure exists */
if (verboseFlag) { std::cout << "Check the target data directory structure..." << std::endl; }
if (verboseFlag) {
std::cout << "Check the target data directory structure..." << std::endl;
}
string dataPath = computeAbsolutePath(kiwixPath, "data/");
if (!fileExists(dataPath)) {
makeDirectory(dataPath);
@@ -137,59 +140,32 @@ int main(int argc, char **argv) {
makeDirectory(dataLibraryPath);
}
/* Check if the directory "data/index" structure exists */
string dataIndexPath = computeAbsolutePath(kiwixPath, "data/index/");
if (!fileExists(dataIndexPath)) {
makeDirectory(dataIndexPath);
}
/* Copy the file to the data/content directory */
if (verboseFlag) { std::cout << "Copy ZIM file to the target directory..." << std::endl; }
string newContentPath = computeAbsolutePath(dataContentPath, contentFilename);
if (!fileExists(newContentPath) || getFileSize(contentPath) != getFileSize(newContentPath)) {
if (verboseFlag) {
std::cout << "Copy ZIM file to the target directory..." << std::endl;
}
string newContentPath
= computeAbsolutePath(dataContentPath, contentFilename);
if (!fileExists(newContentPath)
|| getFileSize(contentPath) != getFileSize(newContentPath)) {
copyFile(contentPath, newContentPath);
}
/* Index the file if necessary */
if (verboseFlag) { std::cout << "Check if the index directory exists..." << std::endl; }
string indexFilename = contentFilename + ".idx";
string indexPath = computeAbsolutePath(dataIndexPath, indexFilename);
if (buildIndexFlag && !fileExists(indexPath)) {
if (verboseFlag) { std::cout << "Start indexing the ZIM file..." << std::endl; }
kiwix::XapianIndexer *indexer = NULL;
try {
indexer = new kiwix::XapianIndexer();
} catch (...) {
cerr << "Unable to index '" << contentPath << "'." << endl;
exit(1);
}
if (indexer != NULL) {
indexer->setVerboseFlag(verboseFlag);
indexer->start(contentPath, indexPath);
while (indexer->isRunning()) {
kiwix::sleep(1000);
}
delete indexer;
} else {
cerr << "Unable instanciate the Kiwix indexer." << endl;
exit(1);
}
}
/* Add the file to the library.xml */
if (verboseFlag) { std::cout << "Create the library XML file..." << std::endl; }
if (verboseFlag) {
std::cout << "Create the library XML file..." << std::endl;
}
kiwix::Manager libraryManager;
string libraryPath = computeAbsolutePath(dataLibraryPath, contentFilename + ".xml");
string bookId = libraryManager.addBookFromPathAndGetId(newContentPath, "../content/" + contentFilename, "", false);
string libraryPath
= computeAbsolutePath(dataLibraryPath, contentFilename + ".xml");
string bookId = libraryManager.addBookFromPathAndGetId(
newContentPath, "../content/" + contentFilename, "", false);
if (!bookId.empty()) {
libraryManager.setCurrentBookId(bookId);
if (buildIndexFlag) {
libraryManager.setBookIndex(bookId, "../index/" + indexFilename, kiwix::XAPIAN);
}
libraryManager.writeFile(libraryPath);
} else {
cerr << "Unable to build or save library file '" << libraryPath << "'" << endl;
cerr << "Unable to build or save library file '" << libraryPath << "'"
<< endl;
}
}

View File

@@ -21,47 +21,54 @@
#include <unistd.h>
#endif
#include <getopt.h>
#include <iostream>
#include <cstdlib>
#include <kiwix/common/pathTools.h>
#include <kiwix/manager.h>
#include <cstdlib>
#include <iostream>
using namespace std;
enum supportedAction { NONE, ADD, SHOW, REMOVE };
void show(kiwix::Library library) {
std::vector<kiwix::Book>::iterator itr;
unsigned int inc = 1;
for ( itr = library.books.begin(); itr != library.books.end(); ++itr ) {
std::cout << "#" << inc++
<< std::endl << "id:\t\t" << itr->id
<< std::endl << "path:\t\t" << itr->path
<< std::endl << "indexpath:\t" << itr->indexPath
<< std::endl << "url:\t\t" << itr->url
<< std::endl << "title:\t\t" << itr->title
<< std::endl << "name:\t\t" << itr->name
<< std::endl << "tags:\t\t" << itr->tags
<< std::endl << "description:\t" << itr->description
<< std::endl << "creator:\t" << itr->creator
<< std::endl << "date:\t\t" << itr->date
<< std::endl << "articleCount:\t" << itr->articleCount
<< std::endl << "mediaCount:\t" << itr->mediaCount
<< std::endl << "size:\t\t" << itr->size << " KB"
<< std::endl << std::endl;
}
void show(kiwix::Library library)
{
std::vector<kiwix::Book>::iterator itr;
unsigned int inc = 1;
for (itr = library.books.begin(); itr != library.books.end(); ++itr) {
std::cout << "#" << inc++ << std::endl
<< "id:\t\t" << itr->id << std::endl
<< "path:\t\t" << itr->path << std::endl
<< "indexpath:\t" << itr->indexPath << std::endl
<< "url:\t\t" << itr->url << std::endl
<< "title:\t\t" << itr->title << std::endl
<< "name:\t\t" << itr->name << std::endl
<< "tags:\t\t" << itr->tags << std::endl
<< "description:\t" << itr->description << std::endl
<< "creator:\t" << itr->creator << std::endl
<< "date:\t\t" << itr->date << std::endl
<< "articleCount:\t" << itr->articleCount << std::endl
<< "mediaCount:\t" << itr->mediaCount << std::endl
<< "size:\t\t" << itr->size << " KB" << std::endl
<< std::endl;
}
}
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;
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;
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
string libraryPath = "";
supportedAction action = NONE;
string zimPath = "";
@@ -89,9 +96,9 @@ int main(int argc, char **argv) {
}
/* Try to read the file */
libraryPath = isRelativePath(libraryPath) ?
computeAbsolutePath(getCurrentDirectory(), libraryPath) :
libraryPath;
libraryPath = isRelativePath(libraryPath)
? computeAbsolutePath(getCurrentDirectory(), libraryPath)
: libraryPath;
libraryManager.readFile(libraryPath, false);
/* SHOW */
@@ -103,81 +110,78 @@ int main(int argc, char **argv) {
string indexPath;
kiwix::supportedIndexType indexBackend = kiwix::XAPIAN;
string url;
string origID="";
string origID = "";
bool setCurrent = false;
if (argc>3) {
if (argc > 3) {
zimPath = argv[3];
}
/* 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'},
{"indexBackend", required_argument, 0, 'b'},
{"zimPathToSave", required_argument, 0, 'z'},
{"current", no_argument, 0, 'c'},
{0, 0, 0, 0}};
static struct option long_options[] = {
{"url", required_argument, 0, 'u'},
{"origId", required_argument, 0, 'o'},
{"indexPath", required_argument, 0, 'i'},
{"indexBackend", required_argument, 0, 'b'},
{"zimPathToSave", required_argument, 0, 'z'},
{"current", no_argument, 0, 'c'},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv, "cz:u:i:b:", long_options, &option_index);
if (c != -1) {
switch (c) {
case 'u':
url = optarg;
break;
switch (c) {
case 'u':
url = optarg;
break;
case 'o':
origID = optarg;
break;
case 'o':
origID = optarg;
break;
case 'c':
setCurrent = true;
break;
case 'c':
setCurrent = true;
break;
case 'i':
indexPath = optarg;
break;
case 'i':
indexPath = optarg;
break;
case 'b':
if (!strcmp(optarg, "xapian")) {
indexBackend = kiwix::XAPIAN;
} else {
usage();
}
break;
case 'b':
if (!strcmp(optarg, "xapian")) {
indexBackend = kiwix::XAPIAN;
} else {
usage();
}
break;
case 'z':
zimPathToSave = optarg;
break;
}
case 'z':
zimPathToSave = optarg;
break;
}
} else {
break;
break;
}
}
if (!zimPath.empty()) {
zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
string bookId = libraryManager.addBookFromPathAndGetId(zimPath, zimPathToSave, url, false);
string bookId = libraryManager.addBookFromPathAndGetId(
zimPath, zimPathToSave, url, false);
if (!bookId.empty()) {
if (setCurrent)
libraryManager.setCurrentBookId(bookId);
if (setCurrent)
libraryManager.setCurrentBookId(bookId);
/* Save the index infos if necessary */
if (!indexPath.empty())
libraryManager.setBookIndex(bookId, indexPath, indexBackend);
/* Save the index infos if necessary */
if (!indexPath.empty())
libraryManager.setBookIndex(bookId, indexPath, indexBackend);
} else {
cerr << "Unable to build or save library file '" << libraryPath << "'" << endl;
cerr << "Unable to build or save library file '" << libraryPath << "'"
<< endl;
}
} else {
std::cerr << "Invalid zim file path" << std::endl;
@@ -187,7 +191,7 @@ int main(int argc, char **argv) {
unsigned int bookIndex = 0;
const unsigned int totalBookCount = libraryManager.getBookCount(true, true);
if (argc>3) {
if (argc > 3) {
bookIndex = atoi(argv[3]);
}
@@ -195,9 +199,13 @@ int main(int argc, char **argv) {
libraryManager.removeBookByIndex(bookIndex - 1);
} else {
if (totalBookCount > 0) {
std::cerr << "Invalid book index number. Please give a number between 1 and " << totalBookCount << std::endl;
std::cerr
<< "Invalid book index number. Please give a number between 1 and "
<< totalBookCount << std::endl;
} else {
std::cerr << "Invalid book index number. Library is empty, no book to delete." << std::endl;
std::cerr
<< "Invalid book index number. Library is empty, no book to delete."
<< std::endl;
}
}
}

View File

@@ -1,6 +1,4 @@
subdir('indexer')
subdir('installer')
subdir('manager')
subdir('reader')

View File

@@ -18,59 +18,53 @@
*/
#include <getopt.h>
#include <unistd.h>
#include <string>
#include <map>
#include <kiwix/common/tree.h>
#include <kiwix/reader.h>
#include <unistd.h>
#include <map>
#include <string>
void usage() {
cout << "Usage: kiwix-read --suggest=<PATTERN> ZIM_FILE_PATH" << endl;
exit(1);
void usage()
{
cout << "Usage: kiwix-read --suggest=<PATTERN> ZIM_FILE_PATH" << endl;
exit(1);
}
void updateSuggestionTree(tree< pair<string, unsigned> > &suggestionTree, string suggestion) {
return;
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
/* Init the variables */
const char *filePath = NULL;
const char *pattern = NULL;
const char* filePath = NULL;
const char* pattern = NULL;
int option_index = 0;
int c = 0;
kiwix::Reader *reader = NULL;
kiwix::Reader* reader = NULL;
/* Argument parsing */
while (42) {
static struct option long_options[]
= {{"verbose", no_argument, 0, 'v'},
{"suggest", required_argument, 0, 's'},
{0, 0, 0, 0}};
static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'},
{"suggest", required_argument, 0, 's'},
{0, 0, 0, 0}
};
if (c != -1) {
c = getopt_long(argc, argv, "vs:", long_options, &option_index);
switch (c) {
case 'v':
break;
case 's':
pattern = optarg;
break;
case 'v':
break;
case 's':
pattern = optarg;
break;
}
} else {
if (optind < argc) {
if (filePath == NULL) {
filePath = argv[optind++];
} else {
usage();
}
if (filePath == NULL) {
filePath = argv[optind++];
} else {
usage();
}
} else {
break;
break;
}
}
}
@@ -90,25 +84,23 @@ int main(int argc, char **argv) {
string contentType;
unsigned int contentLength = 0;
string suggestion;
if (pattern != NULL) {
std::cout << "Searching suggestions for: " << pattern << std::endl;
reader->searchSuggestionsSmart(pattern, 10);
while (reader->getNextSuggestion(suggestion)) {
std::cout << suggestion << std::endl;
std::cout << suggestion << std::endl;
}
}
/*
if (reader->getContentByUrl(mainPageUrl, content, contentLength, contentType)) {
if (reader->getContentByUrl(mainPageUrl, content, contentLength,
contentType)) {
cout << content << endl;
}
*/
// tree< pair<string, unsigned> > tree;
//updateSuggestionTree(tree, string(suggestion));
delete reader;
} else {
cerr << "Unable instanciate the Kiwix reader." << endl;

View File

@@ -18,95 +18,97 @@
*/
#include <getopt.h>
#include <kiwix/reader.h>
#include <kiwix/searcher.h>
#include <unistd.h>
#include <kiwix/xapianSearcher.h>
enum supportedBackend { XAPIAN };
void usage() {
cout << "Usage: kiwix-search [--verbose|-v] [--backend|-b=xapian] INDEX_PATH SEARCH" << endl;
exit(1);
void usage()
{
cout << "Usage: kiwix-search [--verbose|-v] ZIM_PATH SEARCH" << endl;
exit(1);
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
/* Init the variables */
//const char *indexPath = "/home/itamar/.www.kiwix.org/kiwix/43k0i1j4.default/6d2e587b-d586-dc6a-dc6a-e4ef035a1495d15c.index";
//const char *indexPath = "/home/itamar/testindex";
const char *indexPath = NULL;
const char *search = NULL;
// const char *indexPath =
// "/home/itamar/.www.kiwix.org/kiwix/43k0i1j4.default/6d2e587b-d586-dc6a-dc6a-e4ef035a1495d15c.index";
// const char *indexPath = "/home/itamar/testindex";
const char* zimPath = NULL;
const char* search = NULL;
bool verboseFlag = false;
int option_index = 0;
int c = 0;
supportedBackend backend = XAPIAN;
kiwix::Searcher *searcher = NULL;
kiwix::Searcher* searcher = NULL;
kiwix::Reader* reader = NULL;
/* Argument parsing */
while (42) {
static struct option long_options[] = {
{"verbose", no_argument, 0, 'v'},
{"backend", required_argument, 0, 'b'},
{0, 0, 0, 0}
};
static struct option long_options[]
= {{"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0}};
if (c != -1) {
c = getopt_long(argc, argv, "vb:", long_options, &option_index);
switch (c) {
case 'v':
verboseFlag = true;
break;
case 'b':
if (!strcmp(optarg, "xapian")) {
backend = XAPIAN;
} else {
usage();
}
break;
case 'v':
verboseFlag = true;
break;
}
} else {
if (optind < argc) {
if (indexPath == NULL) {
indexPath = argv[optind++];
} else if (search == NULL) {
search = argv[optind++];
} else {
cout << indexPath << endl;
usage();
}
if (zimPath == NULL) {
zimPath = argv[optind++];
} else if (search == NULL) {
search = argv[optind++];
} else {
cout << zimPath << endl;
usage();
}
} else {
break;
break;
}
}
}
/* Check if we have enough arguments */
if (indexPath == NULL || search == NULL) {
if (zimPath == NULL || search == NULL) {
usage();
}
/* Try to prepare the indexing */
try {
searcher = new kiwix::XapianSearcher(indexPath);
reader = new kiwix::Reader(zimPath);
} catch (...) {
cerr << "Unable to search through index '" << indexPath << "'." << endl;
exit(1);
/* Cannot open the zimPath, maybe it is a plain old xapian database
* directory */
}
if (reader) {
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);
}
}
/* Start the indexing */
if (searcher != NULL) {
string searchString(search);
searcher->search(searchString, 0, 10);
string url;
string title;
unsigned int score;
while (searcher->getNextResult(url, title, score)) {
cout << title << endl;
kiwix::Result* p_result;
while ((p_result = searcher->getNextResult())) {
cout << p_result->get_title() << endl;
delete p_result;
}
delete searcher;
delete reader;
// kiwix::XapianSearcher::terminate();
} else {

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
res_compiler = find_program('compile_resources.py')
res_compiler = find_program('kiwix-compile-resources', 'compile_resources.py')
subdir('server')

View File

@@ -0,0 +1,13 @@
<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="Search">
</form>
</div>
</div>
</span>
</span>
<div style="display: block; height: 5em;"></div>

View File

@@ -3,10 +3,43 @@
<head>
<meta charset="UTF-8" />
<title>Welcome to Kiwix Server</title>
<script type="text/javascript" src="/skin/jquery-ui/external/jquery/jquery.js"></script>
<script type="text/javascript" src="/skin/jquery-ui/jquery-ui.min.js"></script>
<link type="text/css" href="/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
<link type="text/css" href="/skin/jquery-ui/jquery-ui.theme.min.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>
<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();
@@ -15,7 +48,7 @@ $( "#accordion" ).accordion();
</head>
<body class="kiwix">
<div id="accordion" class="kiwix">
<div class="kiwix">
__BOOKS__
</div>
</body>

View File

@@ -1,11 +1,14 @@
<script type="text/javascript" src="/skin/jquery-ui/external/jquery/jquery.js"></script>
<script type="text/javascript" src="/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" />
<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: "/suggest?content=__CONTENT__",
source: "__ROOT_LOCATION__/suggest?content=__CONTENT__",
dataType: "json",
cache: false,

View File

@@ -21,3 +21,4 @@ home.html.tmpl
include.html.part
taskbar.css
taskbar.html.part
global_taskbar.html.part

View File

@@ -5,16 +5,57 @@
right:0;
top: 0;
z-index:100;
max-height: 2.8em;
}
#kiwixtoolbar > a {
float: left;
}
.height_separator {
height: 3em;
}
#kiwixsearchbox {
width: 20em;
}
.kiwixsearch {
float: right;
}s
.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 {
@@ -26,25 +67,22 @@ li.ui-state-focus {
font-weight: bold;
}
/* Specific CSS for Bookeen Cybook device (800x600 B&W ereader) */
.cybook #kiwixtoolbar button, .cybook #kiwixtoolbar input {
font-size: 1.5em;
@media (max-width: 520px) {
.kiwixsearch {
margin-top: 5px;
}
}
.cybook #kiwixsearchbox {
width: 7em;
}
.cybook a {
text-decoration: underline;
}
@media only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5/1),
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
#kiwixtoolbar button, #kiwixtoolbar input {
font-size: 2em;
@media (max-width: 645px) {
.kiwixsearch {
float: none;
}
#kiwixsearchbox {
width: 7em;
}
width: 65%;
}
#kiwixsearchform input[type="submit"] {
width: 28%;
}
.height_separator {
height: 6em;
}
}

View File

@@ -1,15 +1,19 @@
<link type="text/css" href="/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
<link type="text/css" href="/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
<span class="kiwix">
<span id="kiwixtoolbar" class="ui-widget-header">
<a href="/"><button>Library</button></a>
<a href="/__CONTENT__/"><button>Home</button></a>
<a href="/random?content=__CONTENT__"><button>Random</button></a>
<form class="kiwixsearch" method="GET" action="/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="Search">
</form>
<div class="kiwix_centered">
<div class="kiwix_button_wrapper">
<a id="kiwix_serve_taskbar_library_button" href="__ROOT_LOCATION__/"><button>Library</button></a>
<a id="kiwix_serve_taskbar_home_button" href="__ROOT_LOCATION__/__CONTENT__/"><button>Home</button></a>
<a id="kiwix_serve_taskbar_random_button" href="__ROOT_LOCATION__/random?content=__CONTENT__"><button>Random</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="Search">
</form>
</div>
</div>
</span>
</span>
<div style="display: block; height: 3em;"></div>
<div style="display: block; height: 5em;"></div>

36
travis/compile.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e
BUILD_DIR=${HOME}/BUILD_${PLATFORM}
INSTALL_DIR=${BUILD_DIR}/INSTALL
case ${PLATFORM} in
"native_static")
MESON_OPTION="--default-library=static"
;;
"native_dyn")
MESON_OPTION="--default-library=shared"
;;
"win32_static")
MESON_OPTION="--default-library=static --cross-file ${BUILD_DIR}/meson_cross_file.txt"
;;
"win32_dyn")
MESON_OPTION="--default-library=shared --cross-file ${BUILD_DIR}/meson_cross_file.txt"
;;
"android_arm")
MESON_OPTION="-Dandroid=true --default-library=shared --cross-file ${BUILD_DIR}/meson_cross_file.txt"
;;
"android_arm64")
MESON_OPTION="-Dandroid=true --default-library=shared --cross-file ${BUILD_DIR}/meson_cross_file.txt"
;;
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}
cd build
ninja

47
travis/install_deps.sh Executable file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -e
REPO_NAME=${TRAVIS_REPO_SLUG#*/}
ARCHIVE_NAME=deps_${PLATFORM}_${REPO_NAME}.tar.gz
# Packages.
case ${PLATFORM} in
"native_static")
PACKAGES="gcc cmake libbz2-dev ccache zlib1g-dev uuid-dev libctpp2-dev"
;;
"native_dyn")
PACKAGES="gcc cmake libbz2-dev ccache zlib1g-dev uuid-dev libctpp2-dev libmicrohttpd-dev"
;;
"win32_static")
PACKAGES="g++-mingw-w64-i686 gcc-mingw-w64-i686 gcc-mingw-w64-base mingw-w64-tools ccache"
;;
"win32_dyn")
PACKAGES="g++-mingw-w64-i686 gcc-mingw-w64-i686 gcc-mingw-w64-base mingw-w64-tools ccache"
;;
"android_arm")
PACKAGES="gcc cmake ccache"
;;
"android_arm64")
PACKAGES="gcc cmake ccache"
;;
esac
sudo apt-get update -qq
sudo apt-get install -qq python3-pip ${PACKAGES}
sudo pip3 install meson
# Ninja
cd $HOME
git clone git://github.com/ninja-build/ninja.git
cd ninja
git checkout release
./configure.py --bootstrap
sudo cp ninja /bin
# Dependencies comming from kiwix-build.
cd ${HOME}
wget http://tmp.kiwix.org/ci/${ARCHIVE_NAME}
mkdir -p BUILD_${PLATFORM}
cd BUILD_${PLATFORM}
tar xf ${HOME}/${ARCHIVE_NAME}