Cookie for tracking if info tab should be shown

This commit is contained in:
Michał 2023-05-29 10:40:29 +00:00
parent e5b066a50c
commit bc2ed9e2be
2 changed files with 18 additions and 5 deletions
onlylegs/views

View file

@ -3,11 +3,11 @@ Onlylegs - Image Groups
Why groups? Because I don't like calling these albums Why groups? Because I don't like calling these albums
sounds more limiting that it actually is in this gallery sounds more limiting that it actually is in this gallery
""" """
from flask import Blueprint, render_template, url_for from flask import Blueprint, render_template, url_for, request
from onlylegs.models import Post, User, GroupJunction, Group from onlylegs.models import Post, User, GroupJunction, Group
from onlylegs.extensions import db from onlylegs.extensions import db
from onlylegs.utils import contrast from onlylegs.utils.colour import contrast
blueprint = Blueprint("group", __name__, url_prefix="/group") blueprint = Blueprint("group", __name__, url_prefix="/group")
@ -72,7 +72,7 @@ def group(group_id):
# Check contrast for the first image in the group for the banner # Check contrast for the first image in the group for the banner
text_colour = "rgb(var(--fg-black))" text_colour = "rgb(var(--fg-black))"
if images: if images:
text_colour = contrast.contrast( text_colour = contrast(
images[0].colours[0], "rgb(var(--fg-black))", "rgb(var(--fg-white))" images[0].colours[0], "rgb(var(--fg-black))", "rgb(var(--fg-white))"
) )
@ -127,6 +127,14 @@ def group_post(group_id, image_id):
if prev_url: if prev_url:
prev_url = url_for("group.group_post", group_id=group_id, image_id=prev_url[0]) prev_url = url_for("group.group_post", group_id=group_id, image_id=prev_url[0])
close_tab = True
if request.cookies.get("image-info") == "0":
close_tab = False
return render_template( return render_template(
"image.html", image=image, next_url=next_url, prev_url=prev_url "image.html",
image=image,
next_url=next_url,
prev_url=prev_url,
close_tab=close_tab,
) )

View file

@ -2,7 +2,7 @@
Onlylegs - Image View Onlylegs - Image View
""" """
from math import ceil from math import ceil
from flask import Blueprint, render_template, url_for, current_app from flask import Blueprint, render_template, url_for, current_app, request
from onlylegs.models import Post, GroupJunction, Group from onlylegs.models import Post, GroupJunction, Group
from onlylegs.extensions import db from onlylegs.extensions import db
@ -72,10 +72,15 @@ def image(image_id):
return_page = i + 1 return_page = i + 1
break break
close_tab = True
if request.cookies.get("image-info") == "0":
close_tab = False
return render_template( return render_template(
"image.html", "image.html",
image=image, image=image,
next_url=next_url, next_url=next_url,
prev_url=prev_url, prev_url=prev_url,
return_page=return_page, return_page=return_page,
close_tab=close_tab,
) )