diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-26 23:07:42 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-26 23:07:42 +0200 |
commit | 60e8e751c76d949a28eefe0c5462e0cf17337217 (patch) | |
tree | 59eaf44623710c7031dd3930b8d7bbdcde1b5d9d | |
parent | e991b497e8433ee207e597b17f0b7daa3a0e0f26 (diff) | |
download | cerrado-60e8e751c76d949a28eefe0c5462e0cf17337217.tar.gz cerrado-60e8e751c76d949a28eefe0c5462e0cf17337217.tar.bz2 cerrado-60e8e751c76d949a28eefe0c5462e0cf17337217.zip |
feat: Add slug to build
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | templates/base.qtpl | 5 | ||||
-rw-r--r-- | templates/base.qtpl.go | 141 |
3 files changed, 91 insertions, 71 deletions
@@ -1,5 +1,10 @@ -build: sass tmpl - go build -o bin/cerrado +COMMIT := $(shell git rev-parse --short HEAD) +LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(COMMIT)' -s -w" + +build: sass-slug tmpl + go build \ + -ldflags=$(LDFLAGS) \ + -o bin/cerrado run: sass tmpl go run . @@ -7,8 +12,13 @@ run: sass tmpl test: go test -v --tags=unit ./... +sass-slug: + mkdir -p static + sassc \ + -I scss scss/main.scss static/main.$(COMMIT).css + sass: - @mkdir -p static + mkdir -p static sassc \ -I scss scss/main.scss static/main.css diff --git a/templates/base.qtpl b/templates/base.qtpl index 444afc6..d8d1d34 100644 --- a/templates/base.qtpl +++ b/templates/base.qtpl @@ -19,6 +19,9 @@ Page { } %} +{% code + var Slug = "" +%} Page prints a page implementing Page interface. {% func PageTemplate(p Page) %} @@ -27,7 +30,7 @@ Page prints a page implementing Page interface. <meta charset="utf-8"> <link rel="icon" href="data:,"> <title>cerrado | {%= p.Title() %}</title> - <link rel="stylesheet" href="/static/main.css"> + <link rel="stylesheet" href="/static/main{%s Slug%}.css"> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head> <body> diff --git a/templates/base.qtpl.go b/templates/base.qtpl.go index 1d30cd8..15c9e4f 100644 --- a/templates/base.qtpl.go +++ b/templates/base.qtpl.go @@ -54,22 +54,29 @@ func FromUInttoString(u *uint) string { return "" } +//line base.qtpl:23 +var Slug = "" + // Page prints a page implementing Page interface. -//line base.qtpl:24 +//line base.qtpl:27 func StreamPageTemplate(qw422016 *qt422016.Writer, p Page) { -//line base.qtpl:24 +//line base.qtpl:27 qw422016.N().S(` <html lang="en"> <head> <meta charset="utf-8"> <link rel="icon" href="data:,"> <title>cerrado | `) -//line base.qtpl:29 +//line base.qtpl:32 p.StreamTitle(qw422016) -//line base.qtpl:29 +//line base.qtpl:32 qw422016.N().S(`</title> - <link rel="stylesheet" href="/static/main.css"> + <link rel="stylesheet" href="/static/main`) +//line base.qtpl:33 + qw422016.E().S(Slug) +//line base.qtpl:33 + qw422016.N().S(`.css"> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head> <body> @@ -83,144 +90,144 @@ func StreamPageTemplate(qw422016 *qt422016.Writer, p Page) { </nav> <div class="container"> `) -//line base.qtpl:43 +//line base.qtpl:46 p.StreamContent(qw422016) -//line base.qtpl:43 +//line base.qtpl:46 qw422016.N().S(` </div> </body> `) -//line base.qtpl:46 +//line base.qtpl:49 p.StreamScript(qw422016) -//line base.qtpl:46 +//line base.qtpl:49 qw422016.N().S(` </html> `) -//line base.qtpl:48 +//line base.qtpl:51 } -//line base.qtpl:48 +//line base.qtpl:51 func WritePageTemplate(qq422016 qtio422016.Writer, p Page) { -//line base.qtpl:48 +//line base.qtpl:51 qw422016 := qt422016.AcquireWriter(qq422016) -//line base.qtpl:48 +//line base.qtpl:51 StreamPageTemplate(qw422016, p) -//line base.qtpl:48 +//line base.qtpl:51 qt422016.ReleaseWriter(qw422016) -//line base.qtpl:48 +//line base.qtpl:51 } -//line base.qtpl:48 +//line base.qtpl:51 func PageTemplate(p Page) string { -//line base.qtpl:48 +//line base.qtpl:51 qb422016 := qt422016.AcquireByteBuffer() -//line base.qtpl:48 +//line base.qtpl:51 WritePageTemplate(qb422016, p) -//line base.qtpl:48 +//line base.qtpl:51 qs422016 := string(qb422016.B) -//line base.qtpl:48 +//line base.qtpl:51 qt422016.ReleaseByteBuffer(qb422016) -//line base.qtpl:48 +//line base.qtpl:51 return qs422016 -//line base.qtpl:48 +//line base.qtpl:51 } -//line base.qtpl:50 +//line base.qtpl:53 type BasePage struct{} -//line base.qtpl:51 +//line base.qtpl:54 func (p *BasePage) StreamTitle(qw422016 *qt422016.Writer) { -//line base.qtpl:51 +//line base.qtpl:54 qw422016.N().S(`Empty`) -//line base.qtpl:51 +//line base.qtpl:54 } -//line base.qtpl:51 +//line base.qtpl:54 func (p *BasePage) WriteTitle(qq422016 qtio422016.Writer) { -//line base.qtpl:51 +//line base.qtpl:54 qw422016 := qt422016.AcquireWriter(qq422016) -//line base.qtpl:51 +//line base.qtpl:54 p.StreamTitle(qw422016) -//line base.qtpl:51 +//line base.qtpl:54 qt422016.ReleaseWriter(qw422016) -//line base.qtpl:51 +//line base.qtpl:54 } -//line base.qtpl:51 +//line base.qtpl:54 func (p *BasePage) Title() string { -//line base.qtpl:51 +//line base.qtpl:54 qb422016 := qt422016.AcquireByteBuffer() -//line base.qtpl:51 +//line base.qtpl:54 p.WriteTitle(qb422016) -//line base.qtpl:51 +//line base.qtpl:54 qs422016 := string(qb422016.B) -//line base.qtpl:51 +//line base.qtpl:54 qt422016.ReleaseByteBuffer(qb422016) -//line base.qtpl:51 +//line base.qtpl:54 return qs422016 -//line base.qtpl:51 +//line base.qtpl:54 } -//line base.qtpl:52 +//line base.qtpl:55 func (p *BasePage) StreamBody(qw422016 *qt422016.Writer) { -//line base.qtpl:52 +//line base.qtpl:55 qw422016.N().S(`HelloWorld`) -//line base.qtpl:52 +//line base.qtpl:55 } -//line base.qtpl:52 +//line base.qtpl:55 func (p *BasePage) WriteBody(qq422016 qtio422016.Writer) { -//line base.qtpl:52 +//line base.qtpl:55 qw422016 := qt422016.AcquireWriter(qq422016) -//line base.qtpl:52 +//line base.qtpl:55 p.StreamBody(qw422016) -//line base.qtpl:52 +//line base.qtpl:55 qt422016.ReleaseWriter(qw422016) -//line base.qtpl:52 +//line base.qtpl:55 } -//line base.qtpl:52 +//line base.qtpl:55 func (p *BasePage) Body() string { -//line base.qtpl:52 +//line base.qtpl:55 qb422016 := qt422016.AcquireByteBuffer() -//line base.qtpl:52 +//line base.qtpl:55 p.WriteBody(qb422016) -//line base.qtpl:52 +//line base.qtpl:55 qs422016 := string(qb422016.B) -//line base.qtpl:52 +//line base.qtpl:55 qt422016.ReleaseByteBuffer(qb422016) -//line base.qtpl:52 +//line base.qtpl:55 return qs422016 -//line base.qtpl:52 +//line base.qtpl:55 } -//line base.qtpl:53 +//line base.qtpl:56 func (p *BasePage) StreamScript(qw422016 *qt422016.Writer) { -//line base.qtpl:53 +//line base.qtpl:56 } -//line base.qtpl:53 +//line base.qtpl:56 func (p *BasePage) WriteScript(qq422016 qtio422016.Writer) { -//line base.qtpl:53 +//line base.qtpl:56 qw422016 := qt422016.AcquireWriter(qq422016) -//line base.qtpl:53 +//line base.qtpl:56 p.StreamScript(qw422016) -//line base.qtpl:53 +//line base.qtpl:56 qt422016.ReleaseWriter(qw422016) -//line base.qtpl:53 +//line base.qtpl:56 } -//line base.qtpl:53 +//line base.qtpl:56 func (p *BasePage) Script() string { -//line base.qtpl:53 +//line base.qtpl:56 qb422016 := qt422016.AcquireByteBuffer() -//line base.qtpl:53 +//line base.qtpl:56 p.WriteScript(qb422016) -//line base.qtpl:53 +//line base.qtpl:56 qs422016 := string(qb422016.B) -//line base.qtpl:53 +//line base.qtpl:56 qt422016.ReleaseByteBuffer(qb422016) -//line base.qtpl:53 +//line base.qtpl:56 return qs422016 -//line base.qtpl:53 +//line base.qtpl:56 } |