Changes
10 changed files (+43/-39)
-
-
@@ -23,9 +23,13 @@ repo:# Runtime directories. dirs: # Path to a directory containing HTML templates. # [optional] # Path to a directory containing custom HTML templates. # Templates are written in Go's html/template syntax. # <https://pkg.go.dev/html/template> # # If you omit this, legit will use its default templates directory # ("templates" directory next to this file) embedded in the binary. templates: ./templates # [optional]
-
-
-
@@ -55,8 +55,12 @@ func Read(f string) (*Config, error) {if c.Repo.ScanPath, err = resolvePath(c.Repo.ScanPath, f); err != nil { return nil, err } if c.Dirs.Templates, err = resolvePath(c.Dirs.Templates, f); err != nil { return nil, err // Override templates dir if c.Dirs.Templates != "" { if c.Dirs.Templates, err = resolvePath(c.Dirs.Templates, f); err != nil { return nil, err } } // Override static dir
-
-
-
@@ -28,9 +28,6 @@ repo:- main - trunk dirs: templates: ../templates meta: title: legit Demo description: Test legit features with real repositories.
-
-
-
@@ -29,10 +29,7 @@legit = self.packages.${system}.legit; files = pkgs.lib.fileset.toSource { root = ./.; fileset = pkgs.lib.fileset.unions [ ./config.yaml ./templates ]; fileset = pkgs.lib.fileset.unions [ ./config.yaml ]; }; in {
-
@@ -47,6 +44,7 @@./go.mod ./go.sum ./static ./templates (fileFilter (file: file.hasExt "go") ./.) ]; };
-
-
-
@@ -17,6 +17,9 @@ import (//go:embed static/* var defaultStaticDir embed.FS //go:embed templates/* var defaultTemplatesDir embed.FS func main() { var cfg string var host string
-
@@ -68,7 +71,17 @@ func main() {} } mux := routes.Handlers(c, staticDir) var templatesDir fs.FS if c.Dirs.Templates != "" { templatesDir = os.DirFS(c.Dirs.Templates) } else { templatesDir, err = fs.Sub(defaultTemplatesDir, "templates") if err != nil { log.Fatalf("Unable to open default templates dir: %s", err) } } mux := routes.Handlers(c, staticDir, templatesDir) addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port) log.Println("starting server on", addr) log.Fatal(http.ListenAndServe(addr, mux))
-
-
-
@@ -30,12 +30,13 @@ func (d *deps) Multiplex(w http.ResponseWriter, r *http.Request) {} } func Handlers(c *config.Config, staticDir fs.FS) *http.ServeMux { func Handlers(c *config.Config, staticDir fs.FS, templatesDir fs.FS) *http.ServeMux { mux := http.NewServeMux() d := deps{ c: c, staticDir: staticDir, ugcPolicy: bluemonday.UGCPolicy(), c: c, staticDir: staticDir, templatesDir: templatesDir, ugcPolicy: bluemonday.UGCPolicy(), } mux.HandleFunc("GET /", d.Index)
-
-
-
@@ -30,6 +30,8 @@ type deps struct {// returned by "os.Root.FS". staticDir fs.FS templatesDir fs.FS // ugcPolicy is a bluemonday policy for user generated content. ugcPolicy *bluemonday.Policy }
-
@@ -83,8 +85,7 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) {return summaries[j].LastCommit.Committer.When.Before(summaries[i].LastCommit.Committer.When) }) tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) data := repoListData{ Config: d.c,
-
@@ -200,8 +201,7 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {} } tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) if len(commits) >= 3 { commits = commits[:3]
-
@@ -273,8 +273,7 @@ func (d *deps) RepoTree(w http.ResponseWriter, r *http.Request) {Files: files, } tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) if err := t.ExecuteTemplate(w, "repo-tree-ref", data); err != nil { log.Println(err)
-
@@ -336,8 +335,7 @@ func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) {relpath = strings.Split(treePath, "/") } tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) if r.URL.Query().Has("preview") { previewType := r.URL.Query().Get("preview")
-
@@ -510,8 +508,7 @@ func (d *deps) Log(w http.ResponseWriter, r *http.Request) {return } tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) data := repoLogRefData{ Config: d.c,
-
@@ -557,8 +554,7 @@ func (d *deps) Diff(w http.ResponseWriter, r *http.Request) {return } tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) data := repoCommitData{ Config: d.c,
-
@@ -619,8 +615,7 @@ func (d *deps) Refs(w http.ResponseWriter, r *http.Request) {return } tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) data := repoRefsData{ Config: d.c,
-
-
-
@@ -4,12 +4,10 @@ import ("html/template" "log" "net/http" "path/filepath" ) func (d *deps) Write404(w http.ResponseWriter) { tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) data := error404Data{ Config: d.c,
-
@@ -22,8 +20,7 @@ func (d *deps) Write404(w http.ResponseWriter) {} func (d *deps) Write500(w http.ResponseWriter) { tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseFS(d.templatesDir, "*")) data := error500Data{ Config: d.c,
-
-
-
@@ -8,9 +8,6 @@ repo:mainBranch: - trunk dirs: templates: ../../templates meta: title: Legit Load Testing syntaxHighlight: true
-
-
-
@@ -15,7 +15,6 @@ stdenv.mkDerivation {fileset = lib.fileset.unions [ ./create_repos.bash ./config.yaml ../../templates ]; };
-
@@ -24,7 +23,6 @@ stdenv.mkDerivation {cd $out/tests/k6/repos bash $src/tests/k6/create_repos.bash ln -s $src/tests/k6/config.yaml $out/tests/k6/config.yaml ln -s $src/templates $out/templates ''; nativeBuildInputs = [
-