<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Data Unbound &#187; Zotero</title>
	<atom:link href="http://blog.dataunbound.com/category/zotero/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dataunbound.com</link>
	<description>Helping organizations access and share data effectively.  Special focus on web APIs for data integration.</description>
	<lastBuildDate>Thu, 11 Feb 2010 00:25:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<image>
  <link>http://blog.dataunbound.com</link>
  <url>http://blog.dataunbound.com/wp-content/plugins/favicon-manager/dataunbound.ico</url>
  <title>Data Unbound</title>
</image>
		<item>
		<title>Zotz and the limitations of the Zotero plugin framework</title>
		<link>http://blog.dataunbound.com/2009/01/15/zotz-and-the-limitations-of-the-zotero-plugin-framework/</link>
		<comments>http://blog.dataunbound.com/2009/01/15/zotz-and-the-limitations-of-the-zotero-plugin-framework/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 02:31:50 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Zotero]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Zotz]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=288</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Zotz+and+the+limitations+of+the+Zotero+plugin+framework&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2009-01-15&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2009/01/15/zotz-and-the-limitations-of-the-zotero-plugin-framework/&amp;rft.language=English"></span>
Zotz Developer&#039;s Guide &#8211; SIMILE has a useful warning to all who work on developing Zotero plugins: Zotz is a Zotero add-on, but it&#039;s written as a regular Firefox extension: the nature of firefox extensions all living in the same address space allows extensions to invoke each other internal methods, which means that Zotz can [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Zotz+and+the+limitations+of+the+Zotero+plugin+framework&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2009-01-15&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2009/01/15/zotz-and-the-limitations-of-the-zotero-plugin-framework/&amp;rft.language=English"></span>
<p><a href="http://simile.mit.edu/wiki/Zotz_Developer%27s_Guide">Zotz Developer&#039;s Guide &#8211; SIMILE</a> has a useful warning to all who work on developing Zotero plugins:</p>
<blockquote><p>Zotz is a Zotero add-on, but it&#039;s written as a regular Firefox extension: the nature of firefox extensions all living in the same address space allows extensions to invoke each other internal methods, which means that Zotz can extend Zotero without Zotero having to expose special APIs for this.</p>
<p>While this is a very powerful mechanism, it is also insecure and fragile.</p>
<p>Insecure because it allows potentially malicious extensions to do act uncontrolled inside your browser (stealing your data and/or altering the browser or the extensions&#039; own activities) and fragile because Zotero might change internal APIs not knowing that Zotz dependend on them and would immediately break Zotz functionality.</p>
<p>There is currently no better way to do things so we&#039;re stuck with it for the time being, but being aware of the situation helps forecast future development needs and potential issues that could arise.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2009/01/15/zotz-and-the-limitations-of-the-zotero-plugin-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>copying to clipboard Zotero citations as HTML  w/ chickenfoot</title>
		<link>http://blog.dataunbound.com/2009/01/02/copying-to-clipboard-zotero-citations-as-html-w-chickenfoot/</link>
		<comments>http://blog.dataunbound.com/2009/01/02/copying-to-clipboard-zotero-citations-as-html-w-chickenfoot/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 21:27:25 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=259</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=copying+to+clipboard+Zotero+citations+as+HTML++w%2F+chickenfoot&amp;rft.aulast=Yee&amp;rft.aufirst=Raymond&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2009-01-02&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2009/01/02/copying-to-clipboard-zotero-citations-as-html-w-chickenfoot/&amp;rft.language=English"></span>
Here&#039;s a first pass at a Chickenfoot script that copies selected Zotero items as HTML to the clipboard.  (I couldn&#039;t find anything in the Zotero interface to do exactly this function.  There is a  Create Bibliography from Selected Item(s)-&#62;Copy to Clipboard but that seems to copy citations as RTF for me.) var Zotero = chromeWindow.Zotero; [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=copying+to+clipboard+Zotero+citations+as+HTML++w%2F+chickenfoot&amp;rft.aulast=Yee&amp;rft.aufirst=Raymond&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2009-01-02&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2009/01/02/copying-to-clipboard-zotero-citations-as-html-w-chickenfoot/&amp;rft.language=English"></span>
<p>Here&#039;s a first pass at a Chickenfoot script that copies selected Zotero items as HTML to the clipboard.  (I couldn&#039;t find anything in the Zotero interface to do exactly this function.  There is a  Create Bibliography from Selected Item(s)-&gt;Copy to Clipboard but that seems to copy citations as RTF for me.)</p>
<pre id="pre"><span style="color: purple;">var</span> Zotero = chromeWindow.Zotero;
<span style="color: purple;">var</span> ZoteroPane = chromeWindow.ZoteroPane;
<span style="color: purple;">var</span> zfi = chromeWindow.Zotero_File_Interface;

<span style="color: blue;">// zfi.bibliographyFromItems();</span>

<span style="color: blue;">// create the bibliography out of the default style </span>
<span style="color: blue;">// and copy directly to clipboard w/o any popup windows.</span>

<span style="color: blue;">// get the default style</span>
<span style="color: purple;">var</span> style=Zotero.Prefs.get(<span style="color: green;">"export.lastStyle"</span>);

<span style="color: blue;">// e.g., http://www.zotero.org/styles/chicago-note-bibliographystyle</span>

<span style="color: purple;">var</span> items = ZoteroPane.getSelectedItems();
zfi.copyItemsToClipboard(items, style);</pre>
<p>For more details, you can look at how <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.9/chrome/content/zotero/fileInterface.js#L108">Zotero_File_Interface is defined in v 1.0.9</a> to study <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.9/chrome/content/zotero/fileInterface.js#L328">copyItemsToClipboard</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2009/01/02/copying-to-clipboard-zotero-citations-as-html-w-chickenfoot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Range of creator types in Zotero</title>
		<link>http://blog.dataunbound.com/2008/12/16/range-of-creator-types-in-zotero/</link>
		<comments>http://blog.dataunbound.com/2008/12/16/range-of-creator-types-in-zotero/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 19:44:09 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=173</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Range+of+creator+types+in+Zotero&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-16&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/16/range-of-creator-types-in-zotero/&amp;rft.language=English"></span>
One thing that I didn&#039;t know about Zotero was the range of creator types in Zotero. Here&#039;s a Chickenfoot script that you can run to list them: // to explore the range of creatorTypes // to do: figure out how to get localized string for different creator types var Zotero = chromeWindow.Zotero; var creatorTypes = [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Range+of+creator+types+in+Zotero&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-16&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/16/range-of-creator-types-in-zotero/&amp;rft.language=English"></span>
<p>One thing that I didn&#039;t know about Zotero was the range of creator types in Zotero.  Here&#039;s a  Chickenfoot script that you can run to list them:</p>
<pre id="pre"><span style="color: blue;">// to explore the range of creatorTypes</span>
<span style="color: blue;">// to do:  figure out how to get localized string for different creator types</span>

<span style="color: purple;">var</span> Zotero = chromeWindow.Zotero;
<span style="color: purple;">var</span> creatorTypes = Zotero.CreatorTypes.getTypes()
<span style="color: purple;">for</span> (<span style="color: purple;">var</span> i=0; i&lt;creatorTypes.length; i++) {
  output(creatorTypes[i].id + <span style="color: green;">": "</span> + Zotero.CreatorTypes.getName(creatorTypes[i].id));
}</pre>
<p>The results (in Zotero 1.0.7):</p>
<p><code>22: artist<br />
15: attorneyAgent<br />
1: author<br />
20: cartographer<br />
11: castMember<br />
23: commenter<br />
18: composer<br />
2: contributor<br />
13: counsel<br />
8: director<br />
3: editor<br />
25: guest<br />
6: interviewee<br />
7: interviewer<br />
14: inventor<br />
17: performer<br />
26: podcaster<br />
24: presenter<br />
10: producer<br />
21: programmer<br />
16: recipient<br />
27: reviewedAuthor<br />
9: scriptwriter<br />
5: seriesEditor<br />
12: sponsor<br />
4: translator<br />
19: wordsBy</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/12/16/range-of-creator-types-in-zotero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing attributes of Zotero Items</title>
		<link>http://blog.dataunbound.com/2008/12/16/access-attributes-of-zotero-items/</link>
		<comments>http://blog.dataunbound.com/2008/12/16/access-attributes-of-zotero-items/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 19:05:21 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=169</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Accessing+attributes+of+Zotero+Items&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-16&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/16/access-attributes-of-zotero-items/&amp;rft.language=English"></span>
The following Chickenfoot script demonstrates how to access attributes related to Zotero items. (I&#039;ve run this script on both Zotero 1.0.7 and the latest named release of  Zotero 1.5 Sync Preview (1.5-sync3.5))): // zotero_item_show_pieces.js // code to extract elements of the first selected item // Dec 16, 2008 var Zotero = chromeWindow.Zotero; var ZoteroPane = [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Accessing+attributes+of+Zotero+Items&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-16&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/16/access-attributes-of-zotero-items/&amp;rft.language=English"></span>
<p>The following Chickenfoot script demonstrates how to access attributes related to Zotero items.  (I&#039;ve run this script on both Zotero 1.0.7 and the latest named release of  <a href="http://www.zotero.org/support/sync_preview">Zotero 1.5 Sync Preview</a> (1.5-sync3.5))):</p>
<pre id="pre"><span style="color: blue;">// zotero_item_show_pieces.js
// code to extract elements of the first selected item</span>
// Dec 16, 2008

<span style="color: purple;">var</span> Zotero = chromeWindow.Zotero;
<span style="color: purple;">var</span> ZoteroPane = chromeWindow.ZoteroPane;
<span style="color: purple;">var</span> items = ZoteroPane.getSelectedItems();
<span style="color: purple;">var</span> item = items[0];

<span style="color: blue;">// get item ID</span>

output(<span style="color: green;">"item ID: "</span> + item.id);

<span style="color: blue;">// get named type</span>

<span style="color: purple;">var</span> iType = item.getType();
output(<span style="color: green;">"type: "</span> + Zotero.ItemTypes.getName(iType));

<span style="color: blue;">// figure out whether this is a top level item, note, etc.</span>
<span style="color: blue;">// if not, is it a  note or attachment</span>
output(<span style="color: green;">"isRegularItem: "</span> + item.isRegularItem());
output(<span style="color: green;">"isAttachment: "</span> + item.isAttachment());
output(<span style="color: green;">"isNote: "</span> + item.isNote()); <span style="color: blue;">// or just check type == note</span>

<span style="color: blue;">// get all possible fields for the type and their value</span>
<span style="color: purple;">var</span> fields = Zotero.ItemFields.getItemTypeFields(iType);
<span style="color: purple;">for</span> (<span style="color: purple;">var</span> i=0; i&lt;fields.length; i++) {
  fieldName = Zotero.ItemFields.getName(fields[i]);
  fieldVal = item.getField(fieldName);
  fieldLocalName = Zotero.ItemFields.getLocalizedString(iType,fields[i])
  output(fieldLocalName + <span style="color: green;">": "</span> + fieldVal);
}
<span style="color: blue;">//fields;</span>

<span style="color: blue;">// get creators</span>

<span style="color: purple;">var</span> creators = item.getCreators();

<span style="color: purple;">for</span> (<span style="color: purple;">var</span> i=0; i&lt;creators.length; i++) {
  <span style="color: blue;">// Zoteo 1.5 +</span>
  <span style="color: purple;">if</span> (creators[i].ref) {
    output (Zotero.CreatorTypes.getName(creators[i].creatorTypeID) + <span style="color: green;">": "</span> +creators[i].ref.lastName + <span style="color: green;">", "</span> + creators[i].ref.firstName);  }
  <span style="color: blue;">// Zotero 1.0.x</span>
  <span style="color: purple;">else</span> {
    output (Zotero.CreatorTypes.getName(creators[i].creatorTypeID) + <span style="color: green;">": "</span> +creators[i].lastName + <span style="color: green;">", "</span> + creators[i].firstName);
  }
}

<span style="color: blue;">// date added and date modified</span>
output(<span style="color: green;">"Date Added: "</span> + item.getField(<span style="color: green;">'dateAdded'</span>));
output(<span style="color: green;">"Date Modified: "</span> + item.getField(<span style="color: green;">'dateModified'</span>));

<span style="color: blue;">// Notes -- return ids for the notes</span>

<span style="color: purple;">var</span> notes = item.getNotes();
output(<span style="color: green;">"notes: "</span> + notes);

<span style="color: blue;">// Attachments -- there are more details to take care of</span>
<span style="color: blue;">// https://www.zotero.org/trac/browser/extension/tags/1.5-sync3.5/chrome/content/zotero/xpcom/data/item.js#L3469</span>

<span style="color: purple;">var</span> attachments = item.getAttachments();
output(<span style="color: green;">"attachments: "</span> + attachments);

<span style="color: blue;">// Tags -- Z 1.5.x has more complex structures than Z 1.0.7</span>

<span style="color: purple;">var</span> tags = item.getTags();
output("tags:");
<span style="color: purple;">for</span> (<span style="color: purple;">var</span> i=0; i&lt;tags.length; i++) {
  <span style="color: purple;">if</span> (tags[i].name) {
    output(<span style="color: green;">"|"</span> + tags[i].name + <span style="color: green;">"|"</span>);
  }
  <span style="color: purple;">else</span> {
  output(<span style="color: green;">"|"</span> + tags[i][<span style="color: green;">'tag'</span>] + <span style="color: green;">"|"</span>);
  }
}

<span style="color: blue;">// Related</span>

<span style="color: blue;">// https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/xpcom/data_access.js#L2180</span>

<span style="color: purple;">if</span> (item.getSeeAlso) {
  <span style="color: purple;">var</span> related = item.getSeeAlso();
} <span style="color: purple;">else</span> <span style="color: purple;">if</span> (item.relatedItems) {
  <span style="color: purple;">var</span> related = item.relatedItems;
}

output(<span style="color: green;">"related: "</span> + related);

<span style="color: blue;">// Collections -- get which collections the item belongs in.</span>
output(<span style="color: green;">"collections: "</span> + item.getCollections());</pre>
<p>A few notes:</p>
<ul>
<li>Some of the conditionals in the script reflect differences in how Zotero 1.0.x and the upcoming Zotero 1.5+ Zotero object model work.</li>
<li>For Zotero 1.5+,  you can learn a lot about how to access attributes related to a Zotero item by studying <a href="https://www.zotero.org/trac/browser/extension/tags/1.5-sync3.5/chrome/content/zotero/xpcom/data/item.js#L3382">Zotero.Item.serialize (v 1.5-sync3.5)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/12/16/access-attributes-of-zotero-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding all tabs to Zotero Version 2 &#8212; scraping translatable sites</title>
		<link>http://blog.dataunbound.com/2008/12/11/adding-all-tabs-to-zotero-translatable-sites/</link>
		<comments>http://blog.dataunbound.com/2008/12/11/adding-all-tabs-to-zotero-translatable-sites/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 22:50:39 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=165</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Adding+all+tabs+to+Zotero+Version+2+%26%238212%3B+scraping+translatable+sites&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-11&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/11/adding-all-tabs-to-zotero-translatable-sites/&amp;rft.language=English"></span>
In a previous post adding all Firefox tabs to Zotero using Chickenfoot, I showed how to write a Chickenfoot script to loop through all Firefox  tabs and add each of them as an item into Zotero.  A limitation of the script was that it used only ZoteroPane.addItemFromPage for every tab, even if a given tab [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Adding+all+tabs+to+Zotero+Version+2+%26%238212%3B+scraping+translatable+sites&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-11&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/11/adding-all-tabs-to-zotero-translatable-sites/&amp;rft.language=English"></span>
<p>In a previous post <a href="http://blog.dataunbound.com/2008/11/12/adding-all-firefox-tabs-to-zotero-using-chickenfoot/">adding all Firefox tabs to Zotero using Chickenfoot</a>, I showed how to write a Chickenfoot script to loop through all Firefox  tabs and add each of them as an item into Zotero.  A limitation of the script was that it used only <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/overlay.js#L1899">ZoteroPane.addItemFromPage</a> for every tab, even if a given tab had a translator that could be used to save the item.  As explained in <a href="http://blog.dataunbound.com/2008/11/01/adding-item-to-zotero-with-chickenfoot/">Adding items to Zotero with Chickenfoot</a>,  you can use <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L121">Zotero_Browser.scrapeThisPage</a> to invoke the appropriate translator for tab. The reason I didn&#039;t use <code>Zotero_Browser.scrapeThisPage</code> in my Chickenfoot script to add items is that I didn&#039;t know how to write a function to determine suitable translator exists.</p>
<p>Now, I think I&#039;ve come up with a way of determining whether a translator exists &#8212; though I&#039;m not highly confident that the solution is fullproof.    I&#039;ll share my  Chickenfoot script here, explain the logic behind it, and write about its possible limitations.  First the script:</p>
<pre id="pre"><span style="color: blue;">// add_each_tab_to_Zotero_2.js</span>
<span style="color: blue;">// R. Yee</span>

<span style="color: purple;">var</span> Zotero = chromeWindow.Zotero;
<span style="color: purple;">var</span> ZoteroPane = chromeWindow.ZoteroPane;
<span style="color: purple;">var</span> Zotero_Browser = chromeWindow.Zotero_Browser;
<span style="color: purple;">var</span> tabBrowser = getTabBrowser(chromeWindow);

// getIcon returns a link to the translator icon for the current
// tab and false if there is no suitable
// translator and '<span style="color: green;">chrome://zotero/skin/treesource-collection.png</span>'
// if there are multiple savable elements on a page

<span style="color: purple;">function</span> getIcon() {

  <span style="color: purple;">var</span> browser = Zotero_Browser.tabbrowser.selectedBrowser;
  <span style="color: purple;">var</span> tab0 = <span style="color: purple;">new</span> Zotero_Browser.Tab(browser);

  <span style="color: blue;">// need to figure out whether doc is HTMLDocument</span>
  <span style="color: blue;">// doc instanceof HTMLDocument doesn't seem to work here</span>

  <span style="color: purple;">var</span> doc = browser.contentWindow.document;

  // in emulation of
  // https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L311

  <span style="color: purple;">var</span> rootDoc = doc;
  <span style="color: purple;">if</span> (rootDoc.defaultView) {
    <span style="color: purple;">while</span>(rootDoc.defaultView.frameElement) {
      rootDoc = rootDoc.defaultView.frameElement.ownerDocument;
    }
  }

  // detect possible translators and return the corresponding icon
  tab0.detectTranslators(rootDoc,doc);
  <span style="color: purple;">return</span> tab0.getCaptureIcon();

} <span style="color: blue;">// getIcon()</span>

// create a new collection with current date
<span style="color: purple;">var</span> new_Collection = Zotero.Collections.add(<span style="color: green;">"_Saved "</span> + (<span style="color: purple;">new</span> Date()).toLocaleString());

// output # tabs
output(tabBrowser.browsers.length);

// loop through tabs, selecting each one in turn
<span style="color: purple;">for</span> (<span style="color: purple;">var</span> i=0; i &lt; tabBrowser.browsers.length; i++) {
  tabBrowser.mTabContainer.advanceSelectedTab(1, <span style="color: purple;">true</span>);
  output(tabBrowser.selectedBrowser.contentWindow.location);
  <span style="color: purple;">var</span> icon = getIcon();
  // if icon is not false and not representing multiple items -- scrape page
  <span style="color: purple;">if</span> (icon &amp;&amp; icon != <span style="color: green;">'chrome://zotero/skin/treesource-collection.png'</span>) {
    Zotero_Browser.scrapeThisPage(new_Collection.id);
  // otherwise add item as a generic web page
  } <span style="color: purple;">else</span> {
   ZoteroPane.addItemFromPage(new_Collection.id);
  }
}</pre>
<p>A few points about the script:</p>
<ul>
<li>I wrote this code by adapting the logic of <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js">browser.js</a></li>
<li>A starting point was studying <a href="scrapeThisPage 	https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L121">Zotero_Browser.scrapeThisPage</a></li>
<li>Ideally, I wanted to call the private method <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L503">_getTabObject</a>  (or read from the private array  <code>_browserData </code>)</li>
<li>I followed the logic of  <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L514">line 514</a> to instantiate <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L580">Zotero_Browser.Tab</a>.</li>
<li>once a tab is created, <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L596">Zotero_Browser.Tab.detectTranslators</a> is used to detect translators &#8212; see <a href=" https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L365">line 365</a></li>
<li><a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L304">contentLoad</a> showed me how to calculate <code>rootDoc</code></li>
<li><a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L697">getCaptureIcon</a> shows how to interpret the different values for an translator icon</li>
</ul>
<p>When I ran the script with 3 tabs, it seemed to work fine.  When I had 20+ tabs, all the tabs were saved &#8212; but only the first one ended up in the right collection.  (I don&#039;t know why&#8230;.)  Also, the code is not terribly elegant &#8212; for example, it depends on creating a new <code>Zotero_Browser.Tab</code> for each tab; I figure there should be some way to read off whether an icon exists in the interface already without having to recalculate possible translators.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/12/11/adding-all-tabs-to-zotero-translatable-sites/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting primary and secondary item types in Zotero</title>
		<link>http://blog.dataunbound.com/2008/12/02/getting-primary-and-secondary-item-types-in-zotero/</link>
		<comments>http://blog.dataunbound.com/2008/12/02/getting-primary-and-secondary-item-types-in-zotero/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 00:53:54 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=159</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Getting+primary+and+secondary+item+types+in+Zotero&amp;rft.aulast=Yee&amp;rft.aufirst=Raymond&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-02&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/02/getting-primary-and-secondary-item-types-in-zotero/&amp;rft.language=English"></span>
A Chickenfoot script for calculating the primary and secondary Zotero items (which draws upon the code in overlay.js->onLoad(): // based on https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/overlay.js#L153 var Zotero = chromeWindow.Zotero; var itemTypes = Zotero.ItemTypes.getPrimaryTypes(); for(var i = 0; i&#60;itemTypes.length; i++) { output (itemTypes[i]['name'] + ":" + itemTypes[i]['id']); } var itemTypes = Zotero.ItemTypes.getSecondaryTypes(); for(var i = 0; i&#60;itemTypes.length; i++) { output (itemTypes[i]['name'] + ":" + itemTypes[i]['id']); } The output of the script is (for [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Getting+primary+and+secondary+item+types+in+Zotero&amp;rft.aulast=Yee&amp;rft.aufirst=Raymond&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-12-02&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/12/02/getting-primary-and-secondary-item-types-in-zotero/&amp;rft.language=English"></span>
<p>A Chickenfoot script for calculating the primary and secondary Zotero items (which draws upon the code in <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/overlay.js#L153">overlay.js->onLoad()</a>:</p>
<pre id="pre">

// based on https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/overlay.js#L153

var Zotero = chromeWindow.Zotero;

<span class="k">var</span> <span class="nx">itemTypes</span> <span class="o">=</span> <span class="nx">Zotero</span><span class="p">.</span><span class="nx">ItemTypes</span><span class="p">.</span><span class="nx">getPrimaryTypes</span><span class="p">();</span>

<span class="k">for</span><span class="p">(</span><span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">itemTypes</span><span class="p">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> {
  output (itemTypes[i]['name'] + ":" + itemTypes[i]['id']);
}

<span class="k">var</span> <span class="nx">itemTypes</span> <span class="o">=</span> <span class="nx">Zotero</span><span class="p">.</span><span class="nx">ItemTypes</span><span class="p">.</span><span class="nx">getSecondaryTypes</span><span class="p">();</span>

<span class="k">for</span><span class="p">(</span><span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">itemTypes</span><span class="p">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> {
  output (itemTypes[i]['name'] + ":" + itemTypes[i]['id']);
}</pre>
<p>The output of the script is (for Zotero 1.0.7):</p>
<pre>
book:2
bookSection:3
document:34
journalArticle:4
magazineArticle:5
newspaperArticle:6
artwork:12
audioRecording:26
bill:16
blogPost:23
case:17
computerProgram:32
conferencePaper:33
dictionaryEntry:36
email:21
encyclopediaArticle:35
film:11
forumPost:25
hearing:18
instantMessage:24
interview:10
letter:8
manuscript:9
map:22
patent:19
podcast:31
presentation:27
radioBroadcast:30
report:15
statute:20
thesis:7
tvBroadcast:29
videoRecording:28
</pre>
<p>When you hit &#034;New Item&#034; button in Zotero, you are given the option of creating a new item of one of a given type:</p>
<p><a href="http://www.flickr.com/photos/raymondyee/3078837408/" title="primary and secondary Zotero item types by Raymond Yee, on Flickr"><img src="http://farm4.static.flickr.com/3235/3078837408_e07fe1554c_m.jpg" width="169" height="240" alt="primary and secondary Zotero item types" /></a></p>
<p>Furthermore, you can use <code>Zotero.ItemTypes</code> to map between item types and IDs:</p>
<p><code>Zotero.ItemTypes.getID('book');</code> yields 2</p>
<p>and</p>
<p><code>Zotero.ItemTypes.getName(2);</code> returns <code>book</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/12/02/getting-primary-and-secondary-item-types-in-zotero/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A screencast to show Chickenfoot scripting of Zotero</title>
		<link>http://blog.dataunbound.com/2008/11/21/a-screencast-to-show-chickenfoot-scripting-of-zotero/</link>
		<comments>http://blog.dataunbound.com/2008/11/21/a-screencast-to-show-chickenfoot-scripting-of-zotero/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 16:00:33 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>
		<category><![CDATA[screencast]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=153</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=A+screencast+to+show+Chickenfoot+scripting+of+Zotero&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.subject=screencast&amp;rft.source=Data+Unbound&amp;rft.date=2008-11-21&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/11/21/a-screencast-to-show-chickenfoot-scripting-of-zotero/&amp;rft.language=English"></span>
Several weeks ago, I wrote (a blog post and a post on the zotero-dev group) on how to use Chickenfoot to script Zotero. I&#039;m starting to experiment with creating little videos that I hope will make my technical posts easier to understand. Here&#039;s one I just made to illustrate what I wrote about in the [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=A+screencast+to+show+Chickenfoot+scripting+of+Zotero&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.subject=screencast&amp;rft.source=Data+Unbound&amp;rft.date=2008-11-21&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/11/21/a-screencast-to-show-chickenfoot-scripting-of-zotero/&amp;rft.language=English"></span>
<p>Several weeks ago, I wrote  (<a href="http://blog.dataunbound.com/2008/10/28/zotero-chickenfoot-intro/">a blog post</a> and a <a href="http://groups.google.com/group/zotero-dev/browse_thread/thread/319c69f7882fe171#">post on the zotero-dev group</a>) on how to use <a href="http://groups.csail.mit.edu/uid/chickenfoot/">Chickenfoot</a> to script <a href="http://www.zotero.org">Zotero</a>.    I&#039;m starting to experiment with creating little videos that I hope will make my technical posts easier to understand.  Here&#039;s one I just made to illustrate what I wrote about in the previous post:</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/xvOp6NkK6Qw&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xvOp6NkK6Qw&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>Please forgive my video-newbie level of craft &#8212; I&#039;m still learning to make my way around <a href="http://www.techsmith.com/camtasia.asp">Camtasia Studio 6</a>.  (One fault is that I produced the video for 640&#215;480, which is not the optimal setting for YouTube.)</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/11/21/a-screencast-to-show-chickenfoot-scripting-of-zotero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>adding all Firefox tabs to Zotero using Chickenfoot</title>
		<link>http://blog.dataunbound.com/2008/11/12/adding-all-firefox-tabs-to-zotero-using-chickenfoot/</link>
		<comments>http://blog.dataunbound.com/2008/11/12/adding-all-firefox-tabs-to-zotero-using-chickenfoot/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 19:31:59 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=143</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=adding+all+Firefox+tabs+to+Zotero+using+Chickenfoot&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-11-12&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/11/12/adding-all-firefox-tabs-to-zotero-using-chickenfoot/&amp;rft.language=English"></span>
We can now build on what was presented in the previous blog post: Adding items to Zotero with Chickenfoot. The end goal is to loop through all the tabs and add Each of them as items into Zotero. So we need to figure out how to access the tabs. I would do so here by [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=adding+all+Firefox+tabs+to+Zotero+using+Chickenfoot&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-11-12&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/11/12/adding-all-firefox-tabs-to-zotero-using-chickenfoot/&amp;rft.language=English"></span>
<p>We can now build on what was presented in the previous blog post: <a href="http://blog.dataunbound.com/2008/11/01/adding-item-to-zotero-with-chickenfoot/">Adding items to Zotero with Chickenfoot</a>.</p>
<p>The end goal is to loop through all the tabs and add Each of them as items into Zotero.  So we need to figure out how to access the tabs.    I would do so here by presenting a series of code fragments that you can try out using Chickenfoot and Zotero.</p>
<p>But let&#039;s first work through some code to manipulate tabs in Firefox, drawn from two reference documents:</p>
<ul>
<li><a href="https://developer.mozilla.org/En/XUL/Tabbrowser">tabbrowser &#8211; MDC</a>: a reference to the tabbrowser object</li>
<li><a href="https://developer.mozilla.org/en/Code_snippets/Tabbed_browser">Tabbed browser &#8211; MDC</a> has some nice sample code, which seems to work best in Firefox 3.x, &#8212; something seemed to fail in Firefox 2.x (I should put an example here)</li>
</ul>
<p>For example, one example  of code doesn&#039;t work in 2.x &#8212; using addTab:<br />
<code><br />
var tabBrowser = getTabBrowser(chromeWindow);<br />
tabBrowser.addTab("http://yahoo.com");<br />
</code></p>
<p>Since I&#039;ve had some problems using Firefox 2.x, I recommend running the following code fragments in Firefox 3.x.</p>
<p>First, let&#039;s get the tabbrowser object:<br />
<code><br />
var tabBrowser = getTabBrowser(chromeWindow);<br />
tabBrowser;<br />
</code></p>
<p>You can show the URL of the currently selected tab:<br />
<code><br />
var tabBrowser = getTabBrowser(chromeWindow);<br />
tabBrowser.selectedBrowser.contentWindow.location;<br />
</code></p>
<p>The following code advances selects the tab to the right of the currently tab &#8212; and loops around if needed:<br />
<code><br />
var tabBrowser = getTabBrowser(chromeWindow);<br />
tabBrowser.mTabContainer.advanceSelectedTab(1, true);<br />
</code></p>
<p>We can write out the current number of open tabs:<br />
<code><br />
var tabBrowser = getTabBrowser(chromeWindow);<br />
output(tabBrowser.browsers.length);<br />
</code></p>
<p>Here&#039;s code to select each tab in turn and output its location:</p>
<pre>var tabBrowser = getTabBrowser(chromeWindow);
output(tabBrowser.browsers.length);
for (var i=0; i &lt; tabBrowser.browsers.length; i++) {
  tabBrowser.mTabContainer.advanceSelectedTab(1, true);
  output(tabBrowser.selectedBrowser.contentWindow.location);
}</pre>
<p>how to create a new collection in Zotero:<br />
<code><br />
var Zotero = chromeWindow.Zotero;<br />
var new_Collection = Zotero.Collections.add("testing");<br />
new_Collection;<br />
</code></p>
<p>Here&#039;s code to create a new collection and add an item to it.  (In my tries, the code crashes in FF 2.0.x  but seems to work in FF 3.0.3):</p>
<pre>var Zotero = chromeWindow.Zotero;
var ZoteroPane = chromeWindow.ZoteroPane;

var new_Collection = Zotero.Collections.add("testing");
var new_item = ZoteroPane.addItemFromPage(new_Collection.id);</pre>
<p>Here&#039;s code that pulls it altogether &#8212; it loops through the tabs and adds the document of each tab to Zotero in a new collection:</p>
<pre>var Zotero = chromeWindow.Zotero;
var ZoteroPane = chromeWindow.ZoteroPane;
var tabBrowser = getTabBrowser(chromeWindow);

var new_Collection = Zotero.Collections.add("Saved from tabs");
output(tabBrowser.browsers.length);

for (var i=0; i &lt; tabBrowser.browsers.length; i++) {
  tabBrowser.mTabContainer.advanceSelectedTab(1, true);
  output(tabBrowser.selectedBrowser.contentWindow.location);
  var new_item = ZoteroPane.addItemFromPage(new_Collection.id);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/11/12/adding-all-firefox-tabs-to-zotero-using-chickenfoot/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Adding items to Zotero with Chickenfoot</title>
		<link>http://blog.dataunbound.com/2008/11/01/adding-item-to-zotero-with-chickenfoot/</link>
		<comments>http://blog.dataunbound.com/2008/11/01/adding-item-to-zotero-with-chickenfoot/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 22:55:36 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Chickenfoot]]></category>
		<category><![CDATA[Zotero]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=135</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Adding+items+to+Zotero+with+Chickenfoot&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-11-01&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/11/01/adding-item-to-zotero-with-chickenfoot/&amp;rft.language=English"></span>
Here I report a few code fragments that you can try in Chickenfoot to create a Zotero item from the contents in the selected tab of your browser. (For a bit of context for what I&#039;m talking about here, see my previous post Data Unbound » Accessing Zotero via Chickenfoot: a warm up exercise.) There&#039;s [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Adding+items+to+Zotero+with+Chickenfoot&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Chickenfoot&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-11-01&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/11/01/adding-item-to-zotero-with-chickenfoot/&amp;rft.language=English"></span>
<p>Here I report a few code fragments that you can try in Chickenfoot to create a Zotero item from the contents in the selected tab of your browser.  (For a bit of context for what I&#039;m talking about here, see my previous post <a href="http://blog.dataunbound.com/2008/10/28/zotero-chickenfoot-intro/">Data Unbound » Accessing Zotero via Chickenfoot: a warm up exercise</a>.)</p>
<p>There&#039;s a difference between the Zotero function that is  invoked if an appropriate translator is found verses when there is no translator (and you have to then &#034;create a new item from current page&#034;.  (It would be helpful to show you how I deduced what these code fragments should be &#8212; I hope to do so later.)</p>
<p>When there is an appropriate translator, you invoke <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/browser.js#L121">Zotero_Browser.scrapeThisPage</a>:<br />
<code><br />
var Zotero_Browser = chromeWindow.Zotero_Browser;<br />
Zotero_Browser.scrapeThisPage();<br />
</code></p>
<p>When there isn&#039;t &#8212; and you add the page to Zotero as a web page using <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/overlay.js#L1899">ZoteroPane.addItemFromPage</a>:<br />
<code><br />
var ZoteroPane = chromeWindow.ZoteroPane;<br />
ZoteroPane.addItemFromPage();<br />
</code></p>
<p>Yet to figure out:   How to ask Zotero whether for the selected tab there is an appropriate translator to use.  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/11/01/adding-item-to-zotero-with-chickenfoot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Accessing Zotero via Chickenfoot:  a warm up exercise</title>
		<link>http://blog.dataunbound.com/2008/10/28/zotero-chickenfoot-intro/</link>
		<comments>http://blog.dataunbound.com/2008/10/28/zotero-chickenfoot-intro/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 18:37:22 +0000</pubDate>
		<dc:creator>Raymond Yee</dc:creator>
				<category><![CDATA[Zotero]]></category>
		<category><![CDATA[Chickenfoot]]></category>

		<guid isPermaLink="false">http://blog.dataunbound.com/?p=92</guid>
		<description><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Accessing+Zotero+via+Chickenfoot%3A++a+warm+up+exercise&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-10-28&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/10/28/zotero-chickenfoot-intro/&amp;rft.language=English"></span>
I&#039;m currently learning how to program Zotero, specifically how to integrate Zotero with other applications. I document my learning experience to make it easier for others to learn what I&#039;ve learned. Note that I&#039;m still learning (I&#039;m far from an expert) &#8212; so I think my advice will improve over time. But it decided not [...]]]></description>
			<content:encoded><![CDATA[	
	<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;rft.title=Accessing+Zotero+via+Chickenfoot%3A++a+warm+up+exercise&amp;rft.aulast=&amp;rft.aufirst=&amp;rft.subject=Zotero&amp;rft.source=Data+Unbound&amp;rft.date=2008-10-28&amp;rft.type=blogPost&amp;rft.format=text&amp;rft.identifier=http://blog.dataunbound.com/2008/10/28/zotero-chickenfoot-intro/&amp;rft.language=English"></span>
<p>I&#039;m currently learning how to program Zotero, specifically how to integrate Zotero with other applications.  I document my learning experience to make it easier for others to learn what I&#039;ve learned.   Note that I&#039;m still learning (I&#039;m far from an expert) &#8212; so I think my advice will improve over time.    But it decided not to wait until I am an expert  before I share  my experiences.</p>
<p>You can write Zotero plugins (a Firefox extension that accesses the Zotero extension) as a way of extending Zotero &#8212; see <a href="http://www.zotero.org/documentation/plugins">plugins [Zotero Documentation]</a>.</p>
<p>In a series of posts, I would like to explore how to use <a href="http://groups.csail.mit.edu/uid/chickenfoot/">Chickenfoot</a> as a scripting framework for Zotero and as a way to explore a working Zotero instance.  Why Chickenfoot?  Chickenfoot is appealing because it&#039;s the closest thing we have to a Web automation framework running within a web browser &#8212; and hence something that can take advantage of all the scriptability and context of the Web browser. (Besides, much of the work  we do with Chickenfoot will be transferable to writing a Zotero plug-in.)</p>
<p>A goal I&#039;ve set for myself to focus my learning &#8212; and to provide a narrative for the series:   create a Chickenfoot script to grab all the references I added on a given date and format those items to be sent out as HTML, wiki formatting, and to be uplaoded to some social bookmarking systems, including delicious and Connotea.</p>
<p><em>Note</em>:  I&#039;m using v 1.0.7 of Zotero, running on Firefox 2.0.0.17 on Windows XP.  I&#039;m also using Chickenfoot v 1.0.4. I assume that you will have some basic knowledge of JavaScript and Firefox extensions.  (I plan to provide more background later.)  The overall approach we take here is a combination of experimenting with bits and pieces of source code, combined with reading the original Zotero source code. </p>
<p>In this first post, we warm up by studying how to access with Chickenfoot <code>Zotero</code> and <code>ZoteroPane</code>, two important <code>Zotero</code> objects, and perform some basic tasks with them.   </p>
<p>First, the <code>Zotero</code> object is arguably the main JavaScript object, one that gives you access to the underlying functionality of Zotero.  You can access it in this way (see <a href="https://www.zotero.org/trac/browser/extension/tags/1.0.7/chrome/content/zotero/include.js">include.js</a>):</p>
<p><code>var Zotero = Components.classes["@zotero.org/Zotero;1"].<br />
getService(Components.interfaces.nsISupports).wrappedJSObject;</code></p>
<p>or, in the context of Chickenfoot script:</p>
<p><code>var Zotero = chromeWindow.Zotero;</code></p>
<p>(See <a href="http://www.sitepoint.com/article/rewrite-web-chickenfoot/3/">Rewrite the Web with Chickenfoot [JavaScript &#038; Ajax Tutorials]</a> for a description of  the <code>chromeWindow</code>,  which is the top-level object of the Firefox browser.)</p>
<p>From a <a href="http://forums.zotero.org/discussion/3637/">thread on the Zotero forums</a>, I learned an incantation (courtesy of Dan Stillman) to access the <code>ZoteroPane</code>:<br />
<code><br />
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]<br />
                   .getService(Components.interfaces.nsIWindowMediator);<br />
var browserWindow = wm.getMostRecentWindow("navigator:browser");<br />
var ZoteroPane = browserWindow.ZoteroPane;<br />
</code></p>
<p>It turns out but you can also use <code>chromeWindow </code>to get at <code>ZoteroPane</code>:</p>
<p><code>var ZoteroPane = chromeWindow.ZoteroPane;</code></p>
<h2>What can we do with <code>Zotero </code>and <code>ZoteroPane</code>?</h2>
<p><a href="http://www.flickr.com/photos/raymondyee/2982180673/" title="Zotero object in Chickenfoot by Raymond Yee, on Flickr"><img src="http://farm4.static.flickr.com/3011/2982180673_7d51567ce9.jpg" width="231" height="500" alt="Zotero object in Chickenfoot"  align="left"/></a><br />
The first thing to do is to examine the two objects. You can examine them the output panel by toggling the output variable to see the children of the output object.  For example, if you run the following code, you can get a list of all the children of <code>Zotero </code> and <code>ZoteroPane</code>:</p>
<p><code><br />
function list_props(obj) {<br />
  var name, props;<br />
  var props;<br />
  props = "";<br />
  for (name in obj) {<br />
    props = props + " " + name;<br />
  }<br />
  return props;<br />
}<br />
var Zotero = chromeWindow.Zotero;<br />
var ZoteroPane = chromeWindow.ZoteroPane;<br />
list_props(Zotero);<br />
</code></p>
<p>to generate the following list:</p>
<p><code><br />
 init stateCheck getProfileDirectory getZoteroDirectory getStorageDirectory getZoteroDatabase chooseZoteroDirectory debug log getErrors getSystemInfo varDump safeDebug getString localeJoin getLocaleCollation setFontSize flattenArguments getAncestorByTagName join inArray arraySearch arrayToHash hasValues randomString getRandomID moveToUnique initialized skipLoading startupError startupErrorHandler Prefs Keys Hash Text Date Browser UnresponsiveScriptIndicator WebProgressFinishListener JSON DBConnection DB Schema Item Items Notes Collection Collections Creators Tags CachedTypes CreatorTypes ItemTypes FileTypes CharacterSets ItemFields getCollections Attachments Notifier History Search Searches SearchConditions Ingester OpenURL Translate Cite CSL QuickCopy Report Timeline Utilities Integration File Fulltext MIME ItemTreeView ItemTreeCommandController CollectionTreeView CollectionTreeCommandController ItemGroup ProgressWindowSet ProgressWindow Annotate Annotations Annotation Highlight version isFx2 isFx3 platform isMac isWin isLinux locale dir Maps IconFactory<br />
</code></p>
<h2>Calculating the number of top level items</h2>
<p>The following simple Chickenfoot script returns the number of top-level items in my Zotero collection:</p>
<p><code><br />
var Zotero = chromeWindow.Zotero;<br />
var items = Zotero.Items.getAll(true);<br />
items.length + 1;<br />
</code></p>
<h2>Toggle the Zotero Panel</h2>
<p>The following two-liner  shows how to turn the  Zotero display on and off (equivalent to hitting <code>Ctrl-Alt-Z</code>)</p>
<p><code<br />
var ZoteroPane = chromeWindow.ZoteroPane;<br />
ZoteroPane.toggleDisplay();<br />
</code></p>
<h2>printing the title of the first selected item</h2>
<p>Finally, a three-liner to print out the title of the first selected item:</p>
<p><code><br />
var ZoteroPane = chromeWindow.ZoteroPane;<br />
var selectedItems = ZoteroPane.getSelectedItems();<br />
var title = selectedItems[0].getField("title");<br />
title;<br />
</code></p>
<h2>Conclusion</h2>
<p>This post is meant only to lay the foundation for the ultimate goal which is to integrate Zotero and other systems using Chickenfoot.    I hope it also whet your appetite for more -- and if you're a Zotero user, that you would go right away to install Chickenfoot  to explore Zotero in a deeper way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dataunbound.com/2008/10/28/zotero-chickenfoot-intro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
