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,167 +13175,156 @@ 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"?> <info>
<style xmlns="http://purl.org/net/xbiblio/csl" class="author-date" xml:lang="en"> <title>American Psychological Association</title>
<info> <id>http://purl.org/net/xbiblio/csl/styles/apa.csl</id>
<title>American Psychological Association</title> <link>http://purl.org/net/xbiblio/csl/styles/apa.csl</link>
<id>http://purl.org/net/xbiblio/csl/styles/apa.csl</id> <author>
<link>http://purl.org/net/xbiblio/csl/styles/apa.csl</link> <name>Simon Kornblith</name>
<author> <email>simon@simonster.com</email>
<name>Bruce DArcus</name> </author>
<email>bdarcus@sourceforge.net</email> <category term="psychology"/>
</author> <category term="generic-base"/>
<contributor> <updated>2007-07-11T14:27:56+08:00</updated>
<name>Simon Kornblith</name> </info>
<email>simon@simonster.com</email> <macro name="editor-translator">
</contributor> <names variable="editor translator" prefix="(" suffix=")" delimiter=", ">
<contributor> <name and="symbol" initialize-with="." delimiter=", "/>
<name>Johan Kool</name> <label form="short" prefix=", " text-transform="capitalize" suffix="."/>
<email>johankool@users.sourceforge.net</email> </names>
</contributor> </macro>
<updated>2006-09-04T20:14:00+05:00</updated> <macro name="author">
</info> <names variable="author">
<defaults> <name name-as-sort-order="all" and="symbol"
<contributor name-as-sort-order="no"> sort-separator=", " initialize-with="." delimiter=", "
<name and="symbol" initialize-with="." delimiter=", " delimiter-precedes-last="always"/> delimiter-precedes-last="always"/>
<label form="short" prefix=", " text-transform="capitalize" suffix="."/> <label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
</contributor> <substitute>
<author name-as-sort-order="all"> <names variable="editor"/>
<name and="symbol" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/> <names variable="translator"/>
<label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/> <text macro="title"/>
<substitute> </substitute>
<choose> </names>
<editor/> </macro>
<translator/> <macro name="author-short">
<titles/> <names variable="author">
</choose> <name form="short" and="symbol" delimiter=", "
</substitute> initialize-with="."/>
</author> <substitute>
<locator> <names variable="editor"/>
<number/> <names variable="translator"/>
</locator> <choose>
<identifier> <if type="book">
<number/> <text variable="title" form="short" font-style="italic"/>
</identifier> </if>
<titles> <else>
<title/> <text variable="title" form="short" quotes="true"/>
</titles> </else>
<date> </choose>
<year/> </substitute>
<month prefix=", "/> </names>
<day prefix=" "/> </macro>
</date> <macro name="access">
<access> <group>
<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>
<text term-name="from" suffix=" "/> <group>
<url/> <text term-name="from" suffix=" "/>
</access> <text variable="URL"/>
</defaults> </group>
<citation prefix="(" suffix=")" delimiter="; "> </group>
<et-al min-authors="6" use-first="1" position="first"/> </macro>
<et-al min-authors="3" use-first="1" position="subsequent"/> <macro name="title">
<layout> <choose>
<item> <if type="book">
<author form="short"> <text variable="title" font-style="italic"/>
<name and="symbol" delimiter=", "/> </if>
<label form="short" prefix=", " text-transform="capitalize" suffix="."/> <else>
</author> <text variable="title"/>
<date prefix=", "> </else>
<year/> </choose>
</date> </macro>
<locator prefix=": "/> <macro name="publisher">
</item> <group delimiter=": ">
</layout> <text variable="published-place"/>
</citation> <text variable="publisher"/>
<bibliography hanging-indent="true"> </group>
<sort algorithm="author-date"/> </macro>
<et-al min-authors="6" use-first="6"/> <citation>
<layout> <option name="et-al-min" value="6"/>
<list> <option name="et-al-use-first" value="6"/>
<heading> <option name="et-al-subsequent-min" value="6"/>
<text term-name="references"/> <option name="et-al-subsequent-use-first" value="1"/>
</heading> <layout prefix="(" suffix=")" delimiter="; ">
</list> <text macro="author-short"/>
<item suffix="."> <date variable="published" prefix=", ">
<choose> <date-part name="year"/>
<type name="book"> </date>
<author/> <locator prefix=": "/>
<date prefix=" (" suffix=")."> </layout>
<year/> </citation>
</date> <bibliography>
<group suffix="."> <option name="hanging-indent" value="true"/>
<titles font-style="italic" prefix=" "/> <option name="sort-algorithm" value="author-date"/>
<group prefix=" (" suffix=")" delimiter=", "> <option name="et-al-min" value="6"/>
<editor/> <option name="et-al-use-first" value="6"/>
<translator/> <option name="disambiguate-year-suffix" value="true"/>
</group> <option name="disambiguate-add-givenname" value="true"/>
</group> <option name="disambiguate-add-names" value="true"/>
<group prefix=" " delimiter=": "> <layout>
<publisher><place/></publisher> <text macro="author" suffix="."/>
<publisher><name/></publisher> <date variable="published" prefix=" (" suffix=").">
</group> <date-part name="year"/>
<access prefix=" "/> </date>
</type> <choose>
<type name="chapter"> <if type="book">
<author/> <group suffix=".">
<date prefix=" (" suffix=")."> <text macro="title" prefix=" "/>
<year/> <text macro="editor-translator" prefix=" "/>
</date> </group>
<titles font-style="italic" prefix=" "/> <text prefix=" " suffix="." macro="publisher"/>
<group class="container" prefix=" "> </if>
<text term-name="in" text-transform="capitalize"/> <else-if type="chapter">
<editor prefix=" " suffix=","> <text macro="title" prefix=" "/>
<name and="symbol" sort-separator=", " initialize-with="."/> <group class="container" prefix=". ">
<label form="short" prefix=" (" suffix=")" text-transform="capitalize"/> <text term-name="in" text-transform="capitalize"/>
</editor> <names variable="editor translator" prefix=" " suffix="," delimiter=", ">
<translator prefix=" " suffix=","> <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"/> </names>
</translator> <text variable="container-title" font-style="italic" prefix=" " suffix="."/>
<titles relation="container" font-style="italic" prefix=" " suffix="."/> <text variable="collection-title" prefix=" " suffix="."/>
<titles relation="collection" prefix=" " suffix="."/> <group suffix=".">
<group prefix=" " delimiter=": "> <text macro="publisher" prefix=" "/>
<publisher><place/></publisher> <group prefix=" (" suffix=")">
<publisher><name/></publisher> <text term-name="page" plural="true" form="short" suffix=". "/>
</group> <text variable="pages"/>
<pages prefix=" (" suffix=")"> </group>
<label form="short" text-transform="capitalize" suffix=". "/> </group>
<number/> </group>
</pages> </else-if>
</group> <else>
<access prefix=" "/> <group suffix=".">
</type> <text macro="title" prefix=" "/>
<type name="article"> <text macro="editor-translator" prefix=" "/>
<author/> </group>
<date prefix=" (" suffix=")."> <group class="container" prefix=" " suffix=".">
<year/> <text variable="container-title" font-style="italic"/>
</date> <text variable="volume" prefix=", " font-style="italic"/>
<group suffix="."> <text variable="issue" prefix="(" suffix=")"/>
<titles prefix=" "/> <text variable="pages" prefix=", "/>
<group prefix=" (" suffix=")" delimiter=", "> </group>
<editor/> </else>
<translator/> </choose>
</group> <text prefix=" " macro="access"/>
</group> </layout>
<group class="container" prefix=" " suffix="."> </bibliography>
<titles relation="container" font-style="italic"/>
<volume prefix=", " font-style="italic"/>
<issue prefix="(" suffix=")"/>
<pages prefix=", "/>
</group>
<access prefix=" "/>
</type>
</choose>
</item>
</layout>
</bibliography>
</style>'); </style>');
REPLACE INTO csl VALUES('http://www.zotero.org/namespaces/CSL/chicago-author-date.csl', '2007-04-25 23:40:00', 'Chicago Manual of Style (Author-Date)', REPLACE INTO csl VALUES('http://www.zotero.org/namespaces/CSL/chicago-author-date.csl', '2007-04-25 23:40:00', 'Chicago Manual of Style (Author-Date)',