It's really difficult to use /cgi-bin/koha/tools/upload.pl to upload arbitrary files. If we had a "Copy link" button, it would make it easier to upload files and then use them in content/news sections.
Created attachment 104858 [details] [review] Bug 25475: add "Copy link" button to upload.pl This patch adds a "Copy link" button to /cgi-bin/koha/tools/upload.pl. It will create a modal that displays a URL like the following: http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl? id=beb928969032f980056ea8269bc816fe Users can then copy the URL from that modal. If the browser supports the Clipboard API, the URL is also written to the browser's clipboard, making manually copying from the modal redundant. Test plan: 0) Apply patch 1) Go to http://localhost:8081/cgi-bin/koha/tools/upload.pl 2) Upload a file with the "Allow public downloads" box checked 3) Note the "Copy link" button in the "Actions" column 4) Click "Copy link" 5) Note that a modal is created with contents like the following: http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl? id=beb928969032f980056ea8269bc816fe 5b) If you're using a modern browser, try Ctrl+V somewhere and note that the URL has already been copied to your clipboard 6) Manually highlight the text in the modal and Ctrl+C 7) Click outside the modal 8) Paste the URL somewhere useful like a system preference or News item 9) Profit
Created attachment 111296 [details] [review] Bug 25475: add "Copy link" button to upload.pl This patch adds a "Copy link" button to /cgi-bin/koha/tools/upload.pl. It will create a modal that displays a URL like the following: http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl? id=beb928969032f980056ea8269bc816fe Users can then copy the URL from that modal. If the browser supports the Clipboard API, the URL is also written to the browser's clipboard, making manually copying from the modal redundant. Test plan: 0) Apply patch 1) Go to http://localhost:8081/cgi-bin/koha/tools/upload.pl 2) Upload a file with the "Allow public downloads" box checked 3) Note the "Copy link" button in the "Actions" column 4) Click "Copy link" 5) Note that a modal is created with contents like the following: http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl? id=beb928969032f980056ea8269bc816fe 5b) If you're using a modern browser, try Ctrl+V somewhere and note that the URL has already been copied to your clipboard 6) Manually highlight the text in the modal and Ctrl+C 7) Click outside the modal 8) Paste the URL somewhere useful like a system preference or News item 9) Profit Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
This works but perhaps someone else wants to test the automatic link copying using a HTTPS site? The sandbox I was using doesn't have an SSL certificate, so the link wasn't automatically copied to the clipboard, because Clipboard API isn't supported on HTTP.
Comment on attachment 111296 [details] [review] Bug 25475: add "Copy link" button to upload.pl Review of attachment 111296 [details] [review]: ----------------------------------------------------------------- ::: koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt @@ +431,5 @@ > + var popup = '<div class="modal fade"><div class="modal-dialog"><div class="modal-content"><div class="modal-body">'+res+'</div></div></div></div>' > + $(popup).modal(); > + } > + > + console.log(res); Oops. That's a bit of debugging code that shouldn't be there.
(In reply to Sally from comment #3) > This works but perhaps someone else wants to test the automatic link copying > using a HTTPS site? > > The sandbox I was using doesn't have an SSL certificate, so the link wasn't > automatically copied to the clipboard, because Clipboard API isn't supported > on HTTP. As far as I know, that shouldn't be an issue. I tested this using a HTTP site. What browser did you use and what exact issue did you have?
(In reply to David Cook from comment #5) > > As far as I know, that shouldn't be an issue. I tested this using a HTTP > site. > > What browser did you use and what exact issue did you have? The problem is this: 5b) If you're using a modern browser, try Ctrl+V somewhere and note that the URL has already been copied to your clipboard (If the browser supports the Clipboard API, the URL is also written to the browser's clipboard, making manually copying from the modal redundant.) This doesn't happen for me on the sandbox - I had to manually copy the link from the modal, because Ctrl+V still retains my previous clipboard contents. The web browser is Chrome 86.
(In reply to Sally from comment #6) > (In reply to David Cook from comment #5) > > > > As far as I know, that shouldn't be an issue. I tested this using a HTTP > > site. > > > > What browser did you use and what exact issue did you have? > > The problem is this: > > 5b) If you're using a modern browser, try Ctrl+V somewhere and note > that the URL has already been copied to your clipboard > > (If the browser supports the Clipboard API, the URL is also written to the > browser's clipboard, making manually copying from the modal redundant.) > > This doesn't happen for me on the sandbox - I had to manually copy the link > from the modal, because Ctrl+V still retains my previous clipboard contents. > > The web browser is Chrome 86. Hmm that's interesting. It should've worked for you. Maybe I'll have to test this one again...
FAIL koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt OK filters FAIL forbidden patterns forbidden pattern: console.log (line 435) I believe the line can just be removed?
Please also see comment #7 :)
(In reply to Katrin Fischer from comment #8) > FAIL koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt > OK filters > FAIL forbidden patterns > forbidden pattern: console.log (line 435) > > I believe the line can just be removed? Yep. Just haven't gotten around to it yet heh.
I don't think we should add workarounds for old browsers. I'd just keep the feature for supported browsers.
(In reply to Tomás Cohen Arazi from comment #11) > I don't think we should add workarounds for old browsers. > I'd just keep the feature for supported browsers. Hmm, I suppose that would be all right.
*** This bug has been marked as a duplicate of bug 27594 ***