From 130fbd52dd1c01ef79b2699851bc6cecdff5b61d Mon Sep 17 00:00:00 2001 From: VnPower Date: Wed, 14 Feb 2024 10:02:10 +0700 Subject: [PATCH 1/8] Fix ranking calendar images #57 --- core/config/session.go | 8 ++++++++ core/webapi/rankingCalendar.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/config/session.go b/core/config/session.go index 6e3ebe9..58d5163 100644 --- a/core/config/session.go +++ b/core/config/session.go @@ -34,6 +34,14 @@ func ProxyImageUrl(c *fiber.Ctx, s string) string { return s } +func ProxyImageUrlNoEscape(c *fiber.Ctx, s string) string { + proxy := GetImageProxy(c) + s = strings.ReplaceAll(s, `https://i.pximg.net`, "https://"+proxy) + // s = strings.ReplaceAll(s, `https:\/\/i.pximg.net`, "/proxy/i.pximg.net") + s = strings.ReplaceAll(s, `https://s.pximg.net`, "/proxy/s.pximg.net") + return s +} + func GetImageProxy(c *fiber.Ctx) string { sess, err := Store.Get(c) if err != nil { diff --git a/core/webapi/rankingCalendar.go b/core/webapi/rankingCalendar.go index 672c46c..4b369d3 100644 --- a/core/webapi/rankingCalendar.go +++ b/core/webapi/rankingCalendar.go @@ -64,7 +64,7 @@ func GetRankingCalendar(c *fiber.Ctx, mode string, year, month int) (template.HT for _, a := range n.Attr { if a.Key == "data-src" { // adds a new link entry when the attribute matches - links = append(links, session.ProxyImageUrl(c, a.Val)) + links = append(links, session.ProxyImageUrlNoEscape(c, a.Val)) } } } From 100ec92cb830cba6f2831effcf03d5c53333432e Mon Sep 17 00:00:00 2001 From: iacore Date: Wed, 14 Feb 2024 15:03:53 +0000 Subject: [PATCH 2/8] tweak htmx seems to better performance but i don't understand why --- views/layout.jet.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/layout.jet.html b/views/layout.jet.html index 495cbea..41d8077 100644 --- a/views/layout.jet.html +++ b/views/layout.jet.html @@ -32,7 +32,7 @@ {{ end }} - +