go.mod | 2 +-
hr-pkg.tmpl | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
hr-root.tmpl | 12 ++++++++++++
hr.go | 97 ++++-------------------------------------------------
list.go | 36 +++++++++---------------------------
list.tmpl | 13 +++++++++++++
root.tmpl | 11 +++++++++++
diff --git a/go.mod b/go.mod
index 25b82b1b6cd2cb3cfab2fe9914befa1e5db03b2cc2018cbe64e6537bad9a60fb..356ebdbe687d0021ab1ab96ff203b5182a3c78467e22e471ad44ec899453531f 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module go.cypherpunks.ru/gocheese/v3
-go 1.12
+go 1.16
require (
go.cypherpunks.ru/recfile v0.4.3
diff --git a/hr-pkg.tmpl b/hr-pkg.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..8496338403478b413af9fb83e65971ed4b3b75deefc086088794eacc4ee2b8f1
--- /dev/null
+++ b/hr-pkg.tmpl
@@ -0,0 +1,77 @@
+`
+
+
+ {{.Version}}: package {{.PkgName}}
+
+
+
+ {{with .Info.Name}}- Name
- {{.}}
{{end}}
+ {{with .Info.Version}}- Version
- {{.}}
{{end}}
+
+ {{with .Info.Platform}}- Platform
+ {{range .}}- {{.}}
+ {{end}}
{{end}}
+
+ {{with .Info.SupportedPlatform}}- SupportedPlatform
+ {{range .}}- {{.}}
+ {{end}}
{{end}}
+
+ - Summary
- {{.Info.Summary}}
+ - Description
+{{.Info.Description}}
+
+
+ {{with .Info.DescriptionContentType}}- DescriptionContentType
- {{.}}
{{end}}
+ {{with .Info.Keywords}}- Keywords
- {{.}}
{{end}}
+ {{with .Info.HomePage}}- HomePage
- {{.}}
{{end}}
+ {{with .Info.Author}}- Author
- {{.}}
{{end}}
+ {{with .Info.AuthorEmail}}- AuthorEmail
- {{.}}
{{end}}
+ {{with .Info.Maintainer}}- Maintainer
- {{.}}
{{end}}
+ {{with .Info.MaintainerEmail}}- MaintainerEmail
- {{.}}
{{end}}
+ {{with .Info.License}}- License
- {{.}}
{{end}}
+
+ {{with .Info.Classifier}}- Classifier
+ {{range .}}- {{.}}
+ {{end}}
{{end}}
+
+ {{with .Info.RequiresDist}}- RequiresDist
+ {{range .}}- {{.}}
+ {{end}}
{{end}}
+
+ {{with .Info.RequiresPython}}- RequiresPython
- {{.}}
{{end}}
+
+ {{with .Info.RequiresExternal}}- RequiresExternal
+ {{range .}}- {{.}}
+ {{end}}
{{end}}
+
+ {{with .Info.ProjectURL}}- ProjectURL
+ {{range .}}- {{.}}
+ {{end}}
{{end}}
+
+ {{with .Info.ProvidesExtra}}- ProvidesExtra
+ {{range .}}- {{.}}
+ {{end}}
{{end}}
+
+
+ Releases
+
+
+ | Filename |
+ Version |
+ Uploaded |
+ Size |
+ Digests |
+
+ {{range .Releases}}{{if .Size}}
+
+ | {{.Filename}}
+ | {{.Version}}
+ | {{.UploadTimeISO8601}}
+ | {{.Size}}
+ | {{range $a, $d := .Digests}}
+ - {{$a}}: {{$d}}
+ {{end}} |
+
{{end}}{{end}}
+
+
+
diff --git a/hr-root.tmpl b/hr-root.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..bea8032611c6a7987a03aadf5c72a3d23fb45f5e7f2c4bdd55900347645686ae
--- /dev/null
+++ b/hr-root.tmpl
@@ -0,0 +1,12 @@
+
+
+
+ {{.Version}}: packages
+
+
+ {{range .Packages}}
+ - {{.}}
+{{- end}}
+
+
+
diff --git a/hr.go b/hr.go
index 8fd7eaf5e64c0b5ad31744467f5386b2196f176a105a017b37d84f49dbe09b11..00434738b4ea2a7ba4013e02fb8b753e60952e3438a5c3d04faf2fff3f2e2199 100644
--- a/hr.go
+++ b/hr.go
@@ -19,6 +19,7 @@ package main
import (
"bytes"
+ _ "embed"
"html/template"
"io/ioutil"
"log"
@@ -29,97 +30,13 @@ "strings"
)
var (
- HRRootTmpl = template.Must(template.New("hr-root").Parse(`
-
-
- {{.Version}}: packages
-
-
- {{range .Packages}}
- - {{.}}
-{{- end}}
-
-
-
-`))
- HRPkgTmpl = template.Must(template.New("hr-pkg").Parse(`
-
-
- {{.Version}}: package {{.PkgName}}
-
-
-
- {{with .Info.Name}}- Name
- {{.}}
{{end}}
- {{with .Info.Version}}- Version
- {{.}}
{{end}}
+ //go:embed hr-root.tmpl
+ HRRootTmplRaw string
+ HRRootTmpl = template.Must(template.New("hr-root").Parse(HRRootTmplRaw))
- {{with .Info.Platform}}- Platform
- {{range .}}- {{.}}
- {{end}}
{{end}}
-
- {{with .Info.SupportedPlatform}}- SupportedPlatform
- {{range .}}- {{.}}
- {{end}}
{{end}}
-
- - Summary
- {{.Info.Summary}}
- - Description
-{{.Info.Description}}
-
-
- {{with .Info.DescriptionContentType}}- DescriptionContentType
- {{.}}
{{end}}
- {{with .Info.Keywords}}- Keywords
- {{.}}
{{end}}
- {{with .Info.HomePage}}- HomePage
- {{.}}
{{end}}
- {{with .Info.Author}}- Author
- {{.}}
{{end}}
- {{with .Info.AuthorEmail}}- AuthorEmail
- {{.}}
{{end}}
- {{with .Info.Maintainer}}- Maintainer
- {{.}}
{{end}}
- {{with .Info.MaintainerEmail}}- MaintainerEmail
- {{.}}
{{end}}
- {{with .Info.License}}- License
- {{.}}
{{end}}
-
- {{with .Info.Classifier}}- Classifier
- {{range .}}- {{.}}
- {{end}}
{{end}}
-
- {{with .Info.RequiresDist}}- RequiresDist
- {{range .}}- {{.}}
- {{end}}
{{end}}
-
- {{with .Info.RequiresPython}}- RequiresPython
- {{.}}
{{end}}
-
- {{with .Info.RequiresExternal}}- RequiresExternal
- {{range .}}- {{.}}
- {{end}}
{{end}}
-
- {{with .Info.ProjectURL}}- ProjectURL
- {{range .}}- {{.}}
- {{end}}
{{end}}
-
- {{with .Info.ProvidesExtra}}- ProvidesExtra
- {{range .}}- {{.}}
- {{end}}
{{end}}
-
-
- Releases
-
-
- | Filename |
- Version |
- Uploaded |
- Size |
- Digests |
-
- {{range .Releases}}{{if .Size}}
-
- | {{.Filename}}
- | {{.Version}}
- | {{.UploadTimeISO8601}}
- | {{.Size}}
- | {{range $a, $d := .Digests}}
- - {{$a}}: {{$d}}
- {{end}} |
-
{{end}}{{end}}
-
-
-
-`))
+ //go:embed hr-pkg.tmpl
+ HRPkgTmplRaw string
+ HRPkgTmpl = template.Must(template.New("hr-pkg").Parse(HRPkgTmplRaw))
)
func serveHRRoot(w http.ResponseWriter, r *http.Request) {
diff --git a/list.go b/list.go
index 9054d1538811a0697f4ad6bc7628ee26c349de05b2293097bb45180c8a0fcc52..aef9de1fa6d625a3c69bb5b54c88417ccdec0918d8f1ee101dff8a23ed12b584 100644
--- a/list.go
+++ b/list.go
@@ -19,6 +19,7 @@ package main
import (
"bytes"
+ _ "embed"
"encoding/hex"
"errors"
"fmt"
@@ -37,33 +38,14 @@ )
// https://warehouse.pypa.io/api-reference/legacy.html
var (
- HTMLRootTmpl = template.Must(template.New("root").Parse(`
-
-
-
- Simple index
-
- {{$Refresh := .RefreshURLPath}}{{range .Packages}}
- {{.}}
-{{- end}}
-
-
-`))
- HTMLReleasesTmpl = template.Must(template.New("list").Parse(`
-
-
-
- Links for {{.PkgName}}
-
- {{$Refresh := .RefreshURLPath}}{{$PkgName := .PkgName}}{{range .Releases}}
- {{.Filename}}
-{{- end}}
-
-
-`))
- KnownExts = []string{".tar.bz2", ".tar.gz", ".whl", ".zip", ".egg",
+ //go:embed root.tmpl
+ HTMLRootTmplRaw string
+ HTMLRootTmpl = template.Must(template.New("root").Parse(HTMLRootTmplRaw))
+
+ //go:embed list.tmpl
+ HTMLReleasesTmplRaw string
+ HTMLReleasesTmpl = template.Must(template.New("list").Parse(HTMLReleasesTmplRaw))
+ KnownExts = []string{".tar.bz2", ".tar.gz", ".whl", ".zip", ".egg",
".exe", ".dmg", ".msi", ".rpm", ".deb", ".tgz"}
)
diff --git a/list.tmpl b/list.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..82a7ea6ac865a459e1d7362adf0eda2da7032ac3c0ed37b405e51fd4131dcff1
--- /dev/null
+++ b/list.tmpl
@@ -0,0 +1,13 @@
+
+
+
+
+ Links for {{.PkgName}}
+
+ {{$Refresh := .RefreshURLPath}}{{$PkgName := .PkgName}}{{range .Releases}}
+ {{.Filename}}
+{{- end}}
+
+
diff --git a/root.tmpl b/root.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..374ae9b2f22648bde91beb4b96ba185769ac759bedf45dfab0ba36ce22142bbd
--- /dev/null
+++ b/root.tmpl
@@ -0,0 +1,11 @@
+
+
+
+
+ Simple index
+
+ {{$Refresh := .RefreshURLPath}}{{range .Packages}}
+ {{.}}
+{{- end}}
+
+