From 00d91580aa319c29dd3ece697ee4b6a19881888d Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Sat, 28 Dec 2024 13:51:02 +0100 Subject: [PATCH] Added shuffle option of frontpage --- README.md | 16 +++++++++------- app.py | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4c38f6b..1ab6a03 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/app.py b/app.py index 4921d1f..49999f7 100644 --- a/app.py +++ b/app.py @@ -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]