Skip to content

Commit

Permalink
v117
Browse files Browse the repository at this point in the history
  • Loading branch information
annihilation7071 committed Jan 4, 2025
1 parent bd2b359 commit ec2f1b1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion backend/db/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Project(Base):
preview = Column(String(length=500))
parody = Column(JSON)
character = Column(JSON)
tag = Column(JSON)
tag = Column(JSON, index=True)
artist = Column(JSON, index=True)
group = Column(JSON)
language = Column(JSON)
Expand Down
53 changes: 37 additions & 16 deletions routers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ async def index(request: Request, page: int = 1, search: str = ""):
)


@router.get("/project/{project_id}", response_class=HTMLResponse)
async def detail_view(request: Request, project_id: int):
project = projects.get_project_by_id(project_id)
images = utils.get_pages(project)
return templates.TemplateResponse(
"detailview.html",
{
"request": request,
"project": project,
"images": images
},
)
# @router.get("/project/{project_id}", response_class=HTMLResponse)
# async def detail_view(request: Request, project_id: int):
# project = projects.get_project_by_id(project_id)
# images = utils.get_pages(project)
# return templates.TemplateResponse(
# "detailview.html",
# {
# "request": request,
# "project": project,
# "images": images
# },
# )


@router.get("/project/lid/{project_lid}", response_class=HTMLResponse)
Expand All @@ -68,9 +68,30 @@ async def detail_view_lid(request: Request, project_lid: str):
)


@router.get("/project/{project_id}/{page_id}", response_class=HTMLResponse)
async def reader(request: Request, project_id: int, page_id: int):
project = projects.get_project_by_id(project_id)
# @router.get("/project/{project_id}/{page_id}", response_class=HTMLResponse)
# async def reader(request: Request, project_id: int, page_id: int):
# project = projects.get_project_by_id(project_id)
# images = utils.get_pages(project)
# page = page_id
# image = images[page - 1]["path"]
# total_pages = len(images)
# visible_pages = get_visible_pages(page, total_pages)
# return templates.TemplateResponse(
# "reader.html",
# {
# "request": request,
# "image": image,
# "current_page": page,
# "project_id": project_id,
# "total_pages": total_pages,
# "visible_pages": visible_pages,
# },
# )


@router.get("/project/lid/{project_lid}/{page_id}", response_class=HTMLResponse)
async def reader_lid(request: Request, project_lid: str, page_id: int):
project = projects.get_project_by_lid(project_lid)
images = utils.get_pages(project)
page = page_id
image = images[page - 1]["path"]
Expand All @@ -82,7 +103,7 @@ async def reader(request: Request, project_id: int, page_id: int):
"request": request,
"image": image,
"current_page": page,
"project_id": project_id,
"project_id": project_lid,
"total_pages": total_pages,
"visible_pages": visible_pages,
},
Expand Down
2 changes: 1 addition & 1 deletion templates/detailview.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ <h2>{{ project.subtitle }}</h2>
<main class="detail-view-pages">
<div class="grid-container-pages">
{% for image in images %}
<a href="{{ request.url_for('reader', project_id=project.id, page_id=image.idx + 1) }}{{ ('?' + request.query_string.decode('utf-8')) if request.query_string else '' }}"
<a href="{{ request.url_for('reader_lid', project_lid=project.lid, page_id=image.idx + 1) }}{{ ('?' + request.query_string.decode('utf-8')) if request.query_string else '' }}"
class="image-item">
<img src="{{ request.url_for('get_image', image_path=image.path | urlencode) }}" alt="Error">
</a>
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<main>
<div class="grid-container">
{% for project in projects %}
<a href="{{ request.url_for('detail_view', project_id=project.id) }}?page={{ current_page }}&search={{ request.query_params.get('search', '') }}"
<a href="{{ request.url_for('detail_view_lid', project_lid=project.lid) }}?page={{ current_page }}&search={{ request.query_params.get('search', '') }}"
class="project-item-container">
<div class="project-item-preview-data pages-count">{{ project.pages }}</div>
{% if project.lid.startswith('pool_') %}
Expand Down

0 comments on commit ec2f1b1

Please sign in to comment.