Commit Graph

87 Commits

Author SHA1 Message Date
Matthieu Gautier 7060afae66 [SERVER] Catch any error and return a 500 response instead of crashing.
The server will be running some code on the behalf of the calling code.
We really don't what to crash the library (and the binary) because
of a wrong request.
2019-08-11 11:30:43 +02:00
Matthieu Gautier de819dff25 Fix few errors in static files. 2019-08-11 11:30:43 +02:00
Matthieu Gautier ce09375c6c Reduce complexity of handle_search. 2019-08-11 11:30:43 +02:00
Matthieu Gautier c1faf55ae8 Introduce the server functionality in the kiwix-lib.
This code is mainly copied from kiwix-tools.

But :
- Move all the response thing in a new class Response.
- This Response class is responsible to handle all the MHD_response
  configuration. This way the server handle a global object and do
  no call to MHD_response*
- Server uses a lot more the templating system with mustache.
  There are still few regex operations (because we need to
  change a content already existing).
- By default, the server serves the content using the id as name.
- Server creates a new Searcher per request. This way, we don't have
  to protect the search for multi-thread and we can do several search
  in the same time.
- search results are not cached, this will allow future improvement in the
  search algorithm.
- the home page is not cached.
- Few more verbose information (number of request served, time spend to
  respond to a request).

TOOD:
 - Readd interface selection.
 - Do Android wrapper.
 - Remove KiwixServer (who use a external process).
 -
2019-08-11 11:30:43 +02:00
Matthieu Gautier 64dfea2547 Move the search html renderer in a different class than the searcher.
This is two different functionnalies, we don't need to polute the searcher
api with things to render the html.
2019-08-11 10:19:48 +02:00
Matthieu Gautier b9696dceac Workaround a bug in meson 0.43.0 about custom_target's depend_files option.
There is a bug in meson 0.43.0 about the option depend_files
(mesonbuild/meson#2633)

By using the `files('search_result.tmpl')`, we workaround the bug and
have everything working whatever the meson version is.
2019-01-10 15:59:42 +01:00
Matthieu Gautier 92c9a47a0d Move the templating system to mustache instead of ctpp2.
Mustache templating system is a bit simpler than ctpp2 and ctpp2 is no
more maintained (see #189).
We are moving to the kainjow's Mustache project
(https://github.com/kainjow/Mustache).

It simplify a lot our system has it is header only and we don't have to
precompile the template.

Fix #21
2019-01-09 18:28:48 +01:00
Matthieu Gautier 622d2fc23d Remove unused static resources.
Stop words are not use anymore since a long time now that indexing has
been moved to libzim. No need to embedded them in kiwix-lib.
2018-05-15 11:30:30 +02:00
Chris Li cf93c8719f Allow kiwix-lib to compile without ctpp2c.
ctpp2c is used to pre-compile the template resource.
However, on OSX, ctpp2c seems to be difficult to compile, as we don't need
ctpp2 at all on OSX/iOS, lets just stop to force the use of ctpp2c.
2017-08-14 10:42:16 -04:00
kelson42 b6a58d1684 Fix wording problem 2017-07-19 21:39:38 +02:00
Matthieu Gautier bc5f4f5de4 Use right contentId to generate the article url in search template.
As we do multisearch, we must use the associated contentID of the result
to generate the url.
2017-07-18 10:04:40 +02:00
Matthieu Gautier 64cc69f6ae Use ctpp2c to generate template from source instead of use generated one.
Fixes #50.
2017-07-12 15:45:44 +02:00
Matthieu Gautier cba71b4e75 Add a new script to compile resources.
- No more dependency to reswrap binary (everything is done in python)
- Resource strings can be directly accessed.
  As side effect, it add a check at compilation if the resource is
  declared and compiled in the binary.
- The resource content can be overwritten at runtime with a env variable.

There is also few clean in the static as some files shoul be in the tools
directory.

The compile_resource script is install to let other project use it.
2016-12-23 13:06:12 +01:00
renaud gaudin 855c7ef4c2 give some margin (ahah) for the margin to be eaten up 2015-03-02 15:03:30 +00:00
renaud gaudin 68059281f3 transparency kiwix-serve 2015-03-02 15:00:13 +00:00
renaud gaudin dda3dd4749 [kiwix-serve] Fixed taskbar margin from content if content has no margin 2015-03-02 14:54:29 +00:00
renaud gaudin 2491a5a0c4 [kiwix-serve] Fixed taskbar height (2 lines) on Cybook and transparency of autocomplete search result 2015-03-02 14:23:26 +00:00
renaud gaudin af1ee3c317 Fixed incorect behavior of buttons in taskbar 2015-02-19 15:31:16 +00:00
renaud gaudin 950637abef Added Bookeen/Cybook CSS/JS hack for taskbar on ereader and increased taskbar size on hdpi screens 2015-02-19 14:57:50 +00:00
Kelson42 517a02b814 + fix taskbar CSS 2014-09-18 14:54:49 +02:00
Kelson42 4beccfbc0b + improve taskbar CSS 2014-09-18 14:50:11 +02:00
Kelson42 ec6c0b2ea3 + fix kiwix-serve taskbar css 2014-09-18 14:22:47 +02:00
Kelson42 f6dedb11b9 + fix tasbar css 2014-09-18 14:17:56 +02:00
Kelson42 436d57976e + improve kiwix-serve taskbar css 2014-09-18 14:08:36 +02:00
kelson42 f585bed1cb FIXED: kiwix-serve crash if unattended search "start" & "end" values 2014-08-28 13:36:58 -06:00
kelson42 518ce6635d + fix a few problem with the autocompletebox on kiwix-serve 2014-08-27 21:08:14 -06:00
Kelson42 1c3eaaf42a remove useless code 2014-07-28 13:36:10 +02:00
kelson42 beae77db89 Avoid kiwix-serve taskbar jquery dependencies to conflict with potential other version (in the ZIM file) 2014-07-20 22:06:52 +02:00
kelson42 17724fe70b + fix Doctype HTML line (was breaking Opera output) 2014-07-09 21:11:34 +02:00
kelson42 cef7967bcb Merge commit '2e9e80f4b73af420e342ae35bff6f95af4d4b9d0' 2014-05-25 20:27:46 +02:00
Shivam b341b9654d Added a random article button for server mode 2014-05-25 12:25:13 -04:00
Shivam faf1f3e01d Removed blank space above taskbar 2014-05-24 16:04:02 -04:00
renaud gaudin 2bbe2cb9ad Added compiled template to static 2013-11-13 20:02:20 +00:00
renaud gaudin 2a8d7fde56 Fixed CTPP2 not working
* Fixed templates
* Changed behavior of getHtml() to use higher level VM API
2013-11-13 19:58:56 +00:00
renaud gaudin d2a2802897 ctpp2 as external lib on unix 2013-08-10 22:14:18 +08:00
kelson42 4ab6898586 + replace POST method with GET method in kiwix-serve UI 2013-06-17 14:56:15 +02:00
kelson42 d38bc834c5 + new trial to fix the bug with the failing onclick on the kiwiwx-serve suggestion list 2013-05-21 11:09:35 +02:00
kelson42 d068ed9037 + last fix in the suggestion bug (with click) 2013-05-20 12:50:53 +02:00
kelson42 ae44b87f82 * FIXED: Buggy kiwix-serve suggestion click handling 2013-05-20 12:40:30 +02:00
kelson42 499b50172f + small visual UI fixes 2013-02-12 19:33:00 +00:00
kelson42 36f0b977f7 * FIXED: kiwix-serve UI for non-javascript browsers like Dillo (#587) 2013-02-12 18:13:01 +00:00
kelson42 306b7ebbb0 + fix fulltext result page for pattern including mustbeurlencoded characters 2012-12-30 16:55:08 +00:00
kelson42 bb62f3aa94 + kiwix-serve page margin-top a little bit bigger 2012-12-20 22:30:35 +00:00
kelson42 5b5abceda4 + some fixes in static pages 2012-11-15 14:06:30 +00:00
kelson42 76596f8f35 + improve a few static html templates 2012-11-15 14:00:32 +00:00
kelson42 c74bb9c939 + better html conformance for static pages 2012-11-15 13:51:33 +00:00
kelson42 1823771770 + lang. fix in the result page template 2012-11-10 22:48:30 +00:00
kelson42 c1961faeb4 + small renaming of stopword files 2012-09-01 11:38:09 +00:00
kelson42 3a3b34ade2 + stopwords list in french 2012-09-01 11:17:54 +00:00
kelson42 0f563d33d4 + move the stopworkds directory 2012-09-01 11:14:51 +00:00