From 791103b8a78cd22ad0faf557be639853f1efc69f Mon Sep 17 00:00:00 2001 From: lv <~@l1v.in> Date: Sat, 25 Sep 2021 12:01:34 -0400 Subject: [PATCH] fix: Add temporary templates to fix Docker build --- templates/basepage.qtpl | 31 +++++ templates/basepage.qtpl.go | 165 ++++++++++++++++++++++ templates/errorpage.qtpl | 20 +++ templates/errorpage.qtpl.go | 77 +++++++++++ templates/mainpage.qtpl | 31 +++++ templates/mainpage.qtpl.go | 119 ++++++++++++++++ templates/tablepage.qtpl | 58 ++++++++ templates/tablepage.qtpl.go | 265 ++++++++++++++++++++++++++++++++++++ 8 files changed, 766 insertions(+) create mode 100644 templates/basepage.qtpl create mode 100644 templates/basepage.qtpl.go create mode 100644 templates/errorpage.qtpl create mode 100644 templates/errorpage.qtpl.go create mode 100644 templates/mainpage.qtpl create mode 100644 templates/mainpage.qtpl.go create mode 100644 templates/tablepage.qtpl create mode 100644 templates/tablepage.qtpl.go diff --git a/templates/basepage.qtpl b/templates/basepage.qtpl new file mode 100644 index 0000000..155e773 --- /dev/null +++ b/templates/basepage.qtpl @@ -0,0 +1,31 @@ +This is a base page template. All the other template pages implement this interface. + +{% interface +Page { + Title() + Body() +} +%} + + +Page prints a page implementing Page interface. +{% func PageTemplate(p Page) %} + + + {%= p.Title() %} + + +
+ return to main page +
+ {%= p.Body() %} + + +{% endfunc %} + + +Base page implementation. Other pages may inherit from it if they need +overriding only certain Page methods +{% code type BasePage struct {} %} +{% func (p *BasePage) Title() %}This is a base title{% endfunc %} +{% func (p *BasePage) Body() %}This is a base body{% endfunc %} diff --git a/templates/basepage.qtpl.go b/templates/basepage.qtpl.go new file mode 100644 index 0000000..9bc62ee --- /dev/null +++ b/templates/basepage.qtpl.go @@ -0,0 +1,165 @@ +// Code generated by qtc from "basepage.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +// This is a base page template. All the other template pages implement this interface. +// + +//line templates/basepage.qtpl:3 +package templates + +//line templates/basepage.qtpl:3 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line templates/basepage.qtpl:3 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line templates/basepage.qtpl:4 +type Page interface { +//line templates/basepage.qtpl:4 + Title() string +//line templates/basepage.qtpl:4 + StreamTitle(qw422016 *qt422016.Writer) +//line templates/basepage.qtpl:4 + WriteTitle(qq422016 qtio422016.Writer) +//line templates/basepage.qtpl:4 + Body() string +//line templates/basepage.qtpl:4 + StreamBody(qw422016 *qt422016.Writer) +//line templates/basepage.qtpl:4 + WriteBody(qq422016 qtio422016.Writer) +//line templates/basepage.qtpl:4 +} + +// Page prints a page implementing Page interface. + +//line templates/basepage.qtpl:12 +func StreamPageTemplate(qw422016 *qt422016.Writer, p Page) { +//line templates/basepage.qtpl:12 + qw422016.N().S(` + + + `) +//line templates/basepage.qtpl:15 + p.StreamTitle(qw422016) +//line templates/basepage.qtpl:15 + qw422016.N().S(` + + +
+ return to main page +
+ `) +//line templates/basepage.qtpl:21 + p.StreamBody(qw422016) +//line templates/basepage.qtpl:21 + qw422016.N().S(` + + +`) +//line templates/basepage.qtpl:24 +} + +//line templates/basepage.qtpl:24 +func WritePageTemplate(qq422016 qtio422016.Writer, p Page) { +//line templates/basepage.qtpl:24 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/basepage.qtpl:24 + StreamPageTemplate(qw422016, p) +//line templates/basepage.qtpl:24 + qt422016.ReleaseWriter(qw422016) +//line templates/basepage.qtpl:24 +} + +//line templates/basepage.qtpl:24 +func PageTemplate(p Page) string { +//line templates/basepage.qtpl:24 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/basepage.qtpl:24 + WritePageTemplate(qb422016, p) +//line templates/basepage.qtpl:24 + qs422016 := string(qb422016.B) +//line templates/basepage.qtpl:24 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/basepage.qtpl:24 + return qs422016 +//line templates/basepage.qtpl:24 +} + +// Base page implementation. Other pages may inherit from it if they need +// overriding only certain Page methods + +//line templates/basepage.qtpl:29 +type BasePage struct{} + +//line templates/basepage.qtpl:30 +func (p *BasePage) StreamTitle(qw422016 *qt422016.Writer) { +//line templates/basepage.qtpl:30 + qw422016.N().S(`This is a base title`) +//line templates/basepage.qtpl:30 +} + +//line templates/basepage.qtpl:30 +func (p *BasePage) WriteTitle(qq422016 qtio422016.Writer) { +//line templates/basepage.qtpl:30 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/basepage.qtpl:30 + p.StreamTitle(qw422016) +//line templates/basepage.qtpl:30 + qt422016.ReleaseWriter(qw422016) +//line templates/basepage.qtpl:30 +} + +//line templates/basepage.qtpl:30 +func (p *BasePage) Title() string { +//line templates/basepage.qtpl:30 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/basepage.qtpl:30 + p.WriteTitle(qb422016) +//line templates/basepage.qtpl:30 + qs422016 := string(qb422016.B) +//line templates/basepage.qtpl:30 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/basepage.qtpl:30 + return qs422016 +//line templates/basepage.qtpl:30 +} + +//line templates/basepage.qtpl:31 +func (p *BasePage) StreamBody(qw422016 *qt422016.Writer) { +//line templates/basepage.qtpl:31 + qw422016.N().S(`This is a base body`) +//line templates/basepage.qtpl:31 +} + +//line templates/basepage.qtpl:31 +func (p *BasePage) WriteBody(qq422016 qtio422016.Writer) { +//line templates/basepage.qtpl:31 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/basepage.qtpl:31 + p.StreamBody(qw422016) +//line templates/basepage.qtpl:31 + qt422016.ReleaseWriter(qw422016) +//line templates/basepage.qtpl:31 +} + +//line templates/basepage.qtpl:31 +func (p *BasePage) Body() string { +//line templates/basepage.qtpl:31 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/basepage.qtpl:31 + p.WriteBody(qb422016) +//line templates/basepage.qtpl:31 + qs422016 := string(qb422016.B) +//line templates/basepage.qtpl:31 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/basepage.qtpl:31 + return qs422016 +//line templates/basepage.qtpl:31 +} diff --git a/templates/errorpage.qtpl b/templates/errorpage.qtpl new file mode 100644 index 0000000..71eb68e --- /dev/null +++ b/templates/errorpage.qtpl @@ -0,0 +1,20 @@ +// Error page template. Implements BasePage methods. + +{% code +type ErrorPage struct { + // inherit from base page, so its' title is used in error page. + BasePage + + // error path + Path []byte +} +%} + + +{% func (p *ErrorPage) Body() %} +

Error page

+ + Unsupported path {%z p.Path %}. + + Base page body: {%= p.BasePage.Body() %} +{% endfunc %} diff --git a/templates/errorpage.qtpl.go b/templates/errorpage.qtpl.go new file mode 100644 index 0000000..da15d4e --- /dev/null +++ b/templates/errorpage.qtpl.go @@ -0,0 +1,77 @@ +// Code generated by qtc from "errorpage.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +// Error page template. Implements BasePage methods. +// + +//line templates/errorpage.qtpl:3 +package templates + +//line templates/errorpage.qtpl:3 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line templates/errorpage.qtpl:3 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line templates/errorpage.qtpl:4 +type ErrorPage struct { + // inherit from base page, so its' title is used in error page. + BasePage + + // error path + Path []byte +} + +//line templates/errorpage.qtpl:14 +func (p *ErrorPage) StreamBody(qw422016 *qt422016.Writer) { +//line templates/errorpage.qtpl:14 + qw422016.N().S(` +

Error page

+ + Unsupported path `) +//line templates/errorpage.qtpl:17 + qw422016.E().Z(p.Path) +//line templates/errorpage.qtpl:17 + qw422016.N().S(`. + + Base page body: `) +//line templates/errorpage.qtpl:19 + p.BasePage.StreamBody(qw422016) +//line templates/errorpage.qtpl:19 + qw422016.N().S(` +`) +//line templates/errorpage.qtpl:20 +} + +//line templates/errorpage.qtpl:20 +func (p *ErrorPage) WriteBody(qq422016 qtio422016.Writer) { +//line templates/errorpage.qtpl:20 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/errorpage.qtpl:20 + p.StreamBody(qw422016) +//line templates/errorpage.qtpl:20 + qt422016.ReleaseWriter(qw422016) +//line templates/errorpage.qtpl:20 +} + +//line templates/errorpage.qtpl:20 +func (p *ErrorPage) Body() string { +//line templates/errorpage.qtpl:20 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/errorpage.qtpl:20 + p.WriteBody(qb422016) +//line templates/errorpage.qtpl:20 + qs422016 := string(qb422016.B) +//line templates/errorpage.qtpl:20 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/errorpage.qtpl:20 + return qs422016 +//line templates/errorpage.qtpl:20 +} diff --git a/templates/mainpage.qtpl b/templates/mainpage.qtpl new file mode 100644 index 0000000..ec1ac4e --- /dev/null +++ b/templates/mainpage.qtpl @@ -0,0 +1,31 @@ +// Main page template. Implements BasePage methods. + +{% import "github.com/valyala/fasthttp" %} + +{% code +type MainPage struct { + CTX *fasthttp.RequestCtx +} +%} + + +{% func (p *MainPage) Title() %} + This is the main page +{% endfunc %} + + +{% func (p *MainPage) Body() %} +

Main page

+
+ Click links below: + +
+
+ Some info about you:
+ IP: {%s p.CTX.RemoteIP().String() %}
+ User-Agent: {%z p.CTX.UserAgent() %}
+
+{% endfunc %} diff --git a/templates/mainpage.qtpl.go b/templates/mainpage.qtpl.go new file mode 100644 index 0000000..2e1c978 --- /dev/null +++ b/templates/mainpage.qtpl.go @@ -0,0 +1,119 @@ +// Code generated by qtc from "mainpage.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +// Main page template. Implements BasePage methods. +// + +//line templates/mainpage.qtpl:3 +package templates + +//line templates/mainpage.qtpl:3 +import "github.com/valyala/fasthttp" + +//line templates/mainpage.qtpl:5 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line templates/mainpage.qtpl:5 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line templates/mainpage.qtpl:6 +type MainPage struct { + CTX *fasthttp.RequestCtx +} + +//line templates/mainpage.qtpl:12 +func (p *MainPage) StreamTitle(qw422016 *qt422016.Writer) { +//line templates/mainpage.qtpl:12 + qw422016.N().S(` + This is the main page +`) +//line templates/mainpage.qtpl:14 +} + +//line templates/mainpage.qtpl:14 +func (p *MainPage) WriteTitle(qq422016 qtio422016.Writer) { +//line templates/mainpage.qtpl:14 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/mainpage.qtpl:14 + p.StreamTitle(qw422016) +//line templates/mainpage.qtpl:14 + qt422016.ReleaseWriter(qw422016) +//line templates/mainpage.qtpl:14 +} + +//line templates/mainpage.qtpl:14 +func (p *MainPage) Title() string { +//line templates/mainpage.qtpl:14 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/mainpage.qtpl:14 + p.WriteTitle(qb422016) +//line templates/mainpage.qtpl:14 + qs422016 := string(qb422016.B) +//line templates/mainpage.qtpl:14 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/mainpage.qtpl:14 + return qs422016 +//line templates/mainpage.qtpl:14 +} + +//line templates/mainpage.qtpl:17 +func (p *MainPage) StreamBody(qw422016 *qt422016.Writer) { +//line templates/mainpage.qtpl:17 + qw422016.N().S(` +

Main page

+
+ Click links below: + +
+
+ Some info about you:
+ IP: `) +//line templates/mainpage.qtpl:28 + qw422016.E().S(p.CTX.RemoteIP().String()) +//line templates/mainpage.qtpl:28 + qw422016.N().S(`
+ User-Agent: `) +//line templates/mainpage.qtpl:29 + qw422016.E().Z(p.CTX.UserAgent()) +//line templates/mainpage.qtpl:29 + qw422016.N().S(`
+
+`) +//line templates/mainpage.qtpl:31 +} + +//line templates/mainpage.qtpl:31 +func (p *MainPage) WriteBody(qq422016 qtio422016.Writer) { +//line templates/mainpage.qtpl:31 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/mainpage.qtpl:31 + p.StreamBody(qw422016) +//line templates/mainpage.qtpl:31 + qt422016.ReleaseWriter(qw422016) +//line templates/mainpage.qtpl:31 +} + +//line templates/mainpage.qtpl:31 +func (p *MainPage) Body() string { +//line templates/mainpage.qtpl:31 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/mainpage.qtpl:31 + p.WriteBody(qb422016) +//line templates/mainpage.qtpl:31 + qs422016 := string(qb422016.B) +//line templates/mainpage.qtpl:31 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/mainpage.qtpl:31 + return qs422016 +//line templates/mainpage.qtpl:31 +} diff --git a/templates/tablepage.qtpl b/templates/tablepage.qtpl new file mode 100644 index 0000000..0d1870a --- /dev/null +++ b/templates/tablepage.qtpl @@ -0,0 +1,58 @@ +// Table page template. Implements BasePage methods. + +{% code +type TablePage struct { + Rows []string +} +%} + + +{% func (p *TablePage) Title() %} + This is table page +{% endfunc %} + + +{% func (p *TablePage) Body() %} +

Table page

+ + {%= p.form() %} + + {% if len(p.Rows) == 0 %} + No rows. Click here. + {% else %} + + {%= emitRows(p.Rows) %} +
+ {% endif %} +{% endfunc %} + +{% func emitRows(rows []string) %} + + # + value + + + {% for n, r := range rows %} + {% if r == "bingo" %} +

BINGO!

+ {% return %} + {% elseif n == 42 %} + 42 rows already generated + {% break %} + {% endif %} + + + {%d n+1 %} + {%s r %} + + {% endfor %} + + No bingo found +{% endfunc %} + +{% func (p *TablePage) form() %} +
+ Rows:
+ +
+{% endfunc %} diff --git a/templates/tablepage.qtpl.go b/templates/tablepage.qtpl.go new file mode 100644 index 0000000..433644d --- /dev/null +++ b/templates/tablepage.qtpl.go @@ -0,0 +1,265 @@ +// Code generated by qtc from "tablepage.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +// Table page template. Implements BasePage methods. +// + +//line templates/tablepage.qtpl:3 +package templates + +//line templates/tablepage.qtpl:3 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line templates/tablepage.qtpl:3 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line templates/tablepage.qtpl:4 +type TablePage struct { + Rows []string +} + +//line templates/tablepage.qtpl:10 +func (p *TablePage) StreamTitle(qw422016 *qt422016.Writer) { +//line templates/tablepage.qtpl:10 + qw422016.N().S(` + This is table page +`) +//line templates/tablepage.qtpl:12 +} + +//line templates/tablepage.qtpl:12 +func (p *TablePage) WriteTitle(qq422016 qtio422016.Writer) { +//line templates/tablepage.qtpl:12 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/tablepage.qtpl:12 + p.StreamTitle(qw422016) +//line templates/tablepage.qtpl:12 + qt422016.ReleaseWriter(qw422016) +//line templates/tablepage.qtpl:12 +} + +//line templates/tablepage.qtpl:12 +func (p *TablePage) Title() string { +//line templates/tablepage.qtpl:12 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/tablepage.qtpl:12 + p.WriteTitle(qb422016) +//line templates/tablepage.qtpl:12 + qs422016 := string(qb422016.B) +//line templates/tablepage.qtpl:12 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/tablepage.qtpl:12 + return qs422016 +//line templates/tablepage.qtpl:12 +} + +//line templates/tablepage.qtpl:15 +func (p *TablePage) StreamBody(qw422016 *qt422016.Writer) { +//line templates/tablepage.qtpl:15 + qw422016.N().S(` +

Table page

+ + `) +//line templates/tablepage.qtpl:18 + p.streamform(qw422016) +//line templates/tablepage.qtpl:18 + qw422016.N().S(` + + `) +//line templates/tablepage.qtpl:20 + if len(p.Rows) == 0 { +//line templates/tablepage.qtpl:20 + qw422016.N().S(` + No rows. Click here. + `) +//line templates/tablepage.qtpl:22 + } else { +//line templates/tablepage.qtpl:22 + qw422016.N().S(` + + `) +//line templates/tablepage.qtpl:24 + streamemitRows(qw422016, p.Rows) +//line templates/tablepage.qtpl:24 + qw422016.N().S(` +
+ `) +//line templates/tablepage.qtpl:26 + } +//line templates/tablepage.qtpl:26 + qw422016.N().S(` +`) +//line templates/tablepage.qtpl:27 +} + +//line templates/tablepage.qtpl:27 +func (p *TablePage) WriteBody(qq422016 qtio422016.Writer) { +//line templates/tablepage.qtpl:27 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/tablepage.qtpl:27 + p.StreamBody(qw422016) +//line templates/tablepage.qtpl:27 + qt422016.ReleaseWriter(qw422016) +//line templates/tablepage.qtpl:27 +} + +//line templates/tablepage.qtpl:27 +func (p *TablePage) Body() string { +//line templates/tablepage.qtpl:27 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/tablepage.qtpl:27 + p.WriteBody(qb422016) +//line templates/tablepage.qtpl:27 + qs422016 := string(qb422016.B) +//line templates/tablepage.qtpl:27 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/tablepage.qtpl:27 + return qs422016 +//line templates/tablepage.qtpl:27 +} + +//line templates/tablepage.qtpl:29 +func streamemitRows(qw422016 *qt422016.Writer, rows []string) { +//line templates/tablepage.qtpl:29 + qw422016.N().S(` + + # + value + + + `) +//line templates/tablepage.qtpl:35 + for n, r := range rows { +//line templates/tablepage.qtpl:35 + qw422016.N().S(` + `) +//line templates/tablepage.qtpl:36 + if r == "bingo" { +//line templates/tablepage.qtpl:36 + qw422016.N().S(` +

BINGO!

+ `) +//line templates/tablepage.qtpl:38 + return +//line templates/tablepage.qtpl:39 + } else if n == 42 { +//line templates/tablepage.qtpl:39 + qw422016.N().S(` + 42 rows already generated + `) +//line templates/tablepage.qtpl:41 + break +//line templates/tablepage.qtpl:42 + } +//line templates/tablepage.qtpl:42 + qw422016.N().S(` + + + `) +//line templates/tablepage.qtpl:45 + qw422016.N().D(n + 1) +//line templates/tablepage.qtpl:45 + qw422016.N().S(` + `) +//line templates/tablepage.qtpl:46 + qw422016.E().S(r) +//line templates/tablepage.qtpl:46 + qw422016.N().S(` + + `) +//line templates/tablepage.qtpl:48 + } +//line templates/tablepage.qtpl:48 + qw422016.N().S(` + + No bingo found +`) +//line templates/tablepage.qtpl:51 +} + +//line templates/tablepage.qtpl:51 +func writeemitRows(qq422016 qtio422016.Writer, rows []string) { +//line templates/tablepage.qtpl:51 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/tablepage.qtpl:51 + streamemitRows(qw422016, rows) +//line templates/tablepage.qtpl:51 + qt422016.ReleaseWriter(qw422016) +//line templates/tablepage.qtpl:51 +} + +//line templates/tablepage.qtpl:51 +func emitRows(rows []string) string { +//line templates/tablepage.qtpl:51 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/tablepage.qtpl:51 + writeemitRows(qb422016, rows) +//line templates/tablepage.qtpl:51 + qs422016 := string(qb422016.B) +//line templates/tablepage.qtpl:51 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/tablepage.qtpl:51 + return qs422016 +//line templates/tablepage.qtpl:51 +} + +//line templates/tablepage.qtpl:53 +func (p *TablePage) streamform(qw422016 *qt422016.Writer) { +//line templates/tablepage.qtpl:53 + qw422016.N().S(` +
+ Rows:
+ +
+`) +//line templates/tablepage.qtpl:58 +} + +//line templates/tablepage.qtpl:58 +func (p *TablePage) writeform(qq422016 qtio422016.Writer) { +//line templates/tablepage.qtpl:58 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/tablepage.qtpl:58 + p.streamform(qw422016) +//line templates/tablepage.qtpl:58 + qt422016.ReleaseWriter(qw422016) +//line templates/tablepage.qtpl:58 +} + +//line templates/tablepage.qtpl:58 +func (p *TablePage) form() string { +//line templates/tablepage.qtpl:58 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/tablepage.qtpl:58 + p.writeform(qb422016) +//line templates/tablepage.qtpl:58 + qs422016 := string(qb422016.B) +//line templates/tablepage.qtpl:58 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/tablepage.qtpl:58 + return qs422016 +//line templates/tablepage.qtpl:58 +}