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
Site name, link back to main page, better styles
author
Ben Vogt <[email protected]>
date
2023-04-05 14:32:26
stats
7 file(s) changed, 51 insertions(+), 30 deletions(-)
files
config.go
gshr.css
gshr.toml
index.go
main.go
templates/index.html
templates/partials.html
  1diff --git a/config.go b/config.go
  2index 5dae1ec..d9697c6 100644
  3--- a/config.go
  4+++ b/config.go
  5@@ -5,8 +5,9 @@ import (
  6 )
  7 
  8 type Config struct {
  9-	Repos   []Repo
 10-	BaseURL string `toml:"base_url"`
 11+	SiteName string `toml:"site_name"`
 12+	Repos    []Repo
 13+	BaseURL  string `toml:"base_url"`
 14 }
 15 
 16 type Repo struct {
 17@@ -23,22 +24,6 @@ func ParseConfiguration(data string) Config {
 18 	return conf
 19 }
 20 
 21-type CmdArgs struct {
 22-	DebugOn    bool
 23-	ConfigFile string
 24-	OutputDir  string
 25-	CloneDir   string
 26-}
 27-
 28-func DefaultCmdArgs() CmdArgs {
 29-	return CmdArgs{
 30-		DebugOn:    true,
 31-		ConfigFile: "",
 32-		OutputDir:  "",
 33-		CloneDir:   "",
 34-	}
 35-}
 36-
 37 type RepoData struct {
 38 	Name            string
 39 	GitURL          string
 40diff --git a/gshr.css b/gshr.css
 41index 1e0f032..9661e23 100644
 42--- a/gshr.css
 43+++ b/gshr.css
 44@@ -160,13 +160,13 @@ h6>a:hover {
 45 @media screen and (max-width: 920px) {
 46   div.content {
 47     margin: 0 auto;
 48-    padding: 40px 20px;
 49+    padding: 20px;
 50   }
 51 }
 52 
 53 div.content {
 54   margin: 0 auto;
 55-  padding: 40px 20px;
 56+  padding: 20px;
 57   max-width: 860px
 58 }
 59 
 60@@ -240,6 +240,9 @@ div.content div.metadata h1 {
 61   margin: 0;
 62 }
 63 
 64+div.content div:not(.metadata) * tr:hover {
 65+  background: #efefef;
 66+}
 67 
 68 div.content div.log .commit {
 69   white-space: nowrap;
 70@@ -266,10 +269,6 @@ div.content div.files table {
 71   font-family: var(--mono-font);
 72 }
 73 
 74-div.content * tr:hover {
 75-  background: #efefef;
 76-}
 77-
 78 div.content * td {
 79   padding: 0 0.4em;
 80   max-width: 380px;
 81diff --git a/gshr.toml b/gshr.toml
 82index 53047b7..1516496 100644
 83--- a/gshr.toml
 84+++ b/gshr.toml
 85@@ -1,4 +1,5 @@
 86 base_url = "/"
 87+site_name = "public, self hosted git repositories"
 88 
 89 [[repos]]
 90 name = "gshr"
 91@@ -14,6 +15,6 @@ git_url = "[email protected]:vogtb/www.git"
 92 
 93 [[repos]]
 94 name = "f7"
 95-description = "F7 is the spreadsheet formula execution library"
 96+description = "f7 is a spreadsheet formula execution library"
 97 path = "/Users/bvogt/dev/src/ben/f7"
 98 git_url = "[email protected]:vogtb/f7.git"
 99diff --git a/index.go b/index.go
100index a696b52..e4a15fc 100644
101--- a/index.go
102+++ b/index.go
103@@ -7,8 +7,9 @@ import (
104 )
105 
106 type IndexPage struct {
107-	BaseURL string
108-	Repos   []RepoData
109+	BaseURL  string
110+	SiteName string
111+	Repos    []RepoData
112 }
113 
114 func (l *IndexPage) Render(t *template.Template) {
115@@ -22,7 +23,8 @@ func RenderIndexPage(repos []RepoData) {
116 	t, err := template.ParseFS(htmlTemplates, "templates/index.html", "templates/partials.html")
117 	checkErr(err)
118 	(&IndexPage{
119-		BaseURL: config.BaseURL,
120-		Repos:   repos,
121+		BaseURL:  config.BaseURL,
122+		SiteName: config.SiteName,
123+		Repos:    repos,
124 	}).Render(t)
125 }
126diff --git a/main.go b/main.go
127index 674d2bd..4f9af89 100644
128--- a/main.go
129+++ b/main.go
130@@ -130,6 +130,22 @@ func findFileInRoot(name string, oneOfThese map[string]bool) string {
131 	return ""
132 }
133 
134+type CmdArgs struct {
135+	DebugOn    bool
136+	ConfigFile string
137+	OutputDir  string
138+	CloneDir   string
139+}
140+
141+func DefaultCmdArgs() CmdArgs {
142+	return CmdArgs{
143+		DebugOn:    true,
144+		ConfigFile: "",
145+		OutputDir:  "",
146+		CloneDir:   "",
147+	}
148+}
149+
150 type Settings struct {
151 	TextExtensions      map[string]bool
152 	PlainFiles          map[string]bool
153@@ -152,6 +168,9 @@ func DefaultSettings() Settings {
154 			".dot":            true,
155 			".eslintignore":   true,
156 			".eslintrc":       true,
157+			".bashrc":         true,
158+			".zshrc":          true,
159+			".zshprofile":     true,
160 			".g4":             true,
161 			".gitignore":      true,
162 			".gitmodules":     true,
163diff --git a/templates/index.html b/templates/index.html
164index 562b48d..cad9ad0 100644
165--- a/templates/index.html
166+++ b/templates/index.html
167@@ -12,7 +12,7 @@
168         <tbody>
169           <tr>
170             <td>
171-              <h1>Git Repositories</h1>
172+              <h1>{{ .SiteName }}</h1>
173             </td>
174           </tr>
175         </tbody>
176diff --git a/templates/partials.html b/templates/partials.html
177index 25fe1cf..e023016 100644
178--- a/templates/partials.html
179+++ b/templates/partials.html
180@@ -17,6 +17,19 @@
181 <div class="metadata">
182   <table>
183     <tbody>
184+      <tr>
185+        <td>
186+          <a href="{{ .BaseURL }}">
187+            <span>
188+              ←
189+              Back to main page
190+            </span>
191+          </a>
192+        </td>
193+      </tr>
194+      <tr>
195+        <td>&nbsp;</td>
196+      </tr>
197       <tr>
198         <td>
199           <h1>{{ .Name }}</h1>