Commit 7233123
Eric Bower
·
2023-08-13 14:53:59 -0400 EDT
parent 1833a80
refactor: templates
12 files changed,
+49,
-33
+0,
-1
| ... | ... | @@ -21,7 +21,6 @@ jobs: | |
| 21 | 21 | - name: generate site | |
| 22 | 22 | run: | | |
| 23 | 23 | pgit --out ./public --label pgit --desc "static site generator for git" --clone-url "https://github.com/picosh/pgit.git" --revs main | |
| 24 | - | pgit --out ./public --assets | |
| 25 | 24 | - name: Set outputs | |
| 26 | 25 | id: vars | |
| 27 | 26 | run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
+13,
-0
| ... | ... | @@ -0,0 +1,13 @@ | |
| 1 | + | # pgit | |
| 2 | + | ||
| 3 | + | A static site generator for git | |
| 4 | + | ||
| 5 | + | # usage | |
| 6 | + | ||
| 7 | + | ```bash | |
| 8 | + | make build | |
| 9 | + | ``` | |
| 10 | + | ||
| 11 | + | ```bash | |
| 12 | + | ./pgit --revs main --label pico --out ./public | |
| 13 | + | ``` |
+15,
-9
| ... | ... | @@ -1,16 +1,22 @@ | |
| 1 | 1 | {{define "base"}} | |
| 2 | 2 | <!doctype html> | |
| 3 | 3 | <html lang="en"> | |
| 4 | - | <head> | |
| 5 | - | <meta charset='utf-8'> | |
| 6 | - | <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| 7 | - | <title>{{template "title" .}}</title> | |
| 4 | + | <head> | |
| 5 | + | <meta charset='utf-8'> | |
| 6 | + | <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| 7 | + | <title>{{template "title" .}}</title> | |
| 8 | 8 | ||
| 9 | - | <meta name="keywords" content="git code forge repo repository" /> | |
| 9 | + | <meta name="keywords" content="git code forge repo repository" /> | |
| 10 | 10 | ||
| 11 | - | <link rel="stylesheet" href="/main.css" /> | |
| 12 | - | <link rel="stylesheet" href="/syntax.css" /> | |
| 13 | - | </head> | |
| 14 | - | <body>{{template "content" .}}</body> | |
| 11 | + | <link rel="stylesheet" href="/main.css" /> | |
| 12 | + | <link rel="stylesheet" href="/syntax.css" /> | |
| 13 | + | </head> | |
| 14 | + | <body> | |
| 15 | + | <header>{{template "header" .}}</header> | |
| 16 | + | <hr /> | |
| 17 | + | <main>{{template "content" .}}</main> | |
| 18 | + | <hr /> | |
| 19 | + | <footer>{{template "footer" .}}</footer> | |
| 20 | + | </body> | |
| 15 | 21 | </html> | |
| 16 | 22 | {{end}} |
+0,
-2
| ... | ... | @@ -2,8 +2,6 @@ | |
| 2 | 2 | {{define "title"}}commit log{{end}} | |
| 3 | 3 | ||
| 4 | 4 | {{define "content"}} | |
| 5 | - | {{template "header" .}} | |
| 6 | - | ||
| 7 | 5 | <dl> | |
| 8 | 6 | <dt>commit</dt> | |
| 9 | 7 | <dd><a href="{{.CommitURL}}">{{.CommitID}}</a></dd> |
+1,
-3
| ... | ... | @@ -2,8 +2,6 @@ | |
| 2 | 2 | {{define "title"}}file{{end}} | |
| 3 | 3 | ||
| 4 | 4 | {{define "content"}} | |
| 5 | - | {{template "header" .}} | |
| 6 | - | ||
| 7 | - | <h1 class="text-lg">{{.Path}}</h1> | |
| 5 | + | <h2 class="text-lg">{{.Path}}</h2> | |
| 8 | 6 | {{.Contents}} | |
| 9 | 7 | {{end }} |
| ... | ... | @@ -0,0 +1,5 @@ | |
| 1 | + | {{define "footer"}} | |
| 2 | + | <div> | |
| 3 | + | published with <a href="https://pgs.sh">pgs.sh</a> | |
| 4 | + | </div> | |
| 5 | + | {{end}} |
+8,
-6
| ... | ... | @@ -1,20 +1,22 @@ | |
| 1 | 1 | {{define "header"}} | |
| 2 | - | <h1 class="text-xl"> | |
| 3 | - | {{.Repo.RepoName}} | |
| 2 | + | <h1 class="text-xl flex gap"> | |
| 3 | + | {{if .SiteURLs.HomeURL}} | |
| 4 | + | <a href="{{.SiteURLs.HomeURL}}">repos</a> | |
| 5 | + | <span>/</span> | |
| 6 | + | {{end}} | |
| 7 | + | <span>{{.Repo.RepoName}}</span> | |
| 4 | 8 | </h1> | |
| 5 | 9 | ||
| 6 | - | <div class="text-lg"> | |
| 10 | + | <nav class="text-lg"> | |
| 7 | 11 | <a href="{{.SiteURLs.SummaryURL}}">summary</a> | | |
| 8 | 12 | <a href="{{.SiteURLs.RefsURL}}">refs</a> | | |
| 9 | 13 | <span class="font-bold">{{.RevData.RevName}}</span> | | |
| 10 | 14 | <a href="{{.RevData.TreeURL}}">tree</a> | | |
| 11 | 15 | <a href="{{.RevData.LogURL}}">log</a> | |
| 12 | - | </div> | |
| 16 | + | </nav> | |
| 13 | 17 | ||
| 14 | 18 | <div class="mt-lg"> | |
| 15 | 19 | <div class="text-lg">{{.Repo.Desc}}</div> | |
| 16 | 20 | <pre style="margin: 0;">git clone {{.SiteURLs.CloneURL}}</pre> | |
| 17 | 21 | </div> | |
| 18 | - | ||
| 19 | - | <hr /> | |
| 20 | 22 | {{end}} |
+0,
-2
| ... | ... | @@ -3,8 +3,6 @@ | |
| 3 | 3 | {{define "title"}}log{{end}} | |
| 4 | 4 | ||
| 5 | 5 | {{define "content"}} | |
| 6 | - | {{template "header" .}} | |
| 7 | - | ||
| 8 | 6 | <div> | |
| 9 | 7 | {{range .Logs}} | |
| 10 | 8 | <div class="box"> |
+1,
-3
| ... | ... | @@ -3,9 +3,7 @@ | |
| 3 | 3 | {{define "title"}}refs{{end}} | |
| 4 | 4 | ||
| 5 | 5 | {{define "content"}} | |
| 6 | - | {{template "header" .}} | |
| 7 | - | ||
| 8 | - | <h2 class="text-md font-bold">refs</h2> | |
| 6 | + | <h2 class="text-lg font-bold">refs</h2> | |
| 9 | 7 | ||
| 10 | 8 | <ul> | |
| 11 | 9 | {{range .Refs}} |
+0,
-2
| ... | ... | @@ -3,7 +3,5 @@ | |
| 3 | 3 | {{define "title"}}summary{{end}} | |
| 4 | 4 | ||
| 5 | 5 | {{define "content"}} | |
| 6 | - | {{template "header" .}} | |
| 7 | - | ||
| 8 | 6 | {{.Readme}} | |
| 9 | 7 | {{end}} |
+0,
-2
| ... | ... | @@ -3,8 +3,6 @@ | |
| 3 | 3 | {{define "title"}}tree{{end}} | |
| 4 | 4 | ||
| 5 | 5 | {{define "content"}} | |
| 6 | - | {{template "header" .}} | |
| 7 | - | ||
| 8 | 6 | <div> | |
| 9 | 7 | {{range .Tree}} | |
| 10 | 8 | <div class="flex justify-between items-center gap my-sm border-b"> |
M
main.go
+6,
-3
| ... | ... | @@ -56,7 +56,7 @@ type Config struct { | |
| 56 | 56 | HideTreeLastCommit bool | |
| 57 | 57 | ||
| 58 | 58 | // user-defined urls | |
| 59 | - | HomeUrl template.URL | |
| 59 | + | HomeURL template.URL | |
| 60 | 60 | CloneURL template.URL | |
| 61 | 61 | ||
| 62 | 62 | // computed |
| ... | ... | @@ -135,7 +135,7 @@ type BranchOutput struct { | |
| 135 | 135 | } | |
| 136 | 136 | ||
| 137 | 137 | type SiteURLs struct { | |
| 138 | - | RootURL template.URL | |
| 138 | + | HomeURL template.URL | |
| 139 | 139 | CloneURL template.URL | |
| 140 | 140 | SummaryURL template.URL | |
| 141 | 141 | RefsURL template.URL |
| ... | ... | @@ -313,6 +313,7 @@ func (c *Config) writeHtml(writeData *WriteData) { | |
| 313 | 313 | efs, | |
| 314 | 314 | writeData.Template, | |
| 315 | 315 | "html/header.partial.tmpl", | |
| 316 | + | "html/footer.partial.tmpl", | |
| 316 | 317 | "html/base.layout.tmpl", | |
| 317 | 318 | ) | |
| 318 | 319 | bail(err) |
| ... | ... | @@ -531,7 +532,7 @@ func (c *Config) getCommitURL(commitID string) template.URL { | |
| 531 | 532 | ||
| 532 | 533 | func (c *Config) getURLs() *SiteURLs { | |
| 533 | 534 | return &SiteURLs{ | |
| 534 | - | RootURL: c.HomeUrl, | |
| 535 | + | HomeURL: c.HomeURL, | |
| 535 | 536 | CloneURL: c.CloneURL, | |
| 536 | 537 | RefsURL: c.getRefsURL(), | |
| 537 | 538 | SummaryURL: c.getSummaryURL(), |
| ... | ... | @@ -752,6 +753,7 @@ func main() { | |
| 752 | 753 | var themeFlag = flag.String("theme", "dracula", "theme to use for site") | |
| 753 | 754 | var labelFlag = flag.String("label", "", "pretty name for the subdir where we create the repo, default is last folder in --repo") | |
| 754 | 755 | var cloneFlag = flag.String("clone-url", "", "git clone URL") | |
| 756 | + | var homeFlag = flag.String("home-url", "", "URL for breadcumbs to get to list of repositories") | |
| 755 | 757 | var descFlag = flag.String("desc", "", "description for repo") | |
| 756 | 758 | var maxCommitsFlag = flag.Int("max-commits", 0, "maximum number of commits to generate") | |
| 757 | 759 | var hideTreeLastCommitFlag = flag.Bool("hide-tree-last-commit", false, "dont calculate last commit for each file in the tree") |