wrolpi/wrolpi/scripts/default_zim/src/index.html
Roland 19f4958fb5 zim: ship a default fallback Zim and honor the configured Zim directory
Two related gaps in how WROLPi serves Kiwix content:

1. A fresh WROLPi (or one whose zims are all corrupt/absent) showed a blank
   Kiwix.  Every image now ships a small built-in default Zim that Kiwix falls
   back to, telling the user to download real Zim files.

2. The startup scripts hardcoded the `/zims` directory, ignoring wrolpi.yaml's
   `zims_destination` (which the Python side already honors).

Changes:
- New wrolpi/scripts/read_config_value.sh: a zero-dependency (awk) reader so
  non-Python scripts can reliably read top-level wrolpi.yaml scalars.  Also a
  config_value() wrapper in wrolpi/scripts/lib.sh.
- New wrolpi/scripts/default_zim/: HTML source + a reproducible builder
  (ghcr.io/openzim/zim-tools) that outputs the committed wrolpi/blobs/default.zim.
- New wrolpi/blobs/: any committed blob here is copied to /opt/wrolpi-blobs by
  the pi-gen and debian-live builds; the Docker zim image bakes it in.
- start_kiwix_serve.sh honors zims_destination and falls back to the default
  Zim when no functioning zim is found.
- docker/zim/entrypoint.sh gains the same default-Zim fallback.  It needs no
  config read: it already scans the whole mounted media dir, and
  zims_destination is always a subdirectory of that mount.
- Changing zims_destination via the settings API now restarts Kiwix so it
  serves the new directory without a reboot.

Tests: new test_read_config_value.py, extended test_start_kiwix_serve.py
(configured dir + default-Zim fallback), and a root_api test for the restart.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 19:09:57 -06:00

60 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>WROLPi — No Zim files yet</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
line-height: 1.6;
max-width: 40rem;
margin: 3rem auto;
padding: 0 1.25rem;
color: #222;
}
img.logo { width: 96px; height: 96px; }
h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; }
code {
background: #f2f2f2;
padding: 0.1rem 0.35rem;
border-radius: 4px;
font-size: 0.95em;
}
.hint {
background: #eef6ff;
border-left: 4px solid #2185d0;
padding: 0.75rem 1rem;
border-radius: 4px;
margin: 1.5rem 0;
}
footer { margin-top: 2rem; color: #777; font-size: 0.9rem; }
</style>
</head>
<body>
<img class="logo" src="favicon.png" alt="WROLPi">
<h1>This is the default WROLPi Zim</h1>
<p>
You are seeing this page because your WROLPi has <strong>no Zim files</strong> yet
(or the Zim files it found could not be read). This built-in placeholder keeps the
Kiwix viewer running until you download real content.
</p>
<div class="hint">
To add encyclopedias and reference libraries, open <strong>Zim</strong> in the WROLPi
menu and download what you want &mdash; Wikipedia, Wiktionary, StackExchange, iFixit,
medical and survival references, and more.
</div>
<p>
Downloaded Zim files are stored in your Zim directory (by default
<code>zims</code> inside your media directory). Once at least one working Zim file is
present, Kiwix will serve it here automatically and this page will disappear.
</p>
<footer>
WROLPi &mdash; your own off-grid library.
</footer>
</body>
</html>