diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-30 17:01:38 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-30 17:01:38 +0200 |
commit | e52226c05fb54dfe41c9bc5ebc6ce1b7ded7e1fe (patch) | |
tree | 9b067f810dfb9cbe6e7aabf2f7c88c77fc306531 | |
parent | 242ba7f412d4e54f21385afff3f2b884f57f6ced (diff) | |
download | cerrado-e52226c05fb54dfe41c9bc5ebc6ce1b7ded7e1fe.tar.gz cerrado-e52226c05fb54dfe41c9bc5ebc6ce1b7ded7e1fe.tar.bz2 cerrado-e52226c05fb54dfe41c9bc5ebc6ce1b7ded7e1fe.zip |
feat: Add initial git item page
-rw-r--r-- | pkg/handler/git/handler.go | 5 | ||||
-rw-r--r-- | pkg/handler/router.go | 1 | ||||
-rw-r--r-- | scss/main.scss | 5 | ||||
-rw-r--r-- | templates/config.qtpl | 3 | ||||
-rw-r--r-- | templates/config.qtpl.go | 63 | ||||
-rw-r--r-- | templates/gititem.qtpl | 48 | ||||
-rw-r--r-- | templates/gititem.qtpl.go | 175 | ||||
-rw-r--r-- | templates/gitlist.qtpl | 1 | ||||
-rw-r--r-- | templates/gitlist.qtpl.go | 61 | ||||
-rw-r--r-- | templates/navbar.qtpl | 4 | ||||
-rw-r--r-- | templates/navbar.qtpl.go | 4 |
11 files changed, 306 insertions, 64 deletions
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() %} +<p>This is the configuration that is currently loaded</p> +<div class="code-view"> {%z= p.Body %} +</div> {% 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(` +<p>This is the configuration that is currently loaded</p> +<div class="code-view"> `) -//line config.qtpl:12 +//line config.qtpl:14 qw422016.N().Z(p.Body) -//line config.qtpl:12 +//line config.qtpl:14 qw422016.N().S(` +</div> `) -//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) %} + <nav class="container navbar navbar-expand"> + <div class="navbar-nav"> + <a class="nav-link{%= insertIfEqual(s, Git) %}" href="/">git</a> + <a class="nav-link{%= insertIfEqual(s, List) %}" href="/list">list</a> + <a class="nav-link{%= insertIfEqual(s, About) %}" href="/about">about</a> + <a class="nav-link{%= insertIfEqual(s, Config) %}" href="/config">config</a> + </div> + </nav> +{% endfunc %} + +{% func (p *GitItemPage) Title() %}Git | List{% endfunc %} + +{% func (p *GitItemPage) Navbar() %}{%= Navbar(Git) %}{% endfunc %} + +{% func (p *GitItemPage) Content() %} +<div class="row"> + <h3>AoC2022.git</h3> +</div> +<div class="row"> + <ul class="nav"> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">about</a> + </li> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">summary</a> + </li> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">refs</a> + </li> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">tree</a> + </li> + </ul> +</div> +{% 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(` +<div class="row"> + <h3>AoC2022.git</h3> +</div> +<div class="row"> + <ul class="nav"> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">about</a> + </li> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">summary</a> + </li> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">refs</a> + </li> + <li class="nav-item"> + <a class="nav-link" aria-current="page" href="#">tree</a> + </li> + </ul> +</div> +`) +//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 { </hr> <p>{%s r.LastCommitMessage %}</p> <p><small>{%s r.LastCommitDate %}</small></p> + <p><a href="#">summary</a> <a href="#">log</a> <a href="#">tree</a></p> </div> {% endfor %} </div> 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(`</small></p> + <p><a href="#">summary</a> <a href="#">log</a> <a href="#">tree</a></p> </div> `) -//line gitlist.qtpl:26 +//line gitlist.qtpl:27 } -//line gitlist.qtpl:26 +//line gitlist.qtpl:27 qw422016.N().S(` </div> `) -//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 } // </div> // </div> // -//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) %} - <nav class="container navbar navbar-expand-sm"> + <nav class="container navbar navbar-expand"> <div class="navbar-nav"> - <a class="nav-link{%= insertIfEqual(s, Git) %}" href="/git">git</a> + <a class="nav-link{%= insertIfEqual(s, Git) %}" href="/">git</a> <a class="nav-link{%= insertIfEqual(s, List) %}" href="/list">list</a> <a class="nav-link{%= insertIfEqual(s, About) %}" href="/about">about</a> <a class="nav-link{%= insertIfEqual(s, Config) %}" href="/config">config</a> diff --git a/templates/navbar.qtpl.go b/templates/navbar.qtpl.go index e2b738c..1caade2 100644 --- a/templates/navbar.qtpl.go +++ b/templates/navbar.qtpl.go @@ -68,13 +68,13 @@ func insertIfEqual(s, d Selection) string { func StreamNavbar(qw422016 *qt422016.Writer, s Selection) { //line navbar.qtpl:14 qw422016.N().S(` - <nav class="container navbar navbar-expand-sm"> + <nav class="container navbar navbar-expand"> <div class="navbar-nav"> <a class="nav-link`) //line navbar.qtpl:17 streaminsertIfEqual(qw422016, s, Git) //line navbar.qtpl:17 - qw422016.N().S(`" href="/git">git</a> + qw422016.N().S(`" href="/">git</a> <a class="nav-link`) //line navbar.qtpl:18 streaminsertIfEqual(qw422016, s, List) |