Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide download button for public preview of audio files #27674

Merged
merged 3 commits into from
Jul 21, 2021
Merged

hide download button for public preview of audio files #27674

merged 3 commits into from
Jul 21, 2021

Conversation

fstorz
Copy link
Contributor

@fstorz fstorz commented Jun 25, 2021

When the option to hide downloads was selected at public link creation, the download button can be hidden by the audio html attribute controlsList="nodownload"

closes #26086
closes #27872

code was not tested, due to lack of local php setup

@szaimen szaimen added the 3. to review Waiting for reviews label Jun 25, 2021
@szaimen szaimen added this to the Nextcloud 23 milestone Jun 25, 2021
@szaimen
Copy link
Contributor

szaimen commented Jun 25, 2021

cc @nextcloud/server please review

@tcitworld
Copy link
Member

The controlsList attribute is not standard… at the moment at least. Chrome has got it for a while, but both Webkit (Safari) and Firefox voted against.

@fstorz
Copy link
Contributor Author

fstorz commented Jun 25, 2021

  • Safari does not show the "Download" button at all, that this PR should fix (Tested on MacOS).
  • Don't Safari & Firefox just ignore the attribute when they don't support it?
  • According to Mozilla MDN Web Docs also Opera & Edge support the controlsList attribute

@tcitworld
Copy link
Member

Yes, it was more about adding code that doesn't follow standards, even if it doesn't break anything that bothered me. It means support for it can be changed/removed at any time.

Opera & Edge use the same rendering engine as Chrome, so their support will always be the same than Chrome (except for feature flags activated at different times).

@szaimen
Copy link
Contributor

szaimen commented Jun 25, 2021

Is there maybe another flag that could be added that follows standards?

@fstorz
Copy link
Contributor Author

fstorz commented Jun 25, 2021

The "download" button is only implemented by Chrome (or Chromium based browsers), correct?
So from the discussions in the threads, @tcitworld linked in his comment above, there will be no "standard" in the near future.

Additional discussion on this topic in the "HTML Standard" repository

Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested the patch successfully and it works on Chromium based browsers. 👍
The download option doesnt get shown in firefox either way so it doesnt need to work in firefox.

Copy link
Member

@Pytal Pytal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blizz
Copy link

blizz commented Jun 27, 2021 via email

@artonge
Copy link
Contributor

artonge commented Jun 28, 2021

Not sure about how useful this is.

  1. I agree with @tcitworld about this not being a standard and that it will probably be replaced, or removed.
  2. Only chromium browsers seems to offer a download button behind a three-dot menu.
  3. The user still has the option to download the file by right-clicking on the audio element. So what's next, overriding right-click to prevent that too ?

But, if this comes with a comment pointing to this PR or other relevant info that adds context, then I won't oppose :).

@juliusknorr
Copy link
Member

juliusknorr commented Jun 28, 2021

Only chromium browsers seems to offer a download button behind a three-dot menu.
The user still has the option to download the file by right-clicking on the audio element. So what's next, overriding right-click to prevent that too ?

I'd be ok getting this in as it would fit the "hide download" feature which is kind of controversial anyways, as it always was ment to just affect UI elements since there is no real way we can be sure that downloading is not possible anymore (right click, network console, screenshotting, ...) The PR properly hides the element where it is shown, which is chromium only anyways.

Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically IIRC, @fstorz please add a comment that points to the discussion here in the code and everybody should be fine :)

@LukasReschke
Copy link
Member

The user still has the option to download the file by right-clicking on the audio element. So what's next, overriding right-click to prevent that too ?

FWIW: This is what Gmail "Confidential Emails" does. One can still bypass this with the developer console, but it is about making it harder :)

@szaimen
Copy link
Contributor

szaimen commented Jul 13, 2021

@fstorz any update here? :)

@fstorz
Copy link
Contributor Author

fstorz commented Jul 13, 2021

@szaimen is there any best practice in the nextcloud repo to add such a comment?

Sample 1

<audio tabindex="0" controls="" preload="none" style="width: 100%; max-width: <?php p($_['previewMaxX']); ?>px; max-height: <?php p($_['previewMaxY']); ?>px"
	<?php // See https://github.com/nextcloud/server/pull/27674 ?>
	<?php if ($_['hideDownload']) { ?>controlsList="nodownload" <?php } ?>>

Sample 2

<!-- See https://github.com/nextcloud/server/pull/27674 -->
<audio tabindex="0" controls="" preload="none" style="width: 100%; max-width: <?php p($_['previewMaxX']); ?>px; max-height: <?php p($_['previewMaxY']); ?>px"
	<?php if ($_['hideDownload']) { ?>controlsList="nodownload" <?php } ?>>

@szaimen
Copy link
Contributor

szaimen commented Jul 13, 2021

Maybe @LukasReschke or @juliushaertl can comment on this one ⬆️? Thanks! :)

@LukasReschke
Copy link
Member

Both methods would be ok to me. I'd probably tend more to 1.

@szaimen

This comment has been minimized.

fstorz added 3 commits July 19, 2021 18:55
When the option to hide downloads was selected at public link creation, the download button can be hidden by the audio html attribute controlsList="nodownload"

Signed-off-by: Florian Storz <[email protected]>
PR contains discussion about the implementation with pros and cons

Signed-off-by: Florian Storz <[email protected]>
@szaimen szaimen added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jul 19, 2021
@szaimen
Copy link
Contributor

szaimen commented Jul 19, 2021

/backport to stable22

@szaimen
Copy link
Contributor

szaimen commented Jul 19, 2021

/backport to stable21

@szaimen
Copy link
Contributor

szaimen commented Jul 19, 2021

/backport to stable20

@szaimen szaimen merged commit 654672f into nextcloud:master Jul 21, 2021
@welcome
Copy link

welcome bot commented Jul 21, 2021

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@fstorz fstorz deleted the hide-download-button-for-public-preview-of-audio-files branch July 21, 2021 16:03
@szaimen
Copy link
Contributor

szaimen commented Jul 21, 2021

/backport to stable21

@szaimen
Copy link
Contributor

szaimen commented Jul 21, 2021

/backport to stable20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish
Projects
None yet
8 participants