97 lines
4.0 KiB
Markdown
97 lines
4.0 KiB
Markdown
# Image Swipe App
|
|
|
|
A web application for sorting and organizing images using swipe gestures, similar to dating apps.
|
|
|
|
## Features
|
|
|
|
- **Swipe Interface**: Swipe images in four directions (left, right, up, down) to categorize them
|
|
- **Full-size Image View**: Click on any image to view it in full resolution with metadata
|
|
- **History Page**: View all your past selections with rich filtering and sort options
|
|
- **NSFW Filtering**: Toggle to include/exclude NSFW images on both the main swiper and history pages
|
|
- **NSFW Blur**: Optional blur for NSFW thumbnails on the history page with a toolbar toggle
|
|
- **Orientation & Action Filters**: Filter results by orientation (portrait/landscape/square) and by action taken
|
|
- **Image Sorting**: Choose to display images in random order (default), oldest first, or newest first
|
|
- **Database Storage**: All selections are saved in a SQLite database
|
|
- **Reset Functionality**: Option to clear all selections and start fresh
|
|
|
|
## File Structure
|
|
|
|
- `server.py`: Entry point that starts the HTTP server
|
|
- `handler.py`: HTTP request handler implementing all API endpoints
|
|
- `database.py`: SQLite helpers (initialisation, queries, sync)
|
|
- `config.py`: Centralised constants (paths, port)
|
|
- `index.html`: Main page with the swipe interface
|
|
- `history.html`: Page to view and manage past selections
|
|
- `js/`: Front-end JavaScript (`main.js`, `utils.js`, etc.)
|
|
- `styles.css`: CSS styling for the application
|
|
- `update_nsfw_flags.py`: Utility script to (re)calculate NSFW flags for existing images after changing keyword lists
|
|
|
|
## How to Use
|
|
|
|
1. Run the server: `python server.py`
|
|
2. Open a web browser and navigate to `http://localhost:8000`
|
|
|
|
### Main Page Features
|
|
- **Sort Order**: Use the dropdown in the sidebar to select image display order (Random, Oldest to Newest, or Newest to Oldest)
|
|
- **Mobile View**: On smaller screens, action buttons appear directly below the swipe window for easy access
|
|
3. Use the on-screen buttons or swipe gestures to categorize images:
|
|
- Left: Discard
|
|
- Right: Keep
|
|
- Up: Favorite
|
|
- Down: Review Later
|
|
4. Click on an image to view it in full resolution
|
|
5. Use the "View History" link to see all your selections. The toolbar lets you:
|
|
- Filter by action/orientation/NSFW status
|
|
- Toggle blur of NSFW thumbnails
|
|
- Sort by creation date, swipe date or resolution
|
|
6. Use the "Reset Database" button in the history page to clear all selections
|
|
|
|
## NSFW Detection & Maintenance
|
|
|
|
NSFW status is inferred from prompt keywords defined in `config.py` (`NSFW_KEYWORDS`).
|
|
|
|
After changing the keyword list or adding new images you can refresh the database flags:
|
|
```bash
|
|
python update_nsfw_flags.py
|
|
```
|
|
This will reset and recalculate all `nsfw` flags so that the new filters work correctly.
|
|
|
|
## Requirements
|
|
|
|
- Python 3.x
|
|
- Standard Python libraries (http.server, sqlite3, etc.)
|
|
- Web browser with JavaScript enabled
|
|
|
|
## Docker
|
|
|
|
If you have Docker installed you can build and run the application in an isolated container:
|
|
|
|
```bash
|
|
# Build image (only once)
|
|
docker build -t swiper-app .
|
|
|
|
# Run the container on port 8888
|
|
docker run --rm -p 8888:8888 swiper-app
|
|
```
|
|
|
|
Then open [http://localhost:8888](http://localhost:8888) in your browser.
|
|
|
|
The Dockerfile uses a minimal Python 3.11 image, installs the Python dependencies from `requirements.txt`, exposes port 8888 and starts the app with `python server.py`.
|
|
|
|
### Docker Compose
|
|
|
|
A `docker-compose.yml` file is included so you can run the container with your image folders mounted automatically.
|
|
|
|
```bash
|
|
# Build image (first time or when code changes)
|
|
docker compose up --build
|
|
```
|
|
|
|
This will:
|
|
|
|
- Publish port **8888** on your host → container.
|
|
- Mount the portrait and landscape image folders (update paths in `docker-compose.yml` as needed) read-only into `/media/Portrait` and `/media/Landscape` inside the container.
|
|
- Set `IMAGE_DIRS=/media/Portrait:/media/Landscape` so the server finds the images.
|
|
|
|
Adjust ports, folders or environment variables by editing `docker-compose.yml`. Remember to rebuild (`docker compose up --build`) after changes.
|