libkiwix/src
Veloman Yunkan e3e4bfa533 Support for serving customized resources
During work on the kiwix-serve front-end, the edit-save-test cycle is
a multistep procedure:

1. build and install libkiwix
2. build kiwix-tools
3. run kiwix-serve
4. reload the web-page in the browser

When making changes in static resources that are served by kiwix-serve
unmodified, the steps 1-3 can be eliminated if kiwix-serve is capable of
serving resources from the file-system. This commit adds such a
functionality to kiwix-serve. Now, if during startup of kiwix-serve the
environment variable `KIWIX_SERVE_CUSTOMIZED_RESOURCES` is defined it is
assumed to point to a file where every line has the following format:

URL MIMETYPE RESOURCE_FILE_PATH

When a request is received by kiwix-serve and its URL matches any of the
URLs read from the customized resource file, then the resource data is
read from the respective file RESOURCE_FILE_PATH and served with
mime-type MIMETYPE.

Though this feature was introduced in order to facilitate the
development of the iframe-based content viewer, it can also be useful to
users who would like to customize the kiwix-serve front-end on their own
(without re-building all of kiwix-serve).

There is some overlap with a feature of the kiwix-compile-resources
script that also allows to override resources. The differences are:

1. The new way of customizing front-end resources has all such resources
   listed in a text file and there is a single environment variable
   from which the path of that file is read. kiwix-compile-resources
   associates a separate environment variable with each resource.

2. The new way uses regular paths to identify a resource. The
   kiwix-compile-resources method encodes the resource path by replacing
   any non-alphanumeric characters (including the path separator) with
   underscores (so that the resulting resource identifier can be used
   to construct the name of the environment variable controlling that
   resource).

3. The new method allows adding new front-end resources. The old method
   only allows to modify existing resources.

4. The new method allows (actually requires) to specify the URL at which
   the overriden resource should be served (similarly, the MIME-type can/must
   be specified, too). The old method only allows to override the contents of
   a resource.

5. The new method only allows to override front-end resources that are
   served without any preprocessing by kiwix-serve at runtime. The old
   method allows to override template resources as well (note that
   internationalization/translation resources cannot be overriden using the
   old method, either).
2022-06-22 10:59:41 +02:00
..
server Support for serving customized resources 2022-06-22 10:59:41 +02:00
tools Add a template specialization for ConcurrentCache storing shared_ptr 2022-06-02 12:37:52 +02:00
aria2.cpp Introduce kiwix::fileReadable 2022-01-05 20:16:38 +05:30
aria2.h Make aria2 secret a random value 2022-01-03 09:35:04 +01:00
book.cpp Correctly detect the number of article for zim version <= 6 2022-04-06 17:21:14 +02:00
bookmark.cpp Add bookmarks support. 2018-12-02 15:47:29 +01:00
config.h.in Better libkiwix version variable name 2021-12-13 18:22:40 +01:00
downloader.cpp Better error printing. 2020-08-28 15:27:03 +02:00
entry.cpp Deprecate `Entry` creation. 2022-01-13 14:23:29 +01:00
kiwixserve.cpp Move back used helper functions to the public API. 2021-07-07 14:43:13 +02:00
library.cpp Do not use deprecated constructor for Reader. 2022-06-10 10:41:31 +02:00
libxml_dumper.cpp Deprecate methods on Book. 2022-01-12 18:07:46 +01:00
manager.cpp Manager::reload() also removes books from Library 2021-11-30 18:20:27 +04:00
meson.build Remove the java wrapper. 2022-06-09 10:23:02 +02:00
microhttpd_wrapper.h Fix compilation with libmicrohttpd v0.97.1 2020-07-08 14:42:46 +02:00
name_mapper.cpp Renamed NameMapperProxy -> UpdatableNameMapper 2021-11-30 18:20:27 +04:00
opds_catalog.cpp OpdsCatalog::getSearchUrl() 2021-06-30 18:27:00 +02:00
opds_dumper.cpp kiwix::onlyAsNonEmptyMustacheValue() 2022-03-28 14:56:40 +02:00
reader.cpp Add a new private constructor not deprecated for Reader. 2022-01-18 12:22:11 +01:00
search_renderer.cpp Properly set "language" parameter in `opensearch::Query` tag. 2022-06-03 15:46:41 +02:00
searcher.cpp Make the Searcher owning the stored Reader 2022-06-02 17:08:17 +02:00
server.cpp Make the limit of zim files per search configurable. 2022-06-02 12:37:52 +02:00
subprocess.cpp Do not add NULL at end of commandLine on Windows. 2018-10-31 13:56:42 +01:00
subprocess.h Do not add NULL at end of commandLine on Windows. 2018-10-31 13:56:42 +01:00
subprocess_unix.cpp Use c++11 std::thread instead of pthread. 2021-01-26 17:53:25 +01:00
subprocess_unix.h Use c++11 std::thread instead of pthread. 2021-01-26 17:53:25 +01:00
subprocess_windows.cpp Wait for waitingThread to exit before destroying the subprocess memory. 2020-08-26 12:26:04 +02:00
subprocess_windows.h Wait for waitingThread to exit before destroying the subprocess memory. 2020-08-26 12:26:04 +02:00
version.cpp New kiwix::getVersions() and printVersions() 2022-01-02 12:22:11 +01:00
xmlrpc.h Add missing include 2020-10-07 18:43:57 +02:00