Commit 32c5e95

Eric Bower  ·  2025-08-10 09:41:11 -0400 EDT
parent 8573635
fix: ensure readme is in root for summary page
2 files changed,  +12, -15
+1, -1
......@@ -1,5 +1,5 @@
11 {{define "footer"}}
22 <div>
3- built with <a href="https://erock-git-pgit.pgs.sh">pgit</a> and published with <a href="https://pgs.sh">pgs.sh</a>
3+ built with <a href="https://pgit.pico.sh">pgit</a>
44 </div>
55 {{end}}
+11, -14
......@@ -25,8 +25,11 @@ import (
2525 git "github.com/gogs/git-module"
2626 )
2727
28-//go:embed html/*.tmpl static/*
29-var efs embed.FS
28+//go:embed html/*.tmpl
29+var embedFS embed.FS
30+
31+//go:embed static/*
32+var staticFS embed.FS
3033
3134 type Config struct {
3235 // required params
......@@ -308,7 +311,7 @@ func readmeFile(repo *Config) string {
308311
309312 func (c *Config) writeHtml(writeData *WriteData) {
310313 ts, err := template.ParseFS(
311- efs,
314+ embedFS,
312315 writeData.Template,
313316 "html/header.partial.tmpl",
314317 "html/footer.partial.tmpl",
......@@ -331,7 +334,7 @@ func (c *Config) writeHtml(writeData *WriteData) {
331334 }
332335
333336 func (c *Config) copyStatic(dir string) error {
334- entries, err := efs.ReadDir(dir)
337+ entries, err := staticFS.ReadDir(dir)
335338 bail(err)
336339
337340 for _, e := range entries {
......@@ -340,7 +343,7 @@ func (c *Config) copyStatic(dir string) error {
340343 continue
341344 }
342345
343- w, err := efs.ReadFile(infp)
346+ w, err := staticFS.ReadFile(infp)
344347 bail(err)
345348 fp := filepath.Join(c.Outdir, e.Name())
346349 c.Logger.Info("writing", "filepath", fp)
......@@ -421,7 +424,7 @@ func (c *Config) writeHTMLTreeFile(pageData *PageData, treeItem *TreeItem) strin
421424
422425 nameLower := strings.ToLower(treeItem.Entry.Name())
423426 summary := readmeFile(pageData.Repo)
424- if nameLower == summary {
427+ if d == "." && nameLower == summary {
425428 readme = contents
426429 }
427430
......@@ -454,13 +457,7 @@ func (c *Config) writeLogDiff(repo *git.Repository, pageData *PageData, commit *
454457 c.Mutex.Unlock()
455458 }
456459
457- diff, err := repo.Diff(
458- commitID,
459- 0,
460- 0,
461- 0,
462- git.DiffOptions{},
463- )
460+ diff, err := repo.Diff(commitID, 0, 0, 0, git.DiffOptions{})
464461 bail(err)
465462
466463 rnd := &DiffRender{
......@@ -1022,7 +1019,7 @@ func (c *Config) writeRevision(repo *git.Repository, pageData *PageData, refs []
10221019 wg.Wait()
10231020
10241021 c.Logger.Info(
1025- "compilation complete branch",
1022+ "compilation complete",
10261023 "repoName", c.RepoName,
10271024 "revision", pageData.RevData.Name(),
10281025 )