Brad's Car Manuals - Custom Patches for LEMON + CHARM Mirror
=============================================================

These are the custom files used at https://manuals.brads.computer/ — a 3rd
party mirror of the LEMON and CHARM car repair manual databases.

The LEMON binary (included in the torrent) serves the site. All patches here
are served by nginx as static overrides that intercept specific paths before
they reach the upstream binary. The binary itself is unmodified.


WHAT IS IN THIS BUNDLE
----------------------

static/
  style.css       -- Replaces the binary's built-in stylesheet. Adds CSS custom
                     properties for theming (light / dark / system-auto), a
                     --link / --link-visited variable for readable link colors in
                     dark mode, and a flex layout to hold the theme picker widget.

  script.js       -- Replaces the binary's built-in script. The original lemon
                     JS is preserved verbatim at the bottom. A theme-picker IIFE
                     is prepended: reads localStorage['bcm-theme'], sets
                     data-theme on <html> before first paint (no flash), and
                     injects a System/Light/Dark dropdown into the header bar.
                     Dark mode styling is based on lemon.dogeware.me.

  about.html      -- Replaces the binary's about page. Documents CHARM and LEMON,
                     lists useful links, official domains, and other mirrors.
                     Includes a thank-you to Dogeware for the dark theme.

  bittorrent.html -- Not in the binary at all. A torrent download page with
                     infohash, magnet link, .torrent file download, and
                     self-hosting instructions.

  nfo.html        -- The binary's announcement/ASCII-art page, with lang="en"
                     and script.js injected so the theme picker runs on it.

  robots.txt      -- Not in the binary. Allows all crawlers, points to sitemap.

  sitemap.xml     -- Not in the binary. Auto-generated XML sitemap.

nginx/
  manuals.brads.computer.conf
                  -- Full nginx vhost config. Reverse-proxies to the lemon
                     binary, intercepts the above static paths, sets security
                     headers (HSTS, CSP, X-Frame-Options, etc.), strips
                     X-Forwarded-For to prevent rate-limit bypass, TLS only.

systemd/
  lemon-website.service
                  -- Hardened systemd unit for the lemon binary. Sets --site-name,
                     --slogan, --announcement-html, --production, and binds to
                     a specific LAN IP. Includes NoNewPrivileges, PrivateTmp,
                     ProtectSystem=strict, MemoryDenyWriteExecute, and others.


HOW TO APPLY
------------

Prerequisites:
  - LEMON torrent downloaded and seeding
    Infohash: E9DFAF202D2B8B99988D2E87517B7A90EB73AD92
  - nginx installed on your web server
  - certbot / Let's Encrypt cert for your domain (or your own TLS)
  - A Linux host for the lemon binary (glibc or musl build both included in torrent)

Step 1 - Copy the lemon binary to a stable path:

    sudo cp /path/to/torrent/lemon-website-linux-x86_64-musl /usr/local/bin/lemon-website
    sudo chmod 755 /usr/local/bin/lemon-website

Step 2 - Install the systemd service:

    Edit systemd/lemon-website.service:
      - Change --listen-address to your server LAN IP and chosen port
      - Change --site-name to your site name
      - Change --slogan to your slogan
      - Update the data paths to your torrent download location
      - Update ReadWritePaths= to match

    sudo cp systemd/lemon-website.service /etc/systemd/system/
    sudo systemctl daemon-reload
    sudo systemctl enable --now lemon-website

Step 3 - Create the static override directory:

    sudo mkdir -p /var/www/manuals-static
    sudo cp static/* /var/www/manuals-static/
    sudo chown -R www-data:www-data /var/www/manuals-static

    Edit the files as needed:
      - about.html: update site name, links, contact info
      - bittorrent.html: update infohash/magnet if using a different torrent
      - sitemap.xml: update the domain name throughout
      - robots.txt: update the sitemap URL

Step 4 - Install the nginx vhost:

    Edit nginx/manuals.brads.computer.conf:
      - Change server_name to your domain
      - Change proxy_pass IP:port to match your lemon binary address
      - Update SSL certificate paths

    sudo cp nginx/manuals.brads.computer.conf /etc/nginx/sites-available/yourdomain.conf
    sudo ln -s /etc/nginx/sites-available/yourdomain.conf /etc/nginx/sites-enabled/
    sudo nginx -t && sudo systemctl reload nginx

Step 5 - Obtain a TLS certificate (if not already done):

    sudo certbot --nginx -d yourdomain.com


NOTES
-----

- The binary's --production flag tells it to trust X-Real-IP for rate limiting.
  The nginx config sets X-Real-IP to $remote_addr and overwrites X-Forwarded-For
  to prevent IP spoofing. Do not change this without understanding the implications.

- The binary has no /bittorrent.html route. nginx intercepts it as a static file.

- nfo.html and about.html are served as static overrides even though the binary
  also has these routes, so we can inject script.js (theme picker) and correct
  the CHARM acronym (Collection of High-quality Auto Repair Manuals).

- The theme picker stores the user's choice in localStorage under the key
  'bcm-theme'. Values: 'auto' (default, follows OS prefers-color-scheme),
  'light', or 'dark'.

- Dark mode palette is based on lemon.dogeware.me. Thanks to Dogeware.

- Original LEMON project: https://lemon-manuals.la
- Original CHARM project: https://charm.li
- Dogeware mirror:        https://lemon.dogeware.me
