Fix JS and JS-based image upload

This commit is contained in:
Christoph Haas 2025-05-02 00:38:42 +02:00
parent 36984ff1d4
commit fa8a7fc77a
6 changed files with 95 additions and 51 deletions

View file

@ -1,5 +1,9 @@
/ Render this callout on top of the package's details page
/ if images have just been uploaded.
// Make variables accessible by the JS that handles uploads
#data-js-upload-form data-upload-url=upload_receive_json_path
- if (@valid_images and @valid_images.any?) or (@invalid_images and @invalid_images.any?)
.callout.warning

View file

@ -66,13 +66,8 @@
= render(partial: 'details_rightbox', locals: {pkg: @package})
javascript:
import {upload_paste_handler} from 'aplication';
// Handle Ctrl-V to paste an image directly
document.onpaste = upload_paste_handler;
// Where to send POST requests for uploads
var ajax_upload_url = '#{{upload_receive_json_path}}';
let ajax_upload_url = '#{{upload_receive_json_path}}';
// Where to go to after a successful image upload
var after_upload_url = '#{{package_path(@package)}}';
let after_upload_url = '#{{package_path(@package)}}';

View file

@ -64,18 +64,11 @@ h1 = "Upload screenshots for #{@package.name}"
' from a shell using after setting "export LANG=C".
li can be pasted here from your clipboard (Ctrl-V)
/ javascript:
/ // Hide the submit button unless images are selected for upload
/ // $(document).ready(upload_form_init);
/ import upload_form_init from '../../assets/javascripts/upload.js';
/ document.addEventListener('DOMContentLoaded', upload_form_init);
javascript:
// todo: use data attributes to pass this information to javascript
// https://chat.deepseek.com/a/chat/s/41a4350b-7799-42bf-aec9-3c205b22ab24
// Where to send POST requests for uploads
let ajax_upload_url = '#{{upload_receive_json_path}}';
/ // import upload_paste_handler from '../../assets/javascripts/debshots.js';
/ // Handle Ctrl-V to paste an image directly
/ document.onpaste = upload_paste_handler;
/ // Where to send POST requests for uploads
/ var ajax_upload_url = '#{{upload_receive_json_path}}';
/ // Where to go to after a successful image upload
/ var after_upload_url = '#{{package_path(@package)}}';
// Where to go to after a successful image upload
let after_upload_url = '#{{package_path(@package)}}';