Skip to content

Commit

Permalink
fix replacement image_ *ALWAYS* prompts for a confirmation.
Browse files Browse the repository at this point in the history
Drop ImageMagick v6 convert command.
  • Loading branch information
bengarrett committed Sep 9, 2024
1 parent 68cb651 commit 78d7d42
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
### Stuff to do

* Repack zips that contain programs with bad filenames, for example: http://localhost:1323/f/ab252e4
* _Replacement image_ *ALWAYS* prompts for a confirmation. This should only occur if there is an existing image.
* _Thumbnail assets_ links need better separation.
* `<div class="modal-body"><picture><source srcset="/public/image/original/0191c3fc-a387-7715-ab41-441ea337f316.webp" type="image/webp" /></picture></div>`
* * Does not work, need to use `img` tag.
Expand Down
3 changes: 0 additions & 3 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const (
Arc = "arc" // Arc is the arc decompression command.
Arj = "arj" // Arj is the arj decompression command.
Ansilove = "ansilove" // Ansilove is the ansilove text to image command.
Convert = "convert" // Convert is the ImageMagick legacy convert command.
Cwebp = "cwebp" // Cwebp is the Google create webp command.
Gwebp = "gif2webp" // Gwebp is the Google gif to webp command.
HWZip = "hwzip" // Hwzip the zip decompression command for files using obsolete methods.
Expand All @@ -79,7 +78,6 @@ func Lookups() []string {
Arc,
Arj,
Ansilove,
Convert,
Cwebp,
Gwebp,
HWZip,
Expand All @@ -100,7 +98,6 @@ func Infos() []string {
"archive utility ver 5+",
"arj32 ver 3+",
"ansilove/c ver 4+",
"ImageMagick ver 6+",
"Google WebP ver 1+",
"Google GIF to WebP ver 1+",
"HWZip ver 2+",
Expand Down
10 changes: 5 additions & 5 deletions internal/command/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (dir Dirs) textImagers(debug *zap.SugaredLogger, unid, tmp string) error {
return errs
}

// PreviewPixels converts the src image to a PNG and webp images in the screenshot directory.
// PreviewPixels converts the src image to a PNG and webp images in the screenshot directory.
// A webp thumbnail image is also created and copied to the thumbnail directory.
// The conversion is useful for screenshots of text, terminals interfaces and pixel art.
//
Expand All @@ -393,7 +393,7 @@ func (dir Dirs) PreviewPixels(debug *zap.SugaredLogger, src, unid string) error
defer os.RemoveAll(tmpDir) // remove temp dir
tmp := filepath.Join(tmpDir, name) // temp output file target
arg = append(arg, tmp)
if err := RunQuiet(Convert, arg...); err != nil {
if err := RunQuiet(Magick, arg...); err != nil {
return fmt.Errorf("preview pixel run convert %w", err)
}
dst := filepath.Join(dir.Preview, unid+png)
Expand Down Expand Up @@ -424,7 +424,7 @@ func (dir Dirs) PreviewPhoto(debug *zap.SugaredLogger, src, unid string) error {

jtmp := filepath.Join(tmpDir, name) // temp output file target
arg = append(arg, jtmp) // destination
if err := RunQuiet(Convert, arg...); err != nil {
if err := RunQuiet(Magick, arg...); err != nil {
return fmt.Errorf("preview photo convert %w", err)
}
wtmp := filepath.Join(tmpDir, unid+webp)
Expand Down Expand Up @@ -797,7 +797,7 @@ func (dir Dirs) ThumbPixels(src, unid string) error {
arg := []string{src} // source file
arg = append(arg, args...) // command line arguments
arg = append(arg, tmp) // destination
if err := RunQuiet(Convert, arg...); err != nil {
if err := RunQuiet(Magick, arg...); err != nil {
return fmt.Errorf("run ansi convert %w", err)
}

Expand All @@ -824,7 +824,7 @@ func (dir Dirs) ThumbPhoto(src, unid string) error {
arg := []string{src} // source file
arg = append(arg, args...) // command line arguments
arg = append(arg, tmp) // destination
if err := RunQuiet(Convert, arg...); err != nil {
if err := RunQuiet(Magick, arg...); err != nil {
return fmt.Errorf("run webp convert %w", err)
}

Expand Down
2 changes: 1 addition & 1 deletion view/app/artifactfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
hx-encoding="multipart/form-data"
hx-post="/editor/upload/preview"
hx-target="#artifact-editor-preview-feedback"
{{- if ne $notFound $statSizeB}}hx-confirm="OK, to replace the existing preview image on the server?"{{end}}
{{- if eq $previewImgStat true}}hx-confirm="OK, to replace the existing preview image on the server?"{{end}}
hx-validate="true">
<input type="hidden" name="artifact-editor-record-key" value="{{$key}}">
<input type="hidden" name="artifact-editor-unid" value="{{$unid}}">
Expand Down

0 comments on commit 78d7d42

Please sign in to comment.