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

Opening zotero links (zotero://...) also opens an empty window #498

Closed
jlegewie opened this issue Jun 4, 2014 · 21 comments
Closed

Opening zotero links (zotero://...) also opens an empty window #498

jlegewie opened this issue Jun 4, 2014 · 21 comments

Comments

@jlegewie
Copy link
Contributor

jlegewie commented Jun 4, 2014

Hi,

when I open a zotero link from a note in Standalone such as <a href="zotero://select/items/0_PZJQAHCA">test</a> Zotero first opens an empty window and then selects the Zotero item. Is there a way to prevent that?

Here is a brief discussion about the issue. fbennett uses a hack in MLZ to circumvent the problem but maybe there is a better solution from the Zotero side.

@mtd91429
Copy link
Contributor

So I started looking into this issue and think that there are 2 components. In the firefox client, if Zotero is in tab mode, opening the links creates a new blank tab. If they're control+clicked, the tab opens in the background; If they're clicked, it opens in the foreground. The other component is the new window opening in the standalone client.

From what I gather, the zotero links are passed from the tinyMCE plugin linksmenu to the zoteroHandler to the loadURI function in zoteroPane.js - at which point the standalone client passes the zotero links to the function openInViewer in standalone.js

If we didn't want to alter the zotero protocol handler as fbennett did, we could put in an 'if statement' with regex matching for the zotero scheme in both the loadURI and openInViewer functions that opens the tab or window and then closes it. I don't think we can prevent the window/tab from opening (although I definitely need to get a better understanding of Mozilla's window/tab structure, so I could be wrong). I'll try to implement this and report back.

@jlegewie
Copy link
Contributor Author

Thanks for checking on this! Would be great if you can get it to work.

@aurimasv
Copy link
Contributor

What needs to happen in general (at least from a Windows perspective), is that Zotero needs to be registered as a global (system-wide) handler for the zotero: protocol. That's not so difficult in itself, but in order for Zotero to handle zotero: protocol outside of the browser, it needs to be able to accept command line parameters (currently it doesn't really do that). I'm also not sure how this works when Zotero is already open (since we don't want to be opening additional instances of Zotero) and whether it would be possible with XULRunner at all.

Sorry, I can't currently offer a lot of help with this, but IMO this would be the direction to take. You can start with the zotero://select (which, honestly, should just be zotero:select, but I think it's a bit late to change now), though I imagine this opening up some interesting possibilities. I know Dan feels fairly strongly against being able to automatically edit the Zotero library via zotero: protocol (for security reasons), but perhaps with proper user notification it may be ok.

Anyway. just my two cents.

@simonster
Copy link
Member

Zotero Standalone is already registered as a system-wide handler for the zotero:// protocol on Mac and Windows. When you click the Z icon in Firefox with Zotero Standalone open, it brings the Standalone window to the foreground by opening zotero://select, which doesn't open a new window in Standalone.

The cause of this issue is most likely that openInViewer opens a new window, and the solution is probably to special-case zotero:// in loadURI so that we open the URL directly instead of calling openInViewer.

@aurimasv
Copy link
Contributor

or, at least in Standalone, https://github.com/zotero/zotero/blob/4.0/chrome/content/zotero/bindings/styled-textbox.xml#L159 should pass all links to nsIExternalProtocolService (and as in @simonster's link above) and let the system figure out how to open the link. (In Firefox, not sure if we would want to open up links in, say, Chrome if it's the default browser.) I don't think special-casing zotero:// is a great idea here, since I can imagine there being plenty of other protocols that could be useful in notes (e.g. evernote)

@simonster
Copy link
Member

That is what ZoteroPane.launchURL does. It's possible we should make this handle protocols besides http/https as well, but zotero:// probably has to be special cased not to go through nsIExternalProtocolService because it may not be registered with the OS (e.g. on Linux).

@aurimasv
Copy link
Contributor

Any reason not to register zotero: on Linux?

@simonster
Copy link
Member

Just that we do not provide an installer.

@aurimasv
Copy link
Contributor

Though yeah, going through the system for our own protocol seems a bit roundabout, so perhaps we should have tinyMCE pass to ZoteroPane.launchURL, have ZoteroPane.launchURL handle all URLs, but short-circuit zotero: protocol by calling the handler directly?

@mtd91429
Copy link
Contributor

I added a commit that special cases zotero links. It works on my end (Windows 7) and don't think it is dependent on the operating system.*

if (uri.match(/^zotero\:\/\/open-pdf/)) return; on Line 2760 is necessary to address the blank tab issue the FF full-tab mode. If the if statement is not included and the line consists simply of return, the functionality of Zotero is lost - double clicking on a PDF in the FF full-tab mode fails to open the document. If the entire line is discarded and no return is present, opening PDFs in FF full-tab mode is restored and the blank windows in the standalone no longer appear - however, use of zotero://open-pdflinks in FF full-tab mode continues to open a blank tab. Because of that, this is the best solution I could devise.

I looked into closing the blank windows/tabs based on the calling URL or the content loaded as a means of creating a more 'versatile' solution. This would allow alternative protocols like Evernote or OneNote (or other, unforeseen protocols) to open their links without the annoyance of these blank windows/tabs as aurimasv brought up earlier. In the standalone client I ran into trouble discerning these blank windows from about:config or other components that utilized the basicViewer. It was also pretty hackish. I think it would be better to explicitly define what to do with these links if we think this is an important feature.

*but more knowledgeable eyes should double check and/or test if possible

@mtd91429
Copy link
Contributor

I failed to fully read jlegewie's initial comment and didn't account for the zotero://select urls (got focused on the open-pdf urls that I most often encounter). I pushed a new commit that addresses this behavior. Sorry about that.

@jlegewie
Copy link
Contributor Author

Thanks for your work on this!

Just as a clarification: zotero://open-pdf are the links used by zotfile to open pdfs on certain pages. So it's not an official zotero protocol. Still, I hope they would be part of any solution. :)

@mtd91429
Copy link
Contributor

Yea, I knew it wasn't part of the official protocol, but I too hope it'd be part of the solution - it only needs a simply regex addition to the fix for the zotero://select problem. Although, it does sort of raise the notion that if we're going to address non-standard-zotero protocols that go through the loadURI function, we should include other major protocols as well (Evernote, OneNote, etc.) - but they may be a bit more complicated to implement and deciding which ones to include may be contentious.

@pavloglushko
Copy link

Hello, I set up everything so that now can open zotero:// links from OneNote - the only problem is with empty window. Can please anyone tell where this file chrome/content/zotero/zoteroPane.js is located for editing? Win 7, Zotero FF.

@fbennett
Copy link
Contributor

fbennett commented Apr 8, 2015

@pavloglushko
Copy link

Thank you for the answer. I mean where it can be found on my local machine to edit? I am not a programmer so sorry if the question is a bit stupid :)

@zuphilip
Copy link
Contributor

zuphilip commented Apr 8, 2015

..\zotero\zotero\chrome\content\zotero\zoteroPane.js

@rameloot
Copy link

rameloot commented May 7, 2015

Is there an update on this? Conveniently opening links from Onenote would still be absolutely awesome!

@xiaoronglv
Copy link

How to open a collection through Zotero link?

"zotero://select/collections/9" doesn't work.

@et2010
Copy link

et2010 commented Mar 16, 2018

I use zotfile to extract annotations to a note and then generate a report from it. I have successfully set Zotero 5 to open the links with pdf-tools. I usually save the report as an html file. However, when I try to open zotero links in the saved html file, an empty browser window is opened. Anyone has the same issue? How can I open links in a saved html report with specific application?

@bwiernik
Copy link
Contributor

bwiernik commented Jul 4, 2018

This issue appears to be fixed on Windows 10 and macOS High Sierra with the current Zotero 5 beta.

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

No branches or pull requests