Skip to content

Preliminary attachments support - #4329

Merged
yurydelendik merged 2 commits into
masterfrom
unknown repository
Apr 18, 2014
Merged

yurydelendik merged 2 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Feb 25, 2014

Copy link
Copy Markdown

Added a partial Filespec support
Added getAttachments in API
Added a new attachments view in UI

attachments.pdf

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

This should answer #2751

Note: web/images/toolbarButton-viewAttachments.png is obviously not acceptable but I don't have the skills to make it better. Some help would be appreciated on this.

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

I haven't really looked at the code, but the feature seems nice to have!
One UI related bug I noticed right away though, is that the CSS changes moved the next/previous page and zoom in/out buttons down.

Comment thread web/viewer.js Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will not work, since the pagemode parameter is called "bookmarks" in the spec, but it's called "outline" in PDF.js (don't ask me why). Change this line to `(params.pagemode === 'bookmarks' instead.

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

@dferer The best way to get a nice looking icon for this feature is to ask @shorlander, since he is the one who created the current UI and the icons.
I don't think he is too active on Github, so an email might be your best bet.

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

/botio-linux preview

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

It was worth trying :)

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

@Snuffleupagus thanks

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

Here is a test file that contain attachments of different types: https://dl.dropboxusercontent.com/u/1910542/attachments.pdf

It has links to a PDF attachment and back (which is not yet supported).

Comment thread web/viewer.html Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Based on the placement of this button, I think that the tabindex of this button should be 4. This unfortunately means that you have to change most of the other indexes, but that's unavoidable in this instance.

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

There is a small issue with the "Attachments" button not getting disabled properly in some circumstances. This can be tricky to reproduce on a fast connection, but the following steps should help:

  1. Open http://107.21.233.14:8877/f04b2ce8dfcc99b/web/viewer.html.
  2. Before the file has begun loading/rendering, quickly click on the "Sidebar" button and then on the "Attachments" button.
  3. Note how the "Attachments" button doesn't get disabled, even after the file is completely loaded.

I'm guessing that this might be caused by not waiting on all the necessary promises to be resolved. You might have to wait for PDFView.animationStartedPromise, as is done here: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1016-L1018.

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

@Snuffleupagus I can't see this issue on my local tests. Could you please call botio one more time to see if it is fixed?

And by the way, thank you for testing my PR

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

Thanks. It looks like it is fixed.

Edit: unless the attachment view is selected before the end of the loading

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

It looks like it is fixed.

I can still reproduce it intermittently, so I wouldn't say so unfortunately.
I don't really know what the issue is, but the only other idea I have is placing the code inside: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1018.

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

Third time lucky I guess, that seems to do it!

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

It does look better indeed. I should have taken your advice the first time.

@timvandermeij

Copy link
Copy Markdown
Collaborator

This is looking good. I have two questions though:

  1. Would it be nice to sort the attachments alphabetically?
  2. What are those buttons in the PDF at https://dl.dropboxusercontent.com/u/1910542/attachments.pdf supposed to do? The do nothing right now.

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

What are those buttons in the PDF at https://dl.dropboxusercontent.com/u/1910542/attachments.pdf supposed to do? The do nothing right now.

Those are GoToE actions (i.e. "Embedded Go-To Actions", section 12.6.4.4 in the ISO version of the PDF spec), which we currently don't support. The reason is that you need support for attachments for those to be meaningful.
If we want to add support for those kind of actions, it would probably be best to do so in a follow-up PR.

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

Attachments are now sorted alphabetically

Comment thread web/viewer.js Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: space before and after operators, i.e. var i = 0;.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, we usually cache the length in loops: for (var i = 0, ii = names.length; i < ii; i++) {.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@shorlander

Copy link
Copy Markdown
Contributor

Here is an attachment icon in the same style as the others:
toolbarbutton-viewattachment

toolbarbutton-viewattachment 2x

@timvandermeij

Copy link
Copy Markdown
Collaborator

@shorlander Thank you for the quick response on this!

@dferer For your information, the second icon's filename should end with @2x because it's a Retina icon. See #4315 in case you hadn't seen that PR yet.

@ghost

ghost commented Feb 25, 2014

Copy link
Copy Markdown
Author

@shorlander Thanks, it looks much better now!

@ghost

ghost commented Feb 27, 2014

Copy link
Copy Markdown
Author

Added retina-specific CSS for the icon

@timvandermeij

Copy link
Copy Markdown
Collaborator

/botio-linux preview

@pdfjsbot

pdfjsbot commented Mar 6, 2014

Copy link
Copy Markdown

Comment thread web/viewer.js Outdated

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.

Please don't remove brackets.

Comment thread src/core/obj.js

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.

We need to use isValidUrl(this._filename, true) here (from shared/utils.js)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Should I, instead, not pass this value to the DownloadManager in viewer.js (which doesn't make sense anyway)?

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.

I'm trying to avoid for users of api to validate url against XSS. But yeah, we should do that at least before DownloadManager

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added a downloadBlob method to DownloadManager to cover the case of URL-less BLOBs. It seems cleaner and prevents unnecessary errors in case of a fallback to the downloadUrl method.
If it's OK with you, your other comments are also addressed.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I had to give up using DownloadManager as downloadUrl adds an extension to the URL that Safari does not appreciate when handling blobs (and isValidUrl does not accept the blob: protocol).
Also, as we don't know the content type of the attachments, and because Safari does not implement the "download" attribute on anchor tags, it tries to display the file in the current page, which generates errors. Opening the attachment in "_blank" is the cleanest way I can find to deal with that. It works fine in Firefox and Chrome though.
What do you think?

@yurydelendik

Copy link
Copy Markdown
Contributor

Sounds good. Let me play with last solution a little

@yurydelendik

Copy link
Copy Markdown
Contributor

/botio-windows preview

@pdfjsbot

Copy link
Copy Markdown

Comment thread web/viewer.js Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I completely agree with the name change of the variable, but I don't think that this line should be added!
By adding || attachmentsView.classList.contains('hidden'), won't wasAnotherViewVisible be true even when the thumbnailView is already visible?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I cannot find an excuse for this one :/

Added a partial Filespec support
Added getAttachments in API
Added a new attachments view in UI (with a new icon by @shorlander)
@yurydelendik

Copy link
Copy Markdown
Contributor

/botio-linux preview

@pdfjsbot

Copy link
Copy Markdown

@yurydelendik

Copy link
Copy Markdown
Contributor

/botio test

@pdfjsbot

Copy link
Copy Markdown

@pdfjsbot

Copy link
Copy Markdown

@yurydelendik

Copy link
Copy Markdown
Contributor

/botio-windows preview

@pdfjsbot

Copy link
Copy Markdown

@pdfjsbot

Copy link
Copy Markdown

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/16b6b83154c552e/output.txt

Total script time: 21.80 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot

Copy link
Copy Markdown

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/82e5812b7e24e2b/output.txt

Total script time: 25.78 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

yurydelendik added a commit that referenced this pull request Apr 18, 2014
@yurydelendik
yurydelendik merged commit 3b2af51 into mozilla:master Apr 18, 2014
@yurydelendik

Copy link
Copy Markdown
Contributor

Thank you for the patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants