diff options
| author | Fuwn <[email protected]> | 2023-07-25 22:17:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-07-25 22:17:41 -0700 |
| commit | 64d38a6dd771c2bb735dbda619e3da5d570e3009 (patch) | |
| tree | bdc47788f73f603545c3d81411cd65982d1688db /src | |
| parent | feat(index): hide manga by default (diff) | |
| download | old.due.moe-64d38a6dd771c2bb735dbda619e3da5d570e3009.tar.xz old.due.moe-64d38a6dd771c2bb735dbda619e3da5d570e3009.zip | |
feat(due): toggle missing display
Diffstat (limited to 'src')
| -rw-r--r-- | src/due/html.py | 12 | ||||
| -rw-r--r-- | src/due/routes/index.py | 19 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/due/html.py b/src/due/html.py index 966dadb..f629afc 100644 --- a/src/due/html.py +++ b/src/due/html.py @@ -42,6 +42,11 @@ def anime_to_html(releasing_outdated_anime): if title is None: title = anime["title"]["romaji"] + if request.cookies.get("show_missing") is not None and str(available)[0] == "?": + ids.pop() + + continue + current_html.append( f'<li><a href="https://anilist.co/anime/{id}" target="_blank">{title}</a> {progress} [{available}]</li>' ) @@ -54,7 +59,7 @@ def anime_to_html(releasing_outdated_anime): return ("".join(current_html), len(ids)) -def manga_to_html(releasing_outdated_manga): +def manga_to_html(releasing_outdated_manga, show_missing): current_html = [] ids = [] @@ -145,6 +150,11 @@ def manga_to_html(releasing_outdated_manga): ) ) + if show_missing is not None and str(available)[0] == "?": + ids.pop() + + return + # Useful when debugging # if str(available)[0] != "?": # ids.pop() diff --git a/src/due/routes/index.py b/src/due/routes/index.py index 4e5042c..7dd0dbd 100644 --- a/src/due/routes/index.py +++ b/src/due/routes/index.py @@ -12,6 +12,7 @@ bp = Blueprint("index", __name__) def home(): response = make_response("") disable_manga = True + show_missing = False if request.args.get("show_manga") is not None: disable_manga = False @@ -19,8 +20,20 @@ def home(): if request.args.get("hide_message") is not None: if request.cookies.get("hide_message") is None: response = redirect("/") + response.set_cookie("hide_message", "1") + if request.args.get("toggle_missing") is not None: + if request.cookies.get("show_missing") is None: + response = redirect("/") + show_missing = True + + response.set_cookie("show_missing", "1") + else: + response = redirect("/") + + response.delete_cookie("show_missing") + # print( # requests.post( # "https://anilist.co/api/v2/oauth/token", @@ -75,7 +88,9 @@ def home(): and int(media["media"]["mediaListEntry"]["progress"]) >= 1 # Useful when testing ] - (manga_html, manga_length) = manga_to_html(releasing_outdated_manga) + (manga_html, manga_length) = manga_to_html( + releasing_outdated_manga, request.cookies.get("show_missing") + ) manga_time = time.time() - start manga_body = f""" <p></p> @@ -91,7 +106,7 @@ def home(): f"""<a href="/auth/logout">Logout from AniList ({name})</a> <br>""", - f"""<details open> + f"""<a href=\"/?toggle_missing\">{'Show' if request.cookies.get('show_missing') else 'Hide'} missing</a><p></p><details open> <summary>Anime [{anime_length}] <small style="opacity: 50%">{round(anime_time, 2)}s</small></summary> {anime_html} </details> |