Added shuffle option of frontpage

This commit is contained in:
FrederikBaerentsen 2024-12-28 13:51:02 +01:00
parent 96d9aa6b5f
commit 00d91580aa
2 changed files with 11 additions and 8 deletions

View File

@ -35,14 +35,15 @@ mkdir static/{sets,instructions,parts,minifigs}
```
REBRICKABLE_API_KEY=your_api_key_here
DOMAIN_NAME=https://your.domain.com
```
If using locally, set `DOMAIN_NAME` to `http://localhost:3333`.
```
LINKS=True
RANDOM=True
```
Can be added to the `.env` file in order for set numbers to be links to Rebrickable on the front page.
- If using locally, set `DOMAIN_NAME` to `http://localhost:3333`.
- `LINKS`: Set to `True` in order for set numbers to be links to Rebrickable on the front page.
- `RANDOM`: Set to `True` in order for the sets to shuffle on the frontpage each load.
3. Deploy with Docker Compose:
```bash
@ -82,7 +83,8 @@ services:
environment:
- REBRICKABLE_API_KEY=your_api_key_here
- DOMAIN_NAME=https://your.domain.com
- LINKS=True #optional, enables set numbers to be Rebrickable links on the front page.
- LINKS=True #optional, enables set numbers to be Rebrickable links on the front page
- RANDOM=False #optional, set to True if you want your front page to be shuffled on load
```
If using locally, set `DOMAIN_NAME` to `http://localhost:3333`.

3
app.py
View File

@ -663,7 +663,8 @@ def index():
results = cursor.fetchall()
set_list = [list(i) for i in results]
if os.getenv("RANDOM") == True:
random.shuffle(set_list)
cursor.execute('SELECT DISTINCT u_id from missing;')
results = cursor.fetchall()
missing_list = [list(i)[0] for i in results]