lens @ b8b6d3037c524575f140650ac243c16df6a98a92

feat: Move last page to qtpl
diff --git a/pkg/service/filesystem.go b/pkg/service/filesystem.go
index 2e4b51099efa02ec811011baa731bd4f4ae2795e..b4479ea3d5cea80dddb58e09f5265d3469f1964e 100644
--- a/pkg/service/filesystem.go
+++ b/pkg/service/filesystem.go
@@ -6,6 +6,7 @@ 	"io/fs"
 	"net/url"
 	"path"
 	"strings"
+	"syscall"
 
 	"git.sr.ht/~gabrielgio/img/pkg/database/repository"
 	"git.sr.ht/~gabrielgio/img/pkg/list"
@@ -32,6 +33,20 @@ 		History []*DirectoryParam
 		Files   []*FileParam
 	}
 )
+
+func (f *FileParam) GetUid() int {
+	if stat, ok := f.Info.Sys().(*syscall.Stat_t); ok {
+		return int(stat.Uid)
+	}
+	return 0
+}
+
+func (f *FileParam) GetGid() int {
+	if stat, ok := f.Info.Sys().(*syscall.Stat_t); ok {
+		return int(stat.Gid)
+	}
+	return 0
+}
 
 func NewFileSystemController(
 	fsRepository repository.FileSystemRepository,
diff --git a/pkg/view/filesystem.go b/pkg/view/filesystem.go
index 7fd7331c7b306a61afbadee990e5a9c0293d51d1..6a011171eef0c61a0385600ec638b4dcc18f672c 100644
--- a/pkg/view/filesystem.go
+++ b/pkg/view/filesystem.go
@@ -3,10 +3,10 @@
 import (
 	"github.com/valyala/fasthttp"
 
-	"git.sr.ht/~gabrielgio/img"
 	"git.sr.ht/~gabrielgio/img/pkg/database/repository"
 	"git.sr.ht/~gabrielgio/img/pkg/ext"
 	"git.sr.ht/~gabrielgio/img/pkg/service"
+	"git.sr.ht/~gabrielgio/img/templates"
 )
 
 type (
@@ -45,17 +45,12 @@ 	if err != nil {
 		return err
 	}
 
-	err = img.Render(ctx, "fs.html", &img.HTMLView[*FilePage]{
-		Title: pathValue,
-		Data: &FilePage{
-			Page:      page,
-			ShowMode:  settings.ShowMode,
-			ShowOwner: settings.ShowOwner,
-		},
+	templates.WritePageTemplate(ctx, &templates.FilePage{
+		Page:      page,
+		ShowMode:  settings.ShowMode,
+		ShowOwner: settings.ShowOwner,
 	})
-	if err != nil {
-		return err
-	}
+
 	return nil
 }
 
diff --git a/static.go b/static.go
index 1c6a086b026205651a0d837e10588b65c5df8aaf..06f1459520097997f642ad087301207e4892f2db 100644
--- a/static.go
+++ b/static.go
@@ -2,33 +2,9 @@ package img
 
 import (
 	"embed"
-	"fmt"
-	"html/template"
-	"io"
 )
 
 var (
-	//go:embed templates/*.html
-	TemplateFS embed.FS
-
 	//go:embed static/*
 	StaticFS embed.FS
-
-	Template *template.Template
 )
-
-type HTMLView[T any] struct {
-	Title    string
-	Username string
-	Data     T
-}
-
-func Render[T any](w io.Writer, page string, view *HTMLView[T]) error {
-	pageFile := fmt.Sprintf("templates/%s", page)
-	tmpl, err := template.New("").ParseFS(TemplateFS, "templates/layout.html", pageFile)
-	if err != nil {
-		return err
-	}
-
-	return tmpl.ExecuteTemplate(w, page, view)
-}
diff --git a/templates/base.qtpl b/templates/base.qtpl
index cbde3552fcaa1f580d3f4afad03bece2aac529a2..0c0578234dc0fcf545c94664b8c4304cc67ed23b 100644
--- a/templates/base.qtpl
+++ b/templates/base.qtpl
@@ -22,13 +22,13 @@     </head>
     <body>
         <nav class="navbar">
             <div class="navbar-start">
-                <a href="/fs" class="navbar-item">
+                <a href="/fs/" class="navbar-item">
                     files
                 </a>
-                <a href="/media" class="navbar-item">
+                <a href="/media/" class="navbar-item">
                     media
                 </a>
-                <a href="/settings" class="navbar-item">
+                <a href="/settings/" class="navbar-item">
                     settings
                 </a>
             </div>
diff --git a/templates/fs.html b/templates/fs.html
deleted file mode 100644
index a44d78f441b53a2e1229120696a4c081908679dd..0000000000000000000000000000000000000000
--- a/templates/fs.html
+++ /dev/null
@@ -1,29 +0,0 @@
-{{template "layout.html" .}}
-{{define "title"}} {{.Title}} {{end}}
-{{define "content"}}
-<div class="panel">
-  <div class="panel-block">
-      <div class="columns file-row is-gapless is-mobile">
-          <div id="path" class="container-fluid">
-              <small>{{range .Data.Page.History}}<a href="/fs?path={{.UrlEncodedPath}}" >{{.Name}}/</a>{{end}}</small>
-          </div>
-      </div>
-  </div>
-  {{range .Data.Page.Files}}
-  <div class="panel-block">
-      <div class="columns wide-column is-mono is-gapless is-mobile">
-          <div class="column">
-              {{if $.Data.ShowMode}}{{.Info.Mode}}&emsp;{{end}}
-              {{if $.Data.ShowOwner}}{{.Info.Sys.Gid}}:{{.Info.Sys.Uid}}&emsp;{{end}}
-              {{if .Info.IsDir}}
-              <a href="/?path={{.UrlEncodedPath}}">{{.Info.Name}}/</a>
-              {{else}}
-              {{.Info.Name}}
-              {{end}}
-          </div>
-          <div class="column  has-text-right">{{.Info.Size}} B</div>
-      </div>
-  </div>
-  {{end}}
-</div>
-{{end}}
diff --git a/templates/fs.qtpl b/templates/fs.qtpl
new file mode 100644
index 0000000000000000000000000000000000000000..489f79fc1ab56f05e95f5e240e2250d5f456f9f4
--- /dev/null
+++ b/templates/fs.qtpl
@@ -0,0 +1,41 @@
+{% import "git.sr.ht/~gabrielgio/img/pkg/service" %}
+
+{% code
+type FilePage struct {
+		Page      *service.Page
+		ShowMode  bool
+		ShowOwner bool
+	}%}
+
+{% func (p *FilePage) Title() %}Files{% endfunc %}
+
+{% func (p *FilePage) Content() %}
+<div class="panel">
+  <div class="panel-block">
+      <div class="columns file-row is-gapless is-mobile">
+          <div id="path" class="container-fluid">
+              <small>{% for _, h := range p.Page.History %}<a href="/fs?path={%s h.UrlEncodedPath %}" >{%s h.Name %}/</a>{% endfor %}</small>
+          </div>
+      </div>
+  </div>
+  {% for _, f := range p.Page.Files %}
+  <div class="panel-block">
+      <div class="columns wide-column is-mono is-gapless is-mobile">
+          <div class="column">
+              {% if p.ShowMode %}{%s f.Info.Mode().String() %}&emsp;{% endif %}
+              {% if p.ShowOwner %}{%d f.GetGid() %}:{%d f.GetUid() %}&emsp;{% endif %}
+              {% if f.Info.IsDir() %}
+              <a href="/?path={%s f.UrlEncodedPath %}">{%s f.Info.Name() %}/</a>
+              {% else %}
+              {%s f.Info.Name() %}
+              {% endif %}
+          </div>
+          <div class="column  has-text-right">{%dl f.Info.Size() %} B</div>
+      </div>
+  </div>
+  {% endfor %}
+</div>
+{% endfunc %}
+
+{% func (p *FilePage) Script() %}
+{% endfunc %}
diff --git a/templates/layout.html b/templates/layout.html
deleted file mode 100644
index bbf1558ff080063b0610a80f4d9846a8a9cad9ce..0000000000000000000000000000000000000000
--- a/templates/layout.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>img | {{block "title" .}} noop {{end}}</title> 
-        <link rel="stylesheet" href="/static/main.css">
-        <link rel="icon" href="/static/square.svg" sizes="any" type="image/svg+xml">
-        <meta name="viewport" content="width=device-width, initial-scale=1" />
-    </head>
-    <body>
-        <nav class="navbar">
-            <div class="navbar-start">
-                <a href="/fs" class="navbar-item">
-                    files
-                </a>
-                <a href="/media" class="navbar-item">
-                    media
-                </a>
-                <a href="/settings" class="navbar-item">
-                    settings
-                </a>
-            </div>
-        </nav>
-        <div class="container">
-            {{block "content" .}}noop{{end}}
-        </div>
-    </body>
-    {{block "script" .}}{{end}}
-</html>