Attempt to better manage basic auth headers

This commit is contained in:
echarp 2022-11-25 18:43:00 +01:00
parent c54ecd9a87
commit cf5ae1bf82
6 changed files with 45 additions and 75 deletions

View File

@ -14,8 +14,8 @@ if ('pages' === topSection) {
} else {
// Special URL which does not require authentication but returns browser's headers
// thus we can deduce if user is authenticated
fetch('/author')
.then(result => { if (result.headers.get('authorization')) document.body.classList.add('author') })
//fetch('/author')
// .then(result => { if (result.headers.get('authorization')) document.body.classList.add('author') })
}
// Setup a "property" attribute, to send to the backend for insertion/update/deletion

View File

@ -1,5 +1,5 @@
{{ define "main" }}
<article class="pa3 pa4-ns nested-copy-line-height">
<section 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"/>
@ -25,5 +25,5 @@
</div>
{{ end }}
</section>
</article>
</section>
{{ end }}

View File

@ -1,5 +1,5 @@
{{ define "main" }}
<article class="pa3 pa4-ns nested-copy-line-height">
<section class="pa3 pa4-ns nested-copy-line-height">
<aside id="actions" class="w-30-l mt4-l fr tc">
{{ if .Parent.IsHome }}
<button id="create"
@ -23,23 +23,9 @@
{{ end }}
<section class="flex-ns flex-wrap justify-around">
{{ if .Parent.IsHome }}
{{ range .Sections }}
<div class="relative w-100 w-30-l mb4 bg-white">
{{ .Render "summary-with-image" }}
</div>
{{ end }}
{{ else }}
{{ range (.Paginate .RegularPagesRecursive).Pages }}
<div class="relative w-100 mb4 bg-white">
{{ .Render "summary-with-image" }}
</div>
{{ end }}
{{- template "_internal/pagination.html" . -}}
{{ range .Pages }}
{{ .Render "summary-with-image" }}
{{ end }}
</section>
</article>
</section>
{{ end }}

View File

@ -1,33 +1,31 @@
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
<article class="bb b--black-10">
<div class="db pa3-ns no-underline dark-gray">
<div class="flex flex-column flex-row-ns">
{{$.Site.Language.LanguageDirection}}
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
<div class="mb4 mb0-ns w-100 w-40-ns {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3-ns" "pr3-ns" }}">
<a href="{{.RelPermalink}}" class="db grow">
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
</a>
</div>
{{ end }}
<div class="blah w-100{{ if $featured_image }} w-60-ns{{ end }}">
{{ if and (eq .Section "users") (.IsPage) }}
<div class="breadcrumb">{{- partial "breadcrumb" . -}}</div>
{{ end }}
<h1 class="f3 fw1 athelas mt0 lh-title">
<a href="{{.RelPermalink}}" class="color-inherit dim link">
{{ .Title }}
</a>
</h1>
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
{{ .Summary }}
</div>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">
{{ $.Param "read_more_copy" | default (i18n "readMore") | humanize }}
</a>
</div>
<article class="bb b--black-10 w-100 mb4 bg-white pa3-ns flex flex-column flex-row-ns">
{{$.Site.Language.LanguageDirection}}
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
<div class="mb4 mb0-ns w-100 w-40-ns {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl3-ns" "pr3-ns" }}">
<a href="{{.RelPermalink}}" class="db grow">
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
</a>
</div>
{{ end }}
<div class="blah w-100{{ if $featured_image }} w-60-ns{{ end }}">
{{ if .IsPage }}
<div class="breadcrumb">{{- partial "breadcrumb" . -}}</div>
{{ end }}
<h1 class="f3 fw1 athelas mt0 lh-title">
<a href="{{.RelPermalink}}" class="color-inherit dim link">
{{ .Title }}
</a>
</h1>
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
{{ .Summary }}
</div>
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">
{{ $.Param "read_more_copy" | default (i18n "readMore") | humanize }}
</a>
</div>
</article>

View File

@ -1,20 +1,20 @@
{{ define "main" }}
<article class="pa3 pa4-ns nested-copy-line-height">
<section class="pa3 pa4-ns nested-copy-line-height">
<aside id="actions" class="w-30-l mt4-l fr tc">
{{ if .Parent.IsHome }}
<button id="create"
class="author-only br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray pointer">
class="br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray pointer">
{{ T (print .Section ".create") }}
</button>
{{ else if .Parent.Parent.IsHome }}
<button id="author-only delete"
class="br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray pointer author-only"
<button id="delete"
class="br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray pointer"
data-confirm="{{ T (print .Section ".delete") }}?">
{{ T (print .Section ".delete") }}
</button>
<a href="mailto:?subject=invitation&body={{.Content | plainify}}"
class="author-only br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray"
class="br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray"
id="invitation">
{{ T (print .Section ".send") }}
</a>
@ -30,24 +30,10 @@
</section>
{{ end }}
<section class="flex-ns flex-wrap justify-around">
{{ if .Params.sections }}
{{ range .Sections }}
<div class="relative w-100 w-30-l mb4 bg-white">
{{ .Render "summary-with-image" }}
</div>
{{ end }}
{{ range (.Paginate .RegularPagesRecursive).Pages }}
{{ .Render "summary-with-image" }}
{{ end }}
{{ else }}
{{ range (.Paginate .RegularPagesRecursive).Pages }}
<div class="relative w-100 mb4 bg-white">
{{ .Render "summary-with-image" }}
</div>
{{ end }}
{{- template "_internal/pagination.html" . -}}
{{ end }}
</section>
</article>
{{- template "_internal/pagination.html" . -}}
</section>
{{ end }}

View File

@ -7,7 +7,7 @@
</ol>
{{ define "breadcrumbnav" }}
{{ if .p1.Parent }}
{{ template "breadcrumbnav" (dict "p1" .p1.Parent "p2" .p2 ) }}
{{ template "breadcrumbnav" (dict "p1" .p1.Parent "p2" .p2) }}
{{ end }}
{{ if (and .p1.IsSection (not .p1.Parent.IsHome)) }}
<li><a href="{{ .p1.Permalink }}">{{ .p1.Title }}</a></li>