82 lines
4.0 KiB
Markdown
82 lines
4.0 KiB
Markdown
# List App
|
|
|
|
A web application for managing and organizing lists of movies, series, and games. The app allows users to add and view media items, with support for sorting and filtering.
|
|
|
|
## Features
|
|
|
|
- **Media Management**: Add and view movies, series, and games
|
|
- **Sorting Options**: Sort by title, year, or date added
|
|
- **Image Caching**: Automatically downloads and caches poster images
|
|
- **Authentication**: Password-protected for adding media
|
|
- **Responsive Design**: Works on mobile and desktop devices
|
|
- **No client-side JavaScript**: Pages are fully rendered server-side; the only script on the page is Bootstrap's own bundle (for the collapsible nav/dropdown), not anything authored by this app
|
|
|
|
## Technologies
|
|
|
|
- **Backend**: Go, standard library `net/http` and `html/template`, `modernc.org/sqlite` (pure Go, cgo-free)
|
|
- **Database**: SQLite
|
|
- **APIs**: OMDB API (movies/series), Twitch IGDB API (games)
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
list_app/
|
|
├── controllers/ # Business logic (OMDB/IGDB lookups, poster downloads)
|
|
├── models/ # Database models
|
|
├── routes/ # Route registration
|
|
├── web/ # Server-rendered page + HTML form handling
|
|
│ ├── page.html # Go html/template for the page
|
|
│ ├── page.go # Grouping/sorting logic, GET / and POST /add handlers
|
|
│ └── templates.go # go:embed for page.html
|
|
├── db/ # DB connection and schema
|
|
├── main.go # Main server entry
|
|
│
|
|
├── public/ # Static assets, embedded into the Go binary
|
|
│ ├── embed.go # go:embed directive
|
|
│ ├── logo.ico # Favicon
|
|
│ └── no_poster.jpg # Fallback poster image
|
|
│
|
|
├── go.mod # Go module
|
|
└── README.md # This file
|
|
```
|
|
|
|
## Setup
|
|
|
|
1. Install Go: https://go.dev/
|
|
2. Set up your API keys in the database:
|
|
- OMDB API key for movies/series
|
|
- Twitch client ID and secret for games
|
|
|
|
## Routes
|
|
|
|
- `GET /` - Renders the media list page. Query params: `listType` (`movies`, `series`, `games`; defaults to `movies`) and `sortType` (`title`, `year`, `id`; defaults to `title`)
|
|
- `POST /add` - Plain HTML form submission to add media (`pass`, `code`, plus hidden `listType`/`sortType` to redirect back to the right view). Always redirects back to `/` with `?error=...` set on failure
|
|
- `GET /api/media/:mediaType` - JSON listing of all media of a type (movies, series, games); not used by the page itself, kept as a small read-only API
|
|
|
|
There is no delete endpoint or UI — removing media isn't supported; use `sqlite3 mydb.sqlite` directly if you need to remove an entry.
|
|
|
|
## Configuration
|
|
|
|
The application uses SQLite for data storage. The database file `mydb.sqlite` will be created automatically on first run with the following tables:
|
|
|
|
- `movies` - Stores movie information
|
|
- `series` - Stores series information
|
|
- `games` - Stores game information
|
|
- `userData` - Stores configuration including API keys and password
|
|
|
|
The compiled binary is self-contained: `logo.ico` and `no_poster.jpg` are embedded into it via `public/embed.go`, and the page markup lives in a Go `html/template` embedded via `web/templates.go` — so only the binary (plus the SQLite file) needs to be deployed. Poster images are fetched from OMDB/IGDB at runtime and can't be embedded, so they're cached on disk under a `posters/` directory created next to wherever the binary runs, and served at `/poster/...`. Whether a poster has actually downloaded yet is checked server-side on each page render — if it's missing, the fallback image is used directly in the rendered `<img src>`, so no client-side JS is needed for that either.
|
|
|
|
## Usage
|
|
|
|
1. Navigate to `http://localhost:4080` in your browser
|
|
2. Use the navigation links to switch between movies, series, and games
|
|
3. Use the "Sort" dropdown to change sorting method
|
|
4. Enter your password and media ID in the form and submit to add new items
|
|
|
|
## Building
|
|
|
|
To build the binary at `output/app`:
|
|
```bash
|
|
./build.sh
|
|
```
|