# LifeLoveMe Command Guide

Quick reference for local web server, content export, book extraction, and testing. Paths use the LifeLoveMe project layout on Mac.

**Project root:**  
`~/Library/Mobile Documents/com~apple~CloudDocs/LifeLoveMe`

**Website root:**  
`~/Library/Mobile Documents/com~apple~CloudDocs/LifeLoveMe/web`

**Local Mac site:**  
http://localhost:8770/home/index.html

**iPhone local testing example** (replace with your Mac’s current LAN IP):  
http://192.168.254.207:8770/home/index.html

> **Note:** The Mac IP may change. Check with:  
> `ipconfig getifaddr en0`

---

## One-Click Launcher

The easiest way to start LifeLoveMe is to double-click the Desktop launcher:

**Launch_LifeLoveMe.command**

This launcher opens the LifeLoveMe Control Panel so I do not have to remember Terminal commands.

Create the launcher once by pasting this into Terminal:

```bash
cat > ~/Desktop/Launch_LifeLoveMe.command <<'EOF'
#!/bin/bash

cd "$HOME/Library/Mobile Documents/com~apple~CloudDocs/LifeLoveMe"

chmod +x scripts/lifeloveme.sh

./scripts/lifeloveme.sh

echo
echo "Press any key to close this window..."
read -n 1
EOF

chmod +x ~/Desktop/Launch_LifeLoveMe.command
```

After this file is created, I can simply double-click **Launch_LifeLoveMe.command** on the Desktop.

If macOS asks for permission to run the file, approve it. If needed, right-click the file and choose **Open**.

---

## 1. Start Local Website Server

```bash
cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/LifeLoveMe/web
python3 -m http.server 8770 --bind 0.0.0.0
```

- **Mac URL:** http://localhost:8770/home/index.html  
- **iPhone URL example:** http://192.168.254.207:8770/home/index.html  

Or use the helper script from the project root:

```bash
scripts/start_web_server.sh
```

---

## 2. Find Mac IP for iPhone Testing

```bash
ipconfig getifaddr en0
```

Use the printed address in place of `192.168.254.207` in URLs.

---

## 3. Stop Server

Click in the terminal where the server is running and press **Control + C**.

---

## 4. Regenerate Content JSON from Excel

```bash
cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/LifeLoveMe
source .venv-rcm/bin/activate
python scripts/export_content_json_from_master.py
```

Or:

```bash
scripts/update_content_json.sh
```

---

## 5. Extract Text from One Revised Book

```bash
cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/LifeLoveMe
source .venv-rcm/bin/activate
python scripts/extract_book_text.py --book-id the_my_other_me --force
```

Or pass any book id:

```bash
scripts/extract_one_book.sh the_my_other_me
```

---

## 6. Test Revised Book on Mac

http://localhost:8770/books/reader.html?id=the_my_other_me&v=20260507_01

---

## 7. Test Revised Book on iPhone

http://192.168.254.207:8770/books/reader.html?id=the_my_other_me&v=20260507_01  

(Use your current Mac IP from `ipconfig getifaddr en0`.)

---

## 8. Replace a Book PDF

1. Back up the old public PDF (e.g. under `web/library/books_archive/`).  
2. Replace the PDF in `web/library/books_public/`.  
3. Update **FileVersion** and **UpdatedDate** in Excel.  
4. Run `export_content_json_from_master.py`.  
5. Run `extract_book_text.py --book-id <book-id> --force`.  
6. Test with a **versioned** URL (see §10).

---

## 9. Important Folder Rules

| Purpose | Path |
|--------|------|
| Excel source files | `data/content/source/` |
| Generated content JSON | `data/content/json/` |
| Website JSON | `web/data/content/` |
| Public book PDFs | `web/library/books_public/` |
| Archived old PDFs | `web/library/books_archive/` |
| Extracted book text | `web/data/extracted/books/` |

---

## 10. Cache-Busting Rule

When a file is replaced with the **same filename**, append a version query so browsers load the new file:

`?v=<FileVersion>`

**Example:**  
`/library/books_public/the_my_other_me.pdf?v=20260507_01`

Match `v` to what you set in Excel / workflow so Books and Reader can open the latest PDF.

---

## HTML version

Open in the browser (with the local server running):  
[/docs/commands.html](http://localhost:8770/docs/commands.html)
