diff options
Diffstat (limited to 'views')
| -rw-r--r-- | views/layouts/general-page.html | 17 | ||||
| -rw-r--r-- | views/pages/blog-catalogue.html | 22 | ||||
| -rw-r--r-- | views/partials/catalogue-blog-card-tags.html | 1 | ||||
| -rw-r--r-- | views/partials/catalogue-blog-cards.html | 2 |
4 files changed, 32 insertions, 10 deletions
diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html index eab7cd1..46ef2e6 100644 --- a/views/layouts/general-page.html +++ b/views/layouts/general-page.html @@ -12,7 +12,7 @@ <link href="/output.css" rel="stylesheet"> </head> -<body data-theme="night" class="font-spectral text-main-dark overflow-hidden bg-interlocked-hexagons h-screen flex flex-row ar-lt-0.8:flex-col"> +<body data-theme="ram" class="font-spectral text-main-dark overflow-hidden bg-interlocked-hexagons h-screen flex flex-row ar-lt-0.8:flex-col"> <script> function switchTheme(theme) { @@ -29,10 +29,14 @@ document.body.setAttribute('data-theme', theme); } - const savedTheme = localStorage.getItem('theme') || 'night'; + const savedTheme = localStorage.getItem('theme') || 'ram'; switchTheme(savedTheme); </script> + <script> + const clientTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; + </script> + <div id="sidebar" class="bg-sidebar flex sticky flex-col ar-gt-0.8:items-center shadow-2xl z-20 w-[5vw] ar-lt-0.8:w-[90vw] ar-lt-0.4:w-[100vw] h-screen ar-lt-0.8:h-[8vh] ar-lt-0.8:ml-[5vw] ar-lt-0.4:ml-0"> <div class="logo-custom ar-lt-0.8:hidden text-sidebar font-patua font-extrabold text-center relative z-20"> saya.today @@ -49,13 +53,12 @@ <div class="pl-[0.5vw] bg-background-dark border-r-[0.4vmin] border-dashed border-main-dark"></div> <div class="ar-gt-0.8:min-w-fit ar-gt-0.8:max-w-[100vh] flex flex-col bg-background-dark relative pt-[1.6vmin] ml-[1.6vmin] pr-[1.6vmin]"> - <div class="flex flex-row mb-[0.4vmin]"> + <div {{ if .PublishedDate }} hx-get="/api/v1/tz" hx-vals='js:{timestamp: "{{ .PublishedDate }}", tz: clientTimeZone}' hx-target="#published-date" hx-swap="innerHTML" hx-trigger="load" {{ end }} + class="flex flex-row mb-[0.4vmin]"> <i onclick="location.pathname += location.pathname.endsWith('/') ? '../' : '/../';" class="fas fa-circle-left hover:bg-main-dark hover:bg-opacity-10 cursor-pointer transition-colors duration-300 rounded-md text-[2vmax] mt-auto mb-auto px-[0.8vmin]"></i> <p class="text-[2vmax] font-spectral italic font-extrabold select-none mt-auto pl-[0.8vmin] pr-[1.2vmin]">//</p> <p class="text-[2vmax] font-spectral italic text-left mt-auto">{{ .Title }}</p> - {{- if .PublishedDate }} - <p class="grow text-[1.5vmax] font-spectral text-secondary text-right mt-auto">{{ .PublishedDate }}</p> - {{- end }} + <p id="published-date" class="grow text-[1.5vmax] font-spectral text-secondary text-right mt-auto">{{ .PublishedDate }}</p> </div> <hr class="border-t-4 border-dotted border-main-dark mb-[0.8vmin]"> @@ -76,6 +79,8 @@ <div class="pr-[0.5vw] bg-background-dark shadow-2xl border-l-[0.4vmin] border-dotted border-main-dark"></div> </div> + <script src="https://f003.backblazeb2.com/file/sayana-static/libs/htmx/2.0.6/htmx.min.js"></script> + {{ block "footer" . }}{{ end }} </body> diff --git a/views/pages/blog-catalogue.html b/views/pages/blog-catalogue.html index 6c0f629..2b248c3 100644 --- a/views/pages/blog-catalogue.html +++ b/views/pages/blog-catalogue.html @@ -49,7 +49,7 @@ <div class="w-[0.5vh] border-r-[0.3vh] border-dotted border-main-dark bg-background-dark"></div> - <div hx-get="/api/v1/blog-search" hx-vals='{"lang": "{{ .Lang }}"}' hx-target="this" hx-swap="innerHTML" hx-trigger="load" hx-include=".tags-list" + <div hx-get="/api/v1/blog-search" hx-vals='js:{lang: "{{ .Lang }}", tz: clientTimeZone}' hx-target="this" hx-swap="innerHTML" hx-trigger="load" hx-include=".tags-list" class="blog-cards grow flex flex-col overflow-y-auto bg-background-light inset-shadow p-[2.4vmin]"> Loading... </div> @@ -57,8 +57,6 @@ {{ end }} {{ define "footer" }} -<script src="https://f003.backblazeb2.com/file/sayana-static/libs/htmx/2.0.6/htmx.min.js"></script> - <script> function selectAll() { const tagsContainers = document.querySelectorAll('form.tags-list'); @@ -120,6 +118,24 @@ window.history.pushState({}, '', url.toString()); } + function pickedTagSetHrefParams(tag) { + const url = new URL(window.location.href); + url.searchParams.delete('tags[]'); + url.searchParams.set('tags[]', tag); + + const tagsContainers = document.querySelectorAll('form.tags-list'); + tagsContainers.forEach(tagsContainer => { + const checkboxes = tagsContainer.querySelectorAll('input[type="checkbox"]'); + checkboxes.forEach(checkbox => { + checkbox.checked = false; + }); + chosenCheckbox = tagsContainer.querySelector(`#tag${tag}Checkbox`); + chosenCheckbox.checked = true; + }); + + window.history.pushState({}, '', url.toString()); + } + document.addEventListener('DOMContentLoaded', contextAll); </script> diff --git a/views/partials/catalogue-blog-card-tags.html b/views/partials/catalogue-blog-card-tags.html new file mode 100644 index 0000000..374314a --- /dev/null +++ b/views/partials/catalogue-blog-card-tags.html @@ -0,0 +1 @@ +{{ range $i, $tag := .Tags }}{{ if ne $i 0 }}, {{ end }}<a hx-trigger="click" hx-get="/api/v1/blog-search" hx-target=".blog-cards" hx-swap="innerHTML" hx-trigger="load" hx-include=".tags-list" class="hx-anchor cursor-pointer" onclick="pickedTagSetHrefParams({{ $tag }})">{{ $tag }}</a>{{ end }}
\ No newline at end of file diff --git a/views/partials/catalogue-blog-cards.html b/views/partials/catalogue-blog-cards.html index a9e4010..406ef9b 100644 --- a/views/partials/catalogue-blog-cards.html +++ b/views/partials/catalogue-blog-cards.html @@ -12,7 +12,7 @@ <p class="flex-3/12 grow-0 text-[1vmax] italic text-secondary text-right">{{ .PublishedTime }}</p> </div> <p class="text-[1vmax] text-main-dark">{{ .ShortDescription }}</p> - <p class="text-[1vmax] text-secondary">{{ .L.TagsLabel }} {{ .Tags }}</p> + <p class="text-[1vmax] text-secondary">{{ $.L.TagsLabel }} {{ template "catalogue-blog-card-tags.html" . }}</p> </div> </div> {{- end }}
\ No newline at end of file |