diff --git a/cmd/cli/commands/link/link.go b/cmd/cli/commands/link/link.go index 3afacce..d4e4c0a 100644 --- a/cmd/cli/commands/link/link.go +++ b/cmd/cli/commands/link/link.go @@ -15,6 +15,7 @@ type ( LinkCmd struct { os string arch string + name string out string } ) @@ -33,6 +34,7 @@ Options: func (p *LinkCmd) SetFlags(f *flag.FlagSet) { f.StringVar(&p.os, "os", "", "set the operating system") f.StringVar(&p.arch, "architecture", "", "set the instruction set") + f.StringVar(&p.name, "name", "", "set the name or label of the link") f.StringVar(&p.out, "out", "./config.json", "path to the configuration file") } @@ -74,6 +76,7 @@ func (p *LinkCmd) add(link, slug string) subcommands.ExitStatus { soft.DownloadLinks = append(soft.DownloadLinks, data.DownloadLink{ OS: p.os, Arch: p.arch, + Name: p.name, URL: link, }) d.Softwares[i] = soft @@ -114,6 +117,10 @@ func (p *LinkCmd) edit(link, slug string) subcommands.ExitStatus { l.Arch = p.arch } + if len(p.name) > 0 { + l.Name = p.name + } + soft.DownloadLinks[y] = l foundLink = true break diff --git a/cmd/server/api/api.go b/cmd/server/api/api.go index 040ef6f..162b63d 100644 --- a/cmd/server/api/api.go +++ b/cmd/server/api/api.go @@ -15,7 +15,7 @@ import ( type ( Server struct { r chi.Router - d data.Service + d data.Data port uint16 } ) @@ -26,7 +26,7 @@ var index string //go:embed templates/description.html var description string -func New(port uint16, d data.Service) *Server { +func New(port uint16, d data.Data) *Server { indexTemplate := template.New("index") indexTemplate.Parse(index) @@ -46,7 +46,7 @@ func New(port uint16, d data.Service) *Server { var soft data.Software var found bool for _, s := range d.Softwares { - if s.UUID == softID { + if s.Slug == softID { soft = s found = true } diff --git a/cmd/server/api/templates/description.html b/cmd/server/api/templates/description.html index 82549ed..6e7b054 100644 --- a/cmd/server/api/templates/description.html +++ b/cmd/server/api/templates/description.html @@ -13,19 +13,46 @@ DownloadHub
-

{{.Name}} ({{.Version}})

- +

{{.Name}} v{{.Version}}

+
+

{{.Description}}

+ {{ if .Description }}
+ {{ end }}
- Download + Assets