aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/handler/config/handler.go63
-rw-r--r--pkg/handler/router.go7
-rw-r--r--templates/config.qtpl19
-rw-r--r--templates/config.qtpl.go165
-rw-r--r--templates/navbar.qtpl1
-rw-r--r--templates/navbar.qtpl.go123
6 files changed, 61 insertions, 317 deletions
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() %}
-<p>This is the configuration that is currently loaded</p>
-<div class="code-view">
-{%z= p.Body %}
-</div>
-{% 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(`
-<p>This is the configuration that is currently loaded</p>
-<div class="code-view">
-`)
-//line templates/config.qtpl:14
- qw422016.N().Z(p.Body)
-//line templates/config.qtpl:14
- qw422016.N().S(`
-</div>
-`)
-//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
<a class="nav-link{%= insertIfEqual(s, About) %}" href="/about/">about</a>
{% endcomment %}
- <a class="nav-link{%= insertIfEqual(s, Config) %}" href="/config">config</a>
</div>
</nav>
{% 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(`
- <a class="nav-link`)
-//line templates/navbar.qtpl:36
- streaminsertIfEqual(qw422016, s, Config)
-//line templates/navbar.qtpl:36
- qw422016.N().S(`" href="/config">config</a>
</div>
</nav>
`)
-//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(`
<div class="row">
<h3 id="name">`)
-//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(`</h3>
</div>
<div class="row">
<ul class="nav">
<li class="nav-item">
<a class="nav-link`)
-//line templates/navbar.qtpl:48
+//line templates/navbar.qtpl:47
streaminsertIfEqual(qw422016, s, Readme)
-//line templates/navbar.qtpl:48
+//line templates/navbar.qtpl:47
qw422016.N().S(`" aria-current="page" href="/`)
-//line templates/navbar.qtpl:48
+//line templates/navbar.qtpl:47
qw422016.E().S(name)
-//line templates/navbar.qtpl:48
+//line templates/navbar.qtpl:47
qw422016.N().S(`/about/">about</a>
</li>
<li class="nav-item">
<a class="nav-link`)
-//line templates/navbar.qtpl:51
+//line templates/navbar.qtpl:50
streaminsertIfEqual(qw422016, s, Summary)
-//line templates/navbar.qtpl:51
+//line templates/navbar.qtpl:50
qw422016.N().S(`" aria-current="page" href="/`)
-//line templates/navbar.qtpl:51
+//line templates/navbar.qtpl:50
qw422016.E().S(name)
-//line templates/navbar.qtpl:51
+//line templates/navbar.qtpl:50
qw422016.N().S(`/">summary</a>
</li>
<li class="nav-item">
<a class="nav-link`)
-//line templates/navbar.qtpl:54
+//line templates/navbar.qtpl:53
streaminsertIfEqual(qw422016, s, Refs)
-//line templates/navbar.qtpl:54
+//line templates/navbar.qtpl:53
qw422016.N().S(`" aria-current="page" href="/`)
-//line templates/navbar.qtpl:54
+//line templates/navbar.qtpl:53
qw422016.E().S(name)
-//line templates/navbar.qtpl:54
+//line templates/navbar.qtpl:53
qw422016.N().S(`/refs">refs</a>
</li>
<li class="nav-item">
<a class="nav-link`)
-//line templates/navbar.qtpl:57
+//line templates/navbar.qtpl:56
streaminsertIfEqual(qw422016, s, Log)
-//line templates/navbar.qtpl:57
+//line templates/navbar.qtpl:56
qw422016.N().S(`" aria-current="page" href="/`)
-//line templates/navbar.qtpl:57
+//line templates/navbar.qtpl:56
qw422016.E().S(name)
-//line templates/navbar.qtpl:57
+//line templates/navbar.qtpl:56
qw422016.N().S(`/log/`)
-//line templates/navbar.qtpl:57
+//line templates/navbar.qtpl:56
qw422016.E().S(ref)
-//line templates/navbar.qtpl:57
+//line templates/navbar.qtpl:56
qw422016.N().S(`/">log</a>
</li>
<li class="nav-item">
<a class="nav-link`)
-//line templates/navbar.qtpl:60
+//line templates/navbar.qtpl:59
streaminsertIfEqual(qw422016, s, Tree)
-//line templates/navbar.qtpl:60
+//line templates/navbar.qtpl:59
qw422016.N().S(`" aria-current="page" href="/`)
-//line templates/navbar.qtpl:60
+//line templates/navbar.qtpl:59
qw422016.E().S(name)
-//line templates/navbar.qtpl:60
+//line templates/navbar.qtpl:59
qw422016.N().S(`/tree/`)
-//line templates/navbar.qtpl:60
+//line templates/navbar.qtpl:59
qw422016.E().S(ref)
-//line templates/navbar.qtpl:60
+//line templates/navbar.qtpl:59
qw422016.N().S(`/">tree</a>
</li>
</ul>
</div>
`)
-//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
}