From 6e5062488fc3ecbf37c11e7d111bfe6ea3b5284d Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 5 Oct 2024 16:53:15 +0200 Subject: feat: Remove config page That page was created as playground and had some debug purpose. Now that is not longer used and with introduction of sensible information (hash and aes-key) that has to go. --- pkg/handler/config/handler.go | 63 ---------------- pkg/handler/router.go | 7 +- templates/config.qtpl | 19 ----- templates/config.qtpl.go | 165 ------------------------------------------ templates/navbar.qtpl | 1 - templates/navbar.qtpl.go | 123 +++++++++++++++---------------- 6 files changed, 61 insertions(+), 317 deletions(-) delete mode 100644 pkg/handler/config/handler.go delete mode 100644 templates/config.qtpl delete mode 100644 templates/config.qtpl.go diff --git a/pkg/handler/config/handler.go b/pkg/handler/config/handler.go deleted file mode 100644 index c43b54d..0000000 --- a/pkg/handler/config/handler.go +++ /dev/null @@ -1,63 +0,0 @@ -package config - -import ( - "bytes" - "encoding/json" - "net/http" - - "github.com/alecthomas/chroma/v2/formatters/html" - "github.com/alecthomas/chroma/v2/lexers" - "github.com/alecthomas/chroma/v2/styles" - - "git.gabrielgio.me/cerrado/pkg/config" - "git.gabrielgio.me/cerrado/pkg/ext" - "git.gabrielgio.me/cerrado/templates" -) - -type ( - configurationRepository interface { - GetRootReadme() string - List() []*config.GitRepositoryConfiguration - } -) - -func ConfigFile(configRepo configurationRepository) ext.ErrorRequestHandler { - return func(w http.ResponseWriter, _ *http.Request) error { - - config := struct { - RootReadme string - Repositories []*config.GitRepositoryConfiguration - }{ - RootReadme: configRepo.GetRootReadme(), - Repositories: configRepo.List(), - } - - b, err := json.MarshalIndent(config, "", " ") - if err != nil { - return err - } - - lexer := lexers.Get("json") - style := styles.Get("monokailight") - formatter := html.New( - html.WithLineNumbers(true), - ) - iterator, err := lexer.Tokenise(nil, string(b)) - if err != nil { - return err - } - - var code bytes.Buffer - err = formatter.Format(&code, style, iterator) - if err != nil { - return err - } - - hello := &templates.ConfigPage{ - Body: code.Bytes(), - } - - templates.WritePageTemplate(w, hello) - return nil - } -} diff --git a/pkg/handler/router.go b/pkg/handler/router.go index f464ac2..a2ac98a 100644 --- a/pkg/handler/router.go +++ b/pkg/handler/router.go @@ -6,7 +6,6 @@ import ( serverconfig "git.gabrielgio.me/cerrado/pkg/config" "git.gabrielgio.me/cerrado/pkg/ext" "git.gabrielgio.me/cerrado/pkg/handler/about" - "git.gabrielgio.me/cerrado/pkg/handler/config" "git.gabrielgio.me/cerrado/pkg/handler/git" "git.gabrielgio.me/cerrado/pkg/handler/static" "git.gabrielgio.me/cerrado/pkg/service" @@ -20,9 +19,8 @@ func MountHandler( configRepo *serverconfig.ConfigurationRepository, ) (http.Handler, error) { var ( - gitHandler = git.NewGitHandler(gitService, configRepo) - aboutHandler = about.NewAboutHandler(configRepo) - configHandler = config.ConfigFile(configRepo) + gitHandler = git.NewGitHandler(gitService, configRepo) + aboutHandler = about.NewAboutHandler(configRepo) ) staticHandler, err := static.ServeStaticHandler() @@ -43,7 +41,6 @@ func MountHandler( mux.HandleFunc("/{name}/log/{ref}/", gitHandler.Log) mux.HandleFunc("/{name}/commit/{ref}/", gitHandler.Commit) mux.HandleFunc("/{name}/archive/{file}", gitHandler.Archive) - mux.HandleFunc("/config", configHandler) mux.HandleFunc("/about", aboutHandler.About) mux.HandleFunc("/", gitHandler.List) return mux.Handler(), nil diff --git a/templates/config.qtpl b/templates/config.qtpl deleted file mode 100644 index b3df50e..0000000 --- a/templates/config.qtpl +++ /dev/null @@ -1,19 +0,0 @@ -{% code -type ConfigPage struct { - Body []byte -} -%} - -{% func (p *ConfigPage) Title() %}Hello{% endfunc %} - -{% func (p *ConfigPage) Navbar() %}{%= Navbar(Config) %}{% endfunc %} - -{% func (p *ConfigPage) Content() %} -

This is the configuration that is currently loaded

-
-{%z= p.Body %} -
-{% endfunc %} - -{% func (p *ConfigPage) Script() %} -{% endfunc %} diff --git a/templates/config.qtpl.go b/templates/config.qtpl.go deleted file mode 100644 index 975fea3..0000000 --- a/templates/config.qtpl.go +++ /dev/null @@ -1,165 +0,0 @@ -// Code generated by qtc from "config.qtpl". DO NOT EDIT. -// See https://github.com/valyala/quicktemplate for details. - -//line templates/config.qtpl:1 -package templates - -//line templates/config.qtpl:1 -import ( - qtio422016 "io" - - qt422016 "github.com/valyala/quicktemplate" -) - -//line templates/config.qtpl:1 -var ( - _ = qtio422016.Copy - _ = qt422016.AcquireByteBuffer -) - -//line templates/config.qtpl:2 -type ConfigPage struct { - Body []byte -} - -//line templates/config.qtpl:7 -func (p *ConfigPage) StreamTitle(qw422016 *qt422016.Writer) { -//line templates/config.qtpl:7 - qw422016.N().S(`Hello`) -//line templates/config.qtpl:7 -} - -//line templates/config.qtpl:7 -func (p *ConfigPage) WriteTitle(qq422016 qtio422016.Writer) { -//line templates/config.qtpl:7 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/config.qtpl:7 - p.StreamTitle(qw422016) -//line templates/config.qtpl:7 - qt422016.ReleaseWriter(qw422016) -//line templates/config.qtpl:7 -} - -//line templates/config.qtpl:7 -func (p *ConfigPage) Title() string { -//line templates/config.qtpl:7 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/config.qtpl:7 - p.WriteTitle(qb422016) -//line templates/config.qtpl:7 - qs422016 := string(qb422016.B) -//line templates/config.qtpl:7 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/config.qtpl:7 - return qs422016 -//line templates/config.qtpl:7 -} - -//line templates/config.qtpl:9 -func (p *ConfigPage) StreamNavbar(qw422016 *qt422016.Writer) { -//line templates/config.qtpl:9 - StreamNavbar(qw422016, Config) -//line templates/config.qtpl:9 -} - -//line templates/config.qtpl:9 -func (p *ConfigPage) WriteNavbar(qq422016 qtio422016.Writer) { -//line templates/config.qtpl:9 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/config.qtpl:9 - p.StreamNavbar(qw422016) -//line templates/config.qtpl:9 - qt422016.ReleaseWriter(qw422016) -//line templates/config.qtpl:9 -} - -//line templates/config.qtpl:9 -func (p *ConfigPage) Navbar() string { -//line templates/config.qtpl:9 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/config.qtpl:9 - p.WriteNavbar(qb422016) -//line templates/config.qtpl:9 - qs422016 := string(qb422016.B) -//line templates/config.qtpl:9 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/config.qtpl:9 - return qs422016 -//line templates/config.qtpl:9 -} - -//line templates/config.qtpl:11 -func (p *ConfigPage) StreamContent(qw422016 *qt422016.Writer) { -//line templates/config.qtpl:11 - qw422016.N().S(` -

This is the configuration that is currently loaded

-
-`) -//line templates/config.qtpl:14 - qw422016.N().Z(p.Body) -//line templates/config.qtpl:14 - qw422016.N().S(` -
-`) -//line templates/config.qtpl:16 -} - -//line templates/config.qtpl:16 -func (p *ConfigPage) WriteContent(qq422016 qtio422016.Writer) { -//line templates/config.qtpl:16 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/config.qtpl:16 - p.StreamContent(qw422016) -//line templates/config.qtpl:16 - qt422016.ReleaseWriter(qw422016) -//line templates/config.qtpl:16 -} - -//line templates/config.qtpl:16 -func (p *ConfigPage) Content() string { -//line templates/config.qtpl:16 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/config.qtpl:16 - p.WriteContent(qb422016) -//line templates/config.qtpl:16 - qs422016 := string(qb422016.B) -//line templates/config.qtpl:16 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/config.qtpl:16 - return qs422016 -//line templates/config.qtpl:16 -} - -//line templates/config.qtpl:18 -func (p *ConfigPage) StreamScript(qw422016 *qt422016.Writer) { -//line templates/config.qtpl:18 - qw422016.N().S(` -`) -//line templates/config.qtpl:19 -} - -//line templates/config.qtpl:19 -func (p *ConfigPage) WriteScript(qq422016 qtio422016.Writer) { -//line templates/config.qtpl:19 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/config.qtpl:19 - p.StreamScript(qw422016) -//line templates/config.qtpl:19 - qt422016.ReleaseWriter(qw422016) -//line templates/config.qtpl:19 -} - -//line templates/config.qtpl:19 -func (p *ConfigPage) Script() string { -//line templates/config.qtpl:19 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/config.qtpl:19 - p.WriteScript(qb422016) -//line templates/config.qtpl:19 - qs422016 := string(qb422016.B) -//line templates/config.qtpl:19 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/config.qtpl:19 - return qs422016 -//line templates/config.qtpl:19 -} diff --git a/templates/navbar.qtpl b/templates/navbar.qtpl index 68b1fd8..8614181 100644 --- a/templates/navbar.qtpl +++ b/templates/navbar.qtpl @@ -33,7 +33,6 @@ Add this back once needed Add this back if needed about {% endcomment %} - config {% endfunc %} diff --git a/templates/navbar.qtpl.go b/templates/navbar.qtpl.go index 5a27bb4..ca3a320 100644 --- a/templates/navbar.qtpl.go +++ b/templates/navbar.qtpl.go @@ -92,157 +92,152 @@ func StreamNavbar(qw422016 *qt422016.Writer, s Selection) { `) //line templates/navbar.qtpl:35 qw422016.N().S(` - config `) -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 } -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 func WriteNavbar(qq422016 qtio422016.Writer, s Selection) { -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 StreamNavbar(qw422016, s) -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 qt422016.ReleaseWriter(qw422016) -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 } -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 func Navbar(s Selection) string { -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 qb422016 := qt422016.AcquireByteBuffer() -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 WriteNavbar(qb422016, s) -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 qs422016 := string(qb422016.B) -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 qt422016.ReleaseByteBuffer(qb422016) -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 return qs422016 -//line templates/navbar.qtpl:39 +//line templates/navbar.qtpl:38 } -//line templates/navbar.qtpl:41 +//line templates/navbar.qtpl:40 func StreamGitItemNav(qw422016 *qt422016.Writer, name, ref string, s GitSelection) { -//line templates/navbar.qtpl:41 +//line templates/navbar.qtpl:40 qw422016.N().S(`

`) -//line templates/navbar.qtpl:43 +//line templates/navbar.qtpl:42 qw422016.E().S(name) -//line templates/navbar.qtpl:43 +//line templates/navbar.qtpl:42 qw422016.N().S(` `) -//line templates/navbar.qtpl:43 +//line templates/navbar.qtpl:42 if ref != "" && (s == Log || s == Tree) { -//line templates/navbar.qtpl:43 +//line templates/navbar.qtpl:42 qw422016.N().S(`@ `) -//line templates/navbar.qtpl:43 +//line templates/navbar.qtpl:42 qw422016.E().S(ref) -//line templates/navbar.qtpl:43 +//line templates/navbar.qtpl:42 } -//line templates/navbar.qtpl:43 +//line templates/navbar.qtpl:42 qw422016.N().S(`

`) -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 } -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 func WriteGitItemNav(qq422016 qtio422016.Writer, name, ref string, s GitSelection) { -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 StreamGitItemNav(qw422016, name, ref, s) -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 qt422016.ReleaseWriter(qw422016) -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 } -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 func GitItemNav(name, ref string, s GitSelection) string { -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 qb422016 := qt422016.AcquireByteBuffer() -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 WriteGitItemNav(qb422016, name, ref, s) -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 qs422016 := string(qb422016.B) -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 qt422016.ReleaseByteBuffer(qb422016) -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 return qs422016 -//line templates/navbar.qtpl:64 +//line templates/navbar.qtpl:63 } -- cgit v1.2.3