Proper assets template

This commit is contained in:
echarp 2022-11-13 16:50:48 +01:00
parent 16a7d81535
commit 184b062135
3 changed files with 35 additions and 18 deletions

View File

@ -9,8 +9,12 @@ const topSection = window.location.pathname.split('/')[1]
if (topSection) document.body.classList.add(topSection)
// Differentiate users and authors
if ('pages' === topSection)
if ('pages' === topSection) {
document.body.classList.add('author')
} else {
// Check if access is authorized to root page
fetch('/').then(() => document.body.classList.add('author'))
}
// Setup a "property" attribute, to send to the backend for insertion/update/deletion
document.querySelectorAll('body > header h1, main article header h1')

View File

@ -0,0 +1,27 @@
{{ define "main" }}
<article class="pa3 pa4-ns nested-copy-line-height">
<aside id="actions" class="w-30-l mt4-l fr tc">
<button class="br-pill pa3 pointer"><label for="file">{{ T (print .Section ".create") }}</label></button>
<input id="file" multiple name="file" type="file"/>
</aside>
{{ with .Content }}
<section id="content"
class="cf ph3 ph5-l pv3 pv4-l f4 tc-l center measure-wide lh-copy {{ $.Param "text_color" | default "mid-gray" }}">
{{- . -}}
</section>
{{ end }}
<section class="flex-ns flex-wrap justify-around">
{{ range .Resources }}
<div class="relative w-100 w-30-l mb4 bg-white">
<img src="{{ .RelPermalink }}" title="{{.}}" alt="{{.}}" />
{{ . }}
<button class="delete_image br-pill pa3 pointer" data-target="{{.RelPermalink}}">
{{ T (print $.Section ".delete") }}
</button>
</div>
{{ end }}
</section>
</article>
{{ end }}

View File

@ -1,12 +1,9 @@
{{ define "main" }}
<article class="pa3 pa4-ns nested-copy-line-height">
<aside id="actions" class="w-30-l mt4-l fr tc">
{{ if eq .Section "assets" }}
<button class="br-pill pa3 pointer"><label for="file">{{ T (print .Section ".create") }}</label></button>
<input id="file" multiple name="file" type="file"/>
{{ else if .Parent.IsHome }}
{{ if .Parent.IsHome }}
<button id="create" class="br-pill pa3 pointer">{{ T (print .Section ".create") }}</button>
{{ else }}
{{ else if .Parent.Parent.IsHome }}
<button id="delete" class="br-pill pa3 pointer">{{ T (print .Section ".delete") }}</button>
{{ end }}
</aside>
@ -33,19 +30,8 @@
{{ .Render "summary-with-image" }}
</div>
{{ end }}
{{- template "_internal/pagination.html" . -}}
{{ if .Parent.IsHome }}
{{ range .Resources }}
<div class="relative w-100 w-30-l mb4 bg-white">
<img src="{{ .RelPermalink }}" title="{{.}}" alt="{{.}}" />
{{ . }}
<button class="delete_image br-pill pa3 pointer" data-target="{{.RelPermalink}}">
{{ T (print $.Section ".delete") }}
</button>
</div>
{{ end }}
{{ end }}
{{- template "_internal/pagination.html" . -}}
{{ end }}
</section>
</article>