Javascript API problem

52 views
Skip to first unread message

Erik Hetzner

unread,
Apr 16, 2011, 4:14:35 PM4/16/11
to zotero-dev
Hi,

In generation citations for my Emacs org-mode integration, I used to
be able to do this, via MozRepl:

var Zotero = Components.classes["@zotero.org/Zotero;1"] .getService(Components.interfaces.nsISupports).wrappedJSObject;
var lkh = Zotero.Items.parseLibraryKeyHash("0_QZXS7E6Q");
var item = Zotero.Items.getByLibraryAndKey(lkh.libraryID, lkh.key);
var biblio = Zotero.QuickCopy.getContentFromItems(new Array(item), "http://www.zotero.org/styles/chicago-note-bibliography");

And then use ``biblio.html`` to retrieve an HTML representation of a
bibliography entry. This no longer seems to work.

According to [1] I can use:

var biblio = Zotero.QuickCopy.getContentFromItems(new Array(item),
Zotero.Prefs.get("export.quickCopy.setting"));
var biblio_html_format = cite.html; /* sic? should be biblio.html? */

But this does not seem to work either. Ultimately I would like to get
away from MozRepl but no other solution seems easy at the moment.

Any suggestions?

best, Erik

1. http://www.zotero.org/support/dev/client_coding/javascript_api

Frank Bennett

unread,
Apr 16, 2011, 7:44:35 PM4/16/11
to zotero-dev
From the code, it looks like you need to prepend the style string with
"bibliography=", so:

var biblio = Zotero.QuickCopy.getContentFromItems(new Array(item),
"bibliography=http://www.zotero.org/styles/chicago-note-
bibliography");

(Guessing that the URI id is used to reference styles internally)

Does that work?

>
> best, Erik
>
> 1.http://www.zotero.org/support/dev/client_coding/javascript_api
>
> Sent from my free software system <http://fsf.org/>.

Erik Hetzner

unread,
Apr 16, 2011, 8:05:30 PM4/16/11
to zoter...@googlegroups.com, Frank Bennett
Hi Frank,

At Sat, 16 Apr 2011 16:44:35 -0700 (PDT),


Frank Bennett wrote:
> From the code, it looks like you need to prepend the style string with
> "bibliography=", so:
>
> var biblio = Zotero.QuickCopy.getContentFromItems(new Array(item),
> "bibliography=http://www.zotero.org/styles/chicago-note-
> bibliography");
>
> (Guessing that the URI id is used to reference styles internally)
>
> Does that work?

Thanks! Turns out that was what I *was* doing in my code, but my
attempts to do this manually were not done right. In the end the issue
was that I needed to increase the time I wait for a file to be
written.

Thanks for the help.

best, Erik

Reply all
Reply to author
Forward
0 new messages