lens @ 55448bc974f71f83e6a6c6d70afe9cfc63d275f4

feat: Move media from `html/template` to qtpl
diff --git a/pkg/view/media.go b/pkg/view/media.go
index 6d380e25a294884a3bc8de9e9c090b1bd33bb31a..4bf8d68aa5fa4de6385a0f60bfb69e75b9d41243 100644
--- a/pkg/view/media.go
+++ b/pkg/view/media.go
@@ -5,20 +5,15 @@ 	"strconv"
 
 	"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/templates"
 )
 
 type (
 	MediaView struct {
 		mediaRepository repository.MediaRepository
 		userRepository  repository.UserRepository
-	}
-
-	Page struct {
-		Medias []*repository.Media
-		Next   *repository.Pagination
 	}
 )
 
@@ -77,16 +72,16 @@ 	if err != nil {
 		return err
 	}
 
-	err = img.Render(ctx, "media.html", &img.HTMLView[*Page]{
-		Title: "Media",
-		Data: &Page{
-			Medias: medias,
-			Next: &repository.Pagination{
-				Size: p.Size,
-				Page: p.Page + 1,
-			},
+	page := &templates.MediaPage{
+		Medias: medias,
+		Next: &repository.Pagination{
+			Size: p.Size,
+			Page: p.Page + 1,
 		},
-	})
+	}
+
+	templates.WritePageTemplate(ctx, page)
+
 	if err != nil {
 		return err
 	}
diff --git a/templates/base.qtpl b/templates/base.qtpl
new file mode 100644
index 0000000000000000000000000000000000000000..cbde3552fcaa1f580d3f4afad03bece2aac529a2
--- /dev/null
+++ b/templates/base.qtpl
@@ -0,0 +1,47 @@
+This is a base page template. All the other template pages implement this interface.
+
+{% interface
+Page {
+	Title()
+	Content()
+    Script()
+}
+%}
+
+
+Page prints a page implementing Page interface.
+{% func PageTemplate(p Page) %}
+<html lang="en">
+    <head>
+        <meta charset="utf-8">
+        <title>img | {%= p.Title() %}</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">
+            {%= p.Content() %}
+        </div>
+    </body>
+    {%= p.Script() %}
+</html>
+{% endfunc %}
+
+{% code type BasePage struct {} %}
+{% func (p *BasePage) Title() %}Empty{% endfunc %}
+{% func (p *BasePage) Body() %}HelloWorld{% endfunc %}
+{% func (p *BasePage) Script() %}{% endfunc %}
diff --git a/templates/media.qtpl b/templates/media.qtpl
new file mode 100644
index 0000000000000000000000000000000000000000..88ce5820e3813ff1962f1ab3d4d06e311cebd231
--- /dev/null
+++ b/templates/media.qtpl
@@ -0,0 +1,37 @@
+{% import "git.sr.ht/~gabrielgio/img/pkg/database/repository" %}
+
+{% code
+type MediaPage struct {
+	Medias []*repository.Media
+	Next   *repository.Pagination
+}
+%}
+
+{% func (p *MediaPage) Title() %}
+Media
+{% endfunc %}
+
+
+{% func (p *MediaPage) Content() %}
+<div class="columns is-multiline">
+{% for _, media := range p.Medias %}
+    <div class="card-image">
+       {% if media.IsVideo() %}
+       <video controls muted="true" poster="/media/thumbnail?path_hash={%s media.PathHash %}" preload="none">
+           <source src="/media/image?path_hash={%s media.PathHash %}" type="{%s media.MIMEType %}">
+       </video>
+       {% else %}
+        <figure class="image is-fit">
+            <img src="/media/thumbnail?path_hash={%s media.PathHash %}">
+        </figure>
+        {% endif %}
+    </div>
+{% endfor %}
+</div>
+<div class="row">
+    <a href="/media?page={%d p.Next.Page %}" class="button is-pulled-right">next</a>
+</div>
+{% endfunc %}
+
+{% func (p *MediaPage) Script() %}
+{% endfunc %}