From e52226c05fb54dfe41c9bc5ebc6ce1b7ded7e1fe Mon Sep 17 00:00:00 2001
From: "Gabriel A. Giovanini"
Date: Thu, 30 May 2024 17:01:38 +0200
Subject: feat: Add initial git item page
---
pkg/handler/git/handler.go | 5 ++
pkg/handler/router.go | 1 +
scss/main.scss | 5 ++
templates/config.qtpl | 3 +
templates/config.qtpl.go | 63 ++++++++--------
templates/gititem.qtpl | 48 +++++++++++++
templates/gititem.qtpl.go | 175 +++++++++++++++++++++++++++++++++++++++++++++
templates/gitlist.qtpl | 1 +
templates/gitlist.qtpl.go | 61 ++++++++--------
templates/navbar.qtpl | 4 +-
templates/navbar.qtpl.go | 4 +-
11 files changed, 306 insertions(+), 64 deletions(-)
create mode 100644 templates/gititem.qtpl
create mode 100644 templates/gititem.qtpl.go
diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go
index 236ac41..e088749 100644
--- a/pkg/handler/git/handler.go
+++ b/pkg/handler/git/handler.go
@@ -34,3 +34,8 @@ func (g *GitHandler) List(w http.ResponseWriter, _ *http.Request) {
gitList := &templates.GitListPage{repos}
templates.WritePageTemplate(w, gitList)
}
+
+func (g *GitHandler) Item(w http.ResponseWriter, _ *http.Request) {
+ gitList := &templates.GitItemPage{}
+ templates.WritePageTemplate(w, gitList)
+}
diff --git a/pkg/handler/router.go b/pkg/handler/router.go
index a8c9c6f..1150f2f 100644
--- a/pkg/handler/router.go
+++ b/pkg/handler/router.go
@@ -33,6 +33,7 @@ func MountHandler(
mux.Handle("/static/", staticHandler)
mux.HandleFunc("/config", configHander)
mux.HandleFunc("/about", aboutHandler.About)
+ mux.HandleFunc("/{name}", gitHandler.Item)
mux.HandleFunc("/", gitHandler.List)
return mux, nil
}
diff --git a/scss/main.scss b/scss/main.scss
index f57579a..deea23b 100644
--- a/scss/main.scss
+++ b/scss/main.scss
@@ -60,3 +60,8 @@ body {
.event > p {
margin: 0.5rem 0;
}
+
+.code-view {
+ display: grid;
+ overflow-x: auto;
+}
diff --git a/templates/config.qtpl b/templates/config.qtpl
index c5146b8..b3df50e 100644
--- a/templates/config.qtpl
+++ b/templates/config.qtpl
@@ -9,7 +9,10 @@ type ConfigPage struct {
{% func (p *ConfigPage) Navbar() %}{%= Navbar(Config) %}{% endfunc %}
{% func (p *ConfigPage) Content() %}
+This is the configuration that is currently loaded
+
{%z= p.Body %}
+
{% endfunc %}
{% func (p *ConfigPage) Script() %}
diff --git a/templates/config.qtpl.go b/templates/config.qtpl.go
index a5df086..58b3881 100644
--- a/templates/config.qtpl.go
+++ b/templates/config.qtpl.go
@@ -92,71 +92,74 @@ func (p *ConfigPage) Navbar() string {
func (p *ConfigPage) StreamContent(qw422016 *qt422016.Writer) {
//line config.qtpl:11
qw422016.N().S(`
+This is the configuration that is currently loaded
+
`)
-//line config.qtpl:12
+//line config.qtpl:14
qw422016.N().Z(p.Body)
-//line config.qtpl:12
+//line config.qtpl:14
qw422016.N().S(`
+
`)
-//line config.qtpl:13
+//line config.qtpl:16
}
-//line config.qtpl:13
+//line config.qtpl:16
func (p *ConfigPage) WriteContent(qq422016 qtio422016.Writer) {
-//line config.qtpl:13
+//line config.qtpl:16
qw422016 := qt422016.AcquireWriter(qq422016)
-//line config.qtpl:13
+//line config.qtpl:16
p.StreamContent(qw422016)
-//line config.qtpl:13
+//line config.qtpl:16
qt422016.ReleaseWriter(qw422016)
-//line config.qtpl:13
+//line config.qtpl:16
}
-//line config.qtpl:13
+//line config.qtpl:16
func (p *ConfigPage) Content() string {
-//line config.qtpl:13
+//line config.qtpl:16
qb422016 := qt422016.AcquireByteBuffer()
-//line config.qtpl:13
+//line config.qtpl:16
p.WriteContent(qb422016)
-//line config.qtpl:13
+//line config.qtpl:16
qs422016 := string(qb422016.B)
-//line config.qtpl:13
+//line config.qtpl:16
qt422016.ReleaseByteBuffer(qb422016)
-//line config.qtpl:13
+//line config.qtpl:16
return qs422016
-//line config.qtpl:13
+//line config.qtpl:16
}
-//line config.qtpl:15
+//line config.qtpl:18
func (p *ConfigPage) StreamScript(qw422016 *qt422016.Writer) {
-//line config.qtpl:15
+//line config.qtpl:18
qw422016.N().S(`
`)
-//line config.qtpl:16
+//line config.qtpl:19
}
-//line config.qtpl:16
+//line config.qtpl:19
func (p *ConfigPage) WriteScript(qq422016 qtio422016.Writer) {
-//line config.qtpl:16
+//line config.qtpl:19
qw422016 := qt422016.AcquireWriter(qq422016)
-//line config.qtpl:16
+//line config.qtpl:19
p.StreamScript(qw422016)
-//line config.qtpl:16
+//line config.qtpl:19
qt422016.ReleaseWriter(qw422016)
-//line config.qtpl:16
+//line config.qtpl:19
}
-//line config.qtpl:16
+//line config.qtpl:19
func (p *ConfigPage) Script() string {
-//line config.qtpl:16
+//line config.qtpl:19
qb422016 := qt422016.AcquireByteBuffer()
-//line config.qtpl:16
+//line config.qtpl:19
p.WriteScript(qb422016)
-//line config.qtpl:16
+//line config.qtpl:19
qs422016 := string(qb422016.B)
-//line config.qtpl:16
+//line config.qtpl:19
qt422016.ReleaseByteBuffer(qb422016)
-//line config.qtpl:16
+//line config.qtpl:19
return qs422016
-//line config.qtpl:16
+//line config.qtpl:19
}
diff --git a/templates/gititem.qtpl b/templates/gititem.qtpl
new file mode 100644
index 0000000..156325f
--- /dev/null
+++ b/templates/gititem.qtpl
@@ -0,0 +1,48 @@
+{% code
+type GitItemPage struct {
+}
+%}
+
+
+{% func insertIfEqual(s, d Selection) %}{% if s == d %} selected{% endif %}{% endfunc %}
+
+
+{% func Navbar (s Selection) %}
+
+{% endfunc %}
+
+{% func (p *GitItemPage) Title() %}Git | List{% endfunc %}
+
+{% func (p *GitItemPage) Navbar() %}{%= Navbar(Git) %}{% endfunc %}
+
+{% func (p *GitItemPage) Content() %}
+
+
AoC2022.git
+
+
+{% endfunc %}
+
+{% func (p *GitItemPage) Script() %}
+{% endfunc %}
diff --git a/templates/gititem.qtpl.go b/templates/gititem.qtpl.go
new file mode 100644
index 0000000..8c14856
--- /dev/null
+++ b/templates/gititem.qtpl.go
@@ -0,0 +1,175 @@
+// Code generated by qtc from "gititem.qtpl". DO NOT EDIT.
+// See https://github.com/valyala/quicktemplate for details.
+
+//line gititem.qtpl:1
+package templates
+
+//line gititem.qtpl:1
+import (
+ qtio422016 "io"
+
+ qt422016 "github.com/valyala/quicktemplate"
+)
+
+//line gititem.qtpl:1
+var (
+ _ = qtio422016.Copy
+ _ = qt422016.AcquireByteBuffer
+)
+
+//line gititem.qtpl:2
+type GitItemPage struct {
+}
+
+//line gititem.qtpl:6
+func (p *GitItemPage) StreamTitle(qw422016 *qt422016.Writer) {
+//line gititem.qtpl:6
+ qw422016.N().S(`Git | List`)
+//line gititem.qtpl:6
+}
+
+//line gititem.qtpl:6
+func (p *GitItemPage) WriteTitle(qq422016 qtio422016.Writer) {
+//line gititem.qtpl:6
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line gititem.qtpl:6
+ p.StreamTitle(qw422016)
+//line gititem.qtpl:6
+ qt422016.ReleaseWriter(qw422016)
+//line gititem.qtpl:6
+}
+
+//line gititem.qtpl:6
+func (p *GitItemPage) Title() string {
+//line gititem.qtpl:6
+ qb422016 := qt422016.AcquireByteBuffer()
+//line gititem.qtpl:6
+ p.WriteTitle(qb422016)
+//line gititem.qtpl:6
+ qs422016 := string(qb422016.B)
+//line gititem.qtpl:6
+ qt422016.ReleaseByteBuffer(qb422016)
+//line gititem.qtpl:6
+ return qs422016
+//line gititem.qtpl:6
+}
+
+//line gititem.qtpl:8
+func (p *GitItemPage) StreamNavbar(qw422016 *qt422016.Writer) {
+//line gititem.qtpl:8
+ StreamNavbar(qw422016, Git)
+//line gititem.qtpl:8
+}
+
+//line gititem.qtpl:8
+func (p *GitItemPage) WriteNavbar(qq422016 qtio422016.Writer) {
+//line gititem.qtpl:8
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line gititem.qtpl:8
+ p.StreamNavbar(qw422016)
+//line gititem.qtpl:8
+ qt422016.ReleaseWriter(qw422016)
+//line gititem.qtpl:8
+}
+
+//line gititem.qtpl:8
+func (p *GitItemPage) Navbar() string {
+//line gititem.qtpl:8
+ qb422016 := qt422016.AcquireByteBuffer()
+//line gititem.qtpl:8
+ p.WriteNavbar(qb422016)
+//line gititem.qtpl:8
+ qs422016 := string(qb422016.B)
+//line gititem.qtpl:8
+ qt422016.ReleaseByteBuffer(qb422016)
+//line gititem.qtpl:8
+ return qs422016
+//line gititem.qtpl:8
+}
+
+//line gititem.qtpl:10
+func (p *GitItemPage) StreamContent(qw422016 *qt422016.Writer) {
+//line gititem.qtpl:10
+ qw422016.N().S(`
+
+
AoC2022.git
+
+
+`)
+//line gititem.qtpl:30
+}
+
+//line gititem.qtpl:30
+func (p *GitItemPage) WriteContent(qq422016 qtio422016.Writer) {
+//line gititem.qtpl:30
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line gititem.qtpl:30
+ p.StreamContent(qw422016)
+//line gititem.qtpl:30
+ qt422016.ReleaseWriter(qw422016)
+//line gititem.qtpl:30
+}
+
+//line gititem.qtpl:30
+func (p *GitItemPage) Content() string {
+//line gititem.qtpl:30
+ qb422016 := qt422016.AcquireByteBuffer()
+//line gititem.qtpl:30
+ p.WriteContent(qb422016)
+//line gititem.qtpl:30
+ qs422016 := string(qb422016.B)
+//line gititem.qtpl:30
+ qt422016.ReleaseByteBuffer(qb422016)
+//line gititem.qtpl:30
+ return qs422016
+//line gititem.qtpl:30
+}
+
+//line gititem.qtpl:32
+func (p *GitItemPage) StreamScript(qw422016 *qt422016.Writer) {
+//line gititem.qtpl:32
+ qw422016.N().S(`
+`)
+//line gititem.qtpl:33
+}
+
+//line gititem.qtpl:33
+func (p *GitItemPage) WriteScript(qq422016 qtio422016.Writer) {
+//line gititem.qtpl:33
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line gititem.qtpl:33
+ p.StreamScript(qw422016)
+//line gititem.qtpl:33
+ qt422016.ReleaseWriter(qw422016)
+//line gititem.qtpl:33
+}
+
+//line gititem.qtpl:33
+func (p *GitItemPage) Script() string {
+//line gititem.qtpl:33
+ qb422016 := qt422016.AcquireByteBuffer()
+//line gititem.qtpl:33
+ p.WriteScript(qb422016)
+//line gititem.qtpl:33
+ qs422016 := string(qb422016.B)
+//line gititem.qtpl:33
+ qt422016.ReleaseByteBuffer(qb422016)
+//line gititem.qtpl:33
+ return qs422016
+//line gititem.qtpl:33
+}
diff --git a/templates/gitlist.qtpl b/templates/gitlist.qtpl
index 588c264..e07f199 100644
--- a/templates/gitlist.qtpl
+++ b/templates/gitlist.qtpl
@@ -22,6 +22,7 @@ type GitListPage struct {
{%s r.LastCommitMessage %}
{%s r.LastCommitDate %}
+ summary log tree
{% endfor %}
diff --git a/templates/gitlist.qtpl.go b/templates/gitlist.qtpl.go
index 5438729..130db5d 100644
--- a/templates/gitlist.qtpl.go
+++ b/templates/gitlist.qtpl.go
@@ -126,77 +126,78 @@ func (p *GitListPage) StreamContent(qw422016 *qt422016.Writer) {
qw422016.E().S(r.LastCommitDate)
//line gitlist.qtpl:24
qw422016.N().S(`
+ summary log tree
`)
-//line gitlist.qtpl:26
+//line gitlist.qtpl:27
}
-//line gitlist.qtpl:26
+//line gitlist.qtpl:27
qw422016.N().S(`
`)
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
}
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
func (p *GitListPage) WriteContent(qq422016 qtio422016.Writer) {
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
qw422016 := qt422016.AcquireWriter(qq422016)
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
p.StreamContent(qw422016)
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
qt422016.ReleaseWriter(qw422016)
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
}
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
func (p *GitListPage) Content() string {
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
qb422016 := qt422016.AcquireByteBuffer()
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
p.WriteContent(qb422016)
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
qs422016 := string(qb422016.B)
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
qt422016.ReleaseByteBuffer(qb422016)
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
return qs422016
-//line gitlist.qtpl:28
+//line gitlist.qtpl:29
}
//
//
//
-//line gitlist.qtpl:32
+//line gitlist.qtpl:33
func (p *GitListPage) StreamScript(qw422016 *qt422016.Writer) {
-//line gitlist.qtpl:32
+//line gitlist.qtpl:33
qw422016.N().S(`
`)
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
}
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
func (p *GitListPage) WriteScript(qq422016 qtio422016.Writer) {
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
qw422016 := qt422016.AcquireWriter(qq422016)
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
p.StreamScript(qw422016)
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
qt422016.ReleaseWriter(qw422016)
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
}
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
func (p *GitListPage) Script() string {
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
qb422016 := qt422016.AcquireByteBuffer()
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
p.WriteScript(qb422016)
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
qs422016 := string(qb422016.B)
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
qt422016.ReleaseByteBuffer(qb422016)
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
return qs422016
-//line gitlist.qtpl:33
+//line gitlist.qtpl:34
}
diff --git a/templates/navbar.qtpl b/templates/navbar.qtpl
index 26991a3..636c619 100644
--- a/templates/navbar.qtpl
+++ b/templates/navbar.qtpl
@@ -12,9 +12,9 @@ const (
{% func Navbar (s Selection) %}
-