This commit is contained in:
julien 2025-06-20 17:05:28 +02:00
parent 05a20e6253
commit 6454d436ae
3 changed files with 100 additions and 76 deletions

View File

@ -1,13 +1,14 @@
<div class="box"> <div class="box">
<h4 class="title is-5">{{ .Entry.Name }}</h4> {{ with .Entry }}
<p><strong>Type :</strong> {{ ext .Entry.Name }}</p> <h4 class="title is-5">{{ .Name }}</h4>
<p><strong>Taille :</strong> {{ printf "%.1f KB" (toKB .Entry.Size) }}</p> <p><strong>Type :</strong> {{ ext .Name }}</p>
<p><strong>Modifié :</strong> {{ .Entry.ModTime.Format "02 Jan 2006 15:04" }}</p> <p><strong>Taille :</strong> {{ printf "%.1f KB" (toKB .Size) }}</p>
{{ if and (not .Entry.IsDir) (or (hasSuffix .Entry.Name ".jpg") (hasSuffix .Entry.Name ".png")) }} <p><strong>Modifié le :</strong> {{ .ModTime.Format "02 Jan 2006 15:04" }}</p>
{{ if and (not .IsDir) (or (hasSuffix .Name ".jpg") (hasSuffix .Name ".png")) }}
<figure class="image"> <figure class="image">
<img src="/static/uploads/{{ .Entry.Path }}"> <img src="/app/upload/{{ .Path }}">
</figure> </figure>
{{ end }} {{ end }}
{{ end }}
</div> </div>

View File

@ -1,16 +1,30 @@
<div class="columns is-multiline"> <div class="columns is-multiline">
{{- range .Entries }} {{- range .Entries }}
<div class="column is-4-mobile is-3-tablet"> <div class="column is-4-mobile is-3-tablet">
<div class="card" <div class="card"
hx-get="{{ if .IsDir }}/folders?path={{ urlquery .Path }}{{ else }}/folders/detail?path={{ urlquery .Path }}{{ end }}" hx-get="{{ if .IsDir }}
/folders?path={{ urlquery .Path }}
{{ else }}
/folders/detail?path={{ urlquery .Path }}
{{ end }}"
hx-target="{{ if .IsDir }}#file-list{{ else }}#detail-panel{{ end }}" hx-target="{{ if .IsDir }}#file-list{{ else }}#detail-panel{{ end }}"
hx-swap="innerHTML"
hx-push-url="true" hx-push-url="true"
style="cursor:pointer"> style="cursor:pointer">
<!-- … contenu de la carte … --> <div class="card-image">
<figure class="image is-4by3">
{{ if .IsDir }}
<i class="fas fa-folder fa-3x has-text-warning" style="margin:1rem"></i>
{{ else if or (hasSuffix .Name ".jpg") (hasSuffix .Name ".png") }}
<img src="/app/upload/{{ .Path }}" alt="{{ .Name }}">
{{ else }}
<i class="fas fa-file fa-3x"></i>
{{ end }}
</figure>
</div>
<div class="card-content">
<p class="title is-6">{{ .Name }}</p>
</div>
</div> </div>
</div> </div>
{{- end }} {{- end }}
</div> </div>

View File

@ -1,8 +1,10 @@
<section class="section"> <section class="section">
<div class="container is-fluid"> <div class="container is-fluid">
<div class="columns"> <div class="columns">
<!-- Sidebar interne si besoin -->
<!-- Sidebar -->
<div class="column is-2"> <div class="column is-2">
<aside class="menu"> <aside class="menu">
<p class="menu-label">Dossiers</p> <p class="menu-label">Dossiers</p>
@ -10,11 +12,10 @@
{{- range .Dirs }} {{- range .Dirs }}
<li> <li>
<a <a
hx-get="/folders?path={{ urlquery .Path }}" hx-get="/folders?path={{ urlquery .Name }}"
hx-target="#file-list" hx-target="#file-list"
hx-swap="innerHTML"
hx-push-url="true" hx-push-url="true"
class="{{ if eq $.CurrentPath .Path }}is-active{{ end }}" class="{{ if eq $.CurrentPath .Name }}is-active{{ end }}"
> >
{{ .Name }} {{ .Name }}
</a> </a>
@ -24,15 +25,16 @@
</aside> </aside>
</div> </div>
<!-- Grille principale --> <!-- Grille -->
<div class="column is-7"> <div class="column is-7">
<nav class="breadcrumb" aria-label="breadcrumbs"> <nav class="breadcrumb" aria-label="breadcrumbs">
<ul> <ul>
<li> <li>
<a hx-get="/folders" <a
hx-get="/folders"
hx-target="#file-list" hx-target="#file-list"
hx-swap="innerHTML" hx-push-url="true"
hx-push-url="true"> >
Home Home
</a> </a>
</li> </li>
@ -42,10 +44,11 @@
{{- if ne $p "" }} {{- if ne $p "" }}
{{- $acc = printf "%s/%s" $acc $p }} {{- $acc = printf "%s/%s" $acc $p }}
<li class="is-active"> <li class="is-active">
<a hx-get="/folders?path={{ urlquery (trimPrefix "/" $acc) }}" <a
hx-get="/folders?path={{ urlquery (trimPrefix "/" $acc) }}"
hx-target="#file-list" hx-target="#file-list"
hx-swap="innerHTML" hx-push-url="true"
hx-push-url="true"> >
{{ $p }} {{ $p }}
</a> </a>
</li> </li>
@ -54,17 +57,23 @@
</ul> </ul>
</nav> </nav>
<div id="file-list"> <div
{{ template "_file_list" . }} id="file-list"
hx-trigger="load"
hx-get="/folders?path={{ urlquery .CurrentPath }}"
hx-target="#file-list"
>
{{ template "_file_list.pages.tmpl" . }}
</div> </div>
</div> </div>
<!-- Détails --> <!-- Détails -->
<div class="column is-3"> <div class="column is-3">
<div id="detail-panel"> <div id="detail-panel">
<em>Sélectionnez un fichier ou un dossier…</em> <em>Sélectionnez un fichier ou dossier…</em>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> </section>