From 3784181e4fad3c947dfa95081d8a0b34f5be12d4 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Wed, 11 Dec 2024 18:10:12 +0100 Subject: feat: Disable auth if passphrase is empty Disable all auth mechanism when passphrase is empty. That will allow for a simpler setup. --- templates/base.qtpl | 7 +++ templates/base.qtpl.go | 58 ++++++++++-------- templates/commit.qtpl | 2 +- templates/commit.qtpl.go | 2 +- templates/navbar.qtpl | 2 + templates/navbar.qtpl.go | 156 +++++++++++++++++++++++++---------------------- 6 files changed, 126 insertions(+), 101 deletions(-) (limited to 'templates') diff --git a/templates/base.qtpl b/templates/base.qtpl index 2a42cb8..db9deee 100644 --- a/templates/base.qtpl +++ b/templates/base.qtpl @@ -38,6 +38,13 @@ Page { } %} + +{% code func IsAuthenticationDisabled(ctx context.Context) bool { + t, ok := ctx.Value("disableAuthentication").(bool) + return ok && t + } +%} + {% code func IsLoggedIn(ctx context.Context) bool { t, ok := ctx.Value("logged").(bool) return ok && t diff --git a/templates/base.qtpl.go b/templates/base.qtpl.go index 5bb4532..796538e 100644 --- a/templates/base.qtpl.go +++ b/templates/base.qtpl.go @@ -79,7 +79,13 @@ func Ignore[T any](v T, _ error) T { return v } -//line templates/base.qtpl:41 +//line templates/base.qtpl:42 +func IsAuthenticationDisabled(ctx context.Context) bool { + t, ok := ctx.Value("disableAuthentication").(bool) + return ok && t +} + +//line templates/base.qtpl:48 func IsLoggedIn(ctx context.Context) bool { t, ok := ctx.Value("logged").(bool) return ok && t @@ -87,9 +93,9 @@ func IsLoggedIn(ctx context.Context) bool { // Page prints a page implementing Page interface. -//line templates/base.qtpl:48 +//line templates/base.qtpl:55 func StreamPageTemplate(qw422016 *qt422016.Writer, p Page, ctx context.Context) { -//line templates/base.qtpl:48 +//line templates/base.qtpl:55 qw422016.N().S(` @@ -97,64 +103,64 @@ func StreamPageTemplate(qw422016 *qt422016.Writer, p Page, ctx context.Context) `) -//line templates/base.qtpl:54 +//line templates/base.qtpl:61 p.StreamTitle(qw422016, ctx) -//line templates/base.qtpl:54 +//line templates/base.qtpl:61 qw422016.N().S(` `) -//line templates/base.qtpl:60 +//line templates/base.qtpl:67 p.StreamNavbar(qw422016, ctx) -//line templates/base.qtpl:60 +//line templates/base.qtpl:67 qw422016.N().S(`
`) -//line templates/base.qtpl:62 +//line templates/base.qtpl:69 p.StreamContent(qw422016, ctx) -//line templates/base.qtpl:62 +//line templates/base.qtpl:69 qw422016.N().S(`
`) -//line templates/base.qtpl:65 +//line templates/base.qtpl:72 p.StreamScript(qw422016, ctx) -//line templates/base.qtpl:65 +//line templates/base.qtpl:72 qw422016.N().S(` `) -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 } -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 func WritePageTemplate(qq422016 qtio422016.Writer, p Page, ctx context.Context) { -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 StreamPageTemplate(qw422016, p, ctx) -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 qt422016.ReleaseWriter(qw422016) -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 } -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 func PageTemplate(p Page, ctx context.Context) string { -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 qb422016 := qt422016.AcquireByteBuffer() -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 WritePageTemplate(qb422016, p, ctx) -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 qs422016 := string(qb422016.B) -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 qt422016.ReleaseByteBuffer(qb422016) -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 return qs422016 -//line templates/base.qtpl:67 +//line templates/base.qtpl:74 } diff --git a/templates/commit.qtpl b/templates/commit.qtpl index ae26a51..dc6eae4 100644 --- a/templates/commit.qtpl +++ b/templates/commit.qtpl @@ -4,7 +4,7 @@
{% if showTar %}
diff --git a/templates/commit.qtpl.go b/templates/commit.qtpl.go index fac2e88..ea8f020 100644 --- a/templates/commit.qtpl.go +++ b/templates/commit.qtpl.go @@ -39,7 +39,7 @@ func StreamCommit(qw422016 *qt422016.Writer, name string, c *object.Commit, show //line templates/commit.qtpl:7 qw422016.E().S(c.Hash.String()) //line templates/commit.qtpl:7 - qw422016.N().S(`">`) + qw422016.N().S(`/">`) //line templates/commit.qtpl:7 qw422016.E().S(c.Hash.String()[0:8]) //line templates/commit.qtpl:7 diff --git a/templates/navbar.qtpl b/templates/navbar.qtpl index e24edd8..c222171 100644 --- a/templates/navbar.qtpl +++ b/templates/navbar.qtpl @@ -30,11 +30,13 @@ const ( git