- improves HighWire regex

- does not add shortTitle field to imported items (only items scraped via web)
- fixes issues with ibid in Chicago Manual of Style (Note with Bibliography)
- fixes issues with repeat parenthetical citations
This commit is contained in:
Simon Kornblith 2007-06-10 16:59:16 +00:00
parent 4f492dacc3
commit bc54320ff7
4 changed files with 53 additions and 32 deletions

View File

@ -484,8 +484,9 @@ Zotero.CSL.prototype.createCitation = function(citation, format) {
locator = citation.locators[i];
}
var position = (citation.citationType[i] == 1 ? "first" : "subsequent");
var citationString = this._getCitation(Zotero.Items.get(citation.itemIDs[i]),
(citation.citationType[i] == 1 ? "first" : "subsequent"),
position,
locatorType, locator, format, this._cit);
string.concat(citationString);
@ -1041,7 +1042,7 @@ Zotero.CSL.prototype._compareItem = function(a, b, opt) {
* process creator objects; if someone had a creator model that handled
* non-Western names better than ours, this would be the function to change
*/
Zotero.CSL.prototype._processCreators = function(type, element, creators, format, bibCitElement) {
Zotero.CSL.prototype._processCreators = function(type, element, creators, format, bibCitElement, position) {
var maxCreators = creators.length;
if(!maxCreators) return false;
@ -1057,6 +1058,11 @@ Zotero.CSL.prototype._processCreators = function(type, element, creators, format
return false;
}
var etAl = bibCitElement.etAl;
if(position == "subsequent" && bibCitElement.subsequentEtAl) {
etAl = bibCitElement.subsequentEtAl;
}
for(var i in element.children) {
var child = element.children[i];
var string = "";
@ -1065,8 +1071,8 @@ Zotero.CSL.prototype._processCreators = function(type, element, creators, format
var useEtAl = false;
// figure out if we need to use "et al"
if(bibCitElement.etAl && maxCreators > bibCitElement.etAl.minCreators) {
maxCreators = bibCitElement.etAl.useFirst;
if(etAl && maxCreators >= etAl.minCreators) {
maxCreators = etAl.useFirst;
useEtAl = true;
}
@ -1122,15 +1128,16 @@ Zotero.CSL.prototype._processCreators = function(type, element, creators, format
}
authorStrings[maxCreators-1] = and+" "+authorStrings[maxCreators-1];
// skip the comma if there are only two creators and no
// et al, and name as sort is no
if((maxCreators == 2 && child["delimiter-precedes-last"] != "always") ||
(maxCreators > 2 && child["delimiter-precedes-last"] == "never")) {
var lastString = authorStrings.pop();
authorStrings[maxCreators-2] = authorStrings[maxCreators-2]+" "+lastString;
}
}
}
// check whether to use a serial comma
Zotero.debug(child["delimiter-precedes-last"]);
if((authorStrings.length == 2 && child["delimiter-precedes-last"] != "always") ||
(authorStrings.length > 2 && child["delimiter-precedes-last"] == "never")) {
var lastString = authorStrings.pop();
authorStrings[authorStrings.length-1] = authorStrings[authorStrings.length-1]+" "+lastString;
}
}
string = authorStrings.join(joinString);
} else if(child.name == "label") {
@ -1154,19 +1161,18 @@ Zotero.CSL.prototype._processCreators = function(type, element, creators, format
Zotero.CSL.prototype._getCitation = function(item, position, locatorType, locator, format, bibCitElement) {
Zotero.debug("CSL: generating citation for item "+item.getID());
if(!bibCitElement._types[position]) {
position = "first";
}
// use true position if possible, otherwise "first"
var typePosition = (bibCitElement._types[position] ? position : "first");
// determine mapping
if(bibCitElement._types[position][0]) {
if(bibCitElement._types[typePosition][0]) {
// only one element
var typeName = 0;
var type = this._getTypeObject(position, typeName, bibCitElement);
var type = this._getTypeObject(typePosition, typeName, bibCitElement);
} else {
var typeNames = this._getTypeFromItem(item);
for each(var typeName in typeNames) {
var type = this._getTypeObject(position, typeName, bibCitElement);
var type = this._getTypeObject(typePosition, typeName, bibCitElement);
if(type) {
break;
}
@ -1208,13 +1214,13 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr
// handle subsequent author substitute behavior
dataAppended = formattedString.append(bibCitElement.subsequentAuthorSubstitute, element);
} else {
var newString = this._processCreators(name, element, item._csl.authors, formattedString.format, bibCitElement);
var newString = this._processCreators(name, element, item._csl.authors, formattedString.format, bibCitElement, position);
if(newString) dataAppended = formattedString.concat(newString, element);
}
} else if(name == "editor") {
dataAppended = formattedString.concat(this._processCreators(name, element, item._csl.editors, formattedString.format, bibCitElement), element);
dataAppended = formattedString.concat(this._processCreators(name, element, item._csl.editors, formattedString.format, bibCitElement, position), element);
} else if(name == "translator") {
dataAppended = formattedString.concat(this._processCreators(name, element, item._csl.translators, formattedString.format, bibCitElement), element);
dataAppended = formattedString.concat(this._processCreators(name, element, item._csl.translators, formattedString.format, bibCitElement, position), element);
} else if(name == "titles") {
var data = new Zotero.CSL.FormattedString(this, formattedString.format);

View File

@ -509,7 +509,7 @@ Zotero.Integration.SOAP = new function() {
/*
* sets document preferences
* ACCEPTS: (sessionID)?
* RETURNS: sessionID, styleID, style-class
* RETURNS: sessionID, styleID, style-class, has-bibliography, use-endnotes
*/
function setDocPrefs(vars) {
var io = new function() {
@ -549,7 +549,6 @@ Zotero.Integration.Session = function(styleID, useEndnotes) {
}
if(useEndnotes) {
this.useEndnotes = useEndnotes;
Zotero.debug("the answer is "+useEndnotes);
}
this.citationSet = new Zotero.Integration.CitationSet(this.style);
@ -760,7 +759,6 @@ Zotero.Integration.CitationFactory.prototype.updateItems = function(citationSet,
}
}
Zotero.debug(disambiguation);
this.style.preprocessItems(this.items);
var tempCache = new Object();

View File

@ -1193,7 +1193,9 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
}
// create short title
if(item.shortTitle === undefined && Zotero.ItemFields.isValidForType("shortTitle", typeID)) {
if(this.type == "web" &&
item.shortTitle === undefined &&
Zotero.ItemFields.isValidForType("shortTitle", typeID)) {
// get field id
var fieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, "title");
// get title

View File

@ -1,4 +1,4 @@
-- 231
-- 232
-- ***** 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-05-31 20:00:00'));
REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-06-10 16:54:12'));
REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2007-03-21 15:26:54', '1', '100', '4', 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon',
'function detectWeb(doc, url) {
@ -6428,7 +6428,7 @@ function doWeb(doc, url) {
}
}');
REPLACE INTO translators VALUES ('5eacdb93-20b9-4c46-a89b-523f62935ae4', '1.0.0b3.r1', '', '2007-05-15 22:00:00', '1', '100', '4', 'HighWire', 'Simon Kornblith', '^http://[^/]+/(?:cgi/searchresults|cgi/search|cgi/content/(?:abstract|full|short|summary)/[^/]+/[0-9]+/[0-9]+|current.dtl$|content/vol[0-9]+/issue[0-9]+/(?:index.dtl)?$)',
REPLACE INTO translators VALUES ('5eacdb93-20b9-4c46-a89b-523f62935ae4', '1.0.0b3.r1', '', '2007-06-10 16:54:12', '1', '100', '4', 'HighWire', 'Simon Kornblith', '^http://[^/]+/(?:cgi/searchresults|cgi/search|cgi/content/(?:abstract|full|short|summary)|current.dtl$|content/vol[0-9]+/issue[0-9]+/(?:index.dtl)?$)',
'function detectWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
@ -10939,7 +10939,7 @@ function doExport() {
}
}');
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-03-23 19:25:00', 'American Psychological Association',
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-06-10 16:54:12', '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">
@ -11003,8 +11003,8 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</access>
</defaults>
<citation prefix="(" suffix=")" delimiter="; ">
<et-al min-authors="6" use-first="6" position="first"/>
<et-al min-authors="6" use-first="1" position="subsequent"/>
<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">
@ -11431,7 +11431,7 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl
</citation>
</style>');
REPLACE INTO csl VALUES('http://www.zotero.org/namespaces/CSL/chicago-note-bibliography.csl', '2007-04-25 23:40:00', 'Chicago Manual of Style (Note with Bibliography)',
REPLACE INTO csl VALUES('http://www.zotero.org/namespaces/CSL/chicago-note-bibliography.csl', '2007-06-10 16:54:12', 'Chicago Manual of Style (Note with Bibliography)',
'<?xml version="1.0" encoding="UTF-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="note" xml:lang="en">
<info>
@ -11489,7 +11489,22 @@ REPLACE INTO csl VALUES('http://www.zotero.org/namespaces/CSL/chicago-note-bibli
<et-al min-authors="3" use-first="1"/>
<layout>
<item suffix=".">
<author form="short"/>
<author form="short">
<name and="text" sort-separator=", " delimiter=", "/>
</author>
<conditional>
<if type="book">
<titles prefix=", " font-style="italic" form="short"/>
</if><else>
<titles prefix=", " quotes="true" form="short"/>
</else>
</conditional>
<pages prefix=", "/>
</item>
<item suffix="." position="subsequent" ibid="true">
<author form="short">
<name and="text" sort-separator=", " delimiter=", "/>
</author>
<conditional>
<if type="book">
<titles prefix=", " font-style="italic" form="short"/>