diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-10-05 16:47:32 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-10-05 16:47:32 +0200 |
commit | ada6a68b4f25c912705542a6b03aae7ffffb5e99 (patch) | |
tree | 63ffb7d4c2f6c8ce194f90f6b3568b9c08286bf9 /pkg/handler/git/handler.go | |
parent | 78af329f2c7bc1739bcd36baf45ab95aaff43434 (diff) | |
download | cerrado-ada6a68b4f25c912705542a6b03aae7ffffb5e99.tar.gz cerrado-ada6a68b4f25c912705542a6b03aae7ffffb5e99.tar.bz2 cerrado-ada6a68b4f25c912705542a6b03aae7ffffb5e99.zip |
feat: Make syntax highlight configurable
Now cerrado has configurable theme through "syntax-highlight".
Diffstat (limited to 'pkg/handler/git/handler.go')
-rw-r--r-- | pkg/handler/git/handler.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go index 6fae146..5739c8e 100644 --- a/pkg/handler/git/handler.go +++ b/pkg/handler/git/handler.go @@ -27,18 +27,19 @@ import ( type ( GitHandler struct { gitService *service.GitService - readmePath string + config configurationRepository } configurationRepository interface { GetRootReadme() string + GetSyntaxHighlight() string } ) func NewGitHandler(gitService *service.GitService, confRepo configurationRepository) *GitHandler { return &GitHandler{ gitService: gitService, - readmePath: confRepo.GetRootReadme(), + config: confRepo, } } @@ -48,7 +49,7 @@ func (g *GitHandler) List(w http.ResponseWriter, _ *http.Request) error { return err } - f, err := os.Open(g.readmePath) + f, err := os.Open(g.config.GetRootReadme()) if err != nil { return err } @@ -280,7 +281,8 @@ func (g *GitHandler) Blob(w http.ResponseWriter, r *http.Request) error { filename := filepath.Base(rest) lexer := GetLexers(filename) - style := styles.Get("xcode") + style := styles.Get(g.config.GetSyntaxHighlight()) + formatter := html.New( html.WithLineNumbers(true), html.WithLinkableLineNumbers(true, "L"), |