commit 1c21bddbfc25e53c92074ccf24e52772841e57b8
parent 68c480b7b53234c2211dcbf9534beab4d9c9455b
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 30 Aug 2006 04:00:19 +0000
- modifications to citation engine's handling of localized strings
- added the missing integrationDocPrefs.xul file
Diffstat:
4 files changed, 168 insertions(+), 138 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/integrationDocPrefs.xul b/chrome/chromeFiles/content/scholar/integrationDocPrefs.xul
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
+<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="&integration.docPrefs.title;" buttons="accept"
+ ondialogaccept="Scholar_File_Interface_Bibliography.acceptSelection()"
+ id="scholar-bibliography"
+ onload="Scholar_File_Interface_Bibliography.init()">
+
+<script src="include.js"/>
+<script src="bibliography.js"/>
+
+<hbox>
+ <label value="&bibliography.style.label;" control="style-menu"/>
+ <menulist id="style-menu">
+ <menupopup id="style-popup">
+ </menupopup>
+ </menulist>
+</hbox>
+</dialog>
+\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/xpcom/cite.js b/chrome/chromeFiles/content/scholar/xpcom/cite.js
@@ -70,7 +70,7 @@ Scholar.Cite = new function() {
* from the cache
*/
function _getCSL(cslID) {
- if(_lastStyle != cslID) {
+ if(_lastStyle != cslID || Scholar.Prefs.get("cacheTranslatorData") == false) {
// get style
var sql = "SELECT csl FROM csl WHERE cslID = ?";
var style = Scholar.DB.valueQuery(sql, [cslID]);
@@ -114,6 +114,14 @@ CSL = function(csl) {
// parse bibliography options, since these will be necessary for
// disambiguation purposes even for citations
this._parseBibliographyOptions();
+ // if no bibliography exists, parse citation element as bibliography
+ if(!this._bib) {
+ Scholar.debug("CSL: using citation element");
+ if(!this._cit) {
+ this._parseCitationOptions();
+ }
+ this._bib = this._cit;
+ }
}
/*
@@ -137,11 +145,11 @@ CSL.prototype.setItems = function(items) {
Scholar.debug("CSL: items set to "+serializedItemString);
- if(serializedItemString != this._serializedItemString) {
+ //if(serializedItemString != this._serializedItemString) {
// only re-process if there are new items
this._serializedItemString = serializedItemString;
this._preprocessItems();
- }
+ //}
}
/*
@@ -182,15 +190,6 @@ CSL.prototype.createCitation = function(items, format) {
* (items is expected to be an array of items)
*/
CSL.prototype.createBibliography = function(format) {
- if(!this._bib) {
- // decide whether to parse bibliography, or, if none exists, citation
- Scholar.debug("CSL: using citation element");
- if(!this._cit) {
- this._parseCitationOptions();
- }
- this._bib = this._cit;
- }
-
// preprocess this._items
Scholar.debug("CSL: preprocessing items");
this._preprocessItems();
@@ -340,7 +339,7 @@ CSL.prototype._parseLocales = function(termXML) {
// ugh. copy default array. javascript dumb.
for(var i in CSL._defaultTerms) {
termArray[i] = new Object();
- for(var j in CSL._defaulTerms[i]) {
+ for(var j in CSL._defaultTerms[i]) {
if(typeof(CSL._defaultTerms[i]) == "object") {
termArray[i][j] = [CSL._defaultTerms[i][j][0],
CSL._defaultTerms[i][j][1]];
@@ -352,50 +351,45 @@ CSL.prototype._parseLocales = function(termXML) {
}
// loop through terms
- this._parseTerms(locale.term, termArray["default"]);
- // loop through term sets
- locale._termSets = new Object();
- for each(var termSet in locale["term-set"]) {
- var name = termSet.@name.toString();
- if(!termArray[name]) {
- termArray[name] = new Object();
- }
-
- this._parseTerms(termSet.term, termArray[name]);
- }
-
- return termArray;
-}
-
-CSL.prototype._parseTerms = function(terms, termArray) {
- for each(var term in terms) {
+ for each(var term in locale.term) {
var name = term.@name.toString();
if(!name) {
throw("citations cannot be generated: no name defined on term in CSL");
}
+ // unless otherwise specified, assume "long" form
+ var form = term.@form.toString();
+ if(!form) {
+ var form = "long";
+ }
+ if(!termArray[form]) {
+ termArray[form] = new Object();
+ }
var single = term.single.text().toString();
var multiple = term.multiple.text().toString();
if(single || multiple) {
- if((single && multiple) // if there's both elements or
- || !termArray[name]) { // no previously defined value
- termArray[name] = [single, multiple];
+ if((single && multiple) // if there's both elements or
+ || !termArray[form][name]) { // no previously defined value
+ termArray[form][name] = [single, multiple];
} else {
if(typeof(termArray[name]) != "object") {
- termArray[name] = [termArray[name], termArray[name]];
+ // if old object was just a single value, make it two copies
+ termArray[form][name] = [termArray[form][name], termArray[form][name]];
}
// redefine either single or multiple
if(single) {
- termArray[name][0] = single;
+ termArray[form][name][0] = single;
} else {
- termArray[name][1] = multiple;
+ termArray[form][name][1] = multiple;
}
}
} else {
- termArray[name] = term.text().toString();
+ termArray[form][name] = term.text().toString();
}
}
+
+ return termArray;
}
/*
@@ -558,6 +552,10 @@ CSL.prototype._parseEtAl = function(etAl, bibCitElement) {
* optional array of cs-format
*/
CSL.prototype._parseBibliographyOptions = function() {
+ if(!this._csl.bibliography.length()) {
+ return;
+ }
+
var bibliography = this._csl.bibliography;
this._bib = new Object();
@@ -727,24 +725,24 @@ CSL.prototype._getFieldDefaults = function(elementName) {
/*
* gets a term, in singular or plural form
*/
-CSL.prototype._getTerm = function(term, plural, termSet) {
- if(!termSet) {
- termSet = "default";
+CSL.prototype._getTerm = function(term, plural, form) {
+ if(!form) {
+ form = "long";
}
- if(!this._terms[termSet][term]) {
+ if(!this._terms[form][term]) {
return "";
}
- if(typeof(this._terms[termSet][term]) == "object") { // singular and plural forms
- // are available
+ if(typeof(this._terms[form][term]) == "object") { // singular and plural forms
+ // are available
if(plural) {
- return this._terms[termSet][term][1];
+ return this._terms[form][term][1];
} else {
- return this._terms[termSet][term][0];
+ return this._terms[form][term][0];
}
}
- return this._terms[termSet][term];
+ return this._terms[form][term];
}
/*
@@ -915,10 +913,10 @@ CSL.prototype._formatLocator = function(identifier, element, number, format) {
} else if(child.name == "text") {
var plural = (identifier && (number.indexOf(",") != -1
|| number.indexOf("-") != -1));
- string = this._getTerm(child["term-name"], plural);
+ string = this._getTerm(child["term-name"], plural, child["form"]);
} else if(identifier && child.name == "label") {
var plural = (number.indexOf(",") != -1 || number.indexOf("-") != -1);
- string = this._getTerm(identifier, plural, child["term-set"]);
+ string = this._getTerm(identifier, plural, child["form"]);
}
if(string) {
@@ -1216,7 +1214,7 @@ CSL.prototype._processCreators = function(type, element, creators, format, bibCi
}
string = authorStrings.join(joinString);
} else if(child.name == "label") {
- string = this._getTerm(type, (maxCreators != 1), child["term-set"]);
+ string = this._getTerm(type, (maxCreators != 1), child["form"]);
}
diff --git a/chrome/chromeFiles/locale/en-US/scholar/locales.xml b/chrome/chromeFiles/locale/en-US/scholar/locales.xml
@@ -8,77 +8,81 @@
<term name="references">References</term>
<term name="and">and</term>
<term name="et-al">et al.</term>
- <term-set name="locators">
- <term name="page">
- <single>page</single>
- <multiple>pages</multiple>
- </term>
- <term name="paragraph">
- <single>paragraph</single>
- <multiple>paragraph</multiple>
- </term>
- </term-set>
- <term-set name="locators-short">
- <term name="page">
- <single>p</single>
- <multiple>pp</multiple>
- </term>
- <term name="paragraph">
- <single>¶</single>
- <multiple>¶¶</multiple>
- </term>
- </term-set>
- <term-set name="roles">
- <term name="editor">
- <single>editor</single>
- <multiple>editors</multiple>
- </term>
- <term name="translator">
- <single>translator</single>
- <multiple>translators</multiple>
- </term>
- </term-set>
- <term-set name="roles-short">
- <term name="editor">
- <single>ed</single>
- <multiple>eds</multiple>
- </term>
- <term name="translator">
- <single>tran</single>
- <multiple>trans</multiple>
- </term>
- </term-set>
- <term-set name="roles-verb">
- <term name="editor">edited by</term>
- <term name="translator">translated by</term>
- </term-set>
- <term-set name="months">
- <term name="month-01">January</term>
- <term name="month-02">February</term>
- <term name="month-03">March</term>
- <term name="month-04">April</term>
- <term name="month-05">May</term>
- <term name="month-06">June</term>
- <term name="month-07">July</term>
- <term name="month-08">August</term>
- <term name="month-09">September</term>
- <term name="month-10">October</term>
- <term name="month-11">November</term>
- <term name="month-12">December</term>
- </term-set>
- <term-set name="months-short">
- <term name="month-01">Jan</term>
- <term name="month-02">Feb</term>
- <term name="month-03">Mar</term>
- <term name="month-04">Apr</term>
- <term name="month-05">May</term>
- <term name="month-06">Jun</term>
- <term name="month-07">Jul</term>
- <term name="month-08">Aug</term>
- <term name="month-09">Sep</term>
- <term name="month-10">Oct</term>
- <term name="month-11">Nov</term>
- <term name="month-12">Dec</term>
- </term-set>
+
+ <!-- LONG LOCATOR FORMS -->
+ <term name="page">
+ <single>page</single>
+ <multiple>pages</multiple>
+ </term>
+ <term name="paragraph">
+ <single>paragraph</single>
+ <multiple>paragraph</multiple>
+ </term>
+ <term name="volume">volume</term>
+ <term name="issue">issue</term>
+
+ <!-- SHORT LOCATOR FORMS -->
+ <term name="page" form="short">
+ <single>p</single>
+ <multiple>pp</multiple>
+ </term>
+ <term name="paragraph" form="short">
+ <single>¶</single>
+ <multiple>¶¶</multiple>
+ </term>
+ <term name="volume" form="short">vol</term>
+ <term name="issue" form="short">iss</term>
+
+ <!-- LONG ROLE FORMS -->
+ <term name="editor">
+ <single>editor</single>
+ <multiple>editors</multiple>
+ </term>
+ <term name="translator">
+ <single>translator</single>
+ <multiple>translators</multiple>
+ </term>
+
+ <!-- SHORT ROLE FORMS -->
+ <term name="editor" form="short">
+ <single>ed</single>
+ <multiple>eds</multiple>
+ </term>
+ <term name="translator" form="short">
+ <single>tran</single>
+ <multiple>trans</multiple>
+ </term>
+
+ <!-- VERB ROLE FORMS -->
+ <term name="editor" form="verb">edited by</term>
+ <term name="translator" form="verb">translated by</term>
+
+ <!-- LONG MONTH FORMS -->
+ <term name="month-01">January</term>
+ <term name="month-02">February</term>
+ <term name="month-03">March</term>
+ <term name="month-04">April</term>
+ <term name="month-05">May</term>
+ <term name="month-06">June</term>
+ <term name="month-07">July</term>
+ <term name="month-08">August</term>
+ <term name="month-09">September</term>
+ <term name="month-10">October</term>
+ <term name="month-11">November</term>
+ <term name="month-12">December</term>
+
+ <!-- SHORT MOTH FORMS -->
+ <term name="month-01" form="short">Jan</term>
+ <term name="month-02" form="short">Feb</term>
+ <term name="month-03" form="short">Mar</term>
+ <term name="month-04" form="short">Apr</term>
+ <term name="month-05" form="short">May</term>
+ <term name="month-06" form="short">Jun</term>
+ <term name="month-07" form="short">Jul</term>
+ <term name="month-08" form="short">Aug</term>
+ <term name="month-09" form="short">Sep</term>
+ <term name="month-10" form="short">Oct</term>
+ <term name="month-11" form="short">Nov</term>
+ <term name="month-12" form="short">Dec</term>
</locale>
</terms>
\ No newline at end of file
diff --git a/scrapers.sql b/scrapers.sql
@@ -1,4 +1,4 @@
--- 62
+-- 63
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-15 15:42:00'));
@@ -5914,7 +5914,7 @@ function doImport() {
}
}');
-REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2006-08-12 19:22:00', 'APA',
+REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2006-08-29 23:05:00', 'American Psychological Association',
'<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="file:/Users/darcusb/xbiblio/csl/schema/trunk/csl-alt.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="author-date" xml:lang="en">
@@ -5934,16 +5934,16 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
<name>Johan Kool</name>
<email>johankool@users.sourceforge.net</email>
</contributor>
- <updated>2006-08-24T16:30:00+01:00</updated>
+ <updated>2006-08-29T23:05:00+05:00</updated>
</info>
<defaults>
<contributor name-as-sort-order="no">
- <name and="symbol" initialize-with="." delimiter=", "/>
- <label term-set="roles-short" prefix=", " text-transform="capitalize" suffix="."/>
+ <name and="symbol" initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
+ <label form="short" prefix=", " text-transform="capitalize" suffix="."/>
</contributor>
<author name-as-sort-order="all">
- <name and="symbol" sort-separator=", " initialize-with="." delimiter=", "/>
- <label term-set="roles-short" prefix=" (" suffix=".)" text-transform="capitalize"/>
+ <name and="symbol" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
+ <label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
<substitute>
<choose>
<editor/>
@@ -5987,7 +5987,10 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
<et-al min-authors="6" use-first="1" position="subsequent"/>
<layout>
<item>
- <author form="short"/>
+ <author form="short">
+ <name and="symbol" delimiter=", "/>
+ <label form="short" prefix=", " text-transform="capitalize" suffix="."/>
+ </author>
<date prefix=", ">
<year/>
</date>
@@ -6031,17 +6034,17 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
<text term-name="in" text-transform="capitalize"/>
<editor prefix=" " suffix=",">
<name and="symbol" sort-separator=", " initialize-with="."/>
- <label term-set="roles-short" prefix=" (" suffix=")" text-transform="capitalize"/>
+ <label form="short" prefix=" (" suffix=")" text-transform="capitalize"/>
</editor>
<translator prefix=" " suffix=",">
<name and="symbol" sort-separator=", " initialize-with="."/>
- <label term-set="roles-short" prefix=" (" suffix=")" text-transform="capitalize"/>
+ <label form="short" prefix=" (" suffix=")" text-transform="capitalize"/>
</translator>
<titles relation="container" font-style="italic" prefix=" " suffix="."/>
<titles relation="collection" prefix=" " suffix="."/>
<publisher prefix=" "/>
<pages prefix=" (" suffix=")">
- <label term-set="locators-short" text-transform="capitalize" suffix=". "/>
+ <label form="short" text-transform="capitalize" suffix=". "/>
<number/>
</pages>
</group>
@@ -6073,7 +6076,7 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
</bibliography>
</style>');
-REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl', '2006-08-12 19:22:00', 'Chicago (Footnote)',
+REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl', '2006-08-29 23:05:00', 'Chicago Manual of Style (Note)',
'<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="note" xml:lang="en">
@@ -6088,17 +6091,21 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.c
<name>Simon Kornblith</name>
<email>simon@simonster.com</email>
</contributor>
- <updated>2006-08-19T17:12:00-05:00</updated>
+ <contributor>
+ <name>Johan Kool</name>
+ <email>johankool@users.sourceforge.net</email>
+ </contributor>
+ <updated>2006-08-24T16:30:00+01:00</updated>
<summary>The note-without-bibliography variant of the Chicago style.</summary>
</info>
<defaults>
<contributor>
- <label term-set="roles-short" suffix=". " text-transform="lowercase"/>
- <name and="text"/>
+ <label form="short" suffix=". " text-transform="lowercase"/>
+ <name and="text" delimiter=", "/>
</contributor>
<author>
- <name and="text"/>
- <label term-set="roles-short" prefix=", " suffix="." text-transform="lowercase"/>
+ <name and="text" delimiter=", "/>
+ <label form="short" prefix=", " suffix="." text-transform="lowercase"/>
<substitute>
<choose>
<editor/>