Feature: error page
This commit is contained in:
parent
fbc727efff
commit
516d68b8a6
5 changed files with 78 additions and 119 deletions
20
main.go
20
main.go
|
@ -35,6 +35,26 @@ func setup_router() *fiber.App {
|
||||||
EnableTrustedProxyCheck: true,
|
EnableTrustedProxyCheck: true,
|
||||||
TrustedProxies: []string{"0.0.0.0/0"},
|
TrustedProxies: []string{"0.0.0.0/0"},
|
||||||
ProxyHeader: fiber.HeaderXForwardedFor,
|
ProxyHeader: fiber.HeaderXForwardedFor,
|
||||||
|
ErrorHandler: func(c *fiber.Ctx, err error) error {
|
||||||
|
// Status code defaults to 500
|
||||||
|
code := fiber.StatusInternalServerError
|
||||||
|
|
||||||
|
// // Retrieve the custom status code if it's a *fiber.Error
|
||||||
|
// var e *fiber.Error
|
||||||
|
// if errors.As(err, &e) {
|
||||||
|
// code = e.Code
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Send custom error page
|
||||||
|
err = c.Status(code).Render("error", fiber.Map{"Title": code, "Error": err})
|
||||||
|
if err != nil {
|
||||||
|
// In case the SendFile fails
|
||||||
|
return c.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return from handler
|
||||||
|
return nil
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Use(logger.New())
|
server.Use(logger.New())
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{ template "header.html" .Title }}
|
|
||||||
<div class="container" style="text-align: center">
|
|
||||||
<h2>Error: {{ .Title }}</h2>
|
|
||||||
{{ .Error }}
|
|
||||||
</div>
|
|
||||||
{{ template "footer.html" }}
|
|
4
template/error.jet.html
Normal file
4
template/error.jet.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="container" style="text-align: center">
|
||||||
|
<h2>Error: {{ Title }}</h2>
|
||||||
|
{{ Error }}
|
||||||
|
</div>
|
|
@ -1,121 +1,63 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>{{ Title }}</h2>
|
<h2>{{ Title }}</h2>
|
||||||
|
|
||||||
<div class="switcher">
|
<div class="switcher">
|
||||||
<span class="switch-title">Content</span>
|
<span class="switch-title">Content</span>
|
||||||
<a href="/ranking?content=all&mode={{ Mode }}&page=1" class="switch-button"
|
<a href="/ranking?content=all&mode={{ Mode }}&page=1" class="switch-button">Overall</a>
|
||||||
>Overall</a
|
<a href="/ranking?content=illust&mode={{ Mode }}&page=1" class="switch-button">Illustrations</a>
|
||||||
>
|
<a href="/ranking?content=manga&mode={{ Mode }}&page=1" class="switch-button">Mangas</a>
|
||||||
<a
|
</div>
|
||||||
href="/ranking?content=illust&mode={{ Mode }}&page=1"
|
<br />
|
||||||
class="switch-button"
|
|
||||||
>Illustrations</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/ranking?content=manga&mode={{ Mode }}&page=1"
|
|
||||||
class="switch-button"
|
|
||||||
>Mangas</a
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<div class="switcher">
|
<div class="switcher">
|
||||||
<span class="switch-title">Modes</span>
|
<span class="switch-title">Modes</span>
|
||||||
<a
|
<a href="/ranking?content={{ Content }}&mode=daily&page=1" class="switch-button">Daily</a>
|
||||||
href="/ranking?content={{ Content }}&mode=daily&page=1"
|
<a href="/ranking?content={{ Content }}&mode=weekly&page=1" class="switch-button">Weekly</a>
|
||||||
class="switch-button"
|
<a href="/ranking?content={{ Content }}&mode=monthly&page=1" class="switch-button">Monthly</a>
|
||||||
>Daily</a
|
<a href="/ranking?content={{ Content }}&mode=rookie&page=1" class="switch-button">Rookie</a>
|
||||||
>
|
<span class="switch-seperator"></span>
|
||||||
<a
|
<a href="/ranking?content={{ Content }}&mode=daily_r18&page=1" class="switch-button">Daily (R-18)</a>
|
||||||
href="/ranking?content={{ Content }}&mode=weekly&page=1"
|
<a href="/ranking?content={{ Content }}&mode=weekly_r18&page=1" class="switch-button">Weekly (R-18)</a>
|
||||||
class="switch-button"
|
</div>
|
||||||
>Weekly</a
|
<br />
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode=monthly&page=1"
|
|
||||||
class="switch-button"
|
|
||||||
>Monthly</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode=rookie&page=1"
|
|
||||||
class="switch-button"
|
|
||||||
>Rookie</a
|
|
||||||
>
|
|
||||||
<span class="switch-seperator"></span>
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode=daily_r18&page=1"
|
|
||||||
class="switch-button"
|
|
||||||
>Daily (R-18)</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode=weekly_r18&page=1"
|
|
||||||
class="switch-button"
|
|
||||||
>Weekly (R-18)</a
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
|
|
||||||
{{ range Items }}
|
{{ range Items }}
|
||||||
<div class="artwork-thumbnail-small artwork-thumbnail artwork-mobile">
|
<div class="artwork-thumbnail-small artwork-thumbnail artwork-mobile">
|
||||||
<div class="artwork-rank-circle">{{ .Rank }}</div>
|
<div class="artwork-rank-circle">{{ .Rank }}</div>
|
||||||
{{ if toInt(.Pages) > 1 }}
|
{{ if toInt(.Pages) > 1 }}
|
||||||
<div class="artwork-page-count"><span>⧉ {{ .Pages }}</span></div>
|
<div class="artwork-page-count"><span>⧉ {{ .Pages }}</span></div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a href="/artworks/{{ .ID }}">
|
<a href="/artworks/{{ .ID }}">
|
||||||
<img
|
<img src="{{ .Image }}" alt="{{ .Title }}" class="artwork-master-image" />
|
||||||
src="{{ proxyImage(.Image) }}"
|
</a>
|
||||||
alt="{{ .Title }}"
|
|
||||||
class="artwork-master-image"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="artwork-thumbnail-title" href="/artworks/{{ .ID }}">
|
<a class="artwork-thumbnail-title" href="/artworks/{{ .ID }}">
|
||||||
<h3 class="no-margin">{{ .Title }}</h3>
|
<h3 class="no-margin">{{ .Title }}</h3>
|
||||||
</a>
|
</a>
|
||||||
<a href="/users/{{ .ArtistID }}" class="artwork-thumbnail-artist flex"
|
<a href="/users/{{ .ArtistID }}" class="artwork-thumbnail-artist flex"><img src="{{ .ArtistAvatar }}"
|
||||||
><img
|
alt="{{ .ArtistName }}" class="artwork-thumbnail-artist-avatar border-rounded" />
|
||||||
src="{{ proxyImage(.ArtistAvatar) }}"
|
{{ .ArtistName }}</a>
|
||||||
alt="{{ .ArtistName }}"
|
</div>
|
||||||
class="artwork-thumbnail-artist-avatar border-rounded"
|
|
||||||
/>
|
|
||||||
{{ .ArtistName }}</a
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<div class="pagination">
|
|
||||||
{{ if Page >= 1 }}
|
|
||||||
<a href="#" class="pagination-button disabled">First</a>
|
|
||||||
<a href="#" class="pagination-button disabled">Previous</a>
|
|
||||||
{{ else }}
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page=1"
|
|
||||||
class="pagination-button"
|
|
||||||
>First</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page={{ dec(Page) }}"
|
|
||||||
class="pagination-button"
|
|
||||||
>Previous</a
|
|
||||||
>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<a href="#" class="pagination-button disabled">{{ Page }}</a>
|
<div class="pagination">
|
||||||
|
{{ if Page >= 1 }}
|
||||||
|
<a href="#" class="pagination-button disabled">First</a>
|
||||||
|
<a href="#" class="pagination-button disabled">Previous</a>
|
||||||
|
{{ else }}
|
||||||
|
<a href="/ranking?content={{ Content }}&mode={{ Mode }}&page=1" class="pagination-button">First</a>
|
||||||
|
<a href="/ranking?content={{ Content }}&mode={{ Mode }}&page={{ dec(Page) }}"
|
||||||
|
class="pagination-button">Previous</a>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ if Page == 10 }}
|
<a href="#" class="pagination-button disabled">{{ Page }}</a>
|
||||||
<a href="#" class="pagination-button disabled">Next</a>
|
|
||||||
<a href="#" class="pagination-button disabled">Last</a>
|
{{ if Page == 10 }}
|
||||||
{{ else }}
|
<a href="#" class="pagination-button disabled">Next</a>
|
||||||
<a
|
<a href="#" class="pagination-button disabled">Last</a>
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page={{ inc(Page) }}"
|
{{ else }}
|
||||||
class="pagination-button"
|
<a href="/ranking?content={{ Content }}&mode={{ Mode }}&page={{ inc(Page) }}" class="pagination-button">Next</a>
|
||||||
>Next</a
|
<a href="/ranking?content={{ Content }}&mode={{ Mode }}&page=10" class="pagination-button">Last</a>
|
||||||
>
|
{{ end }}
|
||||||
<a
|
</div>
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page=10"
|
|
||||||
class="pagination-button"
|
|
||||||
>Last</a
|
|
||||||
>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -122,7 +122,6 @@ func ranking_page(c *fiber.Ctx) error {
|
||||||
if image_proxy == nil {
|
if image_proxy == nil {
|
||||||
image_proxy = &configs.ProxyServer
|
image_proxy = &configs.ProxyServer
|
||||||
}
|
}
|
||||||
|
|
||||||
mode := c.Query("mode", "daily")
|
mode := c.Query("mode", "daily")
|
||||||
|
|
||||||
content := c.Query("content", "all")
|
content := c.Query("content", "all")
|
||||||
|
|
Loading…
Reference in a new issue