Adds support for the revised CSL schema and an APA CSL. Support for the old schema is maintained through the Zotero.CSL.Compat interface.

closes #563, fix defaults issues in CSL parser (now irrelevant)
closes #335, clean up citation code
This commit is contained in:
Simon Kornblith 2007-07-14 23:23:41 +00:00
parent 5a5a1b7237
commit f5761d507a
5 changed files with 3149 additions and 1584 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -333,6 +333,13 @@ Zotero.Integration.DataListener.prototype._requestFinished = function(response)
} }
} }
Zotero.Integration.citationTypes = {
1:"first",
2:"subsequent",
3:"ibid",
4:"ibid-pages"
}
Zotero.Integration.SOAP = new function() { Zotero.Integration.SOAP = new function() {
this.init = init; this.init = init;
this.update = update; this.update = update;
@ -438,7 +445,7 @@ Zotero.Integration.SOAP = new function() {
Zotero.debug("Integration: Regenerating bibliography"); Zotero.debug("Integration: Regenerating bibliography");
// EBNF: bibliography-data // EBNF: bibliography-data
if(bibliographyMode != "false") { if(bibliographyMode != "false") {
output.push(session.style.createBibliography(session.citationFactory.items, "Integration")); output.push(session.style.createBibliography(session.citationFactory.itemSet, "Integration"));
} else { } else {
output.push("!"); output.push("!");
} }
@ -759,9 +766,9 @@ Zotero.Integration.CitationFactory.prototype.updateItems = function(citationSet,
} }
} }
this.style.preprocessItems(this.items); this.itemSet = this.style.generateItemSet(this.items);
var tempCache = new Object(); /*var tempCache = new Object();
for(var i in this.items) { for(var i in this.items) {
var itemID = this.items[i].getID(); var itemID = this.items[i].getID();
this.dateModified[itemID] = this.items[i].getField("dateModified"); this.dateModified[itemID] = this.items[i].getField("dateModified");
@ -788,7 +795,7 @@ Zotero.Integration.CitationFactory.prototype.updateItems = function(citationSet,
} }
} }
} }
} }*/
// TODO: clear missing items from cache? // TODO: clear missing items from cache?
@ -810,7 +817,9 @@ Zotero.Integration.CitationFactory.prototype.getCitation = function(citation, us
} }
citation.loadLocators(); citation.loadLocators();
var citationText = this.style.createCitation(citation, "Integration"); var citationText = this.style.createCitation(this.itemSet, citation.itemIDs, "Integration",
Zotero.Integration.citationTypes[citation.citationType], citation.locators,
citation.locatorTypes);
if(!usingCache[citation.serializedType]) { if(!usingCache[citation.serializedType]) {
usingCache[citation.serializedType] = new Object(); usingCache[citation.serializedType] = new Object();

View File

@ -58,6 +58,10 @@ Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader) .getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://zotero/content/xpcom/cite.js"); .loadSubScript("chrome://zotero/content/xpcom/cite.js");
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://zotero/content/xpcom/cite_compat.js");
Cc["@mozilla.org/moz/jssubscript-loader;1"] Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader) .getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://zotero/content/xpcom/quickCopy.js"); .loadSubScript("chrome://zotero/content/xpcom/quickCopy.js");

View File

@ -1,4 +1,4 @@
-- 247 -- 248
-- ***** BEGIN LICENSE BLOCK ***** -- ***** BEGIN LICENSE BLOCK *****
-- --
@ -22,7 +22,7 @@
-- Set the following timestamp to the most recent scraper update date -- Set the following timestamp to the most recent scraper update date
REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-06-27 02:00:00')); REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-07-14 22:56:53'));
REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2007-06-21 20:00:00', '1', '100', '4', 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon', REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2007-06-21 20:00:00', '1', '100', '4', 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon',
'function detectWeb(doc, url) { 'function detectWeb(doc, url) {
@ -13175,165 +13175,154 @@ function doExport() {
} }
}'); }');
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-06-13 01:00:00', 'American Psychological Association', REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-07-14 22:56:53', 'American Psychological Association',
'<?xml version="1.0" encoding="UTF-8"?> '<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" xml:lang="en">
<?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="author-date" xml:lang="en">
<info> <info>
<title>American Psychological Association</title> <title>American Psychological Association</title>
<id>http://purl.org/net/xbiblio/csl/styles/apa.csl</id> <id>http://purl.org/net/xbiblio/csl/styles/apa.csl</id>
<link>http://purl.org/net/xbiblio/csl/styles/apa.csl</link> <link>http://purl.org/net/xbiblio/csl/styles/apa.csl</link>
<author> <author>
<name>Bruce DArcus</name>
<email>bdarcus@sourceforge.net</email>
</author>
<contributor>
<name>Simon Kornblith</name> <name>Simon Kornblith</name>
<email>simon@simonster.com</email> <email>simon@simonster.com</email>
</contributor> </author>
<contributor> <category term="psychology"/>
<name>Johan Kool</name> <category term="generic-base"/>
<email>johankool@users.sourceforge.net</email> <updated>2007-07-11T14:27:56+08:00</updated>
</contributor>
<updated>2006-09-04T20:14:00+05:00</updated>
</info> </info>
<defaults> <macro name="editor-translator">
<contributor name-as-sort-order="no"> <names variable="editor translator" prefix="(" suffix=")" delimiter=", ">
<name and="symbol" initialize-with="." delimiter=", " delimiter-precedes-last="always"/> <name and="symbol" initialize-with="." delimiter=", "/>
<label form="short" prefix=", " text-transform="capitalize" suffix="."/> <label form="short" prefix=", " text-transform="capitalize" suffix="."/>
</contributor> </names>
<author name-as-sort-order="all"> </macro>
<name and="symbol" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/> <macro name="author">
<names variable="author">
<name name-as-sort-order="all" and="symbol"
sort-separator=", " initialize-with="." delimiter=", "
delimiter-precedes-last="always"/>
<label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/> <label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
<substitute> <substitute>
<names variable="editor"/>
<names variable="translator"/>
<text macro="title"/>
</substitute>
</names>
</macro>
<macro name="author-short">
<names variable="author">
<name form="short" and="symbol" delimiter=", "
initialize-with="."/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
<choose> <choose>
<editor/> <if type="book">
<translator/> <text variable="title" form="short" font-style="italic"/>
<titles/> </if>
<else>
<text variable="title" form="short" quotes="true"/>
</else>
</choose> </choose>
</substitute> </substitute>
</author> </names>
<locator> </macro>
<number/> <macro name="access">
</locator> <group>
<identifier>
<number/>
</identifier>
<titles>
<title/>
</titles>
<date>
<year/>
<month prefix=", "/>
<day prefix=" "/>
</date>
<access>
<text term-name="retrieved" text-transform="capitalize" suffix=" "/> <text term-name="retrieved" text-transform="capitalize" suffix=" "/>
<date suffix=", "> <date variable="accessed" suffix=", ">
<month suffix=" "/> <date-part name="month" suffix=" "/>
<day suffix=", "/> <date-part name="day" suffix=", "/>
<year/> <date-part name="year"/>
</date> </date>
<group>
<text term-name="from" suffix=" "/> <text term-name="from" suffix=" "/>
<url/> <text variable="URL"/>
</access> </group>
</defaults> </group>
<citation prefix="(" suffix=")" delimiter="; "> </macro>
<et-al min-authors="6" use-first="1" position="first"/> <macro name="title">
<et-al min-authors="3" use-first="1" position="subsequent"/> <choose>
<layout> <if type="book">
<item> <text variable="title" font-style="italic"/>
<author form="short"> </if>
<name and="symbol" delimiter=", "/> <else>
<label form="short" prefix=", " text-transform="capitalize" suffix="."/> <text variable="title"/>
</author> </else>
<date prefix=", "> </choose>
<year/> </macro>
<macro name="publisher">
<group delimiter=": ">
<text variable="published-place"/>
<text variable="publisher"/>
</group>
</macro>
<citation>
<option name="et-al-min" value="6"/>
<option name="et-al-use-first" value="6"/>
<option name="et-al-subsequent-min" value="6"/>
<option name="et-al-subsequent-use-first" value="1"/>
<layout prefix="(" suffix=")" delimiter="; ">
<text macro="author-short"/>
<date variable="published" prefix=", ">
<date-part name="year"/>
</date> </date>
<locator prefix=": "/> <locator prefix=": "/>
</item>
</layout> </layout>
</citation> </citation>
<bibliography hanging-indent="true"> <bibliography>
<sort algorithm="author-date"/> <option name="hanging-indent" value="true"/>
<et-al min-authors="6" use-first="6"/> <option name="sort-algorithm" value="author-date"/>
<option name="et-al-min" value="6"/>
<option name="et-al-use-first" value="6"/>
<option name="disambiguate-year-suffix" value="true"/>
<option name="disambiguate-add-givenname" value="true"/>
<option name="disambiguate-add-names" value="true"/>
<layout> <layout>
<list> <text macro="author" suffix="."/>
<heading> <date variable="published" prefix=" (" suffix=").">
<text term-name="references"/> <date-part name="year"/>
</heading> </date>
</list>
<item suffix=".">
<choose> <choose>
<type name="book"> <if type="book">
<author/>
<date prefix=" (" suffix=").">
<year/>
</date>
<group suffix="."> <group suffix=".">
<titles font-style="italic" prefix=" "/> <text macro="title" prefix=" "/>
<group prefix=" (" suffix=")" delimiter=", "> <text macro="editor-translator" prefix=" "/>
<editor/>
<translator/>
</group> </group>
</group> <text prefix=" " suffix="." macro="publisher"/>
<group prefix=" " delimiter=": "> </if>
<publisher><place/></publisher> <else-if type="chapter">
<publisher><name/></publisher> <text macro="title" prefix=" "/>
</group> <group class="container" prefix=". ">
<access prefix=" "/>
</type>
<type name="chapter">
<author/>
<date prefix=" (" suffix=").">
<year/>
</date>
<titles font-style="italic" prefix=" "/>
<group class="container" prefix=" ">
<text term-name="in" text-transform="capitalize"/> <text term-name="in" text-transform="capitalize"/>
<editor prefix=" " suffix=","> <names variable="editor translator" prefix=" " suffix="," delimiter=", ">
<name and="symbol" sort-separator=", " initialize-with="."/> <name and="symbol" sort-separator=", " initialize-with="."/>
<label form="short" prefix=" (" suffix=")" text-transform="capitalize"/> <label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
</editor> </names>
<translator prefix=" " suffix=","> <text variable="container-title" font-style="italic" prefix=" " suffix="."/>
<name and="symbol" sort-separator=", " initialize-with="."/> <text variable="collection-title" prefix=" " suffix="."/>
<label form="short" prefix=" (" suffix=")" text-transform="capitalize"/>
</translator>
<titles relation="container" font-style="italic" prefix=" " suffix="."/>
<titles relation="collection" prefix=" " suffix="."/>
<group prefix=" " delimiter=": ">
<publisher><place/></publisher>
<publisher><name/></publisher>
</group>
<pages prefix=" (" suffix=")">
<label form="short" text-transform="capitalize" suffix=". "/>
<number/>
</pages>
</group>
<access prefix=" "/>
</type>
<type name="article">
<author/>
<date prefix=" (" suffix=").">
<year/>
</date>
<group suffix="."> <group suffix=".">
<titles prefix=" "/> <text macro="publisher" prefix=" "/>
<group prefix=" (" suffix=")" delimiter=", "> <group prefix=" (" suffix=")">
<editor/> <text term-name="page" plural="true" form="short" suffix=". "/>
<translator/> <text variable="pages"/>
</group> </group>
</group> </group>
</group>
</else-if>
<else>
<group suffix=".">
<text macro="title" prefix=" "/>
<text macro="editor-translator" prefix=" "/>
</group>
<group class="container" prefix=" " suffix="."> <group class="container" prefix=" " suffix=".">
<titles relation="container" font-style="italic"/> <text variable="container-title" font-style="italic"/>
<volume prefix=", " font-style="italic"/> <text variable="volume" prefix=", " font-style="italic"/>
<issue prefix="(" suffix=")"/> <text variable="issue" prefix="(" suffix=")"/>
<pages prefix=", "/> <text variable="pages" prefix=", "/>
</group> </group>
<access prefix=" "/> </else>
</type>
</choose> </choose>
</item> <text prefix=" " macro="access"/>
</layout> </layout>
</bibliography> </bibliography>
</style>'); </style>');