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

Show a text preview instead of a bitmap preview of text #15652

Merged
merged 6 commits into from
May 4, 2015
Merged

Show a text preview instead of a bitmap preview of text #15652

merged 6 commits into from
May 4, 2015

Conversation

oparoz
Copy link
Contributor

@oparoz oparoz commented Apr 15, 2015

A fix for

The text can now be seen with a standard font, without magnification or size problems.

Bonus: the preview size is fixed so that this page works on smaller devices.

@ghost
Copy link

ghost commented Apr 15, 2015

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/11548/
🚀 Test PASSed.🚀
chuck

@oparoz
Copy link
Contributor Author

oparoz commented Apr 15, 2015

@PVince81 Is the JS OK?

@oparoz
Copy link
Contributor Author

oparoz commented Apr 15, 2015

That's what it looks like
text_preview
pic_preview

@oparoz oparoz added this to the 8.1-current milestone Apr 15, 2015
@oparoz
Copy link
Contributor Author

oparoz commented Apr 15, 2015

Assigning to 8.1 because it helps fix an alleged regression #15634

@@ -87,9 +87,12 @@ OCA.Sharing.PublicApp = {


// dynamically load image previews
var bottomMargin = 350;
var previewWidth = $(window).width() * window.devicePixelRatio;
var previewHeight = $(window).height() - bottomMargin * window.devicePixelRatio;
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a min height here, otherwise when your screen is pretty small, you dont see anything anymore
screenshot_2015-04-16-10-24-25

Proposal:

var previewHeight = $(window).height() - bottomMargin * window.devicePixelRatio;
previewHeight = Math.max(450, previewHeight);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can confirm that the text disappears if too small. Will set a minimum height of 150.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think an scroll-container with 150px is not really usable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tested it on both desktop and mobile and it's OK, but maybe 200 is more suitable.

From my pov, the goal is to quickly being able to assess what the preview is about. Even 3000 chars might be tmi.

@nickvergessen
Copy link
Contributor

👎 for now

headers: {Range: "bytes=0-3000"}
}).then(function (data) {
var textDiv = $('<span/>').addClass('text-preview').height(previewHeight);
textDiv.text(data);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should append something like <br><br>... when the data is exactly 3000 characters, to make sure people understand this is only a partly preview

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure some space is going to be enough, but I don't know how else we can make it work.
Maybe
2 spaces
(...)
?

@jancborchardt any idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe @jancborchardt has a better sane idea

@oparoz
Copy link
Contributor Author

oparoz commented Apr 16, 2015

Pushed a new version with:

  • 1000 chars loaded (no need to load 3000 I think)
  • min height of 200 so that it doesn't disappear
  • max height of 800, enough to fit the 1000 chars
  • auto-scroll
  • ellipsis at the end of the text, if text is deemed to be longer than 1000 chars

} else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text') {
$.ajax({
url: $('#downloadURL').val(),
headers: {Range: "bytes=0-1000"}
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems to not work.
For me always the complete file is loaded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not always. Either the web server or oC is deciding not to send a range past a certain file size.
Could have something to do with compression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe @LukasReschke knows why this is only done when using x-sendfile

if (isset($_SERVER['HTTP_RANGE']) &&

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, apparently, oC doesn't support partial reading via its PHP methods and it relies either on the web server or on WebDAV to magically send the proper ranges.

The problem with WebDAV is that I can't find a URL which works

  • remote.php/publicwebdav needs files_external or s2s enabled I think
  • public.php/webdav requires authentication

@oparoz
Copy link
Contributor Author

oparoz commented Apr 16, 2015

@nickvergessen - This should now work properly by bypassing the files_sharing download page and using WebDAV directly

@ghost
Copy link

ghost commented Apr 16, 2015

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/11590/
🚀 Test PASSed.🚀
chuck

@@ -105,6 +110,26 @@ OCA.Sharing.PublicApp = {
(maxGifSize === -1 || fileSize <= (maxGifSize * 1024 * 1024))) {
img.attr('src', $('#downloadURL').val());
img.appendTo('#imgframe');
} else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text') {
// Undocumented Url to public WebDAV endpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

🙈 I don't think this is a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What? To add a comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

To use an undocumented endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, it's undocumented, but not unsupported. @PVince81 pointed out that WebDAV endpoints should actually replace all the "download" endpoints in 8.2.

@oparoz
Copy link
Contributor Author

oparoz commented Apr 23, 2015

@PeterPablo - I did think of alternative ways such as adding a border or even a glass cover effect, but it never seemed right.
I'm just going to go with what was recommended and users can open another issue if they feel we can do better. That will leave plenty of time to explore options such as lazy loading per example.

@jancborchardt
Copy link
Member

Please no drop shadow or other separation, it’s ok like it is.

Generally it’s good to discuss stuff before implementing, but at some point it’s also too much and we just need to get something out. Then iterate. ;)

@PeterPablo
Copy link

Fine by me. I had the impression you were still looking for further inspiration.

@scrutinizer-notifier
Copy link

The inspection completed: 4 new issues, 1 updated code elements

@ghost
Copy link

ghost commented Apr 23, 2015

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/11781/
🚀 Test PASSed.🚀
chuck

@jancborchardt
Copy link
Member

@oparoz can you squash the commits into one as well?

Still not sure this is something for 8.1 since it’s really more a feature than a bugfix. @DeepDiver1975?

@oparoz
Copy link
Contributor Author

oparoz commented Apr 23, 2015

@jancborchardt - I will once this is OKed. I was asked not to do it until the end since it's easier to track changes that way.
And regarding the milestone, well on 8.0-, people can't read the text because it's too small and in master it's too big, so to me it means that there is a bug somewhere with the way text previews are handled, but if the changes seem too risky, then maybe assign it to 8.1-next?

@nickvergessen
Copy link
Contributor

@jancborchardt just so you dont miss it, #15652 (comment) is what people see now on the public page

@jancborchardt
Copy link
Member

Ok, true.

@DeepDiver1975
Copy link
Member

I'm fine to keep this for 8.1

@DeepDiver1975
Copy link
Member

nice - works for me 👍

@LukasReschke
Copy link
Member

Let's get this in for now then 👍

LukasReschke added a commit that referenced this pull request May 4, 2015
Show a text preview instead of a bitmap preview of text
@LukasReschke LukasReschke merged commit 17fedc8 into owncloud:master May 4, 2015
LukasReschke added a commit that referenced this pull request May 19, 2015
`params` in the `OC.generateUrl` function call only replaces all specified occurences of a key just like the l10n PHP functionality does.

This means that to build a query string we have to use `OC.buildQueryString` instead of the params parameters.

Fixes #16336 which is a regression introduced with 58a87d0 of #15652.

Without this fix downloading single files from a public shared folder is not possible.
mmattel pushed a commit to mmattel/core that referenced this pull request May 22, 2015
Show a text preview instead of a bitmap preview of text
mmattel pushed a commit to mmattel/core that referenced this pull request May 22, 2015
`params` in the `OC.generateUrl` function call only replaces all specified occurences of a key just like the l10n PHP functionality does.

This means that to build a query string we have to use `OC.buildQueryString` instead of the params parameters.

Fixes owncloud#16336 which is a regression introduced with owncloud@58a87d0 of owncloud#15652.

Without this fix downloading single files from a public shared folder is not possible.
@lock lock bot locked as resolved and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants