commit
message
Site name, better git links
author
Ben Vogt <[email protected]>
date
2023-04-06 15:45:26
stats
11 file(s) changed,
54 insertions(+),
30 deletions(-)
files
Makefile
config.go
dev-config-gshr.toml
index.go
main.go
template.commit.html
template.file.html
template.files.html
template.index.html
template.log.html
template.partials.html
1diff --git a/Makefile b/Makefile
2index 156ca13..cc89ee5 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -1,9 +1,5 @@
6 # Copyright 2023 Ben Vogt. All rights reserved.
7
8-PWD := $(shell pwd)
9-
10-rfind=$(shell find $1 -type f -not -path "./target/*")
11-
12 target:
13 mkdir -p target
14
15diff --git a/config.go b/config.go
16index 2156585..096d8c5 100644
17--- a/config.go
18+++ b/config.go
19@@ -50,6 +50,12 @@ type RepoData struct {
20 Repo
21 PublishedGitURL string
22 BaseURL string
23+ HeadData HeadData
24 ReadMePath string
25 LicenseFilePath string
26 }
27+
28+type HeadData struct {
29+ BaseURL string
30+ SiteName string
31+}
32diff --git a/dev-config-gshr.toml b/dev-config-gshr.toml
33index f5ac421..032a9c4 100644
34--- a/dev-config-gshr.toml
35+++ b/dev-config-gshr.toml
36@@ -7,3 +7,14 @@ description = "git static host repo -- generates static html for repos"
37 url = "https://github.com/vogtb/gshr"
38 published_git_url = "https://github.com/vogtb/gshr"
39 host_git = true
40+
41+[[repos]]
42+name = "f7"
43+description = "f7 is a spreadsheet formula execution library"
44+url = "https://github.com/vogtb/f7"
45+published_git_url = "https://github.com/vogtb/f7"
46+
47+[[repos]]
48+name = "spreadsheet"
49+description = "typeScript/javascript spreadsheet parser, with formulas"
50+url = "https://github.com/vogtb/spreadsheet"
51diff --git a/index.go b/index.go
52index 27c9d18..f1fc94a 100644
53--- a/index.go
54+++ b/index.go
55@@ -7,13 +7,12 @@ import (
56 )
57
58 type IndexPage struct {
59- BaseURL string
60- SiteName string
61+ HeadData HeadData
62 Repos []RepoData
63 }
64
65 func (l *IndexPage) RenderPage(t *template.Template) {
66- debug("index for '%v'", l.SiteName)
67+ debug("index for '%v'", l.HeadData.SiteName)
68 output, err := os.Create(path.Join(args.OutputDir, "index.html"))
69 checkErr(err)
70 err = t.Execute(output, l)
71@@ -24,8 +23,10 @@ func RenderIndexPage(repos []RepoData) {
72 t, err := template.ParseFS(htmlTemplates, "template.index.html", "template.partials.html")
73 checkErr(err)
74 (&IndexPage{
75- BaseURL: config.BaseURL,
76- SiteName: config.SiteName,
77- Repos: repos,
78+ HeadData: HeadData{
79+ BaseURL: config.BaseURL,
80+ SiteName: config.SiteName,
81+ },
82+ Repos: repos,
83 }).RenderPage(t)
84 }
85diff --git a/main.go b/main.go
86index 0d8cbe0..e0b1f7d 100644
87--- a/main.go
88+++ b/main.go
89@@ -100,6 +100,10 @@ func CloneAndGetData(repo Repo, r *git.Repository) RepoData {
90 Repo: repo,
91 PublishedGitURL: repo.PublishedGitURL,
92 BaseURL: config.BaseURL,
93+ HeadData: HeadData{
94+ BaseURL: config.BaseURL,
95+ SiteName: config.SiteName,
96+ },
97 ReadMePath: repo.FindFileInRoot(settings.AllowedReadMeFiles),
98 LicenseFilePath: repo.FindFileInRoot(settings.AllowedLicenseFiles),
99 }
100diff --git a/template.commit.html b/template.commit.html
101index 3f9d4d0..7f42e39 100644
102--- a/template.commit.html
103+++ b/template.commit.html
104@@ -2,7 +2,7 @@
105 <html lang="en">
106
107 <head>
108- {{ template "head" .RepoData.BaseURL }}
109+ {{ template "head" .RepoData.HeadData }}
110 </head>
111
112 <body>
113@@ -14,7 +14,7 @@
114 <tr>
115 <td><b>commit: </b></td>
116 <td>
117- <a href="{{ .RepoData.BaseURL }}{{ .RepoData.Name }}/commit/{{ .Hash }}/">
118+ <a href="{{ .RepoData.HeadData.BaseURL }}{{ .RepoData.Name }}/commit/{{ .Hash }}/">
119 {{ .Hash }}
120 </a>
121 </td>
122diff --git a/template.file.html b/template.file.html
123index 0e78897..c4246f4 100644
124--- a/template.file.html
125+++ b/template.file.html
126@@ -2,7 +2,7 @@
127 <html lang="en">
128
129 <head>
130- {{ template "head" .RepoData.BaseURL }}
131+ {{ template "head" .RepoData.HeadData }}
132 </head>
133
134 <body>
135diff --git a/template.files.html b/template.files.html
136index 695f77d..222af75 100644
137--- a/template.files.html
138+++ b/template.files.html
139@@ -2,7 +2,7 @@
140 <html lang="en">
141
142 <head>
143- {{ template "head" .RepoData.BaseURL }}
144+ {{ template "head" .RepoData.HeadData }}
145 </head>
146
147 <body>
148@@ -22,7 +22,8 @@
149 <tr>
150 <td>{{ .Mode }}</td>
151 <td>
152- <a href="{{ $.RepoData.BaseURL }}{{ $.RepoData.Name }}/files/{{ .Name }}/index.html">
153+ <a
154+ href="{{ $.RepoData.HeadData.BaseURL }}{{ $.RepoData.Name }}/files/{{ .Name }}/index.html">
155 {{ .Name }}
156 </a>
157 </td>
158diff --git a/template.index.html b/template.index.html
159index ece0c02..02bb242 100644
160--- a/template.index.html
161+++ b/template.index.html
162@@ -2,7 +2,7 @@
163 <html lang="en">
164
165 <head>
166- {{ template "head" .BaseURL }}
167+ {{ template "head" .HeadData }}
168 </head>
169
170 <body>
171@@ -12,7 +12,7 @@
172 <tbody>
173 <tr>
174 <td>
175- <h1>{{ .SiteName }}</h1>
176+ <h1>{{ .HeadData.SiteName }}</h1>
177 </td>
178 </tr>
179 </tbody>
180@@ -32,7 +32,7 @@
181 {{ range .Repos }}
182 <tr>
183 <td>
184- <a href="{{ $.BaseURL }}{{ .Name }}/log.html">
185+ <a href="{{ $.HeadData.BaseURL }}{{ .Name }}/log.html">
186 {{ .Name }}
187 </a>
188 </td>
189@@ -40,9 +40,17 @@
190 {{ .Description }}
191 </td>
192 <td>
193+ {{ if .HostGit }}
194 <a href="{{ .BaseURL }}{{ .Name }}.git">
195 {{ .BaseURL }}{{ .Name }}.git
196 </a>
197+ {{ else if not (eq .PublishedGitURL "") }}
198+ <a href="{{ .PublishedGitURL }}">
199+ {{ .PublishedGitURL }}
200+ </a>
201+ {{ else }}
202+ <em>none</em>
203+ {{ end }}
204 </td>
205 </tr>
206 {{ end }}
207diff --git a/template.log.html b/template.log.html
208index 4f9ca7a..b97023b 100644
209--- a/template.log.html
210+++ b/template.log.html
211@@ -2,7 +2,7 @@
212 <html lang="en">
213
214 <head>
215- {{ template "head" .RepoData.BaseURL }}
216+ {{ template "head" .RepoData.HeadData }}
217 </head>
218
219 <body>
220diff --git a/template.partials.html b/template.partials.html
221index c6374d7..3a2602e 100644
222--- a/template.partials.html
223+++ b/template.partials.html
224@@ -3,13 +3,9 @@
225 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
226 <meta http-equiv="X-UA-Compatible" content="IE=edge">
227 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
228-<title>gshr</title>
229-<link rel="stylesheet" href="{{ . }}gshr.css" type="text/css">
230-<meta name="description"
231- content="git static host repo">
232-<meta property="og:site_name" content="gshr">
233-<meta property="og:type" content="article">
234-<meta property="article:author" content="gshr">
235+<link rel="stylesheet" href="{{ .BaseURL }}gshr.css" type="text/css">
236+<meta name="description" content="git static host repo">
237+<title>{{ .SiteName }}</title>
238 {{ end }}
239
240 {{ define "metadata" }}
241@@ -18,7 +14,7 @@
242 <tbody>
243 <tr>
244 <td>
245- <a href="{{ .BaseURL }}">
246+ <a href="{{ .HeadData.BaseURL }}">
247 <span>
248 ←
249 Back to main page
250@@ -39,7 +35,7 @@
251 </tr>
252 <tr>
253 <td>
254- git clone {{ .BaseURL }}{{ .Name }}.git
255+ git clone {{ .HeadData.BaseURL }}{{ .Name }}.git
256 </td>
257 </tr>
258 {{ if not (eq .PublishedGitURL "") }}
259@@ -51,18 +47,18 @@
260 {{ end }}
261 <tr>
262 <td>
263- <a href="{{ .BaseURL }}{{ .Name }}/log.html">Log</a>
264+ <a href="{{ .HeadData.BaseURL }}{{ .Name }}/log.html">Log</a>
265 |
266- <a href="{{ .BaseURL }}{{ .Name }}/files.html">Files</a>
267+ <a href="{{ .HeadData.BaseURL }}{{ .Name }}/files.html">Files</a>
268 {{ if not (eq .ReadMePath "") }}
269 |
270- <a href="{{ .BaseURL }}{{ .Name }}/files/{{ .ReadMePath }}/index.html">
271+ <a href="{{ .HeadData.BaseURL }}{{ .Name }}/files/{{ .ReadMePath }}/index.html">
272 {{ .ReadMePath }}
273 </a>
274 {{ end }}
275 {{ if not (eq .LicenseFilePath "") }}
276 |
277- <a href="{{ .BaseURL }}{{ .Name }}/files/{{ .LicenseFilePath }}/index.html">
278+ <a href="{{ .HeadData.BaseURL }}{{ .Name }}/files/{{ .LicenseFilePath }}/index.html">
279 {{ .LicenseFilePath }}
280 </a>
281 {{ end }}