import filters for pixiv sidecars, tag filtering, and favicon generation

This commit is contained in:
2026-02-04 19:08:50 -05:00
parent 17403c4e6b
commit c95896693f
24 changed files with 4615 additions and 4234 deletions
+11 -3
View File
@@ -423,7 +423,7 @@ def gallery_jump():
)
def _get_tags_with_previews(kind=None, limit=35, offset=0, images_per_tag=3):
def _get_tags_with_previews(kind=None, limit=35, offset=0, images_per_tag=3, search=None):
"""
Helper function to get tags with counts and preview images.
Returns (tag_data list, total_count, has_more).
@@ -436,6 +436,8 @@ def _get_tags_with_previews(kind=None, limit=35, offset=0, images_per_tag=3):
count_q = db.session.query(func.count(Tag.id))
if kind:
count_q = count_q.filter(Tag.kind == kind)
if search:
count_q = count_q.filter(Tag.name.ilike(f'%{search}%'))
total_count = count_q.scalar()
# Query 1: Get tags with image counts (paginated)
@@ -446,6 +448,8 @@ def _get_tags_with_previews(kind=None, limit=35, offset=0, images_per_tag=3):
if kind:
q = q.filter(Tag.kind == kind)
if search:
q = q.filter(Tag.name.ilike(f'%{search}%'))
tags_with_counts = q.order_by(Tag.name.asc()).offset(offset).limit(limit).all()
@@ -505,22 +509,25 @@ def tag_list():
Generic tag explorer with infinite scroll:
/tags -> all tags
/tags?kind=user -> only user tags
/tags?search=xyz -> tags matching search term
etc.
Shows a few preview images per tag.
Initially loads 35 tags, more loaded via API as user scrolls.
"""
kind = request.args.get('kind')
search = request.args.get('search', '').strip() or None
limit = 35
images_per_tag = 3
tag_data, total_count, has_more = _get_tags_with_previews(
kind=kind, limit=limit, offset=0, images_per_tag=images_per_tag
kind=kind, limit=limit, offset=0, images_per_tag=images_per_tag, search=search
)
return render_template('tags_list.html',
tag_data=tag_data,
images_per_tag=images_per_tag,
active_kind=kind,
search_query=search or '',
total_count=total_count,
has_more=has_more,
page_size=limit)
@@ -533,12 +540,13 @@ def api_tags_list():
Returns JSON with tag cards HTML and pagination info.
"""
kind = request.args.get('kind')
search = request.args.get('search', '').strip() or None
offset = request.args.get('offset', 0, type=int)
limit = request.args.get('limit', 35, type=int)
images_per_tag = 3
tag_data, total_count, has_more = _get_tags_with_previews(
kind=kind, limit=limit, offset=offset, images_per_tag=images_per_tag
kind=kind, limit=limit, offset=offset, images_per_tag=images_per_tag, search=search
)
# Render tag cards to HTML