diff --git a/assets/js/editor-assets.js b/assets/js/editor-assets.js index 6de407c3..f7a45262 100644 --- a/assets/js/editor-assets.js +++ b/assets/js/editor-assets.js @@ -71,6 +71,7 @@ import { progress } from "./uploader.mjs"; default: // note, the #runapp hash is used by js-dos } + // New file download form event listener. document.body.addEventListener("htmx:afterRequest", function (event) { afterFormRequest( @@ -110,11 +111,38 @@ import { progress } from "./uploader.mjs"; "artifact-editor-link-delete", "artifact-editor-link-feedback" ); + afterLinkRequest( + event, + "artifact-editor-comp-previewcopy", + "artifact-editor-comp-feedback" + ); + afterLinkRequest( + event, + "artifact-editor-comp-previewtext", + "artifact-editor-comp-feedback" + ); + afterLinkRequest( + event, + "artifact-editor-comp-textcopy", + "artifact-editor-comp-feedback" + ); }); - function afterDeleteRequest(event, inputId, feedbackId) { + /** + * After link request event listener. + * @param {Event} event - The htmx event. + * @param {string} inputId - The inputId is the id of the input element that triggered the request, + * or the name of the input element that triggered the request. + * @param {string} feedbackId - The feedback name. + * @returns {void} + **/ + function afterLinkRequest(event, inputId, feedbackId) { if (event.detail.elt === null) return; - if (event.detail.elt.id !== `${inputId}`) return; + if ( + event.detail.elt.id !== `${inputId}` && + event.detail.elt.name !== inputId + ) + return; const feedback = document.getElementById(feedbackId); if (feedback === null) { throw new Error( @@ -122,15 +150,10 @@ import { progress } from "./uploader.mjs"; ); } const errClass = "text-danger"; - const okClass = "text-success"; const xhr = event.detail.xhr; if (event.detail.successful) { - feedback.innerText = `The delete request was successful, about to refresh the page.`; + feedback.innerText = `${xhr.responseText}`; feedback.classList.remove(errClass); - feedback.classList.add(okClass); - setTimeout(() => { - location.reload(); - }, 500); return; } if (event.detail.failed && event.detail.xhr) { @@ -146,7 +169,7 @@ import { progress } from "./uploader.mjs"; " please try again or refresh the page."; } - function afterLinkRequest(event, inputId, feedbackId) { + function afterDeleteRequest(event, inputId, feedbackId) { if (event.detail.elt === null) return; if (event.detail.elt.id !== `${inputId}`) return; const feedback = document.getElementById(feedbackId); @@ -156,10 +179,15 @@ import { progress } from "./uploader.mjs"; ); } const errClass = "text-danger"; + const okClass = "text-success"; const xhr = event.detail.xhr; if (event.detail.successful) { - feedback.innerText = `${xhr.responseText}`; + feedback.innerText = `The delete request was successful, about to refresh the page.`; feedback.classList.remove(errClass); + feedback.classList.add(okClass); + setTimeout(() => { + location.reload(); + }, 500); return; } if (event.detail.failed && event.detail.xhr) { diff --git a/go.mod b/go.mod index bef7f5ac..61a61bce 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/Defacto2/server go 1.22.7 require ( - github.com/Defacto2/archive v1.0.1 + github.com/Defacto2/archive v1.0.2 github.com/Defacto2/helper v1.1.1 github.com/Defacto2/magicnumber v1.0.1 github.com/Defacto2/releaser v1.0.4 @@ -33,6 +33,11 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) +replace ( + github.com/Defacto2/archive => /home/ben/github/archive + github.com/Defacto2/helper => /home/ben/github/helper +) + require ( cloud.google.com/go/auth v0.9.4 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect diff --git a/go.sum b/go.sum index af490842..2cd94855 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/Defacto2/archive v1.0.1 h1:f6qli42DWJWwNLbcB6SS0MSmVmaUzCJGXzTRsk8PskE= -github.com/Defacto2/archive v1.0.1/go.mod h1:0/aa1BwDOBp4d87R/N33Lcr3+WzELv041wunK8R5A5c= github.com/Defacto2/helper v1.1.1 h1:wu8ynKF4ZXruTZNrDumzPVyXxFwhCvtWlsdimPNSXXc= github.com/Defacto2/helper v1.1.1/go.mod h1:vtHe6R1Pl3YsxsqXe/UZldvNx1n1Y6dM1JUL9Uczr6g= github.com/Defacto2/magicnumber v1.0.1 h1:UmiBUrYwTk3NPR1lGaaQ3Js+3YllBRf9XxSKInE3Da4= diff --git a/handler/app/internal/filerecord/filerecord.go b/handler/app/internal/filerecord/filerecord.go index 6389316a..74897f1d 100644 --- a/handler/app/internal/filerecord/filerecord.go +++ b/handler/app/internal/filerecord/filerecord.go @@ -58,65 +58,64 @@ type ListEntry struct { UniqueID string Executable magicnumber.Windows Images, Programs, Texts bool + name string + platform string + section string + bytes int64 } // HTML returns the HTML for an file item in the "Download content" section of the File editor. -func (m ListEntry) HTML(bytes int64, platform, section string) string { - name := url.QueryEscape(m.RelativeName) - titlename := m.RelativeName +func (m *ListEntry) HTML(bytes int64, platform, section string) string { + m.name = url.QueryEscape(m.RelativeName) + m.bytes = bytes + m.platform = platform + m.section = section displayname := m.RelativeName if strings.EqualFold(platform, tags.DOS.String()) { if msdos.Rename(displayname) != displayname { displayname = `` + displayname + `` } } - htm := fmt.Sprintf(`
README +
{{$modReadmeSuggest}}
{{$modReadmeSuggest}}
- Repacked ZIP - {{- if eq $notFound $statSizeB}}