From 824eddaf942c1146d2d583e236d49915d6252f5a Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sat, 6 Sep 2025 17:58:17 +0400 Subject: [PATCH 1/4] kiwix-serve --catalogOnly --- docs/kiwix-serve.rst | 6 ++++++ src/server/kiwix-serve.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/docs/kiwix-serve.rst b/docs/kiwix-serve.rst index 588b60c..562c523 100644 --- a/docs/kiwix-serve.rst +++ b/docs/kiwix-serve.rst @@ -49,6 +49,12 @@ Options that the command line argument is rather a :ref:`library XML file `. +.. option:: --catalogOnly + + In this mode ``kiwix-serve`` only serves the welcome (library) page and the + OPDS catalog. ZIM files referred by the :ref:`library XML file + ` need not be accessible. + .. option:: -i ADDR, --address=ADDR Listen only on this IP address. By default the server listens on all diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 7975361..fdf7ed5 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -61,6 +61,7 @@ Mandatory arguments: Options: -h --help Print this help -a --attachToProcess= Exit if given process id is not running anymore [default: 0] + --catalogOnly Serve only the library catalog -d --daemon Detach the HTTP server daemon from the main process -i
--address=
Listen only on the specified IP address. Specify 'ipv4', 'ipv6' or 'all' to listen on all IPv4, IPv6 or both types of addresses, respectively [default: all] -M --monitorLibrary Monitor the XML library file and reload it automatically @@ -229,6 +230,7 @@ int main(int argc, char** argv) std::string customIndexPath=""; std::string indexTemplateString=""; int serverPort = 80; + bool catalogOnlyFlag = false; bool daemonFlag [[gnu::unused]] = false; bool helpFlag = false; bool noLibraryButtonFlag = false; @@ -256,6 +258,7 @@ int main(int argc, char** argv) for (auto const& arg: args) { FLAG("--help", helpFlag) + FLAG("--catalogOnly", catalogOnlyFlag) FLAG("--daemon", daemonFlag) FLAG("--verbose", isVerboseFlag) FLAG("--nosearchbar", noSearchBarFlag) @@ -379,6 +382,7 @@ int main(int argc, char** argv) server.setIpConnectionLimit(ipConnectionLimit); server.setMultiZimSearchLimit(searchLimit); server.setIpMode(ipMode); + server.setCatalogOnlyMode(catalogOnlyFlag); if (! server.start()) { exit(1); From 597223196d43054b34ea8faadfd5c40fdc73a343 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sun, 7 Sep 2025 17:18:17 +0400 Subject: [PATCH 2/4] kiwix-serve --contentServerURL= --- docs/kiwix-serve.rst | 12 ++++++++++++ src/server/kiwix-serve.cpp | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/docs/kiwix-serve.rst b/docs/kiwix-serve.rst index 562c523..5b02e88 100644 --- a/docs/kiwix-serve.rst +++ b/docs/kiwix-serve.rst @@ -55,6 +55,18 @@ Options OPDS catalog. ZIM files referred by the :ref:`library XML file ` need not be accessible. + This option may be combined with the :option:`--contentServerURL` option. + +.. option:: --contentServerURL=URL + + In :option:`--catalogOnly` mode book content is not served by this instance + of `kiwix-serve`. If a separate instance of `kiwix-serve` is running for the + same library without that option and thus serves book content, then the root + URL of that server can be passed to this instance so that books can still be + previewed. + + This option must be combined with the :option:`--catalogOnly` option. + .. option:: -i ADDR, --address=ADDR Listen only on this IP address. By default the server listens on all diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index fdf7ed5..64c6628 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -62,6 +62,7 @@ Options: -h --help Print this help -a --attachToProcess= Exit if given process id is not running anymore [default: 0] --catalogOnly Serve only the library catalog + --contentServerURL= Root URL of the server serving ZIM content for this library -d --daemon Detach the HTTP server daemon from the main process -i
--address=
Listen only on the specified IP address. Specify 'ipv4', 'ipv6' or 'all' to listen on all IPv4, IPv6 or both types of addresses, respectively [default: all] -M --monitorLibrary Monitor the XML library file and reload it automatically @@ -231,6 +232,7 @@ int main(int argc, char** argv) std::string indexTemplateString=""; int serverPort = 80; bool catalogOnlyFlag = false; + std::string contentServerURL; bool daemonFlag [[gnu::unused]] = false; bool helpFlag = false; bool noLibraryButtonFlag = false; @@ -259,6 +261,7 @@ int main(int argc, char** argv) for (auto const& arg: args) { FLAG("--help", helpFlag) FLAG("--catalogOnly", catalogOnlyFlag) + STRING("--contentServerURL", contentServerURL) FLAG("--daemon", daemonFlag) FLAG("--verbose", isVerboseFlag) FLAG("--nosearchbar", noSearchBarFlag) @@ -383,6 +386,7 @@ int main(int argc, char** argv) server.setMultiZimSearchLimit(searchLimit); server.setIpMode(ipMode); server.setCatalogOnlyMode(catalogOnlyFlag); + server.setContentServerUrl(contentServerURL); if (! server.start()) { exit(1); From 5fdea94c0525c52e79c0144ce2d93240e7de4385 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Mon, 8 Sep 2025 16:23:49 +0400 Subject: [PATCH 3/4] Strip trailing slashes from --contentServerURL option --- src/server/kiwix-serve.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 64c6628..5ae11a7 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -386,6 +386,8 @@ int main(int argc, char** argv) server.setMultiZimSearchLimit(searchLimit); server.setIpMode(ipMode); server.setCatalogOnlyMode(catalogOnlyFlag); + while ( !contentServerURL.empty() && contentServerURL.back() == '/' ) + contentServerURL.pop_back(); server.setContentServerUrl(contentServerURL); if (! server.start()) { From fcc8877cb0e8263b79dbbb6f359e003b8a298467 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Fri, 12 Sep 2025 16:18:18 +0400 Subject: [PATCH 4/4] Upgraded CI runner to jammy --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ec78a8..bcc9e0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,11 +64,11 @@ jobs: - linux-x86_64-dyn include: - target: linux-x86_64-static - image_variant: focal + image_variant: jammy lib_postfix: '/x86_64-linux-gnu' arch_name: linux-x86_64 - target: linux-x86_64-dyn - image_variant: focal + image_variant: jammy lib_postfix: '/x86_64-linux-gnu' arch_name: linux-x86_64 @@ -76,7 +76,7 @@ jobs: HOME: /home/runner container: - image: "ghcr.io/kiwix/kiwix-build_ci_${{matrix.image_variant}}:36" + image: "ghcr.io/kiwix/kiwix-build_ci_${{matrix.image_variant}}:2025-06-07" steps: - name: Checkout code