Zotero translator to produce html snippet
This is a follow-up question to
https://forums.zotero.org/discussion/35953/item-zotero-pane-to-item-on-zoteroorg-create-bibliography-from-item
Using the above translator, I can get zotero://... links. However, they are not recognised as links by Google docs.
Is it possible for a zotero translator to produce html snippets, which (with quick copy) are then placed on the clipboard, and can be pasted into Google docs (or Open Office etc) to give zotero style links?
Thanks!
Bjoern
https://forums.zotero.org/discussion/35953/item-zotero-pane-to-item-on-zoteroorg-create-bibliography-from-item
Using the above translator, I can get zotero://... links. However, they are not recognised as links by Google docs.
Is it possible for a zotero translator to produce html snippets, which (with quick copy) are then placed on the clipboard, and can be pasted into Google docs (or Open Office etc) to give zotero style links?
Thanks!
Bjoern
Sure, that wouldn't be hard, would that work for paste to gdocs though?
Do you have an example translator that produces a html snippet?
<a href="zotero://select/items/1700609_RKPTKRPC">zotero</a>
in it, then open this html file in a browser. I then copy and paste the link text into an open office document.
Alternatively, if you have access to the command line, you could just run this:
echo '<a href="zotero://select/items/1700609_RKPTKRPC">zotero</a>' | textutil -stdin -stdout -format html -convert rtf | pbcopy
and then paste into an OO document. When I then open the link (from the open office document), the item opens in zotero (stand alone).
I managed to produce a plain text translator (see forum link above) that produces plain text, with an http:// link to our zotero group on zotero.org, and a zotero:// link.
What I'd link to know is how I can get that translator to produce an html snippet, so that the zotero:// link can get an html link.
Or am I misunderstanding something?
Basically, my translator.js acts like this:
echo '<a href="zotero://select/items/1700609_RKPTKRPC">zotero</a>' | pbcopy
which puts the plain text html code on the clipboard.
What I want is this:
echo '<a href="zotero://select/items/1700609_RKPTKRPC">zotero</a>' | textutil -stdin -stdout -format html -convert rtf | pbcopy
which converts the plain text html code into html, and then puts it onto the clipboard.
here's another thought: Could you create http:// links that redirect to zotero:// links? I experimented a little with a http-equiv="refresh", and it seems to work (at least for Chrome and Zotero stand alone), but it could also work with an appropriate header in the request.
I.e. you could set up something like
http://zotero.org/redirect/1700609_RKPTKRPC
which redirects to
zotero://select/items/1700609_RKPTKRPC
The above link would work in Google docs, and still redirect to Zotero.
When I try this with Chrome, I get an "external protocol request" warning. But if I agree to that, then the item opens in Zotero just fine!
What I did was put
<meta http-equiv="refresh" content="0; url=zotero://select/items/1700609_NHM4H2R9" />
into the header of an html page.
Bjoern
zotero://select/items/1700609_NHM4H2R9
Use this:
http://oer.educ.cam.ac.uk/zotero/select/1700609_NHM4H2R9
(This item is not public, but you can use your own zotero item code!)
Bjoern
It doesn't look like it exposes content in any way, at least as far as I can tell, but it certainly means that we shouldn't allow any data-modifying operations via the protocol handler.
Anyway, I wouldn't really rely on this behavior in Firefox, since either Mozilla or we might fix it at any time. But this should continue to work from other browsers to Standalone like any other protocol scheme. (If we can figure out a way to display a similar prompt for Zotero for Firefox when zotero:// links are triggered, that would be a possible solution.)
So does this also mean that zotero:// links (e.g. in OO or Google Docs) would only ever be able to interact (reliably, officially) with Zotero stand alone, and that any interaction with the Zotero Firefox pane is accidental, and not intended?
It would be really nice to have two way interaction between a Google document and the Firefox pane, within the same window - but that doesn't seem possible?
Thanks!
For Google Docs, I don't know that it's relevant. A solution for Google Docs may very well be more sophisticated and not need to rely on zotero:// links. In any case, Zotero for Firefox can do whatever it wants with any webpage. The connectors are a bit more limited.
How does the number in:
http://zotero.org/groups/257089/items/WUXAHI8Z
relate to the number in:
zotero://select/items/1669433_WUXAHI8Z
(I.e. 257089 vs. 1669433).
In particular, will the zotero:// link work for everybody, or does the number refer to a group specifically within my zotero app?
Thanks!
Bjoern
As I understand it, the zotero.org URL carries a globally unique groupID. The zotero://select address carries a libraryID, which is specific to the local client.
You can translate between the two with:
Zotero.Groups.getGroupIDFromLibraryID(libraryId);
and
Zotero.Groups.getLibraryIDFromGroupID(groupId);
this is wrong. See Dan below.
(fbennett is thinking of the numeric itemID, which, unlike the item key, is local to the client. A libraryID and an item key together globally identify an item.)
libraryIDs aren't really exposed anywhere else (and probably wouldn't be in report URLs either if I had really considered that people would use them externally).
The URLs that don't work are the ones that still use the itemID, such as zotero://attachment/<itemID>