commit
message
Fixing examples, embedding assets
author
Ben Vogt <[email protected]>
date
2023-04-05 16:49:13
stats
3 file(s) changed,
18 insertions(+),
14 deletions(-)
files
Makefile
examples/gshr-simple.toml
examples/ghsr-simple.toml
main.go
1diff --git a/Makefile b/Makefile
2index 15a3e87..e041e91 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -26,32 +26,23 @@ dev: Makefile target target/output target/cloning target/gshr.bin
6 ./target/gshr.bin \
7 --config=$(PWD)/gshr.toml \
8 --output=$(PWD)/target/output \
9- --clone=$(PWD)/target/cloning \
10 && \
11- cp gshr.css $(PWD)/target/output/ && \
12- cp favicon.ico $(PWD)/target/output/ && \
13 cd $(PWD)/target/output && \
14 python3 -m http.server 8000
15
16 dev-example-go-git: Makefile target target/output target/cloning target/gshr.bin
17 ./target/gshr.bin \
18- --config=$(PWD)/example/go-git.toml \
19+ --config=$(PWD)/examples/go-git.toml \
20 --output=$(PWD)/target/output \
21- --clone=$(PWD)/target/cloning \
22 && \
23- cp gshr.css $(PWD)/target/output/ && \
24- cp favicon.ico $(PWD)/target/output/ && \
25 cd $(PWD)/target/output && \
26 python3 -m http.server 8000
27
28 dev-example-gshr: Makefile target target/output target/cloning target/gshr.bin
29 ./target/gshr.bin \
30- --config=$(PWD)/example/gshr-simple.toml \
31+ --config=$(PWD)/examples/ghsr-simple.toml \
32 --output=$(PWD)/target/output \
33- --clone=$(PWD)/target/cloning \
34 && \
35- cp gshr.css $(PWD)/target/output/ && \
36- cp favicon.ico $(PWD)/target/output/ && \
37 cd $(PWD)/target/output && \
38 python3 -m http.server 8000
39
40diff --git a/examples/gshr-simple.toml b/examples/ghsr-simple.toml
41similarity index 100%
42rename from examples/gshr-simple.toml
43rename to examples/ghsr-simple.toml
44diff --git a/main.go b/main.go
45index 33fddc3..c49f127 100644
46--- a/main.go
47+++ b/main.go
48@@ -20,6 +20,12 @@ import (
49 //go:embed templates/*
50 var htmlTemplates embed.FS
51
52+//go:embed gshr.css
53+var css []byte
54+
55+//go:embed favicon.ico
56+var favicon []byte
57+
58 var args CmdArgs
59
60 var config Config
61@@ -39,6 +45,7 @@ func main() {
62 RenderSingleFilePages(data)
63 }
64 RenderIndexPage(allRepoData)
65+ RenderAssets()
66 }
67
68 func Init() {
69@@ -72,6 +79,7 @@ func CloneAndGetData(repo Repo, r *git.Repository) RepoData {
70 checkErr(err)
71 err = os.MkdirAll(path.Join(args.OutputDir, repo.Name), 0755)
72 checkErr(err)
73+ debug("cloning '%v'", repo.Name)
74 repoRef, err := git.PlainClone(path.Join(args.CloneDir, repo.Name), false, &git.CloneOptions{
75 URL: repo.URL,
76 })
77@@ -88,6 +96,13 @@ func CloneAndGetData(repo Repo, r *git.Repository) RepoData {
78 return data
79 }
80
81+func RenderAssets() {
82+ debug("rendering gshr.css")
83+ debug("rendering favicon.ico")
84+ checkErr(os.WriteFile(path.Join(args.OutputDir, "gshr.css"), css, 0666))
85+ checkErr(os.WriteFile(path.Join(args.OutputDir, "favicon.ico"), favicon, 0666))
86+}
87+
88 type LogWriter struct{}
89
90 func (writer LogWriter) Write(bytes []byte) (int, error) {