Bugzilla – Attachment 116218 Details for
Bug 27594
Add access to public download link for publicly-accessible uploads
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27594: Add access to public download link for publicly-accessible uploads
Bug-27594-Add-access-to-public-download-link-for-p.patch (text/plain), 4.82 KB, created by
Owen Leonard
on 2021-02-02 14:48:37 UTC
(
hide
)
Description:
Bug 27594: Add access to public download link for publicly-accessible uploads
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2021-02-02 14:48:37 UTC
Size:
4.82 KB
patch
obsolete
>From b74d9a542f1abe32b91e6151865fb57a7bfc5b6f Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 2 Feb 2021 14:10:49 +0000 >Subject: [PATCH] Bug 27594: Add access to public download link for > publicly-accessible uploads > >This patch adds a link to the display of publicly-accessible uploads so >that the user can copy the public link. This will hopefully lead to >easier use of sound file uploads in the Audio Alerts system. > >To test, apply the patch and go to Tools -> Upload. > >- If necessary, upload a file with the "Allow public downloads" > checkbox checked. >- Upon upload you should be shown the results of your upload in a table > with the file details. >- In the "Public" column you should see that "Yes" is a link. > - When you hover your mouse over the link you should see a tooltip, > "Copy link to this file." > - When you click the link the tooltip should say "Link copied to the > clipboard." > - Verify that the correct link has been copied. >- Test uploading a file which is not publicly-accessible. > - Confirm that the information in the "Public" column says "No" and is > not a link. > >Note: I believe the "wrong filter" warning from the QA is a false >positive because the variable in question should not be URI-encoded. >--- > .../intranet-tmpl/prog/en/modules/tools/upload.tt | 20 +++++++++++++++++++- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 15 ++++++++++++++- > 2 files changed, 33 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt >index 3ed10dcae3..c9e2821df5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt >@@ -170,7 +170,13 @@ > <td>[% record.hashvalue | html %]</td> > <td>[% record.uploadcategorycode | html %]</td> > [% IF !plugin %] >- <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td> >+ <td> >+ [% IF record.public %] >+ <a href="[% Koha.Preference('OPACBaseURL') | html %]/cgi-bin/koha/opac-retrieve-file.pl?id=[% record.hashvalue | uri %]" class="get-file" data-toggle="tooltip" title="Copy link to this file"><i class="fa fa-link" aria-hidden="true"></i> Yes</a> >+ [% ELSE %] >+ No >+ [% END %] >+ </td> > <td>[% IF record.permanent %]No[% ELSE %]Yes[% END %]</td> > [% END %] > <td class="actions"> >@@ -425,6 +431,18 @@ > e.preventDefault(); > SubmitMe('new'); > }); >+ >+ $(".get-file").on("click", function(e){ >+ e.preventDefault(); >+ copyToClipboard( $(this).attr("href") ); >+ $(this).attr("data-original-title", _( "Link copied to the clipboard" ) ) >+ .tooltip("show"); >+ }); >+ $(".get-file").tooltip({ >+ delay: { "show": 100, "hide": 500 } >+ }).on("hidden.bs.tooltip", function(){ >+ $(this).attr("data-original-title", _( "Copy link to this file" ) ); >+ }); > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 4f06af9465..7411567556 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -1,5 +1,5 @@ > /* global shortcut delCookie delBasket Sticky */ >-/* exported paramOfUrl addBibToContext delBibToContext */ >+/* exported paramOfUrl addBibToContext delBibToContext copyToClipboard */ > if ( KOHA === undefined ) var KOHA = {}; > > function _(s) { return s; } // dummy function for gettext >@@ -358,3 +358,16 @@ function saveOrClearSimpleSearchParams() { > localStorage.setItem('cat_search_pulldown_selection', pulldown_selection ); > localStorage.setItem('searchbox_value', searchbox_value ); > } >+ >+// https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f >+function copyToClipboard( text ){ >+ var el = document.createElement("textarea"); // Create a <textarea> element >+ el.value = text; // Set its value to the string that you want copied >+ el.setAttribute("readonly", ""); // Make it readonly to be tamper-proof >+ el.style.position = "absolute"; >+ el.style.left = "-9999px"; // Move outside the screen to make it invisible >+ document.body.appendChild(el); // Append the <textarea> element to the HTML document >+ el.select(); // Select the <textarea> content >+ document.execCommand("copy"); // Copy - only works as a result of a user action (e.g. click events) >+ document.body.removeChild(el); // Remove the <textarea> element >+} >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27594
:
116218
|
116219
|
117289
|
117310
|
119241
|
119304
|
119305
|
119398
|
119906
|
119995
|
119996
|
119997
|
120416