Refactor local settings to dotenv-based gallery paths

This commit is contained in:
2026-03-22 22:52:07 -04:00
parent 16bd651cfb
commit 912446d9b7
5 changed files with 83 additions and 74 deletions

View File

@@ -28,19 +28,21 @@ This document is intentionally explicit so tasks can be completed with minimal r
- Apply migrations: `python manage.py migrate`
- Run server: `python manage.py runserver`
Local configuration (`NibasaViewer/local_settings.py`) is required for real gallery usage:
Local configuration is loaded from `.env` via `python-dotenv`.
```python
from pathlib import Path
Use this minimum `.env` content for gallery paths:
GALLERY_ROOT = Path('/path/to/images')
THUMBNAILS_ROOT = Path('/path/to/thumb-cache')
DEBUG = False
ALLOWED_HOSTS = ['yourdomain.example']
SECRET_KEY = 'replace-me'
```env
GALLERY_ROOT=/path/to/images
THUMBNAILS_ROOT=/path/to/thumb-cache
```
Notes:
- `GALLERY_ROOT` and `THUMBNAILS_ROOT` are parsed as `pathlib.Path` in `settings.py`.
- Both are optional at import time and default to `None` when unset/empty.
- Paths do not need to be inside `BASE_DIR`.
## 4) Build / Lint / Test Commands
There is no dedicated linter or formatter config in-repo (no `ruff`, `flake8`, `black`, `mypy`, `pyright`, `tox`, or `pytest` config files detected).
@@ -145,7 +147,7 @@ Notes:
## 9) Safety and Config Hygiene
- Never commit secrets or production-specific local settings.
- Keep `local_settings.py` local; defaults in `settings.py` should remain safe placeholders.
- Keep `.env` local and out of version control; use `.env.example` as a template.
- Avoid destructive git operations unless explicitly requested.
- Do not revert unrelated working tree changes made by humans.