repos / pgit

static site generator for git
git clone https://github.com/picosh/pgit.git

commit
c0b0fe0
parent
ad355eb
author
Eric Bower
date
2023-08-06 14:32:20 +0000 UTC
changes
2 files changed,  +20, -15
M html/refs.page.tmpl
+8, -4
 1@@ -5,13 +5,17 @@
 2 {{define "content"}}
 3   {{template "header" .}}
 4 
 5-  <h2>branches</h2>
 6+  <h2 class="text-md">branches</h2>
 7+  <ol>
 8   {{range .Data.Branches}}
 9-    <p>{{.Refspec}}</p>
10+    <li>{{.Refspec}}</li>
11   {{end}}
12+  </ol>
13 
14-  <h2>tags</h2>
15+  <h2 class="text-md">tags</h2>
16+  <ol>
17   {{range .Data.Tags}}
18-    <p>{{.Refspec}}</p>
19+    <li>{{.Refspec}}</li>
20   {{end}}
21+  </ol>
22 {{end}}
M main.go
+12, -11
 1@@ -20,7 +20,7 @@ var defaultBranches = []string{"main", "master"}
 2 type RepoItemData struct {
 3 	URL        string
 4 	Name       string
 5-	Desc string
 6+	Desc       string
 7 	CommitDate string
 8 	LastCommit *git.Commit
 9 }
10@@ -46,13 +46,13 @@ type CommitData struct {
11 }
12 
13 type TreeItem struct {
14-	NumLines int
15-	URL      string
16-	Path     string
17-	Entry    *git.TreeEntry
18+	NumLines  int
19+	URL       string
20+	Path      string
21+	Entry     *git.TreeEntry
22 	CommitURL string
23-	Desc string
24-	When string
25+	Desc      string
26+	When      string
27 }
28 
29 type PageData struct {
30@@ -68,7 +68,7 @@ type PageData struct {
31 
32 type CommitPageData struct {
33 	CommitMsg template.HTML
34-	CommitID string
35+	CommitID  string
36 	Commit    *CommitData
37 	Diff      *DiffRender
38 	Repo      *RepoData
39@@ -348,6 +348,7 @@ func (c *Config) writeLogDiffs(repo *git.Repository, pageData *PageData) {
40 					content += fmt.Sprintf("%s\n", line.Content)
41 				}
42 			}
43+			// set filename to something our `ParseText` recognizes (e.g. `.diff`)
44 			finContent, err := pastes.ParseText("commit.diff", content)
45 			bail(err)
46 
47@@ -358,7 +359,7 @@ func (c *Config) writeLogDiffs(repo *git.Repository, pageData *PageData) {
48 
49 		commitData := &CommitPageData{
50 			Commit:    commit,
51-			CommitID: commit.ID.String()[:7],
52+			CommitID:  commit.ID.String()[:7],
53 			Diff:      rnd,
54 			Repo:      pageData.Repo,
55 			Parent:    parentID[:7],
56@@ -482,7 +483,7 @@ func (c *Config) writeBranch(repo *git.Repository, pageData *PageData) *BranchOu
57 		bail(err)
58 
59 		var lc *git.Commit
60-		if (len(lastCommits) > 0) {
61+		if len(lastCommits) > 0 {
62 			lc = lastCommits[0]
63 		}
64 		entry.CommitURL = commitURL(pageData.Repo.Name, lc.ID.String())
65@@ -545,7 +546,7 @@ func main() {
66 		repoList = append(repoList, &RepoItemData{
67 			URL:        url,
68 			Name:       name,
69-			Desc: r.Desc,
70+			Desc:       r.Desc,
71 			CommitDate: timediff.TimeDiff(mainOutput.LastCommit.Author.When),
72 			LastCommit: mainOutput.LastCommit,
73 		})