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() {
this.init = init;
this.update = update;
@ -438,7 +445,7 @@ Zotero.Integration.SOAP = new function() {
Zotero.debug("Integration: Regenerating bibliography");
// EBNF: bibliography-data
if(bibliographyMode != "false") {
output.push(session.style.createBibliography(session.citationFactory.items, "Integration"));
output.push(session.style.createBibliography(session.citationFactory.itemSet, "Integration"));
} else {
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) {
var itemID = this.items[i].getID();
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?
@ -810,7 +817,9 @@ Zotero.Integration.CitationFactory.prototype.getCitation = function(citation, us
}
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]) {
usingCache[citation.serializedType] = new Object();

View File

@ -58,6 +58,10 @@ Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.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"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://zotero/content/xpcom/quickCopy.js");

View File

@ -1,4 +1,4 @@
-- 247
-- 248
-- ***** BEGIN LICENSE BLOCK *****
--
@ -22,7 +22,7 @@
-- 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',
'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',
'<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="author-date" xml:lang="en">
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-07-14 22:56:53', 'American Psychological Association',
'<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" xml:lang="en">
<info>
<title>American Psychological Association</title>
<id>http://purl.org/net/xbiblio/csl/styles/apa.csl</id>
<link>http://purl.org/net/xbiblio/csl/styles/apa.csl</link>
<author>
<name>Bruce DArcus</name>
<email>bdarcus@sourceforge.net</email>
</author>
<contributor>
<name>Simon Kornblith</name>
<email>simon@simonster.com</email>
</contributor>
<contributor>
<name>Johan Kool</name>
<email>johankool@users.sourceforge.net</email>
</contributor>
<updated>2006-09-04T20:14:00+05:00</updated>
</author>
<category term="psychology"/>
<category term="generic-base"/>
<updated>2007-07-11T14:27:56+08:00</updated>
</info>
<defaults>
<contributor name-as-sort-order="no">
<name and="symbol" initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
<macro name="editor-translator">
<names variable="editor translator" prefix="(" suffix=")" delimiter=", ">
<name and="symbol" initialize-with="." delimiter=", "/>
<label form="short" prefix=", " text-transform="capitalize" suffix="."/>
</contributor>
<author name-as-sort-order="all">
<name and="symbol" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
</names>
</macro>
<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"/>
<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>
<editor/>
<translator/>
<titles/>
<if type="book">
<text variable="title" form="short" font-style="italic"/>
</if>
<else>
<text variable="title" form="short" quotes="true"/>
</else>
</choose>
</substitute>
</author>
<locator>
<number/>
</locator>
<identifier>
<number/>
</identifier>
<titles>
<title/>
</titles>
<date>
<year/>
<month prefix=", "/>
<day prefix=" "/>
</date>
<access>
</names>
</macro>
<macro name="access">
<group>
<text term-name="retrieved" text-transform="capitalize" suffix=" "/>
<date suffix=", ">
<month suffix=" "/>
<day suffix=", "/>
<year/>
<date variable="accessed" suffix=", ">
<date-part name="month" suffix=" "/>
<date-part name="day" suffix=", "/>
<date-part name="year"/>
</date>
<group>
<text term-name="from" suffix=" "/>
<url/>
</access>
</defaults>
<citation prefix="(" suffix=")" delimiter="; ">
<et-al min-authors="6" use-first="1" position="first"/>
<et-al min-authors="3" use-first="1" position="subsequent"/>
<layout>
<item>
<author form="short">
<name and="symbol" delimiter=", "/>
<label form="short" prefix=", " text-transform="capitalize" suffix="."/>
</author>
<date prefix=", ">
<year/>
<text variable="URL"/>
</group>
</group>
</macro>
<macro name="title">
<choose>
<if type="book">
<text variable="title" font-style="italic"/>
</if>
<else>
<text variable="title"/>
</else>
</choose>
</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>
<locator prefix=": "/>
</item>
</layout>
</citation>
<bibliography hanging-indent="true">
<sort algorithm="author-date"/>
<et-al min-authors="6" use-first="6"/>
<bibliography>
<option name="hanging-indent" value="true"/>
<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>
<list>
<heading>
<text term-name="references"/>
</heading>
</list>
<item suffix=".">
<text macro="author" suffix="."/>
<date variable="published" prefix=" (" suffix=").">
<date-part name="year"/>
</date>
<choose>
<type name="book">
<author/>
<date prefix=" (" suffix=").">
<year/>
</date>
<if type="book">
<group suffix=".">
<titles font-style="italic" prefix=" "/>
<group prefix=" (" suffix=")" delimiter=", ">
<editor/>
<translator/>
<text macro="title" prefix=" "/>
<text macro="editor-translator" prefix=" "/>
</group>
</group>
<group prefix=" " delimiter=": ">
<publisher><place/></publisher>
<publisher><name/></publisher>
</group>
<access prefix=" "/>
</type>
<type name="chapter">
<author/>
<date prefix=" (" suffix=").">
<year/>
</date>
<titles font-style="italic" prefix=" "/>
<group class="container" prefix=" ">
<text prefix=" " suffix="." macro="publisher"/>
</if>
<else-if type="chapter">
<text macro="title" prefix=" "/>
<group class="container" prefix=". ">
<text term-name="in" text-transform="capitalize"/>
<editor prefix=" " suffix=",">
<names variable="editor translator" prefix=" " suffix="," delimiter=", ">
<name and="symbol" sort-separator=", " initialize-with="."/>
<label form="short" prefix=" (" suffix=")" text-transform="capitalize"/>
</editor>
<translator prefix=" " suffix=",">
<name and="symbol" sort-separator=", " initialize-with="."/>
<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>
<label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
</names>
<text variable="container-title" font-style="italic" prefix=" " suffix="."/>
<text variable="collection-title" prefix=" " suffix="."/>
<group suffix=".">
<titles prefix=" "/>
<group prefix=" (" suffix=")" delimiter=", ">
<editor/>
<translator/>
<text macro="publisher" prefix=" "/>
<group prefix=" (" suffix=")">
<text term-name="page" plural="true" form="short" suffix=". "/>
<text variable="pages"/>
</group>
</group>
</group>
</else-if>
<else>
<group suffix=".">
<text macro="title" prefix=" "/>
<text macro="editor-translator" prefix=" "/>
</group>
<group class="container" prefix=" " suffix=".">
<titles relation="container" font-style="italic"/>
<volume prefix=", " font-style="italic"/>
<issue prefix="(" suffix=")"/>
<pages prefix=", "/>
<text variable="container-title" font-style="italic"/>
<text variable="volume" prefix=", " font-style="italic"/>
<text variable="issue" prefix="(" suffix=")"/>
<text variable="pages" prefix=", "/>
</group>
<access prefix=" "/>
</type>
</else>
</choose>
</item>
<text prefix=" " macro="access"/>
</layout>
</bibliography>
</style>');