port from myago
This commit is contained in:
commit
96e7bdf5c9
11
internal/index.html.gotmpl
Normal file
11
internal/index.html.gotmpl
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Go Libraries</title>
|
||||
</head>
|
||||
<body>
|
||||
{{- range $generate := .Generates }}
|
||||
<div><a href="/{{ $generate.Path }}">{{ $generate.Package }}</a></div>
|
||||
{{- end }}
|
||||
</body>
|
||||
</html>
|
11
internal/lib.html.gotmpl
Normal file
11
internal/lib.html.gotmpl
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="{{ .Package }} {{ .VCS }} {{ .Repository }}">
|
||||
<meta http-equiv="refresh" content="0;URL='{{ .Repository }}'">
|
||||
<title>{{ .Package }}</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="{{ .Repository }}">project page</a>...
|
||||
</body>
|
||||
</html>
|
83
main.go
Normal file
83
main.go
Normal file
@ -0,0 +1,83 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
//go:embed internal/lib.html.gotmpl
|
||||
var libContentTemplate string
|
||||
|
||||
//go:embed internal/index.html.gotmpl
|
||||
var indexContentTemplate string
|
||||
|
||||
type Generate struct {
|
||||
Path string
|
||||
Package string
|
||||
Repository string
|
||||
VCS string
|
||||
}
|
||||
|
||||
func renderFile(filename string, template *template.Template, data any) error {
|
||||
dir := filepath.Dir(filename)
|
||||
_ = os.MkdirAll(dir, 0755)
|
||||
|
||||
file, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
return template.Execute(file, data)
|
||||
}
|
||||
|
||||
func must[T any](val T, err error) T {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func main() {
|
||||
libTemplate := must(template.New("lib").Parse(libContentTemplate))
|
||||
indexTemplate := must(template.New("index").Parse(indexContentTemplate))
|
||||
wd := must(os.Getwd())
|
||||
|
||||
cli := flag.NewFlagSet("go-repo", flag.ExitOnError)
|
||||
|
||||
baseDir := cli.String("base_dir", filepath.Join(wd, "site"), "configure the directory where this script outputs data")
|
||||
|
||||
// ignore due to ExitOnError
|
||||
_ = cli.Parse(os.Args[1:])
|
||||
|
||||
generates := []Generate{
|
||||
{"em", "go.pitz.tech/em", "https://github.com/mjpitz/em", "git"},
|
||||
{"lib", "go.pitz.tech/lib", "https://github.com/mjpitz/myago", "git"},
|
||||
{"okit", "go.pitz.tech/okit", "https://code.pitz.tech/mya/okit", "git"},
|
||||
{"units", "go.pitz.tech/units", "https://github.com/mjpitz/units", "git"},
|
||||
{filepath.Join("gorm", "encryption"), "go.pitz.tech/gorm/encryption", "https://github.com/mjpitz/gorm-encryption", "git"},
|
||||
{filepath.Join("gorm", "crud"), "go.pitz.tech/gorm/crud", "https://code.pitz.tech/mya/gorm-crud", "git"},
|
||||
{"spdx-fmt", "go.pitz.tech/spdx-fmt", "https://github.com/mjpitz/spdx-fmt", "git"},
|
||||
}
|
||||
|
||||
for _, generate := range generates {
|
||||
log.Println("rendering", generate.Path)
|
||||
|
||||
err := renderFile(filepath.Join(*baseDir, generate.Path, "index.html"), libTemplate, generate)
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("rendering", "index.html")
|
||||
err := renderFile(filepath.Join(*baseDir, "index.html"), indexTemplate, map[string]any{"Generates": generates})
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
}
|
11
site/em/index.html
Normal file
11
site/em/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="go.pitz.tech/em git https://github.com/mjpitz/em">
|
||||
<meta http-equiv="refresh" content="0;URL='https://github.com/mjpitz/em'">
|
||||
<title>go.pitz.tech/em</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="https://github.com/mjpitz/em">project page</a>...
|
||||
</body>
|
||||
</html>
|
11
site/gorm/crud/index.html
Normal file
11
site/gorm/crud/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="go.pitz.tech/gorm/crud git https://code.pitz.tech/mya/gorm-crud">
|
||||
<meta http-equiv="refresh" content="0;URL='https://code.pitz.tech/mya/gorm-crud'">
|
||||
<title>go.pitz.tech/gorm/crud</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="https://code.pitz.tech/mya/gorm-crud">project page</a>...
|
||||
</body>
|
||||
</html>
|
11
site/gorm/encryption/index.html
Normal file
11
site/gorm/encryption/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="go.pitz.tech/gorm/encryption git https://github.com/mjpitz/gorm-encryption">
|
||||
<meta http-equiv="refresh" content="0;URL='https://github.com/mjpitz/gorm-encryption'">
|
||||
<title>go.pitz.tech/gorm/encryption</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="https://github.com/mjpitz/gorm-encryption">project page</a>...
|
||||
</body>
|
||||
</html>
|
15
site/index.html
Normal file
15
site/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Go Libraries</title>
|
||||
</head>
|
||||
<body>
|
||||
<div><a href="/em">go.pitz.tech/em</a></div>
|
||||
<div><a href="/lib">go.pitz.tech/lib</a></div>
|
||||
<div><a href="/okit">go.pitz.tech/okit</a></div>
|
||||
<div><a href="/units">go.pitz.tech/units</a></div>
|
||||
<div><a href="/gorm/encryption">go.pitz.tech/gorm/encryption</a></div>
|
||||
<div><a href="/gorm/crud">go.pitz.tech/gorm/crud</a></div>
|
||||
<div><a href="/spdx-fmt">go.pitz.tech/spdx-fmt</a></div>
|
||||
</body>
|
||||
</html>
|
11
site/lib/index.html
Normal file
11
site/lib/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="go.pitz.tech/lib git https://github.com/mjpitz/myago">
|
||||
<meta http-equiv="refresh" content="0;URL='https://github.com/mjpitz/myago'">
|
||||
<title>go.pitz.tech/lib</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="https://github.com/mjpitz/myago">project page</a>...
|
||||
</body>
|
||||
</html>
|
11
site/okit/index.html
Normal file
11
site/okit/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="go.pitz.tech/okit git https://code.pitz.tech/mya/okit">
|
||||
<meta http-equiv="refresh" content="0;URL='https://code.pitz.tech/mya/okit'">
|
||||
<title>go.pitz.tech/okit</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="https://code.pitz.tech/mya/okit">project page</a>...
|
||||
</body>
|
||||
</html>
|
11
site/spdx-fmt/index.html
Normal file
11
site/spdx-fmt/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="go.pitz.tech/spdx-fmt git https://github.com/mjpitz/spdx-fmt">
|
||||
<meta http-equiv="refresh" content="0;URL='https://github.com/mjpitz/spdx-fmt'">
|
||||
<title>go.pitz.tech/spdx-fmt</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="https://github.com/mjpitz/spdx-fmt">project page</a>...
|
||||
</body>
|
||||
</html>
|
11
site/units/index.html
Normal file
11
site/units/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- autogenerated by main.go -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="go-import" content="go.pitz.tech/units git https://github.com/mjpitz/units">
|
||||
<meta http-equiv="refresh" content="0;URL='https://github.com/mjpitz/units'">
|
||||
<title>go.pitz.tech/units</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting you to the <a href="https://github.com/mjpitz/units">project page</a>...
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user