Skip to content

hide download button for public preview of audio files#27674

Merged
szaimen merged 3 commits into
nextcloud:masterfrom
fstorz:hide-download-button-for-public-preview-of-audio-files
Jul 21, 2021
Merged

hide download button for public preview of audio files#27674
szaimen merged 3 commits into
nextcloud:masterfrom
fstorz:hide-download-button-for-public-preview-of-audio-files

Conversation

@fstorz

@fstorz fstorz commented Jun 25, 2021

Copy link
Copy Markdown
Contributor

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

szaimen commented Jun 25, 2021

Copy link
Copy Markdown
Contributor

cc @nextcloud/server please review

@tcitworld

Copy link
Copy Markdown
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

fstorz commented Jun 25, 2021

Copy link
Copy Markdown
Contributor Author
  • 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
Copy Markdown
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

szaimen commented Jun 25, 2021

Copy link
Copy Markdown
Contributor

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

@fstorz

fstorz commented Jun 25, 2021

Copy link
Copy Markdown
Contributor Author

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

@szaimen szaimen left a comment

Copy link
Copy Markdown
Contributor

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.

@Pytal Pytal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@blizz

blizz commented Jun 27, 2021 via email

Copy link
Copy Markdown

@artonge

artonge commented Jun 28, 2021

Copy link
Copy Markdown
Collaborator

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

juliusknorr commented Jun 28, 2021

Copy link
Copy Markdown
Member

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.

@szaimen szaimen left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

szaimen commented Jul 13, 2021

Copy link
Copy Markdown
Contributor

@fstorz any update here? :)

@fstorz

fstorz commented Jul 13, 2021

Copy link
Copy Markdown
Contributor Author

@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

szaimen commented Jul 13, 2021

Copy link
Copy Markdown
Contributor

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

@LukasReschke

Copy link
Copy Markdown
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 <florian.storz@devlix.de>
PR contains discussion about the implementation with pros and cons

Signed-off-by: Florian Storz <florian.storz@devlix.de>
Signed-off-by: Florian Storz <florian.storz@devlix.de>
@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

szaimen commented Jul 19, 2021

Copy link
Copy Markdown
Contributor

/backport to stable22

@szaimen

szaimen commented Jul 19, 2021

Copy link
Copy Markdown
Contributor

/backport to stable21

@szaimen

szaimen commented Jul 19, 2021

Copy link
Copy Markdown
Contributor

/backport to stable20

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

welcome Bot commented Jul 21, 2021

Copy link
Copy Markdown

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

szaimen commented Jul 21, 2021

Copy link
Copy Markdown
Contributor

/backport to stable21

@szaimen

szaimen commented Jul 21, 2021

Copy link
Copy Markdown
Contributor

/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

Development

Successfully merging this pull request may close these issues.

Cannot hide download button Download link of audio file shared via public link is displayed also when 'hide download' option is enabled

8 participants