X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=hr.go;h=64c83355f98676e561b8c6b10d94f5641d31dd3a;hb=095355edeb841fd490353e4b22f9ea3909344260;hp=845a13e5fb98d043a924c13d1657519673212e9c;hpb=60834a0713d5dcc6a9911511cb8618ce7358c824;p=gocheese.git
diff --git a/hr.go b/hr.go
index 845a13e..64c8335 100644
--- a/hr.go
+++ b/hr.go
@@ -19,6 +19,7 @@ package main
import (
"bytes"
+ _ "embed"
"html/template"
"io/ioutil"
"log"
@@ -29,101 +30,17 @@ import (
)
var (
- HRRootTmpl = template.Must(template.New("hr-root").Parse(`
-
-
- {{.Version}}: human readable listing
-
-
- {{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) {
- files, err := ioutil.ReadDir(*Root)
+ files, err := ioutil.ReadDir(Root)
if err != nil {
log.Println("error", r.RemoteAddr, "hr-root", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -153,7 +70,7 @@ func serveHRRoot(w http.ResponseWriter, r *http.Request) {
func serveHRPkg(w http.ResponseWriter, r *http.Request) {
cols := strings.Split(strings.TrimRight(r.URL.Path, "/"), "/")
pkgName := cols[len(cols)-1]
- meta, releases, err := getMetadata(pkgName, "")
+ meta, releases, err := getMD(pkgName, "")
if err != nil {
if os.IsNotExist(err) {
http.NotFound(w, r)