commit
message
Adding examples, cleaning up, documenting.
author
Ben Vogt <[email protected]>
date
2023-04-05 16:24:41
stats
5 file(s) changed,
72 insertions(+),
12 deletions(-)
files
Makefile
README.md
examples/go-git.toml
examples/gshr-simple.toml
main.go
1diff --git a/Makefile b/Makefile
2index 3b0d0be..15a3e87 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -1,9 +1,6 @@
6 # Copyright 2023 Ben Vogt. All rights reserved.
7
8 PWD := $(shell pwd)
9-OS ?= darwin
10-ARCH ?= arm64
11-ENVIRONMENT ?= development
12
13 rfind=$(shell find $1 -type f -not -path "./target/*")
14
15@@ -19,14 +16,14 @@ target/cloning: target
16 clean:
17 rm -rf target/*
18
19-target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin: Makefile target $(wildcard *.go)
20- go build -o target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin $(wildcard *.go)
21+target/gshr.bin: Makefile target $(wildcard *.go)
22+ go build -o target/gshr.bin $(wildcard *.go)
23
24-build: Makefile target target/output target/cloning target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin
25+build: Makefile target target/output target/cloning target/gshr.bin
26 @# intentionally blank, proxy for prerequisite.
27
28-dev: Makefile target target/output target/cloning target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin
29- ./target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin \
30+dev: Makefile target target/output target/cloning target/gshr.bin
31+ ./target/gshr.bin \
32 --config=$(PWD)/gshr.toml \
33 --output=$(PWD)/target/output \
34 --clone=$(PWD)/target/cloning \
35@@ -36,5 +33,27 @@ dev: Makefile target target/output target/cloning target/gshr-${OS}-${ARCH}-${EN
36 cd $(PWD)/target/output && \
37 python3 -m http.server 8000
38
39+dev-example-go-git: Makefile target target/output target/cloning target/gshr.bin
40+ ./target/gshr.bin \
41+ --config=$(PWD)/example/go-git.toml \
42+ --output=$(PWD)/target/output \
43+ --clone=$(PWD)/target/cloning \
44+ && \
45+ cp gshr.css $(PWD)/target/output/ && \
46+ cp favicon.ico $(PWD)/target/output/ && \
47+ cd $(PWD)/target/output && \
48+ python3 -m http.server 8000
49+
50+dev-example-gshr: Makefile target target/output target/cloning target/gshr.bin
51+ ./target/gshr.bin \
52+ --config=$(PWD)/example/gshr-simple.toml \
53+ --output=$(PWD)/target/output \
54+ --clone=$(PWD)/target/cloning \
55+ && \
56+ cp gshr.css $(PWD)/target/output/ && \
57+ cp favicon.ico $(PWD)/target/output/ && \
58+ cd $(PWD)/target/output && \
59+ python3 -m http.server 8000
60+
61 fmt:
62 go fmt
63\ No newline at end of file
64diff --git a/README.md b/README.md
65index f0a4bc0..4a737c8 100644
66--- a/README.md
67+++ b/README.md
68@@ -8,6 +8,26 @@ more.
69
70 ---
71
72+See for yourself:
73+
74+```
75+git clone https://github.com/vogtb/gshr
76+cd gshr
77+make dev-example-gshr
78+```
79+
80+Which basically runs
81+
82+```bash
83+gshr --config=${PWD}/example-configs/gshr-simple.toml --output=/tmp/gshr-output
84+cd /tmp/gshr-output
85+python3 -m http.server 8000
86+```
87+
88+See more examples in [tree/master/examples](tree/master/examples).
89+
90+---
91+
92 ## Usage
93
94 ```
95diff --git a/examples/go-git.toml b/examples/go-git.toml
96new file mode 100644
97index 0000000..6fda03f
98--- /dev/null
99+++ b/examples/go-git.toml
100@@ -0,0 +1,9 @@
101+base_url = "/"
102+site_name = "example of a couple go repos on github"
103+
104+[[repos]]
105+name = "go-git"
106+description = "A highly extensible Git implementation in pure Go."
107+url = "https://github.com/go-git/go-git"
108+published_git_url = "https://github.com/go-git/go-git"
109+
110diff --git a/examples/gshr-simple.toml b/examples/gshr-simple.toml
111new file mode 100644
112index 0000000..f307799
113--- /dev/null
114+++ b/examples/gshr-simple.toml
115@@ -0,0 +1,8 @@
116+base_url = "/"
117+site_name = "public, self hosted git repositories"
118+
119+[[repos]]
120+name = "gshr"
121+description = "git static host repo -- generates static html for repos"
122+url = "https://github.com/vogtb/gshr"
123+published_git_url = "https://github.com/vogtb/gshr"
124diff --git a/main.go b/main.go
125index d8808f1..33fddc3 100644
126--- a/main.go
127+++ b/main.go
128@@ -56,15 +56,15 @@ func Init() {
129 args.CloneDir = fmt.Sprintf("/tmp/gshr-temp-clone-%v", rand.Uint32())
130 }
131
132- debug("config %v", args.ConfigFile)
133- debug("output %v", args.OutputDir)
134- debug("clone %v", args.CloneDir)
135+ debug("config '%v'", args.ConfigFile)
136+ debug("output '%v'", args.OutputDir)
137+ debug("clone '%v'", args.CloneDir)
138 configFileBytes, err := os.ReadFile(args.ConfigFile)
139 configString := string(configFileBytes)
140 checkErr(err)
141 config = ParseConfiguration(configString)
142- debug("base_url %v", config.BaseURL)
143- debug("site_name %v", config.SiteName)
144+ debug("base_url '%v'", config.BaseURL)
145+ debug("site_name '%v'", config.SiteName)
146 }
147
148 func CloneAndGetData(repo Repo, r *git.Repository) RepoData {