Feature: dynamic title

This commit is contained in:
VnPower 2023-06-08 15:55:15 +07:00
parent 7383f23e76
commit 0f113f41d4
Signed by: vnpower
GPG key ID: 881DE3DEB966106C
9 changed files with 19 additions and 14 deletions

View file

@ -1,4 +1,4 @@
{{ template "header.html" .Context }} {{ $parent := . }} {{ template "header.html" .Title }} {{ $parent := . }}
<div class="container"> <div class="container">
<div class="artwork-page"> <div class="artwork-page">
{{ with .Illust }} {{ with .Illust }}

View file

@ -1,7 +1,7 @@
{{ template "header.html" }} {{ template "header.html" .Title}}
<div class="container"> <div class="container">
<h2>Newest works from all users</h2> <h2>Discover works</h2>
<div class="switcher"> <div class="switcher">
<span class="switch-title">Filter</span> <span class="switch-title">Filter</span>
<a href="/discovery?mode=all" class="switch-button">All</a> <a href="/discovery?mode=all" class="switch-button">All</a>

View file

@ -1,4 +1,4 @@
{{ template "header.html" }} {{ template "header.html" .Title }}
<div class="container" style="text-align: center"> <div class="container" style="text-align: center">
<h2>Error: {{ .Title }}</h2> <h2>Error: {{ .Title }}</h2>
{{ .Error }} {{ .Error }}

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
{{ if not .Title }} {{ if not . }}
<title>PixivFE</title> <title>PixivFE</title>
{{ else }} {{ else }}
<title>{{ . }} - PixivFE</title> <title>{{ . }} - PixivFE</title>

View file

@ -1,4 +1,4 @@
{{ template "header.html" }} {{ template "header.html" .Title}}
<div class="container"> <div class="container">
<h2>Newest works from all users</h2> <h2>Newest works from all users</h2>

View file

@ -1,4 +1,4 @@
{{ template "header.html" }} {{ template "header.html" .Title}}
<div class="container"> <div class="container">
<h2>{{ .Title }}</h2> <h2>{{ .Title }}</h2>

View file

@ -1,4 +1,4 @@
{{ template "header.html" }} {{ template "header.html" .Title}}
<div class="container"> <div class="container">
<div class="tag-header"> <div class="tag-header">

View file

@ -1,4 +1,4 @@
{{ template "header.html" }} {{ if isEmpty .User.BackgroundImage }} {{ template "header.html" .Title}} {{ if isEmpty .User.BackgroundImage }}
<div class="user-background-placeholder"></div> <div class="user-background-placeholder"></div>
{{ else }} {{ else }}
<div class="user-background"> <div class="user-background">

View file

@ -94,7 +94,7 @@ func user_page(c *gin.Context) {
worksCount, _ := PC.GetUserArtworksCount(id) worksCount, _ := PC.GetUserArtworksCount(id)
pageLimit := math.Ceil(float64(worksCount)/30.0) + 1.0 pageLimit := math.Ceil(float64(worksCount)/30.0) + 1.0
c.HTML(http.StatusOK, "user.html", gin.H{"User": user, "PageLimit": int(pageLimit), "Page": pageInt}) c.HTML(http.StatusOK, "user.html", gin.H{"Title": user.Name, "User": user, "PageLimit": int(pageLimit), "Page": pageInt})
} }
func ranking_page(c *gin.Context) { func ranking_page(c *gin.Context) {
@ -127,7 +127,9 @@ func ranking_page(c *gin.Context) {
return return
} }
c.HTML(http.StatusOK, "rank.html", gin.H{"Items": response.Artworks, c.HTML(http.StatusOK, "rank.html", gin.H{
"Title": "Ranking",
"Items": response.Artworks,
"Mode": mode, "Mode": mode,
"Content": content, "Content": content,
"Page": pageInt}) "Page": pageInt})
@ -154,7 +156,10 @@ func newest_artworks_page(c *gin.Context) {
return return
} }
c.HTML(http.StatusOK, "newest.html", gin.H{"Items": works}) c.HTML(http.StatusOK, "newest.html", gin.H{
"Items": works,
"Title": "Newest works",
})
} }
func search_page(c *gin.Context) { func search_page(c *gin.Context) {
@ -207,7 +212,7 @@ func search_page(c *gin.Context) {
"Mode": mode, "Mode": mode,
"Category": category, "Category": category,
} }
c.HTML(http.StatusOK, "tag.html", gin.H{"Tag": tag, "Data": result, "Queries": queries}) c.HTML(http.StatusOK, "tag.html", gin.H{"Title": "Results for " + tag.Name, "Tag": tag, "Data": result, "Queries": queries})
} }
func search(c *gin.Context) { func search(c *gin.Context) {
@ -232,7 +237,7 @@ func discovery_page(c *gin.Context) {
return return
} }
c.HTML(http.StatusOK, "discovery.html", gin.H{"Artworks": artworks}) c.HTML(http.StatusOK, "discovery.html", gin.H{"Title": "Discovery", "Artworks": artworks})
} }
func not_found_page(c *gin.Context) { func not_found_page(c *gin.Context) {