From b1355436e96f2dfa777e843b53896d0bb71628e3 Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Sat, 4 Apr 2026 03:03:29 +0700 Subject: feat: replace font-andika feat: replace noise image with lighter paper texture refactor: put colors in tailwind theme block --- views/partials/catalogue-blog-cards.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'views/partials/catalogue-blog-cards.html') diff --git a/views/partials/catalogue-blog-cards.html b/views/partials/catalogue-blog-cards.html index b50f419..45fef12 100644 --- a/views/partials/catalogue-blog-cards.html +++ b/views/partials/catalogue-blog-cards.html @@ -6,18 +6,18 @@
- + {{ .Title }} // {{ .ActionDate }} -

{{ .PublishedTime }}

+

{{ .PublishedTime }}

{{ .ShortDescription }}

{{ .LikeCount }} - // + // {{ .ViewCount }}

-- cgit v1.3.1+17 From 99294b260661a8d3f6992404de7881945eab837b Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Sat, 4 Apr 2026 05:59:30 +0700 Subject: feat: redo the design of blog catalog article rows --- views/pages/blog-catalogue.html | 2 +- views/partials/catalogue-blog-cards.html | 53 +++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 19 deletions(-) (limited to 'views/partials/catalogue-blog-cards.html') diff --git a/views/pages/blog-catalogue.html b/views/pages/blog-catalogue.html index 7e02ced..2584bda 100644 --- a/views/pages/blog-catalogue.html +++ b/views/pages/blog-catalogue.html @@ -58,7 +58,7 @@
+ class="blog-cards relative grow flex flex-col overflow-y-auto bg-paper bg-background-light pr-2"> Loading...
diff --git a/views/partials/catalogue-blog-cards.html b/views/partials/catalogue-blog-cards.html index 45fef12..4333c77 100644 --- a/views/partials/catalogue-blog-cards.html +++ b/views/partials/catalogue-blog-cards.html @@ -1,27 +1,44 @@ {{- range .BlogPages }} -
-
- - - -
+
+
+
+ +
+
+ + + Smiley Thumbs Up Streamline Icon: https://streamlinehq.com + + + + + + + + {{ .LikeCount }} +
+
+ + + View Eye 1 Streamline Icon: https://streamlinehq.com + + + + + {{ .ViewCount }} +
+
+
+
-

{{ .ShortDescription }}

-

- - {{ .LikeCount }} - // - - {{ .ViewCount }} -

-

{{ $.L.TagsLabel }} {{ template "catalogue-blog-card-tags.html" . }}

+

{{ .ShortDescription }}

+

{{ $.L.TagsLabel }} {{ template "catalogue-blog-card-tags.html" . }}

{{- end }} \ No newline at end of file -- cgit v1.3.1+17 From ad6528e1ba16ac9857dff879276834b1b5161382 Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Sun, 5 Apr 2026 04:42:31 +0700 Subject: feat: redesign catalog sidebar feat: add indicators on catalog if user liked or viewed the page feat: add accent colors for each theme --- internal/router/handlers/api-v1-blog-search.go | 2 + static/input.css | 27 ++++- views/pages/blog-catalogue.html | 158 ++++++++++++++++++++----- views/partials/catalogue-blog-cards.html | 18 +-- 4 files changed, 164 insertions(+), 41 deletions(-) (limited to 'views/partials/catalogue-blog-cards.html') diff --git a/internal/router/handlers/api-v1-blog-search.go b/internal/router/handlers/api-v1-blog-search.go index a0316e2..1e8a480 100644 --- a/internal/router/handlers/api-v1-blog-search.go +++ b/internal/router/handlers/api-v1-blog-search.go @@ -91,7 +91,9 @@ func (r *BlogSearchHandler) Render(c *fiber.Ctx, supplements *router.Supplements "Thumbnail": page.Metadata.Thumbnail, "Tags": page.Metadata.Tags, "LikeCount": supplements.ClientCache.GetLikeCount(page.FileName), + "Liked": supplements.ClientCache.GetLikeStatus(c.IP(), page.FileName), "ViewCount": supplements.ClientCache.GetViewCount(page.FileName), + "Viewed": supplements.ClientCache.GetViewStatus(c.IP(), page.FileName), }) break } diff --git a/static/input.css b/static/input.css index 11de22c..375caa4 100644 --- a/static/input.css +++ b/static/input.css @@ -1,6 +1,7 @@ @import url('https://fonts.googleapis.com/css2?family=Gentium+Plus:ital,wght@0,400;0,700;1,400;1,700&family=M+PLUS+Rounded+1c:wght@100;300;400;500;700;800;900&display=swap'); @import "tailwindcss"; +@plugin "@tailwindcss/forms"; @theme { --font-m-plus: "M PLUS Rounded 1c", sans-serif; @@ -13,6 +14,14 @@ --color-background-medium: var(--color-background-medium); --color-background-light: var(--color-background-light); --color-secondary: var(--color-secondary); + --color-accent-light: var(--color-accent-light); + --color-accent-deep: var(--color-accent-deep); + --color-main-light-hard: var(--color-main-light-hard); + --color-main-light-medium: var(--color-main-light-medium); + --color-main-light-soft: var(--color-main-light-soft); + --color-main-dark-hard: var(--color-main-dark-hard); + --color-main-dark-medium: var(--color-main-dark-medium); + --color-main-dark-soft: var(--color-main-dark-soft); } html { @@ -78,6 +87,8 @@ body { } [data-theme="olive"] { + --color-accent-light: var(--color-lime-300); + --color-accent-deep: var(--color-lime-600); --color-main-dark-hard: #4b513a; --color-main-dark-medium: #8a9d8a; --color-main-dark-soft: #a5b8a5; @@ -106,6 +117,8 @@ body { } [data-theme="lettuce"] { + --color-accent-light: var(--color-lime-300); + --color-accent-deep: var(--color-lime-600); --color-main-dark-hard: #384a0c; --color-main-dark-medium: #617c1f; --color-main-dark-soft: #9bb665; @@ -134,6 +147,8 @@ body { } [data-theme="night"] { + --color-accent-light: var(--color-indigo-900); + --color-accent-deep: var(--color-indigo-500); --color-main-light-hard: var(--color-sky-100); --color-main-light-medium: var(--color-sky-200); --color-main-light-soft: var(--color-sky-300); @@ -162,6 +177,8 @@ body { } [data-theme="ram"] { + --color-accent-light: var(--color-orange-800); + --color-accent-deep: var(--color-orange-300); --color-main-light-hard: #fefad8; --color-main-light-medium: #f6e4c5; --color-main-light-soft: #e8d4b8; @@ -190,6 +207,8 @@ body { } [data-theme="lilac"] { + --color-accent-light: var(--color-indigo-300); + --color-accent-deep: var(--color-indigo-800); --color-main-dark-hard: #343b58; --color-main-dark-medium: #414868; --color-main-dark-soft: #6c6e75; @@ -650,12 +669,12 @@ body[data-theme~="ram"] .leaflet-tile { min-width: fit-content; } - .ar-gt-0\.8\:min-w-\[10dvh\] { - min-width: 10dvh; + .ar-gt-0\.8\:min-w-1\/10 { + min-width: 10%; } - .ar-gt-0\.8\:max-w-\[20dvh\] { - max-width: 20dvh; + .ar-gt-0\.8\:max-w-1\/4 { + max-width: 25%; } .ar-gt-0\.8\:items-center { diff --git a/views/pages/blog-catalogue.html b/views/pages/blog-catalogue.html index 2584bda..2f0b45f 100644 --- a/views/pages/blog-catalogue.html +++ b/views/pages/blog-catalogue.html @@ -1,53 +1,155 @@ {{ define "body" }}
-
+
- {{ .L.BlogSearch.TagsHeader }} -
-
- -
- {{- range .Tags }} -
- -
- {{- end }} -
-
-
{{ .L.BlogSearch.OrderByHeader }}
-
- +
+
-
- +
+
-
- +
+
-
- +
+ +
+
+
+
+ +
+
+
+
+ {{ .L.BlogSearch.TagsHeader }} +
- +
+ {{- range .Tags }}
- +
+ {{- end }}

-
- +
+
-
diff --git a/views/partials/catalogue-blog-cards.html b/views/partials/catalogue-blog-cards.html index 4333c77..7096c0d 100644 --- a/views/partials/catalogue-blog-cards.html +++ b/views/partials/catalogue-blog-cards.html @@ -4,26 +4,26 @@
-
+
Smiley Thumbs Up Streamline Icon: https://streamlinehq.com - - - - - + + + + + {{ .LikeCount }}
-
+
View Eye 1 Streamline Icon: https://streamlinehq.com - - + + {{ .ViewCount }}
-- cgit v1.3.1+17 From 2d727cc1eeb926f5b5ee578a0ee54269e0390a96 Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Sat, 2 May 2026 12:58:40 +0700 Subject: refactor: parametrize static & photo storage url refactor: parametrize allow origins --- config/config.go | 23 ++++++++++++++++ config/config.local.yaml | 22 +++++++++++++++ config/config.prod.yaml | 22 +++++++++++++++ config/config.stage.yaml | 22 +++++++++++++++ internal/glightbox/extension.go | 11 +++++--- internal/glightbox/html_renderer.go | 42 ++++++++++++++++++++--------- internal/router/handlers/lang-blog-title.go | 2 +- internal/router/handlers/lang.go | 10 +++++-- internal/router/router.go | 42 ++++++++++++++++++----------- views/layouts/general-page.html | 16 +++++------ views/messages/new-post.html | 2 +- views/pages/global-map.html | 14 +++++----- views/pages/home-page.html | 2 +- views/partials/catalogue-blog-cards.html | 2 +- 14 files changed, 178 insertions(+), 54 deletions(-) (limited to 'views/partials/catalogue-blog-cards.html') diff --git a/config/config.go b/config/config.go index ebe0367..536a333 100644 --- a/config/config.go +++ b/config/config.go @@ -20,6 +20,9 @@ type Config struct { Mail MailConfig `json:"Mail" yaml:"mail" validate:"required"` CanonicalEndpoint string `json:"CanonicalEndpoint" yaml:"canonicalEndpoint" validate:"required"` Meta MetaConfig `json:"Meta" yaml:"meta"` + PhotoStorage PhotoStorageConfig `json:"PhotoStorage" yaml:"photoStorage"` + StaticStorage PhotoTypeConfig `json:"StaticStorage" yaml:"staticStorage"` + AllowOrigins []string `json:"AllowOrigins" yaml:"allowOrigins"` } type BlogPagesConfig struct { @@ -158,6 +161,26 @@ type MetaConfig struct { GoogleSiteVerification string `json:"GoogleSiteVerification" yaml:"googleSiteVerification"` } +type PhotoStorageConfig struct { + Full PhotoTypeConfig `json:"Full" yaml:"full" validate:"required"` + Webp PhotoTypeConfig `json:"Webp" yaml:"webp"` + Thumbnail1600p PhotoTypeConfig `json:"Thumbnail1600p" yaml:"thumbnail1600p"` + Thumbnail1200p PhotoTypeConfig `json:"Thumbnail1200p" yaml:"thumbnail1200p"` + Thumbnail800p PhotoTypeConfig `json:"Thumbnail800p" yaml:"thumbnail800p"` + Thumbnail560p PhotoTypeConfig `json:"Thumbnail560p" yaml:"thumbnail560p"` + Thumbnail320p PhotoTypeConfig `json:"Thumbnail320p" yaml:"thumbnail320p"` + HomePageGifs HomePageGifsConfig `json:"HomePageGifs" yaml:"homePageGifs"` +} + +type PhotoTypeConfig struct { + BaseUrl string `json:"BaseUrl" yaml:"baseUrl" validate:"url,required"` +} + +type HomePageGifsConfig struct { + BaseUrl string `json:"BaseUrl" yaml:"baseUrl" validate:"url,required"` + Indexes []string `json:"Indexes" yaml:"indexes"` +} + func LoadConfig(path string, config *Config) error { fileBytes, err := os.ReadFile(path) if err != nil { diff --git a/config/config.local.yaml b/config/config.local.yaml index c02dc2d..d312504 100644 --- a/config/config.local.yaml +++ b/config/config.local.yaml @@ -46,3 +46,25 @@ mail: trigger: onNewPost: "* * * * *" canonicalEndpoint: 'http://127.0.0.1:3000' +photoStorage: + full: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/full/%s + webp: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp/%s.webp + thumbnail1600p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-1600p/%s.webp + thumbnail1200p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-1200p/%s.webp + thumbnail800p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-800p/%s.webp + thumbnail560p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-560p/%s.webp + thumbnail320p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-320p/%s.webp + homePageGifs: + baseUrl: https://f003.backblazeb2.com/file/sayana-static/home-page-gifs/otter-%s.gif + indexes: ['1', '2', '3'] +staticStorage: + baseUrl: https://f003.backblazeb2.com/file/sayana-static +allowOrigins: + - https://f003.backblazeb2.com diff --git a/config/config.prod.yaml b/config/config.prod.yaml index b40ba57..2c5a159 100644 --- a/config/config.prod.yaml +++ b/config/config.prod.yaml @@ -47,3 +47,25 @@ mail: canonicalEndpoint: 'https://${FQDN}' meta: googleSiteVerification: '${GOOGLE_SITE_VERIFICATION}' +photoStorage: + full: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/full/%s + webp: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp/%s.webp + thumbnail1600p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-1600p/%s.webp + thumbnail1200p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-1200p/%s.webp + thumbnail800p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-800p/%s.webp + thumbnail560p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-560p/%s.webp + thumbnail320p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-320p/%s.webp + homePageGifs: + baseUrl: https://f003.backblazeb2.com/file/sayana-static/home-page-gifs/otter-%s.gif + indexes: ['1', '2', '3'] +staticStorage: + baseUrl: https://f003.backblazeb2.com/file/sayana-static +allowOrigins: + - https://f003.backblazeb2.com diff --git a/config/config.stage.yaml b/config/config.stage.yaml index efa94ae..0889c19 100644 --- a/config/config.stage.yaml +++ b/config/config.stage.yaml @@ -45,3 +45,25 @@ mail: trigger: onNewPost: "0/3 * * * *" canonicalEndpoint: 'https://${FQDN}' +photoStorage: + full: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/full/%s + webp: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp/%s.webp + thumbnail1600p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-1600p/%s.webp + thumbnail1200p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-1200p/%s.webp + thumbnail800p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-800p/%s.webp + thumbnail560p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-560p/%s.webp + thumbnail320p: + baseUrl: https://f003.backblazeb2.com/file/sayana-photos/webp-320p/%s.webp + homePageGifs: + baseUrl: https://f003.backblazeb2.com/file/sayana-static/home-page-gifs/otter-%s.gif + indexes: ['1', '2', '3'] +staticStorage: + baseUrl: https://f003.backblazeb2.com/file/sayana-static +allowOrigins: + - https://f003.backblazeb2.com diff --git a/internal/glightbox/extension.go b/internal/glightbox/extension.go index 7fd17b1..e9a9f3e 100644 --- a/internal/glightbox/extension.go +++ b/internal/glightbox/extension.go @@ -1,6 +1,7 @@ package glightbox import ( + "github.com/SayaAndy/saya-today-web/config" "github.com/yuin/goldmark" "github.com/yuin/goldmark/parser" "github.com/yuin/goldmark/renderer" @@ -8,10 +9,12 @@ import ( ) // Extension that combines parser and renderer -type GLightboxExtension struct{} +type GLightboxExtension struct { + photoStorage config.PhotoStorageConfig +} -func NewGLightboxExtension() goldmark.Extender { - return &GLightboxExtension{} +func NewGLightboxExtension(photoStorage config.PhotoStorageConfig) goldmark.Extender { + return &GLightboxExtension{photoStorage} } func (e *GLightboxExtension) Extend(m goldmark.Markdown) { @@ -22,7 +25,7 @@ func (e *GLightboxExtension) Extend(m goldmark.Markdown) { ) m.Renderer().AddOptions( renderer.WithNodeRenderers( - util.Prioritized(NewGLightboxHTMLRenderer(), 500), + util.Prioritized(NewGLightboxHTMLRenderer(e.photoStorage), 500), ), ) } diff --git a/internal/glightbox/html_renderer.go b/internal/glightbox/html_renderer.go index f71a8f2..b2cd855 100644 --- a/internal/glightbox/html_renderer.go +++ b/internal/glightbox/html_renderer.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/SayaAndy/saya-today-web/config" "github.com/SayaAndy/saya-today-web/internal/tailwind" "github.com/yuin/goldmark" "github.com/yuin/goldmark/ast" @@ -21,9 +22,10 @@ type GLightboxHTMLRenderer struct { html.Config md goldmark.Markdown anchorMatchRe *regexp.Regexp + photoStorage config.PhotoStorageConfig } -func NewGLightboxHTMLRenderer(opts ...html.Option) renderer.NodeRenderer { +func NewGLightboxHTMLRenderer(photoStorage config.PhotoStorageConfig, opts ...html.Option) renderer.NodeRenderer { r := &GLightboxHTMLRenderer{ Config: html.NewConfig(), md: goldmark.New( @@ -44,11 +46,12 @@ func NewGLightboxHTMLRenderer(opts ...html.Option) renderer.NodeRenderer { ), ), ), + anchorMatchRe: regexp.MustCompile(`(?s)<\s*a(\s+[^<]*)(href\s*=\s*["'].*?["'])\s*([^<]*)>(.*?)<\s*\/\s*a\s*>`), + photoStorage: photoStorage, } for _, opt := range opts { opt.SetHTMLOption(&r.Config) } - r.anchorMatchRe = regexp.MustCompile(`(?s)<\s*a(\s+[^<]*)(href\s*=\s*["'].*?["'])\s*([^<]*)>(.*?)<\s*\/\s*a\s*>`) return r } @@ -111,19 +114,32 @@ func (r *GLightboxHTMLRenderer) renderGLightbox(w util.BufWriter, source []byte, anchorlessCaptionHTML := r.anchorMatchRe.ReplaceAll(captionHTML, []byte("$4")) elements = append(elements, fmt.Sprintf(` - + - - - - - - + + + + + + -

%s

- %d -
`, fullImageUrl, strings.Join(tagClassList, " "), galleryID, dayDate.Format("2006-01-02 15:04:05 -07:00"), dataDescriptionAttribute, imageUrlWithoutExt, imageUrlWithoutExt, imageUrlWithoutExt, imageUrlWithoutExt, imageUrlWithoutExt, imageUrlWithoutExt, anchorlessCaptionHTML, i+1)) +

%[5]s

+ %[6]d + `, + strings.Join(tagClassList, " "), + galleryID, + dayDate.Format("2006-01-02 15:04:05 -07:00"), + dataDescriptionAttribute, + anchorlessCaptionHTML, + i+1, + fmt.Sprintf(r.photoStorage.Full.BaseUrl, fullImageUrl), + fmt.Sprintf(r.photoStorage.Thumbnail1600p.BaseUrl, imageUrlWithoutExt), + fmt.Sprintf(r.photoStorage.Thumbnail1200p.BaseUrl, imageUrlWithoutExt), + fmt.Sprintf(r.photoStorage.Thumbnail800p.BaseUrl, imageUrlWithoutExt), + fmt.Sprintf(r.photoStorage.Thumbnail560p.BaseUrl, imageUrlWithoutExt), + fmt.Sprintf(r.photoStorage.Thumbnail320p.BaseUrl, imageUrlWithoutExt), + )) if glightboxDescId != "" { elements = append(elements, fmt.Sprintf(` diff --git a/internal/router/handlers/lang-blog-title.go b/internal/router/handlers/lang-blog-title.go index f1be0a5..49744c1 100644 --- a/internal/router/handlers/lang-blog-title.go +++ b/internal/router/handlers/lang-blog-title.go @@ -74,7 +74,7 @@ func (r *BlogPageHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, return []router.MetaField{ {Property: "og:title", Content: metadata.Title}, {Property: "og:description", Content: fmt.Sprintf("%s [%s]", metadata.ShortDescription, metadata.ActionDate)}, - {Property: "og:image", Content: fmt.Sprintf("https://f003.backblazeb2.com/file/sayana-photos/webp-320p/%s.webp", metadata.Thumbnail)}, + {Property: "og:image", Content: fmt.Sprintf(supplements.PhotoStorage.Thumbnail320p.BaseUrl, metadata.Thumbnail)}, {Property: "og:url", Content: fmt.Sprintf("%s/%s/blog/%s", templateMap["CanonicalEndpoint"], lang, c.Params("title"))}, {Property: "og:type", Content: "website"}, {Name: "twitter:card", Content: "summary_large_image"}, diff --git a/internal/router/handlers/lang.go b/internal/router/handlers/lang.go index c618353..25b5036 100644 --- a/internal/router/handlers/lang.go +++ b/internal/router/handlers/lang.go @@ -53,7 +53,10 @@ func (r *HomeHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lan return []router.MetaField{ {Property: "og:title", Content: supplements.Localization[lang].HomePage.Header}, {Property: "og:description", Content: supplements.Localization[lang].HomePage.HomePageDescription}, - {Property: "og:image", Content: fmt.Sprintf("https://f003.backblazeb2.com/file/sayana-static/home-page-gifs/otter-%d.gif", rand.Int()%3+1)}, + {Property: "og:image", Content: fmt.Sprintf( + supplements.PhotoStorage.HomePageGifs.BaseUrl, + supplements.PhotoStorage.HomePageGifs.Indexes[rand.Int()%len(supplements.PhotoStorage.HomePageGifs.Indexes)], + )}, {Property: "og:url", Content: fmt.Sprintf("%s/%s", templateMap["CanonicalEndpoint"], lang)}, {Property: "og:type", Content: "website"}, }, nil @@ -63,7 +66,10 @@ func (r *HomeHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplements, templateMap["Title"] = supplements.Localization[lang].HomePage.Header templateMap["FilledHeartCount"] = uint(40) templateMap["OutlineHeartCount"] = uint(40) - templateMap["GifName"] = fmt.Sprintf("otter-%d.gif", rand.Int()%3+1) + templateMap["GifUrl"] = fmt.Sprintf( + supplements.PhotoStorage.HomePageGifs.BaseUrl, + supplements.PhotoStorage.HomePageGifs.Indexes[rand.Int()%len(supplements.PhotoStorage.HomePageGifs.Indexes)], + ) templateMap["FunFacts"] = supplements.FactGiver.Give(lang) return fiber.StatusOK, nil } diff --git a/internal/router/router.go b/internal/router/router.go index e8fb47a..926d21a 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -101,6 +101,8 @@ type Supplements struct { TemplateManager *templatemanager.TemplateManager MarkdownRenderer goldmark.Markdown Meta config.MetaConfig + PhotoStorage config.PhotoStorageConfig + StaticStorage config.PhotoTypeConfig } type Router struct { @@ -156,7 +158,7 @@ func NewRouter(cfg *config.Config) (*Router, error) { supplements.MarkdownRenderer = goldmark.New( goldmark.WithExtensions( - glightbox.NewGLightboxExtension(), + glightbox.NewGLightboxExtension(cfg.PhotoStorage), tailwind.NewTailwindExtension(), ), goldmark.WithParserOptions( @@ -217,6 +219,8 @@ func NewRouter(cfg *config.Config) (*Router, error) { } supplements.Meta = cfg.Meta + supplements.PhotoStorage = cfg.PhotoStorage + supplements.StaticStorage = cfg.StaticStorage enablePrintRoutes := false if cfg.LogLevel <= slog.LevelDebug { @@ -229,7 +233,7 @@ func NewRouter(cfg *config.Config) (*Router, error) { }) app.Use(cors.New(cors.Config{ - AllowOrigins: "https://f003.backblazeb2.com", + AllowOrigins: strings.Join(cfg.AllowOrigins, ","), AllowMethods: "GET,POST,OPTIONS", AllowHeaders: "Origin, Content-Type, Accept", })) @@ -299,11 +303,13 @@ func (r *Router) InitRoutes() (err error) { } defaultMap := fiber.Map{ - "L": r.supplements.Localization[lang], - "Lang": lang, - "Path": trimmedPath, - "QueryString": queryString, - "CanonicalEndpoint": r.canonicalEndpoint, + "L": r.supplements.Localization[lang], + "Lang": lang, + "Path": trimmedPath, + "QueryString": queryString, + "CanonicalEndpoint": r.canonicalEndpoint, + "StaticStorageBaseUrl": r.supplements.StaticStorage.BaseUrl, + "ThumbnailBaseUrl": r.supplements.PhotoStorage.Thumbnail320p.BaseUrl, } statusCode, err := currentRoute.Render(c, r.supplements, lang, defaultMap) @@ -423,10 +429,12 @@ func (r *Router) generalPage(c *fiber.Ctx, route Route, lang string) error { } valueMap := fiber.Map{ - "L": r.supplements.Localization[lang], - "Lang": lang, - "QueryString": queryString, - "CanonicalEndpoint": r.canonicalEndpoint, + "L": r.supplements.Localization[lang], + "Lang": lang, + "QueryString": queryString, + "CanonicalEndpoint": r.canonicalEndpoint, + "StaticStorageBaseUrl": r.supplements.StaticStorage.BaseUrl, + "ThumbnailBaseUrl": r.supplements.PhotoStorage.Thumbnail320p.BaseUrl, } var err error @@ -503,11 +511,13 @@ func (r *Router) generalPageSegment(c *fiber.Ctx, part string) error { var statusCode int defaultMap := fiber.Map{ - "L": r.supplements.Localization[lang], - "Lang": lang, - "Path": strings.Trim(path, "/"), - "QueryString": queryString, - "CanonicalEndpoint": r.canonicalEndpoint, + "L": r.supplements.Localization[lang], + "Lang": lang, + "Path": strings.Trim(path, "/"), + "QueryString": queryString, + "CanonicalEndpoint": r.canonicalEndpoint, + "StaticStorageBaseUrl": r.supplements.StaticStorage.BaseUrl, + "ThumbnailBaseUrl": r.supplements.PhotoStorage.Thumbnail320p.BaseUrl, } switch part { diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html index b620566..1265266 100644 --- a/views/layouts/general-page.html +++ b/views/layouts/general-page.html @@ -13,8 +13,8 @@ {{- end }} {{- end }} - - + + {{- with .LinkedData }} - + - - - + + + + - - + + +