Commit Graph

251 Commits

Author SHA1 Message Date
renaud gaudin bce0e8c37c fix external link blocking for nested elems in link
if a link contains nested elements like `<a href="http://somewhere"><strong>goto</strong></a>`
then the link is trigger by the `<strong />` element which has no `href` attribute.
We were thus releasing the event in this case, resulting in legitimate external links
not blocked.

We are now looking for the closest `<a />` parent (might be self) to retrieve the `href`
attribute and capture if necessary.
2020-04-01 17:50:54 +00:00
renaud gaudin 34a8144f51 cleaned-up external link blocker page
- removed useless JS/CSS
- set specific title
2020-03-30 14:42:51 +00:00
renaud gaudin d04d9bf7f3 Unblock external link in catch page in JS code
Instead of disabling the blocking for the handler, the JS code detects it is
displaying the handler and allows external links to go through
2020-03-27 12:26:22 +00:00
renaud gaudin 412f0d9c61 moved blockExternalLink outside of taskbar
- `setBlockExternalLinks()` on server
- zero-dependency JS code
- JS script added in `inject_externallinks_blocker()`
- changed URL to `/catch/external?source=<source>`
2020-03-27 11:25:39 +00:00
renaud gaudin 0ad8bf45fc Add external links blocking in serve
In many use cases, it is not wanted to have user accidentaly click on external links
and leave the served ZIM content.
This could be because the result is unpredictible (reader not implementing this properly)
or because the serve user knows there's no backup internet connexion or because there is
an induced cost behind external links that doesn't affect served content.

using a new flag (`blockExternalLinks`) on `Response`/`setTaskBar`, a piece of JS code
is injected into the taskbar code.
This code adds a JS handler on all link click events and verifies the destination.
If the destination appears to be an external link (1), the link target is changed to
a specific URL:

```
/external?source=<original_uri>
```

(1) external is a link that's not on the same origin and starts with either `http:` `https:` or `//`.

Server implements a new handler on `/external` that displays a new page (`captured_external.html`)
which returns a generic message explaining the situation and offering to click on the link
again should the user really want to.
This is done by specifically asking `set_taskbar` to not block external requests on that page.

This approach allows integrators using a reverse proxy to handle that endpoint differently (rebrand it)

1. `Server` now has an `m_blockExternalLinks` defaulting to `false`
1. `Server.setTaskbar` is extended to support an additional bool to set the variable.
1. `Response` now has an `m_blockExternalLinks`
1. `Response` constr expects an additional bool for `blockExternalLinks`.
1. `Response.set_taskbar` is extended to support an additional bool to set the variable.
1. JNI/Java Wrapper reflects the extensions.
1. New resource file `templates/block_external.js` (included in head_part). Should it be in skin?
1. New resource file `templates/captured_external.html` for `handle_captured_external()`
1. Added a comment on `head_part.html` to help with JS insertion at the right place
1. `introduce_taskbar()` conditionnaly inserts the JS inside the taskbar
2020-03-26 12:06:36 +00:00
Matthieu Gautier fff2524ee2 Fix opensearch description. 2020-01-30 17:48:56 +01:00
Kelson b7c5e5f339 Remove trailing spaces 2019-12-08 11:52:16 +01:00
Kelson d90774450d Slightly bigger top-padding for kiwix-serve 2019-09-11 13:50:33 +02:00
Matthieu Gautier a13244dc0e Rename `hasResult` to `hasResults` 2019-09-09 14:43:51 +02:00
Matthieu Gautier 78dbd66522 [HTML Rendering] Do not render page navigation buttons if only one page. 2019-09-09 14:43:51 +02:00
Kelson 26d32a36ad Force one columned suggestions in kiwix-serve 2019-09-04 17:34:15 +02:00
Kelson e111316636 Kiwix serve welcome page box size fix 2019-08-29 21:01:21 +02:00
Kelson fc2ad81185 Better kiwix-serve content (because of taskbar) top-padding 2019-08-27 16:24:52 +02:00
Kelson af78aa5fd0 Remove spaces which had visual impact 2019-08-27 16:24:14 +02:00
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
kelson42 59d67aa036 + remove js warning in kiwix-serve autosuggest 2012-08-14 16:36:18 +00:00
kelson42 f553cee7b4 + autosubmit by choosing a value in the search autocomplete list 2012-08-14 16:21:28 +00:00
kelson42 6cac5e6320 + remove useless js code 2012-08-14 07:11:45 +00:00
kelson42 c55de68072 + implement the suggestion in kiwix-serve 2012-08-13 23:37:51 +00:00
reg_ c20fd205dd WARN dangerous: removed old autotools scripts. 2012-07-06 17:21:51 +00:00
reg_ 9fff4b1bac removed DESTDIR from install targets for debian 2012-06-08 13:17:32 +00:00
reg_ e7446e0479 removed dependencies from dist 2012-06-04 11:38:35 +00:00
reg_ a7456d8560 debian desktop integration 2012-05-22 11:11:11 +00:00
kelson42 2cd537fd02 + try to fix the problem with corrupted resources on arm kiwix-serve 2012-05-20 10:53:00 +00:00
kelson42 9329a78528 + include string.h 2012-05-19 19:15:38 +00:00
kelson42 ae8882bd58 + new version of the resources 2012-05-12 21:27:24 +00:00
kelson42 4259de99f2 + change HTML ids of kiwix taskbar 2012-05-03 10:11:05 +00:00
kelson42 69c3c4340f + kiwix-serve welcome page using jsquery 2012-04-28 17:15:24 +00:00
kelson42 bc6d0afca8 + small fix to remove files with "~" 2012-04-28 09:51:37 +00:00
kelson42 508fd68958 + fix small regression in kiwix-serve search engine display 2012-04-24 18:09:09 +00:00
kelson42 b61db587ac + new resources 2012-04-24 16:35:10 +00:00
kelson42 3ddba5b5ff + remove files with # 2012-04-24 16:29:48 +00:00
kelson42 cd3f9591dd + smal bugfix of buildResourceCode.sh 2012-04-24 14:31:40 +00:00
kelson42 f4049dfece + jqueryui stub 2012-04-24 11:37:43 +00:00
kelson42 b8b0f5af60 fix small bug if ressource id generation 2012-04-24 11:36:43 +00:00
kelson42 ed526fc251 + script to build ressource files 2012-04-23 17:30:01 +00:00
reg_ 13a7d481ca moved all Makefile.am to Makefile.am.orig, added .alt ones and added link creation in autogen 2012-03-13 12:02:13 +00:00
kelson42 8df9c53878 + fix the implementation of the arrows in the search restult page 2011-12-04 15:11:38 +00:00
kelson42 aa9ebdb87e + * Add "First" and "Last" arrows in the search result page (ID: 3442313) 2011-12-04 13:40:22 +00:00
kelson42 03a0316ed6 + remove size of articles in the results 2011-08-16 19:28:45 +00:00
kelson42 4b5126ab75 + template adaptation for using in kiwix-serve 2011-04-08 14:12:39 +00:00
kelson42 8051ad4611 + show "no result were found" ... if no result found. 2011-04-03 11:45:55 +00:00
kelson42 bfd78ed71c + possible now to navigate trhough all the results 2011-04-03 11:32:51 +00:00
kelson42 91dfb75b47 + selected only the current page in the page list at the bottom of each result page 2011-04-03 11:08:35 +00:00
kelson42 47bd414a18 + use now the search:// protocol to navigate in the result pages 2011-03-24 20:36:25 +00:00
kelson42 41217c22d8 + search page navigation 2011-03-22 21:04:41 +00:00
kelson42 5e5eb61fd2 + specify the result page title 2011-03-21 11:18:50 +00:00
kelson42 ef3202dc02 + better search results 2011-03-20 18:47:14 +00:00
kelson42 5056c59747 + imp. of the search results display 2011-03-20 17:59:31 +00:00
kelson42 eece284b17 + do not show wordCount and size if not possible 2011-03-20 13:44:43 +00:00
kelson42 f8dc690771 + improved version of the results template 2011-03-19 18:51:48 +00:00
kelson42 51b605906a + load the result template automaticaly from the skin directory 2011-03-19 10:48:23 +00:00