X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=list.go;h=356cd6bf01874f5aaf687028d3dfd556dc56db76;hb=cde8c8c45d508bf29d24365298f3c40c1729514c;hp=7ca9b18f08e8bda641173b42d57c4dac3c97d988;hpb=ac2e1cc0a899d18a38cd47fc3e18d830f94c2422;p=gocheese.git diff --git a/list.go b/list.go index 7ca9b18..356cd6b 100644 --- a/list.go +++ b/list.go @@ -1,6 +1,6 @@ /* GoCheese -- Python private package repository and caching proxy -Copyright (C) 2019-2021 Sergey Matveev +Copyright (C) 2019-2022 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ package main import ( "bytes" + _ "embed" "encoding/hex" "errors" "fmt" @@ -37,33 +38,14 @@ import ( // 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"} ) @@ -213,7 +195,7 @@ func listDir(pkgName string, doSize bool) (int64, []*PkgReleaseInfo, error) { return 0, nil, err } serial := fi.ModTime().Unix() - if fi, err = os.Stat(filepath.Join(dirPath, MetadataFile)); err == nil { + if fi, err = os.Stat(filepath.Join(dirPath, MDFile)); err == nil { serial += fi.ModTime().Unix() } return serial, releases, nil