From 62daa10c6ff5759dc98c98905277227f91612148 Mon Sep 17 00:00:00 2001 From: Code by Ben Date: Thu, 1 Aug 2024 16:16:11 +1000 Subject: [PATCH] download content work in progress --- assets/js/artifact-editor.js | 26 +++++++++++- docs/todo.md | 1 + handler/app/internal/mf/mf.go | 15 +++++-- handler/app/internal/str/str.go | 16 +++----- handler/htmx/artifact.go | 69 ++++++++++++++++++++++++++++++++ handler/routerlock.go | 17 ++++++++ internal/command/command.go | 20 ++++----- public/js/artifact-editor.min.js | 2 +- view/app/artifacteditjsdos.tmpl | 2 +- view/app/artifactfile.tmpl | 25 +++++++++--- view/app/artifacts.tmpl | 2 +- view/app/artifactsedit.tmpl | 23 +++++++---- 12 files changed, 173 insertions(+), 45 deletions(-) diff --git a/assets/js/artifact-editor.js b/assets/js/artifact-editor.js index 873e74a7..58b6db8b 100644 --- a/assets/js/artifact-editor.js +++ b/assets/js/artifact-editor.js @@ -48,16 +48,38 @@ import { clipValue, getElmById } from "./helper.mjs"; const copyUUIDVal = getElmById(`artifact-editor-unique-id-value`); if (copyUUIDVal === null) { - throw new Error("The key value is missing."); + throw new Error("The unique id value is missing."); } const copyUUIDBtn = getElmById(`artifact-editor-unique-id-label`); if (copyUUIDBtn === null) { - throw new Error("The key label is missing."); + throw new Error("The unique id label is missing."); } copyUUIDBtn.addEventListener(`click`, () => clipValue(`artifact-editor-unique-id-value`) ); + const copyLocation = getElmById(`artifact-editor-location-value`); + if (copyLocation === null) { + throw new Error("The location value is missing."); + } + const copyLocationBtn = getElmById(`artifact-editor-location-label`); + if (copyLocationBtn === null) { + throw new Error("The location label is missing."); + } + copyLocationBtn.addEventListener(`click`, () => + clipValue(`artifact-editor-location-value`) + ); + + const copyTempLocation = getElmById(`artifact-editor-templocation`); + if (copyTempLocation !== null) { + const copyTempLocationBtn = getElmById( + `artifact-editor-templocation-label` + ); + copyTempLocationBtn.addEventListener(`click`, () => + clipValue(`artifact-editor-templocation`) + ); + } + const osLabel = document.getElementById("artifact-editor-os-label"); if (osLabel === null) { throw new Error("The operating system label is missing."); diff --git a/docs/todo.md b/docs/todo.md index a096b89a..53bffd4b 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -16,6 +16,7 @@ - [ ] Handle magazines title on artifact page, http://localhost:1323/f/a55ed, this is hard to read, "Issue 4\nThe Pirate Syndicate +\nThe Pirate World" - [ ] If artifact is a text file displayed in readme, then delete image preview, these are often super long, large and not needed. - [ ] If a #hash is appended to a /f/ URL while signed out, then return a 404 or a redirect to the sign in page. Post signing should return to the #hash URL? +- [ ] Delete all previews that are unused, such as textfiles that are displayed as a readme. - [ ] - http://www.platohistory.org/ - [ ] - https://portcommodore.com/dokuwiki/doku.php?id=larry:comp:bbs:about_cbbs diff --git a/handler/app/internal/mf/mf.go b/handler/app/internal/mf/mf.go index bc1c3c90..a7d5d584 100644 --- a/handler/app/internal/mf/mf.go +++ b/handler/app/internal/mf/mf.go @@ -277,17 +277,24 @@ func isText(sign magicnumber.Signature) bool { } func entryHTML(images, programs, texts bool, rel, sign, size, unid string, bytes int64) string { + name := url.QueryEscape(rel) htm := fmt.Sprintf(`
%s
`, rel, rel) - if images || texts { - htm += `
` + if images { + htm += `
` + + fmt.Sprintf(``, unid, name) + + `
` + } else if texts { + htm += `
` + + fmt.Sprintf(``, unid, name) + + `
` } else { htm += `
` } switch { case texts: - name := url.QueryEscape(rel) htm += `
` + fmt.Sprintf(``, unid, name) + `
+ {{- end}} - {{/* Switch to assets and reset buttons */}} {{- template "artifactfooter" . }} diff --git a/view/app/artifactfile.tmpl b/view/app/artifactfile.tmpl index bd533d3c..c9b9e009 100644 --- a/view/app/artifactfile.tmpl +++ b/view/app/artifactfile.tmpl @@ -76,8 +76,10 @@
Artifact for download
- - + +
{{- /* End of the iteration of the records */}} diff --git a/view/app/artifactsedit.tmpl b/view/app/artifactsedit.tmpl index fc971718..f5c046d4 100644 --- a/view/app/artifactsedit.tmpl +++ b/view/app/artifactsedit.tmpl @@ -1,11 +1,20 @@ {{- /* artifactsedit.tmpl */}} {{- define "artifactsedit" }} {{- $zooID := .WebIDDemozoo.Int64 }} -{{- if gt $zooID 0}} - {{- /* Demozoo production ID */}} -

- Lookup Demozoo, production #{{ .WebIDDemozoo.Int64 }} -

- {{- demozooGetLink .Filename .Filesize .WebIDDemozoo .UUID }} -{{- end}} +{{- $editorLink := "link-primary link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover"}} +{{- $syncLink := demozooGetLink .Filename .Filesize .WebIDDemozoo .UUID}} + {{- end}} \ No newline at end of file