From 66dfbefa258b80626e2ffcde275247dc70dd9927 Mon Sep 17 00:00:00 2001 From: Ben Garrett Date: Fri, 2 Feb 2024 13:09:52 +1100 Subject: [PATCH] Get download placeholder. --- handler/app/web.go | 26 ++++++++++++++++++++++++++ view/app/files.tmpl | 1 + 2 files changed, 27 insertions(+) diff --git a/handler/app/web.go b/handler/app/web.go index 294d66c6..00506406 100644 --- a/handler/app/web.go +++ b/handler/app/web.go @@ -21,6 +21,31 @@ import ( "go.uber.org/zap" ) +func EditDownloadGET(filename, filesize, demozoo any) template.HTML { + // TODO confirm signin + switch val := filename.(type) { + case null.String: + if val.Valid && val.String != "" { + return "" + } + } + switch val := filesize.(type) { + case null.Int64: + if val.Valid && val.Int64 > 0 { + return "" + } + } + switch val := demozoo.(type) { + case null.Int64: + if !val.Valid || val.Int64 == 0 { + return "" + } + } + // zoo := demozoo.(null.Int64).Int64 + // fmt.Sprintf("%d", zoo) + return template.HTML(`GET a remote download`) +} + // Web is the configuration and status of the web app. // Rename to app or template? type Web struct { @@ -294,6 +319,7 @@ func (web Web) TemplateClosures() template.FuncMap { // TemplateFuncs are a collection of mapped functions that can be used in a template. func (web Web) TemplateFuncs() template.FuncMap { funcMap := template.FuncMap{ + "editDownloadGET": EditDownloadGET, "add": helper.Add1, "attribute": Attribute, "brief": Brief, diff --git a/view/app/files.tmpl b/view/app/files.tmpl index fd14be89..9834dace 100644 --- a/view/app/files.tmpl +++ b/view/app/files.tmpl @@ -56,6 +56,7 @@

{{$attr}}

{{- end}} {{- linkPage .ID}} + {{- editDownloadGET .Filename .Filesize .WebIDDemozoo }} {{- linkDownload .ID .FileSecurityAlertURL.String }}{{ downloadB .Filesize}} {{- linkPreview .ID .Filename.String .Platform.String}}