commit
message
Getting closer to having multi-repo working
author
Ben Vogt <[email protected]>
date
2023-04-04 23:34:36
stats
9 file(s) changed,
54 insertions(+),
21 deletions(-)
files
config.go
gshr.css
main.go
templates/commit.html
templates/file.html
templates/files.html
templates/index.html
templates/log.html
templates/partials.html
1diff --git a/config.go b/config.go
2index 5f76096..5dae1ec 100644
3--- a/config.go
4+++ b/config.go
5@@ -6,14 +6,14 @@ import (
6
7 type Config struct {
8 Repos []Repo
9- BaseURL string
10+ BaseURL string `toml:"base_url"`
11 }
12
13 type Repo struct {
14 Name string
15 Description string
16 Path string
17- GitURL string
18+ GitURL string `toml:"git_url"`
19 }
20
21 func ParseConfiguration(data string) Config {
22diff --git a/gshr.css b/gshr.css
23index edd175c..2ea68c3 100644
24--- a/gshr.css
25+++ b/gshr.css
26@@ -253,10 +253,16 @@ div.content div.log {
27
28 div.content div.log table,
29 div.content div.commit-detail table,
30+div.content div.index table,
31 div.content div.files table {
32 vertical-align: top;
33 white-space: nowrap;
34 width: 100%;
35+}
36+
37+div.content div.log table,
38+div.content div.commit-detail table,
39+div.content div.files table {
40 font-family: var(--mono-font);
41 }
42
43diff --git a/main.go b/main.go
44index ea0e1ec..2cf2e31 100644
45--- a/main.go
46+++ b/main.go
47@@ -59,6 +59,7 @@ func Init() {
48 configFileByes, err := os.ReadFile(args.ConfigFile)
49 checkErr(err)
50 config = ParseConfiguration(string(configFileByes))
51+ debug("base_url = %v", config.BaseURL)
52 }
53
54 func CloneAndGetData(repo Repo, r *git.Repository) RepoData {
55diff --git a/templates/commit.html b/templates/commit.html
56index 2f27c1b..0a5359b 100644
57--- a/templates/commit.html
58+++ b/templates/commit.html
59@@ -2,7 +2,7 @@
60 <html lang="en">
61
62 <head>
63- {{ template "head" .RepoData }}
64+ {{ template "head" .RepoData.BaseURL }}
65 </head>
66
67 <body>
68diff --git a/templates/file.html b/templates/file.html
69index 894f450..0e78897 100644
70--- a/templates/file.html
71+++ b/templates/file.html
72@@ -2,7 +2,7 @@
73 <html lang="en">
74
75 <head>
76- {{ template "head" .RepoData }}
77+ {{ template "head" .RepoData.BaseURL }}
78 </head>
79
80 <body>
81diff --git a/templates/files.html b/templates/files.html
82index 1d98b3b..f9af0fb 100644
83--- a/templates/files.html
84+++ b/templates/files.html
85@@ -2,7 +2,7 @@
86 <html lang="en">
87
88 <head>
89- {{ template "head" .RepoData }}
90+ {{ template "head" .RepoData.BaseURL }}
91 </head>
92
93 <body>
94diff --git a/templates/index.html b/templates/index.html
95index 71bb554..562b48d 100644
96--- a/templates/index.html
97+++ b/templates/index.html
98@@ -2,33 +2,51 @@
99 <html lang="en">
100
101 <head>
102- {{ template "head" .RepoData }}
103+ {{ template "head" .BaseURL }}
104 </head>
105
106 <body>
107 <div class="content">
108+ <div class="metadata">
109+ <table>
110+ <tbody>
111+ <tr>
112+ <td>
113+ <h1>Git Repositories</h1>
114+ </td>
115+ </tr>
116+ </tbody>
117+ </table>
118+ </div>
119 <div class="index">
120 <div class="metadata">
121 <table>
122+ <thead>
123+ <tr>
124+ <td><b>Name</b></td>
125+ <td><b>Description</b></td>
126+ <td><b>Git URL</b></td>
127+ </tr>
128+ </thead>
129 <tbody>
130+ {{ range .Repos }}
131 <tr>
132 <td>
133- <h1>whatever</h1>
134- <span class="desc">
135- ???
136- </span>
137+ <a href="{{ $.BaseURL }}{{ .Name }}/log.html">
138+ {{ .Name }}
139+ </a>
140 </td>
141- </tr>
142- <tr>
143 <td>
144- <a href="/whatever">link?</a>
145+ {{ .Description }}
146 </td>
147- </tr>
148- <tr>
149 <td>
150- etc.....
151+ git clone
152+ <a href="{{ .GitURL }}">
153+ {{ .GitURL }}
154+ </a>
155 </td>
156 </tr>
157+ {{ end }}
158 </tbody>
159 </table>
160 </div>
161diff --git a/templates/log.html b/templates/log.html
162index 1a4cc46..0ecd756 100644
163--- a/templates/log.html
164+++ b/templates/log.html
165@@ -2,7 +2,7 @@
166 <html lang="en">
167
168 <head>
169- {{ template "head" .RepoData }}
170+ {{ template "head" .RepoData.BaseURL }}
171 </head>
172
173 <body>
174diff --git a/templates/partials.html b/templates/partials.html
175index 6d8a1aa..25fe1cf 100644
176--- a/templates/partials.html
177+++ b/templates/partials.html
178@@ -5,7 +5,7 @@
179 <meta http-equiv="X-UA-Compatible" content="IE=edge">
180 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
181 <title>gshr</title>
182-<link rel="stylesheet" href="{{ .BaseURL }}gshr.css" type="text/css">
183+<link rel="stylesheet" href="{{ . }}gshr.css" type="text/css">
184 <meta name="description"
185 content="git static host repo">
186 <meta property="og:site_name" content="gshr">
187@@ -32,18 +32,18 @@
188 </tr>
189 <tr>
190 <td>
191- <a href="{{ .BaseURL }}log.html">Log</a>
192+ <a href="{{ .BaseURL }}{{ .Name }}/log.html">Log</a>
193 |
194- <a href="{{ .BaseURL }}files.html">Files</a>
195+ <a href="{{ .BaseURL }}{{ .Name }}/files.html">Files</a>
196 {{ if not (eq .ReadMePath "") }}
197 |
198- <a href="{{ .BaseURL }}files/{{ .ReadMePath }}/index.html">
199+ <a href="{{ .BaseURL }}{{ .Name }}/files/{{ .ReadMePath }}/index.html">
200 {{ .ReadMePath }}
201 </a>
202 {{ end }}
203 {{ if not (eq .LicenseFilePath "") }}
204 |
205- <a href="{{ .BaseURL }}files/{{ .LicenseFilePath }}/index.html">
206+ <a href="{{ .BaseURL }}{{ .Name }}/files/{{ .LicenseFilePath }}/index.html">
207 {{ .LicenseFilePath }}
208 </a>
209 {{ end }}