From 1e45ae2ea3497958b2ea6a20137955cfc3bbc964 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Wed, 11 Dec 2024 17:05:12 +0100 Subject: feat: Add UI/Handler login process It adds the whole workflow to store and handle login on both UI and handler level. With that the login information should be available at any point given the context. --- templates/about.qtpl | 11 ++- templates/about.qtpl.go | 176 ++++++++++++++++++------------------- templates/base.qtpl | 27 ++++-- templates/base.qtpl.go | 143 +++++++++++++++--------------- templates/error.qtpl | 10 ++- templates/error.qtpl.go | 165 ++++++++++++++++++----------------- templates/gititem.qtpl | 10 ++- templates/gititem.qtpl.go | 189 ++++++++++++++++++++-------------------- templates/gitlist.qtpl | 9 +- templates/gitlist.qtpl.go | 215 +++++++++++++++++++++++----------------------- templates/login.qtpl | 24 ++++-- templates/login.qtpl.go | 195 ++++++++++++++++++++++------------------- templates/navbar.qtpl | 8 +- templates/navbar.qtpl.go | 211 +++++++++++++++++++++++++-------------------- 14 files changed, 747 insertions(+), 646 deletions(-) (limited to 'templates') diff --git a/templates/about.qtpl b/templates/about.qtpl index faee50e..cfbf0d9 100644 --- a/templates/about.qtpl +++ b/templates/about.qtpl @@ -1,16 +1,19 @@ +{% import "context" %} + {% code type AboutPage struct { + LoggedIn bool Body []byte } %} -{% func (p *AboutPage) Title() %}Hello{% endfunc %} +{% func (p *AboutPage) Title(ctx context.Context) %}Hello{% endfunc %} -{% func (p *AboutPage) Navbar() %}{%= Navbar(About) %}{% endfunc %} +{% func (p *AboutPage) Navbar(ctx context.Context) %}{%= Navbar(ctx, About) %}{% endfunc %} -{% func (p *AboutPage) Content() %} +{% func (p *AboutPage) Content(ctx context.Context) %} {%z= p.Body %} {% endfunc %} -{% func (p *AboutPage) Script() %} +{% func (p *AboutPage) Script(ctx context.Context) %} {% endfunc %} diff --git a/templates/about.qtpl.go b/templates/about.qtpl.go index 2c07ceb..a640f7e 100644 --- a/templates/about.qtpl.go +++ b/templates/about.qtpl.go @@ -5,130 +5,100 @@ package templates //line templates/about.qtpl:1 +import "context" + +//line templates/about.qtpl:3 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/about.qtpl:1 +//line templates/about.qtpl:3 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/about.qtpl:2 +//line templates/about.qtpl:4 type AboutPage struct { - Body []byte + LoggedIn bool + Body []byte } -//line templates/about.qtpl:7 -func (p *AboutPage) StreamTitle(qw422016 *qt422016.Writer) { -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 +func (p *AboutPage) StreamTitle(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/about.qtpl:10 qw422016.N().S(`Hello`) -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 } -//line templates/about.qtpl:7 -func (p *AboutPage) WriteTitle(qq422016 qtio422016.Writer) { -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 +func (p *AboutPage) WriteTitle(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/about.qtpl:10 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/about.qtpl:7 - p.StreamTitle(qw422016) -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 + p.StreamTitle(qw422016, ctx) +//line templates/about.qtpl:10 qt422016.ReleaseWriter(qw422016) -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 } -//line templates/about.qtpl:7 -func (p *AboutPage) Title() string { -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 +func (p *AboutPage) Title(ctx context.Context) string { +//line templates/about.qtpl:10 qb422016 := qt422016.AcquireByteBuffer() -//line templates/about.qtpl:7 - p.WriteTitle(qb422016) -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 + p.WriteTitle(qb422016, ctx) +//line templates/about.qtpl:10 qs422016 := string(qb422016.B) -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 qt422016.ReleaseByteBuffer(qb422016) -//line templates/about.qtpl:7 +//line templates/about.qtpl:10 return qs422016 -//line templates/about.qtpl:7 -} - -//line templates/about.qtpl:9 -func (p *AboutPage) StreamNavbar(qw422016 *qt422016.Writer) { -//line templates/about.qtpl:9 - StreamNavbar(qw422016, About) -//line templates/about.qtpl:9 +//line templates/about.qtpl:10 } -//line templates/about.qtpl:9 -func (p *AboutPage) WriteNavbar(qq422016 qtio422016.Writer) { -//line templates/about.qtpl:9 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/about.qtpl:9 - p.StreamNavbar(qw422016) -//line templates/about.qtpl:9 - qt422016.ReleaseWriter(qw422016) -//line templates/about.qtpl:9 -} - -//line templates/about.qtpl:9 -func (p *AboutPage) Navbar() string { -//line templates/about.qtpl:9 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/about.qtpl:9 - p.WriteNavbar(qb422016) -//line templates/about.qtpl:9 - qs422016 := string(qb422016.B) -//line templates/about.qtpl:9 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/about.qtpl:9 - return qs422016 -//line templates/about.qtpl:9 -} - -//line templates/about.qtpl:11 -func (p *AboutPage) StreamContent(qw422016 *qt422016.Writer) { -//line templates/about.qtpl:11 - qw422016.N().S(` -`) //line templates/about.qtpl:12 - qw422016.N().Z(p.Body) +func (p *AboutPage) StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/about.qtpl:12 + StreamNavbar(qw422016, ctx, About) //line templates/about.qtpl:12 - qw422016.N().S(` -`) -//line templates/about.qtpl:13 } -//line templates/about.qtpl:13 -func (p *AboutPage) WriteContent(qq422016 qtio422016.Writer) { -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 +func (p *AboutPage) WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/about.qtpl:12 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/about.qtpl:13 - p.StreamContent(qw422016) -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 + p.StreamNavbar(qw422016, ctx) +//line templates/about.qtpl:12 qt422016.ReleaseWriter(qw422016) -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 } -//line templates/about.qtpl:13 -func (p *AboutPage) Content() string { -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 +func (p *AboutPage) Navbar(ctx context.Context) string { +//line templates/about.qtpl:12 qb422016 := qt422016.AcquireByteBuffer() -//line templates/about.qtpl:13 - p.WriteContent(qb422016) -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 + p.WriteNavbar(qb422016, ctx) +//line templates/about.qtpl:12 qs422016 := string(qb422016.B) -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 qt422016.ReleaseByteBuffer(qb422016) -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 return qs422016 -//line templates/about.qtpl:13 +//line templates/about.qtpl:12 } +//line templates/about.qtpl:14 +func (p *AboutPage) StreamContent(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/about.qtpl:14 + qw422016.N().S(` +`) //line templates/about.qtpl:15 -func (p *AboutPage) StreamScript(qw422016 *qt422016.Writer) { + qw422016.N().Z(p.Body) //line templates/about.qtpl:15 qw422016.N().S(` `) @@ -136,22 +106,22 @@ func (p *AboutPage) StreamScript(qw422016 *qt422016.Writer) { } //line templates/about.qtpl:16 -func (p *AboutPage) WriteScript(qq422016 qtio422016.Writer) { +func (p *AboutPage) WriteContent(qq422016 qtio422016.Writer, ctx context.Context) { //line templates/about.qtpl:16 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/about.qtpl:16 - p.StreamScript(qw422016) + p.StreamContent(qw422016, ctx) //line templates/about.qtpl:16 qt422016.ReleaseWriter(qw422016) //line templates/about.qtpl:16 } //line templates/about.qtpl:16 -func (p *AboutPage) Script() string { +func (p *AboutPage) Content(ctx context.Context) string { //line templates/about.qtpl:16 qb422016 := qt422016.AcquireByteBuffer() //line templates/about.qtpl:16 - p.WriteScript(qb422016) + p.WriteContent(qb422016, ctx) //line templates/about.qtpl:16 qs422016 := string(qb422016.B) //line templates/about.qtpl:16 @@ -160,3 +130,37 @@ func (p *AboutPage) Script() string { return qs422016 //line templates/about.qtpl:16 } + +//line templates/about.qtpl:18 +func (p *AboutPage) StreamScript(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/about.qtpl:18 + qw422016.N().S(` +`) +//line templates/about.qtpl:19 +} + +//line templates/about.qtpl:19 +func (p *AboutPage) WriteScript(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/about.qtpl:19 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/about.qtpl:19 + p.StreamScript(qw422016, ctx) +//line templates/about.qtpl:19 + qt422016.ReleaseWriter(qw422016) +//line templates/about.qtpl:19 +} + +//line templates/about.qtpl:19 +func (p *AboutPage) Script(ctx context.Context) string { +//line templates/about.qtpl:19 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/about.qtpl:19 + p.WriteScript(qb422016, ctx) +//line templates/about.qtpl:19 + qs422016 := string(qb422016.B) +//line templates/about.qtpl:19 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/about.qtpl:19 + return qs422016 +//line templates/about.qtpl:19 +} diff --git a/templates/base.qtpl b/templates/base.qtpl index 566308f..2a42cb8 100644 --- a/templates/base.qtpl +++ b/templates/base.qtpl @@ -1,5 +1,6 @@ This is a base page template. All the other template pages implement this interface. +{% import "context" %} {% import "strconv" %} {% import "time" %} @@ -9,10 +10,10 @@ This is a base page template. All the other template pages implement this interf {% interface Page { - Title() - Content() - Script() - Navbar() + Title(ctx context.Context) + Content(ctx context.Context) + Script(ctx context.Context) + Navbar(ctx context.Context) } %} @@ -25,6 +26,8 @@ Page { } %} + + {% code func TimeFormat(t time.Time) string { return t.Format("02.01.2006") } @@ -35,24 +38,30 @@ Page { } %} +{% code func IsLoggedIn(ctx context.Context) bool { + t, ok := ctx.Value("logged").(bool) + return ok && t + } +%} + Page prints a page implementing Page interface. -{% func PageTemplate(p Page) %} +{% func PageTemplate(p Page, ctx context.Context) %} - {%= p.Title() %} + {%= p.Title(ctx) %} - {%= p.Navbar() %} + {%= p.Navbar(ctx) %}
- {%= p.Content() %} + {%= p.Content(ctx) %}
- {%= p.Script() %} + {%= p.Script(ctx) %} {% endfunc %} diff --git a/templates/base.qtpl.go b/templates/base.qtpl.go index f8ff91f..5bb4532 100644 --- a/templates/base.qtpl.go +++ b/templates/base.qtpl.go @@ -8,57 +8,60 @@ package templates //line templates/base.qtpl:3 -import "strconv" +import "context" //line templates/base.qtpl:4 +import "strconv" + +//line templates/base.qtpl:5 import "time" -//line templates/base.qtpl:6 +//line templates/base.qtpl:7 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/base.qtpl:6 +//line templates/base.qtpl:7 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/base.qtpl:7 +//line templates/base.qtpl:8 var Slug = "" -//line templates/base.qtpl:11 +//line templates/base.qtpl:12 type Page interface { -//line templates/base.qtpl:11 - Title() string -//line templates/base.qtpl:11 - StreamTitle(qw422016 *qt422016.Writer) -//line templates/base.qtpl:11 - WriteTitle(qq422016 qtio422016.Writer) -//line templates/base.qtpl:11 - Content() string -//line templates/base.qtpl:11 - StreamContent(qw422016 *qt422016.Writer) -//line templates/base.qtpl:11 - WriteContent(qq422016 qtio422016.Writer) -//line templates/base.qtpl:11 - Script() string -//line templates/base.qtpl:11 - StreamScript(qw422016 *qt422016.Writer) -//line templates/base.qtpl:11 - WriteScript(qq422016 qtio422016.Writer) -//line templates/base.qtpl:11 - Navbar() string -//line templates/base.qtpl:11 - StreamNavbar(qw422016 *qt422016.Writer) -//line templates/base.qtpl:11 - WriteNavbar(qq422016 qtio422016.Writer) -//line templates/base.qtpl:11 +//line templates/base.qtpl:12 + Title(ctx context.Context) string +//line templates/base.qtpl:12 + StreamTitle(qw422016 *qt422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 + WriteTitle(qq422016 qtio422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 + Content(ctx context.Context) string +//line templates/base.qtpl:12 + StreamContent(qw422016 *qt422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 + WriteContent(qq422016 qtio422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 + Script(ctx context.Context) string +//line templates/base.qtpl:12 + StreamScript(qw422016 *qt422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 + WriteScript(qq422016 qtio422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 + Navbar(ctx context.Context) string +//line templates/base.qtpl:12 + StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 + WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context) +//line templates/base.qtpl:12 } -//line templates/base.qtpl:20 +//line templates/base.qtpl:21 func FromUInttoString(u *uint) string { if u != nil { return strconv.FormatUint(uint64(*u), 10) @@ -66,21 +69,27 @@ func FromUInttoString(u *uint) string { return "" } -//line templates/base.qtpl:28 +//line templates/base.qtpl:31 func TimeFormat(t time.Time) string { return t.Format("02.01.2006") } -//line templates/base.qtpl:33 +//line templates/base.qtpl:36 func Ignore[T any](v T, _ error) T { return v } +//line templates/base.qtpl:41 +func IsLoggedIn(ctx context.Context) bool { + t, ok := ctx.Value("logged").(bool) + return ok && t +} + // Page prints a page implementing Page interface. -//line templates/base.qtpl:39 -func StreamPageTemplate(qw422016 *qt422016.Writer, p Page) { -//line templates/base.qtpl:39 +//line templates/base.qtpl:48 +func StreamPageTemplate(qw422016 *qt422016.Writer, p Page, ctx context.Context) { +//line templates/base.qtpl:48 qw422016.N().S(` @@ -88,64 +97,64 @@ func StreamPageTemplate(qw422016 *qt422016.Writer, p Page) { `) -//line templates/base.qtpl:45 - p.StreamTitle(qw422016) -//line templates/base.qtpl:45 +//line templates/base.qtpl:54 + p.StreamTitle(qw422016, ctx) +//line templates/base.qtpl:54 qw422016.N().S(` `) -//line templates/base.qtpl:51 - p.StreamNavbar(qw422016) -//line templates/base.qtpl:51 +//line templates/base.qtpl:60 + p.StreamNavbar(qw422016, ctx) +//line templates/base.qtpl:60 qw422016.N().S(`
`) -//line templates/base.qtpl:53 - p.StreamContent(qw422016) -//line templates/base.qtpl:53 +//line templates/base.qtpl:62 + p.StreamContent(qw422016, ctx) +//line templates/base.qtpl:62 qw422016.N().S(`
`) -//line templates/base.qtpl:56 - p.StreamScript(qw422016) -//line templates/base.qtpl:56 +//line templates/base.qtpl:65 + p.StreamScript(qw422016, ctx) +//line templates/base.qtpl:65 qw422016.N().S(` `) -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 } -//line templates/base.qtpl:58 -func WritePageTemplate(qq422016 qtio422016.Writer, p Page) { -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 +func WritePageTemplate(qq422016 qtio422016.Writer, p Page, ctx context.Context) { +//line templates/base.qtpl:67 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/base.qtpl:58 - StreamPageTemplate(qw422016, p) -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 + StreamPageTemplate(qw422016, p, ctx) +//line templates/base.qtpl:67 qt422016.ReleaseWriter(qw422016) -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 } -//line templates/base.qtpl:58 -func PageTemplate(p Page) string { -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 +func PageTemplate(p Page, ctx context.Context) string { +//line templates/base.qtpl:67 qb422016 := qt422016.AcquireByteBuffer() -//line templates/base.qtpl:58 - WritePageTemplate(qb422016, p) -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 + WritePageTemplate(qb422016, p, ctx) +//line templates/base.qtpl:67 qs422016 := string(qb422016.B) -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 qt422016.ReleaseByteBuffer(qb422016) -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 return qs422016 -//line templates/base.qtpl:58 +//line templates/base.qtpl:67 } diff --git a/templates/error.qtpl b/templates/error.qtpl index 771d533..65e1321 100644 --- a/templates/error.qtpl +++ b/templates/error.qtpl @@ -1,16 +1,18 @@ +{% import "context" %} + {% code type ErrorPage struct { Message string } %} -{% func (p *ErrorPage) Title() %}Error{% endfunc %} +{% func (p *ErrorPage) Title(ctx context.Context) %}Error{% endfunc %} -{% func (p *ErrorPage) Navbar() %}{%= Navbar(Git) %}{% endfunc %} +{% func (p *ErrorPage) Navbar(ctx context.Context) %}{%= Navbar(ctx, Git) %}{% endfunc %} -{% func (p *ErrorPage) Content() %} +{% func (p *ErrorPage) Content(ctx context.Context) %} {%s p.Message %} {% endfunc %} -{% func (p *ErrorPage) Script() %} +{% func (p *ErrorPage) Script(ctx context.Context) %} {% endfunc %} diff --git a/templates/error.qtpl.go b/templates/error.qtpl.go index f415968..d4732c5 100644 --- a/templates/error.qtpl.go +++ b/templates/error.qtpl.go @@ -5,80 +5,50 @@ package templates //line templates/error.qtpl:1 +import "context" + +//line templates/error.qtpl:3 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/error.qtpl:1 +//line templates/error.qtpl:3 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/error.qtpl:2 +//line templates/error.qtpl:4 type ErrorPage struct { Message string } -//line templates/error.qtpl:7 -func (p *ErrorPage) StreamTitle(qw422016 *qt422016.Writer) { -//line templates/error.qtpl:7 - qw422016.N().S(`Error`) -//line templates/error.qtpl:7 -} - -//line templates/error.qtpl:7 -func (p *ErrorPage) WriteTitle(qq422016 qtio422016.Writer) { -//line templates/error.qtpl:7 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/error.qtpl:7 - p.StreamTitle(qw422016) -//line templates/error.qtpl:7 - qt422016.ReleaseWriter(qw422016) -//line templates/error.qtpl:7 -} - -//line templates/error.qtpl:7 -func (p *ErrorPage) Title() string { -//line templates/error.qtpl:7 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/error.qtpl:7 - p.WriteTitle(qb422016) -//line templates/error.qtpl:7 - qs422016 := string(qb422016.B) -//line templates/error.qtpl:7 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/error.qtpl:7 - return qs422016 -//line templates/error.qtpl:7 -} - //line templates/error.qtpl:9 -func (p *ErrorPage) StreamNavbar(qw422016 *qt422016.Writer) { +func (p *ErrorPage) StreamTitle(qw422016 *qt422016.Writer, ctx context.Context) { //line templates/error.qtpl:9 - StreamNavbar(qw422016, Git) + qw422016.N().S(`Error`) //line templates/error.qtpl:9 } //line templates/error.qtpl:9 -func (p *ErrorPage) WriteNavbar(qq422016 qtio422016.Writer) { +func (p *ErrorPage) WriteTitle(qq422016 qtio422016.Writer, ctx context.Context) { //line templates/error.qtpl:9 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/error.qtpl:9 - p.StreamNavbar(qw422016) + p.StreamTitle(qw422016, ctx) //line templates/error.qtpl:9 qt422016.ReleaseWriter(qw422016) //line templates/error.qtpl:9 } //line templates/error.qtpl:9 -func (p *ErrorPage) Navbar() string { +func (p *ErrorPage) Title(ctx context.Context) string { //line templates/error.qtpl:9 qb422016 := qt422016.AcquireByteBuffer() //line templates/error.qtpl:9 - p.WriteNavbar(qb422016) + p.WriteTitle(qb422016, ctx) //line templates/error.qtpl:9 qs422016 := string(qb422016.B) //line templates/error.qtpl:9 @@ -89,74 +59,107 @@ func (p *ErrorPage) Navbar() string { } //line templates/error.qtpl:11 -func (p *ErrorPage) StreamContent(qw422016 *qt422016.Writer) { +func (p *ErrorPage) StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/error.qtpl:11 + StreamNavbar(qw422016, ctx, Git) +//line templates/error.qtpl:11 +} + +//line templates/error.qtpl:11 +func (p *ErrorPage) WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/error.qtpl:11 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/error.qtpl:11 + p.StreamNavbar(qw422016, ctx) +//line templates/error.qtpl:11 + qt422016.ReleaseWriter(qw422016) +//line templates/error.qtpl:11 +} + +//line templates/error.qtpl:11 +func (p *ErrorPage) Navbar(ctx context.Context) string { +//line templates/error.qtpl:11 + qb422016 := qt422016.AcquireByteBuffer() //line templates/error.qtpl:11 + p.WriteNavbar(qb422016, ctx) +//line templates/error.qtpl:11 + qs422016 := string(qb422016.B) +//line templates/error.qtpl:11 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/error.qtpl:11 + return qs422016 +//line templates/error.qtpl:11 +} + +//line templates/error.qtpl:13 +func (p *ErrorPage) StreamContent(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/error.qtpl:13 qw422016.N().S(` `) -//line templates/error.qtpl:12 +//line templates/error.qtpl:14 qw422016.E().S(p.Message) -//line templates/error.qtpl:12 +//line templates/error.qtpl:14 qw422016.N().S(` `) -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 } -//line templates/error.qtpl:13 -func (p *ErrorPage) WriteContent(qq422016 qtio422016.Writer) { -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 +func (p *ErrorPage) WriteContent(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/error.qtpl:15 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/error.qtpl:13 - p.StreamContent(qw422016) -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 + p.StreamContent(qw422016, ctx) +//line templates/error.qtpl:15 qt422016.ReleaseWriter(qw422016) -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 } -//line templates/error.qtpl:13 -func (p *ErrorPage) Content() string { -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 +func (p *ErrorPage) Content(ctx context.Context) string { +//line templates/error.qtpl:15 qb422016 := qt422016.AcquireByteBuffer() -//line templates/error.qtpl:13 - p.WriteContent(qb422016) -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 + p.WriteContent(qb422016, ctx) +//line templates/error.qtpl:15 qs422016 := string(qb422016.B) -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 qt422016.ReleaseByteBuffer(qb422016) -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 return qs422016 -//line templates/error.qtpl:13 +//line templates/error.qtpl:15 } -//line templates/error.qtpl:15 -func (p *ErrorPage) StreamScript(qw422016 *qt422016.Writer) { -//line templates/error.qtpl:15 +//line templates/error.qtpl:17 +func (p *ErrorPage) StreamScript(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/error.qtpl:17 qw422016.N().S(` `) -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 } -//line templates/error.qtpl:16 -func (p *ErrorPage) WriteScript(qq422016 qtio422016.Writer) { -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 +func (p *ErrorPage) WriteScript(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/error.qtpl:18 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/error.qtpl:16 - p.StreamScript(qw422016) -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 + p.StreamScript(qw422016, ctx) +//line templates/error.qtpl:18 qt422016.ReleaseWriter(qw422016) -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 } -//line templates/error.qtpl:16 -func (p *ErrorPage) Script() string { -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 +func (p *ErrorPage) Script(ctx context.Context) string { +//line templates/error.qtpl:18 qb422016 := qt422016.AcquireByteBuffer() -//line templates/error.qtpl:16 - p.WriteScript(qb422016) -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 + p.WriteScript(qb422016, ctx) +//line templates/error.qtpl:18 qs422016 := string(qb422016.B) -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 qt422016.ReleaseByteBuffer(qb422016) -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 return qs422016 -//line templates/error.qtpl:16 +//line templates/error.qtpl:18 } diff --git a/templates/gititem.qtpl b/templates/gititem.qtpl index a6a312d..c43bbfd 100644 --- a/templates/gititem.qtpl +++ b/templates/gititem.qtpl @@ -1,3 +1,5 @@ +{% import "context" %} + {% interface GitItemBase { Nav(name, ref string) @@ -13,16 +15,16 @@ type GitItemPage struct { } %} -{% func (p *GitItemPage) Title() %}Git | {%s p.Name %}{% endfunc %} +{% func (p *GitItemPage) Title(ctx context.Context) %}Git | {%s p.Name %}{% endfunc %} -{% func (p *GitItemPage) Navbar() %}{%= Navbar(Git) %}{% endfunc %} +{% func (p *GitItemPage) Navbar(ctx context.Context) %}{%= Navbar(ctx, Git) %}{% endfunc %} -{% func (p *GitItemPage) Content() %} +{% func (p *GitItemPage) Content(ctx context.Context) %} {%= p.Nav(p.Name, p.Ref) %}
{%= p.GitContent(p.Name, p.Ref) %}
{% endfunc %} -{% func (p *GitItemPage) Script() %} +{% func (p *GitItemPage) Script(ctx context.Context) %} {% endfunc %} diff --git a/templates/gititem.qtpl.go b/templates/gititem.qtpl.go index c9a00b2..5292e44 100644 --- a/templates/gititem.qtpl.go +++ b/templates/gititem.qtpl.go @@ -5,101 +5,71 @@ package templates //line templates/gititem.qtpl:1 +import "context" + +//line templates/gititem.qtpl:3 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/gititem.qtpl:1 +//line templates/gititem.qtpl:3 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 type GitItemBase interface { -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 Nav(name, ref string) string -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 StreamNav(qw422016 *qt422016.Writer, name, ref string) -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 WriteNav(qq422016 qtio422016.Writer, name, ref string) -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 GitContent(name, ref string) string -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 StreamGitContent(qw422016 *qt422016.Writer, name, ref string) -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 WriteGitContent(qq422016 qtio422016.Writer, name, ref string) -//line templates/gititem.qtpl:2 +//line templates/gititem.qtpl:4 } -//line templates/gititem.qtpl:9 +//line templates/gititem.qtpl:11 type GitItemPage struct { Name string Ref string GitItemBase } -//line templates/gititem.qtpl:16 -func (p *GitItemPage) StreamTitle(qw422016 *qt422016.Writer) { -//line templates/gititem.qtpl:16 - qw422016.N().S(`Git | `) -//line templates/gititem.qtpl:16 - qw422016.E().S(p.Name) -//line templates/gititem.qtpl:16 -} - -//line templates/gititem.qtpl:16 -func (p *GitItemPage) WriteTitle(qq422016 qtio422016.Writer) { -//line templates/gititem.qtpl:16 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/gititem.qtpl:16 - p.StreamTitle(qw422016) -//line templates/gititem.qtpl:16 - qt422016.ReleaseWriter(qw422016) -//line templates/gititem.qtpl:16 -} - -//line templates/gititem.qtpl:16 -func (p *GitItemPage) Title() string { -//line templates/gititem.qtpl:16 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/gititem.qtpl:16 - p.WriteTitle(qb422016) -//line templates/gititem.qtpl:16 - qs422016 := string(qb422016.B) -//line templates/gititem.qtpl:16 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/gititem.qtpl:16 - return qs422016 -//line templates/gititem.qtpl:16 -} - //line templates/gititem.qtpl:18 -func (p *GitItemPage) StreamNavbar(qw422016 *qt422016.Writer) { +func (p *GitItemPage) StreamTitle(qw422016 *qt422016.Writer, ctx context.Context) { //line templates/gititem.qtpl:18 - StreamNavbar(qw422016, Git) + qw422016.N().S(`Git | `) +//line templates/gititem.qtpl:18 + qw422016.E().S(p.Name) //line templates/gititem.qtpl:18 } //line templates/gititem.qtpl:18 -func (p *GitItemPage) WriteNavbar(qq422016 qtio422016.Writer) { +func (p *GitItemPage) WriteTitle(qq422016 qtio422016.Writer, ctx context.Context) { //line templates/gititem.qtpl:18 qw422016 := qt422016.AcquireWriter(qq422016) //line templates/gititem.qtpl:18 - p.StreamNavbar(qw422016) + p.StreamTitle(qw422016, ctx) //line templates/gititem.qtpl:18 qt422016.ReleaseWriter(qw422016) //line templates/gititem.qtpl:18 } //line templates/gititem.qtpl:18 -func (p *GitItemPage) Navbar() string { +func (p *GitItemPage) Title(ctx context.Context) string { //line templates/gititem.qtpl:18 qb422016 := qt422016.AcquireByteBuffer() //line templates/gititem.qtpl:18 - p.WriteNavbar(qb422016) + p.WriteTitle(qb422016, ctx) //line templates/gititem.qtpl:18 qs422016 := string(qb422016.B) //line templates/gititem.qtpl:18 @@ -110,81 +80,114 @@ func (p *GitItemPage) Navbar() string { } //line templates/gititem.qtpl:20 -func (p *GitItemPage) StreamContent(qw422016 *qt422016.Writer) { +func (p *GitItemPage) StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/gititem.qtpl:20 + StreamNavbar(qw422016, ctx, Git) +//line templates/gititem.qtpl:20 +} + +//line templates/gititem.qtpl:20 +func (p *GitItemPage) WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/gititem.qtpl:20 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/gititem.qtpl:20 + p.StreamNavbar(qw422016, ctx) +//line templates/gititem.qtpl:20 + qt422016.ReleaseWriter(qw422016) +//line templates/gititem.qtpl:20 +} + +//line templates/gititem.qtpl:20 +func (p *GitItemPage) Navbar(ctx context.Context) string { +//line templates/gititem.qtpl:20 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/gititem.qtpl:20 + p.WriteNavbar(qb422016, ctx) +//line templates/gititem.qtpl:20 + qs422016 := string(qb422016.B) +//line templates/gititem.qtpl:20 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/gititem.qtpl:20 + return qs422016 //line templates/gititem.qtpl:20 +} + +//line templates/gititem.qtpl:22 +func (p *GitItemPage) StreamContent(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/gititem.qtpl:22 qw422016.N().S(` `) -//line templates/gititem.qtpl:21 +//line templates/gititem.qtpl:23 p.StreamNav(qw422016, p.Name, p.Ref) -//line templates/gititem.qtpl:21 +//line templates/gititem.qtpl:23 qw422016.N().S(`
`) -//line templates/gititem.qtpl:23 +//line templates/gititem.qtpl:25 p.StreamGitContent(qw422016, p.Name, p.Ref) -//line templates/gititem.qtpl:23 +//line templates/gititem.qtpl:25 qw422016.N().S(`
`) -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 } -//line templates/gititem.qtpl:25 -func (p *GitItemPage) WriteContent(qq422016 qtio422016.Writer) { -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 +func (p *GitItemPage) WriteContent(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/gititem.qtpl:27 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/gititem.qtpl:25 - p.StreamContent(qw422016) -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 + p.StreamContent(qw422016, ctx) +//line templates/gititem.qtpl:27 qt422016.ReleaseWriter(qw422016) -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 } -//line templates/gititem.qtpl:25 -func (p *GitItemPage) Content() string { -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 +func (p *GitItemPage) Content(ctx context.Context) string { +//line templates/gititem.qtpl:27 qb422016 := qt422016.AcquireByteBuffer() -//line templates/gititem.qtpl:25 - p.WriteContent(qb422016) -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 + p.WriteContent(qb422016, ctx) +//line templates/gititem.qtpl:27 qs422016 := string(qb422016.B) -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 qt422016.ReleaseByteBuffer(qb422016) -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 return qs422016 -//line templates/gititem.qtpl:25 +//line templates/gititem.qtpl:27 } -//line templates/gititem.qtpl:27 -func (p *GitItemPage) StreamScript(qw422016 *qt422016.Writer) { -//line templates/gititem.qtpl:27 +//line templates/gititem.qtpl:29 +func (p *GitItemPage) StreamScript(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/gititem.qtpl:29 qw422016.N().S(` `) -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 } -//line templates/gititem.qtpl:28 -func (p *GitItemPage) WriteScript(qq422016 qtio422016.Writer) { -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 +func (p *GitItemPage) WriteScript(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/gititem.qtpl:30 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/gititem.qtpl:28 - p.StreamScript(qw422016) -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 + p.StreamScript(qw422016, ctx) +//line templates/gititem.qtpl:30 qt422016.ReleaseWriter(qw422016) -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 } -//line templates/gititem.qtpl:28 -func (p *GitItemPage) Script() string { -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 +func (p *GitItemPage) Script(ctx context.Context) string { +//line templates/gititem.qtpl:30 qb422016 := qt422016.AcquireByteBuffer() -//line templates/gititem.qtpl:28 - p.WriteScript(qb422016) -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 + p.WriteScript(qb422016, ctx) +//line templates/gititem.qtpl:30 qs422016 := string(qb422016.B) -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 qt422016.ReleaseByteBuffer(qb422016) -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 return qs422016 -//line templates/gititem.qtpl:28 +//line templates/gititem.qtpl:30 } diff --git a/templates/gitlist.qtpl b/templates/gitlist.qtpl index 7c104ca..fa47008 100644 --- a/templates/gitlist.qtpl +++ b/templates/gitlist.qtpl @@ -1,4 +1,5 @@ {% import "git.gabrielgio.me/cerrado/pkg/service" %} +{% import "context" %} {% code type GitListPage struct { @@ -7,11 +8,11 @@ type GitListPage struct { } %} -{% func (p *GitListPage) Title() %}Git | List{% endfunc %} +{% func (p *GitListPage) Title(ctx context.Context) %}Git | List{% endfunc %} -{% func (p *GitListPage) Navbar() %}{%= Navbar(Git) %}{% endfunc %} +{% func (p *GitListPage) Navbar(ctx context.Context) %}{%= Navbar(ctx, Git) %}{% endfunc %} -{% func (p *GitListPage) Content() %} +{% func (p *GitListPage) Content(ctx context.Context) %}
@@ -40,5 +41,5 @@ type GitListPage struct {
{% endfunc %} -{% func (p *GitListPage) Script() %} +{% func (p *GitListPage) Script(ctx context.Context) %} {% endfunc %} diff --git a/templates/gitlist.qtpl.go b/templates/gitlist.qtpl.go index 29adbc6..601dbb2 100644 --- a/templates/gitlist.qtpl.go +++ b/templates/gitlist.qtpl.go @@ -7,159 +7,162 @@ package templates //line templates/gitlist.qtpl:1 import "git.gabrielgio.me/cerrado/pkg/service" -//line templates/gitlist.qtpl:3 +//line templates/gitlist.qtpl:2 +import "context" + +//line templates/gitlist.qtpl:4 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/gitlist.qtpl:3 +//line templates/gitlist.qtpl:4 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/gitlist.qtpl:4 +//line templates/gitlist.qtpl:5 type GitListPage struct { Respositories []*service.Repository About []byte } -//line templates/gitlist.qtpl:10 -func (p *GitListPage) StreamTitle(qw422016 *qt422016.Writer) { -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 +func (p *GitListPage) StreamTitle(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:11 qw422016.N().S(`Git | List`) -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 } -//line templates/gitlist.qtpl:10 -func (p *GitListPage) WriteTitle(qq422016 qtio422016.Writer) { -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 +func (p *GitListPage) WriteTitle(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:11 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/gitlist.qtpl:10 - p.StreamTitle(qw422016) -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 + p.StreamTitle(qw422016, ctx) +//line templates/gitlist.qtpl:11 qt422016.ReleaseWriter(qw422016) -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 } -//line templates/gitlist.qtpl:10 -func (p *GitListPage) Title() string { -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 +func (p *GitListPage) Title(ctx context.Context) string { +//line templates/gitlist.qtpl:11 qb422016 := qt422016.AcquireByteBuffer() -//line templates/gitlist.qtpl:10 - p.WriteTitle(qb422016) -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 + p.WriteTitle(qb422016, ctx) +//line templates/gitlist.qtpl:11 qs422016 := string(qb422016.B) -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 qt422016.ReleaseByteBuffer(qb422016) -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 return qs422016 -//line templates/gitlist.qtpl:10 +//line templates/gitlist.qtpl:11 } -//line templates/gitlist.qtpl:12 -func (p *GitListPage) StreamNavbar(qw422016 *qt422016.Writer) { -//line templates/gitlist.qtpl:12 - StreamNavbar(qw422016, Git) -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 +func (p *GitListPage) StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:13 + StreamNavbar(qw422016, ctx, Git) +//line templates/gitlist.qtpl:13 } -//line templates/gitlist.qtpl:12 -func (p *GitListPage) WriteNavbar(qq422016 qtio422016.Writer) { -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 +func (p *GitListPage) WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:13 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/gitlist.qtpl:12 - p.StreamNavbar(qw422016) -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 + p.StreamNavbar(qw422016, ctx) +//line templates/gitlist.qtpl:13 qt422016.ReleaseWriter(qw422016) -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 } -//line templates/gitlist.qtpl:12 -func (p *GitListPage) Navbar() string { -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 +func (p *GitListPage) Navbar(ctx context.Context) string { +//line templates/gitlist.qtpl:13 qb422016 := qt422016.AcquireByteBuffer() -//line templates/gitlist.qtpl:12 - p.WriteNavbar(qb422016) -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 + p.WriteNavbar(qb422016, ctx) +//line templates/gitlist.qtpl:13 qs422016 := string(qb422016.B) -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 qt422016.ReleaseByteBuffer(qb422016) -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 return qs422016 -//line templates/gitlist.qtpl:12 +//line templates/gitlist.qtpl:13 } -//line templates/gitlist.qtpl:14 -func (p *GitListPage) StreamContent(qw422016 *qt422016.Writer) { -//line templates/gitlist.qtpl:14 +//line templates/gitlist.qtpl:15 +func (p *GitListPage) StreamContent(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:15 qw422016.N().S(`
`) -//line templates/gitlist.qtpl:18 +//line templates/gitlist.qtpl:19 for _, r := range p.Respositories { -//line templates/gitlist.qtpl:18 +//line templates/gitlist.qtpl:19 qw422016.N().S(`

`) -//line templates/gitlist.qtpl:21 +//line templates/gitlist.qtpl:22 qw422016.E().S(r.Name) -//line templates/gitlist.qtpl:21 +//line templates/gitlist.qtpl:22 qw422016.N().S(`

`) -//line templates/gitlist.qtpl:24 +//line templates/gitlist.qtpl:25 qw422016.E().S(r.Description) -//line templates/gitlist.qtpl:24 +//line templates/gitlist.qtpl:25 qw422016.N().S(`

log tree refs

`) -//line templates/gitlist.qtpl:31 +//line templates/gitlist.qtpl:32 } -//line templates/gitlist.qtpl:31 +//line templates/gitlist.qtpl:32 qw422016.N().S(`
`) -//line templates/gitlist.qtpl:35 +//line templates/gitlist.qtpl:36 qw422016.N().Z(p.About) -//line templates/gitlist.qtpl:35 +//line templates/gitlist.qtpl:36 qw422016.N().S(`
`) -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 } -//line templates/gitlist.qtpl:41 -func (p *GitListPage) WriteContent(qq422016 qtio422016.Writer) { -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 +func (p *GitListPage) WriteContent(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:42 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/gitlist.qtpl:41 - p.StreamContent(qw422016) -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 + p.StreamContent(qw422016, ctx) +//line templates/gitlist.qtpl:42 qt422016.ReleaseWriter(qw422016) -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 } -//line templates/gitlist.qtpl:41 -func (p *GitListPage) Content() string { -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 +func (p *GitListPage) Content(ctx context.Context) string { +//line templates/gitlist.qtpl:42 qb422016 := qt422016.AcquireByteBuffer() -//line templates/gitlist.qtpl:41 - p.WriteContent(qb422016) -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 + p.WriteContent(qb422016, ctx) +//line templates/gitlist.qtpl:42 qs422016 := string(qb422016.B) -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 qt422016.ReleaseByteBuffer(qb422016) -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 return qs422016 -//line templates/gitlist.qtpl:41 +//line templates/gitlist.qtpl:42 } -//line templates/gitlist.qtpl:43 -func (p *GitListPage) StreamScript(qw422016 *qt422016.Writer) { -//line templates/gitlist.qtpl:43 +//line templates/gitlist.qtpl:44 +func (p *GitListPage) StreamScript(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:44 qw422016.N().S(` `) -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 } -//line templates/gitlist.qtpl:44 -func (p *GitListPage) WriteScript(qq422016 qtio422016.Writer) { -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 +func (p *GitListPage) WriteScript(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/gitlist.qtpl:45 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/gitlist.qtpl:44 - p.StreamScript(qw422016) -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 + p.StreamScript(qw422016, ctx) +//line templates/gitlist.qtpl:45 qt422016.ReleaseWriter(qw422016) -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 } -//line templates/gitlist.qtpl:44 -func (p *GitListPage) Script() string { -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 +func (p *GitListPage) Script(ctx context.Context) string { +//line templates/gitlist.qtpl:45 qb422016 := qt422016.AcquireByteBuffer() -//line templates/gitlist.qtpl:44 - p.WriteScript(qb422016) -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 + p.WriteScript(qb422016, ctx) +//line templates/gitlist.qtpl:45 qs422016 := string(qb422016.B) -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 qt422016.ReleaseByteBuffer(qb422016) -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 return qs422016 -//line templates/gitlist.qtpl:44 +//line templates/gitlist.qtpl:45 } diff --git a/templates/login.qtpl b/templates/login.qtpl index eee5711..7815bd7 100644 --- a/templates/login.qtpl +++ b/templates/login.qtpl @@ -1,31 +1,41 @@ +{% import "context" %} + {% code type LoginPage struct { + ErrorMessage string } %} -{% func (p *LoginPage) Title() %}Hello{% endfunc %} +{% func (p *LoginPage) Title(ctx context.Context) %}Hello{% endfunc %} -{% func (p *LoginPage) Navbar() %}{%= Navbar(Login) %}{% endfunc %} +{% func (p *LoginPage) Navbar(ctx context.Context) %}{%= Navbar(ctx, Login) %}{% endfunc %} -{% func (p *LoginPage) Content() %} +{% func (p *LoginPage) Content(ctx context.Context) %}
-
+
- +
- +
+ {% if p.ErrorMessage != "" %} +
+
+ {%s p.ErrorMessage %} +
+
+ {% endif %}
{% endfunc %} -{% func (p *LoginPage) Script() %} +{% func (p *LoginPage) Script(ctx context.Context) %} {% endfunc %} diff --git a/templates/login.qtpl.go b/templates/login.qtpl.go index 0d3d2b0..5c07a44 100644 --- a/templates/login.qtpl.go +++ b/templates/login.qtpl.go @@ -5,169 +5,192 @@ package templates //line templates/login.qtpl:1 +import "context" + +//line templates/login.qtpl:3 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/login.qtpl:1 +//line templates/login.qtpl:3 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/login.qtpl:2 +//line templates/login.qtpl:4 type LoginPage struct { + ErrorMessage string } -//line templates/login.qtpl:6 -func (p *LoginPage) StreamTitle(qw422016 *qt422016.Writer) { -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 +func (p *LoginPage) StreamTitle(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/login.qtpl:9 qw422016.N().S(`Hello`) -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 } -//line templates/login.qtpl:6 -func (p *LoginPage) WriteTitle(qq422016 qtio422016.Writer) { -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 +func (p *LoginPage) WriteTitle(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/login.qtpl:9 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/login.qtpl:6 - p.StreamTitle(qw422016) -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 + p.StreamTitle(qw422016, ctx) +//line templates/login.qtpl:9 qt422016.ReleaseWriter(qw422016) -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 } -//line templates/login.qtpl:6 -func (p *LoginPage) Title() string { -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 +func (p *LoginPage) Title(ctx context.Context) string { +//line templates/login.qtpl:9 qb422016 := qt422016.AcquireByteBuffer() -//line templates/login.qtpl:6 - p.WriteTitle(qb422016) -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 + p.WriteTitle(qb422016, ctx) +//line templates/login.qtpl:9 qs422016 := string(qb422016.B) -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 qt422016.ReleaseByteBuffer(qb422016) -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 return qs422016 -//line templates/login.qtpl:6 +//line templates/login.qtpl:9 } -//line templates/login.qtpl:8 -func (p *LoginPage) StreamNavbar(qw422016 *qt422016.Writer) { -//line templates/login.qtpl:8 - StreamNavbar(qw422016, Login) -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 +func (p *LoginPage) StreamNavbar(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/login.qtpl:11 + StreamNavbar(qw422016, ctx, Login) +//line templates/login.qtpl:11 } -//line templates/login.qtpl:8 -func (p *LoginPage) WriteNavbar(qq422016 qtio422016.Writer) { -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 +func (p *LoginPage) WriteNavbar(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/login.qtpl:11 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/login.qtpl:8 - p.StreamNavbar(qw422016) -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 + p.StreamNavbar(qw422016, ctx) +//line templates/login.qtpl:11 qt422016.ReleaseWriter(qw422016) -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 } -//line templates/login.qtpl:8 -func (p *LoginPage) Navbar() string { -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 +func (p *LoginPage) Navbar(ctx context.Context) string { +//line templates/login.qtpl:11 qb422016 := qt422016.AcquireByteBuffer() -//line templates/login.qtpl:8 - p.WriteNavbar(qb422016) -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 + p.WriteNavbar(qb422016, ctx) +//line templates/login.qtpl:11 qs422016 := string(qb422016.B) -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 qt422016.ReleaseByteBuffer(qb422016) -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 return qs422016 -//line templates/login.qtpl:8 +//line templates/login.qtpl:11 } -//line templates/login.qtpl:10 -func (p *LoginPage) StreamContent(qw422016 *qt422016.Writer) { -//line templates/login.qtpl:10 +//line templates/login.qtpl:13 +func (p *LoginPage) StreamContent(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/login.qtpl:13 qw422016.N().S(`
-
+
- +
- +
+ `) +//line templates/login.qtpl:30 + if p.ErrorMessage != "" { +//line templates/login.qtpl:30 + qw422016.N().S(` +
+
+ `) +//line templates/login.qtpl:33 + qw422016.E().S(p.ErrorMessage) +//line templates/login.qtpl:33 + qw422016.N().S(` +
+
+ `) +//line templates/login.qtpl:36 + } +//line templates/login.qtpl:36 + qw422016.N().S(`
`) -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 } -//line templates/login.qtpl:28 -func (p *LoginPage) WriteContent(qq422016 qtio422016.Writer) { -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 +func (p *LoginPage) WriteContent(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/login.qtpl:38 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/login.qtpl:28 - p.StreamContent(qw422016) -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 + p.StreamContent(qw422016, ctx) +//line templates/login.qtpl:38 qt422016.ReleaseWriter(qw422016) -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 } -//line templates/login.qtpl:28 -func (p *LoginPage) Content() string { -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 +func (p *LoginPage) Content(ctx context.Context) string { +//line templates/login.qtpl:38 qb422016 := qt422016.AcquireByteBuffer() -//line templates/login.qtpl:28 - p.WriteContent(qb422016) -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 + p.WriteContent(qb422016, ctx) +//line templates/login.qtpl:38 qs422016 := string(qb422016.B) -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 qt422016.ReleaseByteBuffer(qb422016) -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 return qs422016 -//line templates/login.qtpl:28 +//line templates/login.qtpl:38 } -//line templates/login.qtpl:30 -func (p *LoginPage) StreamScript(qw422016 *qt422016.Writer) { -//line templates/login.qtpl:30 +//line templates/login.qtpl:40 +func (p *LoginPage) StreamScript(qw422016 *qt422016.Writer, ctx context.Context) { +//line templates/login.qtpl:40 qw422016.N().S(` `) -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 } -//line templates/login.qtpl:31 -func (p *LoginPage) WriteScript(qq422016 qtio422016.Writer) { -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 +func (p *LoginPage) WriteScript(qq422016 qtio422016.Writer, ctx context.Context) { +//line templates/login.qtpl:41 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/login.qtpl:31 - p.StreamScript(qw422016) -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 + p.StreamScript(qw422016, ctx) +//line templates/login.qtpl:41 qt422016.ReleaseWriter(qw422016) -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 } -//line templates/login.qtpl:31 -func (p *LoginPage) Script() string { -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 +func (p *LoginPage) Script(ctx context.Context) string { +//line templates/login.qtpl:41 qb422016 := qt422016.AcquireByteBuffer() -//line templates/login.qtpl:31 - p.WriteScript(qb422016) -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 + p.WriteScript(qb422016, ctx) +//line templates/login.qtpl:41 qs422016 := string(qb422016.B) -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 qt422016.ReleaseByteBuffer(qb422016) -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 return qs422016 -//line templates/login.qtpl:31 +//line templates/login.qtpl:41 } diff --git a/templates/navbar.qtpl b/templates/navbar.qtpl index 18400b1..3cd1b39 100644 --- a/templates/navbar.qtpl +++ b/templates/navbar.qtpl @@ -1,3 +1,5 @@ +{% import "context" %} + {% code type Selection int const ( @@ -22,13 +24,17 @@ const ( {% func insertIfEqual(s, d any) %}{% if s == d %} selected{% endif %}{% endfunc %} -{% func Navbar (s Selection) %} +{% func Navbar (ctx context.Context, s Selection) %}