gshr
git static host repo -- generates static html for repos
git clone https://git.vogt.world/gshr.git
Log | Files | README.md | LICENSE
← Commit log
commit
message
Adding generated timestamp to main index page
author
Ben Vogt <[email protected]>
date
2023-04-21 15:06:58
stats
4 file(s) changed, 13 insertions(+), 0 deletions(-)
files
config.go
index.go
main.go
template.index.html
 1diff --git a/config.go b/config.go
 2index 4cffdfd..3c647ab 100644
 3--- a/config.go
 4+++ b/config.go
 5@@ -85,6 +85,7 @@ type repoData struct {
 6 }
 7 
 8 type HeadData struct {
 9+	GenTime  string
10 	BaseURL  string
11 	SiteName string
12 }
13diff --git a/index.go b/index.go
14index eebd00c..ebcbd0e 100644
15--- a/index.go
16+++ b/index.go
17@@ -26,6 +26,7 @@ func renderIndexPage(repos []repoData) {
18 		HeadData: HeadData{
19 			BaseURL:  conf.Site.BaseURL,
20 			SiteName: conf.Site.Name,
21+			GenTime:  args.GenTime,
22 		},
23 		Repos: repos,
24 	}).renderPage(t)
25diff --git a/main.go b/main.go
26index 23735cc..8335030 100644
27--- a/main.go
28+++ b/main.go
29@@ -11,6 +11,7 @@ import (
30 	"os/exec"
31 	"path"
32 	"strings"
33+	"time"
34 
35 	"github.com/alecthomas/chroma/formatters/html"
36 	"github.com/alecthomas/chroma/lexers"
37@@ -104,6 +105,7 @@ func cloneAndGetData(repo repoConfig, r *git.Repository) repoData {
38 		HeadData: HeadData{
39 			BaseURL:  conf.Site.BaseURL,
40 			SiteName: conf.Site.Name,
41+			GenTime:  args.GenTime,
42 		},
43 		ReadMePath:      repo.findFileInRoot(stt.AllowedReadMeFiles),
44 		LicenseFilePath: repo.findFileInRoot(stt.AllowedLicenseFiles),
45@@ -190,6 +192,7 @@ type cmdArgs struct {
46 	Wd         string
47 	ConfigPath string
48 	OutputDir  string
49+	GenTime    string
50 }
51 
52 func defaultCmdArgs() cmdArgs {
53@@ -197,6 +200,7 @@ func defaultCmdArgs() cmdArgs {
54 		Silent:     true,
55 		ConfigPath: "",
56 		OutputDir:  "",
57+		GenTime:    time.Now().Format("Mon Jan 2 15:04:05 MST 2006"),
58 	}
59 }
60 
61diff --git a/template.index.html b/template.index.html
62index fd7b47c..4f7b4ac 100644
63--- a/template.index.html
64+++ b/template.index.html
65@@ -44,6 +44,9 @@
66           {{ end }}
67         </r-grid>
68       </div>
69+      <div style="padding-top: 2em">
70+        <small><b>Generated:</b> {{ .HeadData.GenTime }}</small>
71+      </div>
72     </div>
73   </div>
74 </body>