bert: Add bible.chandlerswift.com

This commit is contained in:
Chandler Swift 2025-07-21 22:35:49 -05:00
parent fba42c5f18
commit d69b4cf8ab
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
3 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Chandler's Bible API Mirror</title>
<style>
body { font-family: sans-serif; max-width: 600px; margin: auto; padding: 2em; }
code { background: #eee; padding: 0.2em 0.4em; }
</style>
</head>
<body>
<h1>Chandler's Bible API Mirror</h1>
<p>This site mirrors the public domain Bible API from <a href="https://bible.helloao.org/">bible.helloao.org</a>.</p>
<h2>License</h2>
<p>The Holy Bible, Berean Standard Bible, BSB is produced in cooperation with Bible Hub, Discovery Bible, OpenBible.com, and the Berean Bible Translation Committee. This text of God's Word has been dedicated to the public domain.</p>
<p><a href="https://berean.bible/terms.htm">https://berean.bible/terms.htm</a></p>
<p>You can fetch JSON files under the <code>/api/</code> path. For example:</p>
<ul>
<li><code><a href="/api/BSB/books.json">/api/available_translations.json</a></code>: A list of available translations</li>
<li><code><a href="/api/BSB/books.json">/api/BSB/books.json</a></code>: All books of the Berean Standard Bible</li>
<li><code><a href="/api/BSB/GEN.json">/api/BSB/GEN/1.json</a></code>: Genesis 1, Berean Standard Bible</li>
</ul>
</body>
</html>

View file

@ -0,0 +1,48 @@
{ pkgs, ... }:
let
bibleApiPackage = pkgs.stdenv.mkDerivation {
pname = "bible-api";
version = "2025-07-18";
src = pkgs.fetchzip {
url = "https://bible.helloao.org/api.zip";
hash = "sha256-bYl8svY++D0+YHXZ8/3h+yn0xiqIDCXcN+Hh9FjP98k=";
stripRoot = false;
};
dontBuild = true;
installPhase = ''
mkdir -p $out/api
mv * $out/api/
'';
};
in {
services.caddy.enable = true;
services.caddy.virtualHosts."bible.chandlerswift.com" = {
extraConfig = ''
encode zstd gzip
file_server
root * ${bibleApiPackage}
handle / {
header Content-Type text/html
# This is a bit of a hack, but I was unable to find a better way to just
# serve the contents of the file. If I knew the directory of the file
# and its filename, I think I could use file_server with try_files, but
# if I do a `file_server` with `.\${./bible.chandlerswift.com.html}`, then
# bible.chandlerswift.com.html just gets copied as a file into nix-store
# and I don't know its name. ...or something? Anyway this seems to work!
respond <<EOF
${builtins.readFile ./bible.chandlerswift.com.html}
EOF
}
handle_errors {
respond "{err.status_code} {err.status_text}"
}
'';
};
}

View file

@ -2,6 +2,7 @@
imports = [
./0hats.com.nix
./bannergen.chandlerswift.com.nix
./bible.chandlerswift.com.nix
./chandlerswift.com.nix
./darylfanclub.chandlerswift.com.nix
./flintlock.chandlerswift.com.nix