commit
message
Listing files, links working, header ok
author
Ben Vogt <[email protected]>
date
2023-04-03 17:10:27
stats
5 file(s) changed,
142 insertions(+),
59 deletions(-)
files
file.template.html
files.template.html
index.template.html
log.template.html
main.go
styles.css
1diff --git a/file.template.html b/file.template.html
2index d572549..af8f118 100644
3--- a/file.template.html
4+++ b/file.template.html
5@@ -18,9 +18,36 @@
6
7 <body>
8 <div class="content">
9- <pre>
10-{{.}}
11- </pre>
12+ <div class="metadata">
13+ <table>
14+ <tbody>
15+ <tr>
16+ <td>
17+ <h1>www</h1>
18+ <span class="desc">
19+ personal website hosted at https:://www.vogt.world/
20+ </span>
21+ </td>
22+ </tr>
23+ <tr>
24+ <td>
25+ git clone
26+ <a href="[email protected]:./www.gitc">[email protected]:./www.git</a>
27+ </td>
28+ </tr>
29+ <tr>
30+ <td>
31+ <a href="/log.html">Log</a>
32+ |
33+ <a href="/files.html">Files</a>
34+ </td>
35+ </tr>
36+ </tbody>
37+ </table>
38+ </div>
39+ <div class="file">
40+ <pre>{{.}}</pre>
41+ </div>
42 </div>
43 </body>
44
45diff --git a/files.template.html b/files.template.html
46index 94b3986..892dfcd 100644
47--- a/files.template.html
48+++ b/files.template.html
49@@ -18,8 +18,35 @@
50
51 <body>
52 <div class="content">
53- <div class="commits">
54- <table id="log">
55+ <div class="metadata">
56+ <table>
57+ <tbody>
58+ <tr>
59+ <td>
60+ <h1>www</h1>
61+ <span class="desc">
62+ personal website hosted at https:://www.vogt.world/
63+ </span>
64+ </td>
65+ </tr>
66+ <tr>
67+ <td>
68+ git clone
69+ <a href="[email protected]:./www.gitc">[email protected]:./www.git</a>
70+ </td>
71+ </tr>
72+ <tr>
73+ <td>
74+ <a href="/log.html">Log</a>
75+ |
76+ <a href="/files.html">Files</a>
77+ </td>
78+ </tr>
79+ </tbody>
80+ </table>
81+ </div>
82+ <div class="files">
83+ <table>
84 <thead>
85 <tr>
86 <td><b>Mode</b></td>
87diff --git a/index.template.html b/log.template.html
88similarity index 66%
89rename from index.template.html
90rename to log.template.html
91index 5bad6d7..0ddbcfa 100644
92--- a/index.template.html
93+++ b/log.template.html
94@@ -18,8 +18,35 @@
95
96 <body>
97 <div class="content">
98- <div class="commits">
99- <table id="log">
100+ <div class="metadata">
101+ <table>
102+ <tbody>
103+ <tr>
104+ <td>
105+ <h1>www</h1>
106+ <span class="desc">
107+ personal website hosted at https:://www.vogt.world/
108+ </span>
109+ </td>
110+ </tr>
111+ <tr>
112+ <td>
113+ git clone
114+ <a href="[email protected]:./www.gitc">[email protected]:./www.git</a>
115+ </td>
116+ </tr>
117+ <tr>
118+ <td>
119+ <a href="/log.html">Log</a>
120+ |
121+ <a href="/files.html">Files</a>
122+ </td>
123+ </tr>
124+ </tbody>
125+ </table>
126+ </div>
127+ <div class="log">
128+ <table>
129 <thead>
130 <tr>
131 <td><b>Date</b></td>
132diff --git a/main.go b/main.go
133index e2da262..a819597 100644
134--- a/main.go
135+++ b/main.go
136@@ -37,14 +37,17 @@ type TrackedFileMetaData struct {
137 }
138
139 type TrackedFile struct {
140- Mode string
141- Name string
142- Size string
143- Origin string
144- Destination string
145+ Mode string
146+ Name string
147+ Size string
148+ Origin string
149+ Destination string
150+ DestinationDir string
151 }
152
153 func (tf *TrackedFile) SaveTemplate(t *template.Template) {
154+ err := os.MkdirAll(tf.DestinationDir, 0775)
155+ checkErr(err)
156 fileBytes, err := os.ReadFile(tf.Origin)
157 checkErr(err)
158 fileStr := string(fileBytes)
159@@ -63,12 +66,12 @@ type GshrCommit struct {
160 Message string
161 }
162
163-type MainIndex struct {
164+type LogPage struct {
165 Commits []GshrCommit
166 }
167
168-func (mi *MainIndex) SaveTemplate(t *template.Template) {
169- output, err := os.Create(path.Join(outputDir, "index.html"))
170+func (mi *LogPage) SaveTemplate(t *template.Template) {
171+ output, err := os.Create(path.Join(outputDir, "log.html"))
172 checkErr(err)
173 err = t.Execute(output, mi)
174 checkErr(err)
175@@ -79,9 +82,7 @@ type FilesIndex struct {
176 }
177
178 func (fi *FilesIndex) SaveTemplate(t *template.Template) {
179- err := os.MkdirAll(path.Join(outputDir, "files"), 0775)
180- checkErr(err)
181- output, err := os.Create(path.Join(outputDir, "files", "index.html"))
182+ output, err := os.Create(path.Join(outputDir, "files.html"))
183 checkErr(err)
184 err = t.Execute(output, fi)
185 checkErr(err)
186@@ -93,9 +94,9 @@ func main() {
187 line("OUTPUT_DIR = %v", outputDir)
188 line("CLONING_DIR = %v", cloningDir)
189 r := CloneAndInfo()
190- BuildMainIndex(r)
191- BuildFilesIndex()
192- BuildTrackedFiles()
193+ BuildLogPage(r)
194+ BuildFilesPages()
195+ BuildSingleFilePages()
196 }
197
198 func CloneAndInfo() *git.Repository {
199@@ -106,8 +107,8 @@ func CloneAndInfo() *git.Repository {
200 return r
201 }
202
203-func BuildMainIndex(r *git.Repository) {
204- t, err := template.ParseFiles("index.template.html")
205+func BuildLogPage(r *git.Repository) {
206+ t, err := template.ParseFiles("log.template.html")
207 commits := make([]GshrCommit, 0)
208 ref, err := r.Head()
209 checkErr(err)
210@@ -126,13 +127,13 @@ func BuildMainIndex(r *git.Repository) {
211 })
212
213 checkErr(err)
214- m := MainIndex{
215+ m := LogPage{
216 Commits: commits,
217 }
218 m.SaveTemplate(t)
219 }
220
221-func BuildFilesIndex() {
222+func BuildFilesPages() {
223 t, err := template.ParseFiles("files.template.html")
224 trackedFiles := make([]TrackedFileMetaData, 0)
225 err = filepath.Walk(cloningDir, func(filename string, info fs.FileInfo, err error) error {
226@@ -165,7 +166,7 @@ func BuildFilesIndex() {
227 index.SaveTemplate(t)
228 }
229
230-func BuildTrackedFiles() {
231+func BuildSingleFilePages() {
232 t, err := template.ParseFiles("file.template.html")
233 checkErr(err)
234
235@@ -178,12 +179,13 @@ func BuildTrackedFiles() {
236 ext := filepath.Ext(filename)
237 if _, ok := allowedExtensions[ext]; ok {
238 partialPath, _ := strings.CutPrefix(filename, cloningDir)
239- outputName := fmt.Sprintf("%v%v.html", outputDir, partialPath)
240+ outputName := path.Join(outputDir, "files", partialPath, "index.html")
241 line("READING: %v", filename)
242 line("WRITING: %v", outputName)
243 tf := TrackedFile{
244- Origin: filename,
245- Destination: outputName,
246+ Origin: filename,
247+ Destination: outputName,
248+ DestinationDir: path.Join(outputDir, "files", partialPath),
249 }
250 tf.SaveTemplate(t)
251 }
252diff --git a/styles.css b/styles.css
253index 93e940f..d812e55 100644
254--- a/styles.css
255+++ b/styles.css
256@@ -65,7 +65,7 @@ pre,
257 blockquote,
258 hr,
259 object {
260- margin: 1rem 0
261+ margin: 0.31rem 0
262 }
263
264 pre,
265@@ -335,24 +335,19 @@ div.content blockquote {
266 font-size: 1.1em
267 }
268
269+div.content div.file {
270+ padding: 0 0.4em;
271+}
272+
273 div.content pre,
274 div.content code {
275 color: var(--code-color);
276 background-color: var(--code-bg);
277- border-radius: 3px
278-}
279-
280-div.content pre>code {
281- background: none;
282- border-radius: 0;
283- color: var(--code-color)
284 }
285
286 div.content pre {
287- line-height: 1.21;
288 overflow-x: auto;
289- padding: 16px;
290- border: var(--code-border-color) solid 1px;
291+ padding: 1em;
292 background: var(--code-bg);
293 color: var(--text-color)
294 }
295@@ -384,39 +379,34 @@ div.content *:target {
296 outline: 4px solid #fe0
297 }
298
299-div.content center {
300- margin: 2em 0;
301- user-select: none;
302- cursor: default;
303- color: var(--text-color)
304+div.content div.metadata {
305+ padding-bottom: 1em;
306 }
307
308-div.content.sub {
309- margin-top: -50px;
310- padding-top: 20px
311+div.content div.metadata h1 {
312+ font-size: 1em;
313+ margin: 0;
314 }
315
316-div.content img.img-responsive {
317- display: block;
318- max-width: 100%;
319- height: auto
320-}
321
322-div.content div.commits {
323+div.content div.log {
324 display: block;
325- font-family: var(--mono-font);
326 }
327
328-div.content div.commits table {
329+div.content div.log table,
330+div.content div.files table {
331+ vertical-align: top;
332+ white-space: nowrap;
333 width: 100%;
334+ font-family: var(--mono-font);
335 }
336
337-div.content div.commits table td {
338- padding: 0 0.4em;
339+div.content>*>tr:hover {
340+ background: #efefef;
341 }
342
343-div.content div.commits table tr:hover {
344- background: #efefef;
345+div.content>*>td {
346+ padding: 0 0.4em;
347 }
348
349 .chroma {