commit feff0aa531994a77b62b6710534575650e83f0a2
parent 46fa6484a56c2cceb66f83bb8b28fc908a977d73
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 14 Aug 2006 20:34:13 +0000
closes #53, export to footnote or bibliography
closes #180, make all contextual menu export/create bibliography options work right
also:
- add Chicago Note style output
- unregister RDF data sources from cache after import
Diffstat:
4 files changed, 386 insertions(+), 101 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/fileInterface.js b/chrome/chromeFiles/content/scholar/fileInterface.js
@@ -2,13 +2,16 @@ Scholar_File_Interface = new function() {
var _unresponsiveScriptPreference, _importCollection;
this.exportFile = exportFile;
+ this.exportProject = exportProject;
+ this.exportItems = exportItems;
this.importFile = importFile;
this.bibliographyFromProject = bibliographyFromProject;
+ this.bibliographyFromItems = bibliographyFromItems;
/*
* Creates Scholar.Translate instance and shows file picker for file export
*/
- function exportFile() {
+ function exportFile(items) {
var translation = new Scholar.Translate("export");
var translators = translation.getTranslators();
@@ -21,6 +24,9 @@ Scholar_File_Interface = new function() {
}
var rv = fp.show();
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
+ if(items) {
+ translation.setItems(items);
+ }
translation.setLocation(fp.file);
translation.setTranslator(translators[fp.filterIndex]);
translation.setHandler("options", _exportOptions);
@@ -35,6 +41,26 @@ Scholar_File_Interface = new function() {
}
/*
+ * exports a collection
+ */
+ function exportProject() {
+ var collection = ScholarPane.getSelectedCollection();
+ if(!collection) throw("no collection currently selected");
+
+ exportFile(Scholar.getItems(collection.getID()));
+ }
+
+ /*
+ * exports items
+ */
+ function exportItems() {
+ var items = ScholarPane.getSelectedItems();
+ if(!items || !items.length) throw("no items currently selected");
+
+ exportFile(items);
+ }
+
+ /*
* closes items exported indicator
*/
function _exportOptions(obj, options) {
@@ -145,16 +171,26 @@ Scholar_File_Interface = new function() {
}
/*
- * Creates a bibliography
+ * Creates a bibliography from a project
*/
function bibliographyFromProject() {
var collection = ScholarPane.getSelectedCollection();
- if(!collection) throw("error in bibliographyFromProject: no collection currently selected");
+ if(!collection) throw("no collection currently selected");
_doBibliographyOptions(Scholar.getItems(collection.getID()));
}
/*
+ * Creates a bibliography from a items
+ */
+ function bibliographyFromItems() {
+ var items = ScholarPane.getSelectedItems();
+ if(!items || !items.length) throw("no items currently selected");
+
+ _doBibliographyOptions(items);
+ }
+
+ /*
* Shows bibliography options and creates a bibliography
*/
function _doBibliographyOptions(items) {
diff --git a/chrome/chromeFiles/content/scholar/xpcom/cite.js b/chrome/chromeFiles/content/scholar/xpcom/cite.js
@@ -68,17 +68,46 @@ CSL = function(csl) {
}
// load defaults from CSL
this._parseFieldDefaults(this._csl.defaults);
+ Scholar.debug(this._defaults);
- // load options
- this._opt = this._parseOptions(this._csl.bibliography);
+ // decide whether to parse bibliography, or, if none exists, citation
+ if(this._csl.bibliography.length()) {
+ var cite = this._csl.bibliography;
+ this._parseBibliographyOptions();
+
+ this._itemElement = this._csl.bibliography.layout.item;
+ } else {
+ var cite = this._csl.citation;
+ this._parseCitationOptions();
+
+ // find the type item without position="subsequent"
+ var itemElements = this._csl.citation.layout.item;
+ for each(var itemElement in itemElements) {
+ if(itemElement.@position.toString() != "subsequent") {
+ this._itemElement = itemElement;
+ break;
+ }
+ }
+ if(!this._itemElement) {
+ throw("no primary item found in citation. cannot cite.");
+ }
+ }
// create an associative array of available types
- this._types = new Object();
- this._serializations = new Object();
- for each(var type in this._csl.bibliography.layout.item.choose.type) {
- this._types[type.@name] = true;
- this._serializations[type.@name] = new Object();
+ if(this._itemElement.choose) {
+ this._types = new Object();
+ this._serializations = new Object();
+ for each(var type in this._itemElement.choose.type) {
+ this._types[type.@name] = true;
+ this._serializations[type.@name] = new Object();
+ }
+ } else {
+ // if there's only one type, bind it to index 0
+ this._serializations[0] = new Object();
+ this._types[0] = this._parseFields(this._itemElement.children(), 0);
}
+
+ Scholar.debug(this._types);
}
/*
@@ -90,10 +119,12 @@ CSL.prototype.createBibliography = function(items, format) {
this._preprocessItems(items);
// sort by sort order
- var me = this;
- items.sort(function(a, b) {
- return me._compareItem(a, b);
- });
+ if(this._opt.sortOrder) {
+ var me = this;
+ items.sort(function(a, b) {
+ return me._compareItem(a, b);
+ });
+ }
// disambiguate items
this._disambiguateItems(items);
@@ -108,31 +139,62 @@ CSL.prototype.createBibliography = function(items, format) {
}
// determine mapping
- if(CSL._optionalTypeMappings[item.itemType]
- && this._types[CSL._optionalTypeMappings[item.itemType]]) {
- if(this._types[CSL._optionalTypeMappings[item.itemType]] === true) {
- // exists but not yet processed
- this._parseReferenceType(CSL._optionalTypeMappings[item.itemType]);
- }
-
- var typeName = CSL._optionalTypeMappings[item.itemType];
- } else {
- if(this._types[CSL._fallbackTypeMappings[item.itemType]] === true) {
- this._parseReferenceType(CSL._fallbackTypeMappings[item.itemType]);
+ if(!this._types[0]) { // multiple types
+ if(CSL._optionalTypeMappings[item.itemType]
+ && this._types[CSL._optionalTypeMappings[item.itemType]]) {
+ // try preferred types first
+ if(this._types[CSL._optionalTypeMappings[item.itemType]] === true) {
+ // exists but not yet processed
+ this._parseReferenceType(CSL._optionalTypeMappings[item.itemType]);
+ }
+
+ var typeName = CSL._optionalTypeMappings[item.itemType];
+ } else {
+ // otherwise, use fallback types
+ if(this._types[CSL._fallbackTypeMappings[item.itemType]] === true) {
+ this._parseReferenceType(CSL._fallbackTypeMappings[item.itemType]);
+ }
+
+ var typeName = CSL._fallbackTypeMappings[item.itemType];
}
-
- var typeName = CSL._fallbackTypeMappings[item.itemType];
+ } else { // only one element
+ var typeName = 0;
}
var type = this._types[typeName];
var string = "";
- for(var i in type) {
- string += this._getFieldValue(type[i].name, type[i], item, format, typeName);
+ for(var j in type) {
+ var value = this._getFieldValue(type[j].name, type[j], item, format, typeName);
+
+ if(this._opt.format && this._opt.format.delimiter && string && value) {
+ // add delimiter before if one exists, and this isn't the first
+ // element with content
+ string += this._opt.format.delimiter;
+ }
+ string += value;
+ }
+
+ if(this._opt.format) {
+ // add citation prefix or suffix
+ if(this._opt.format.prefix) {
+ string = string + this._opt.format.prefix;
+ }
+
+ if(this._opt.format.suffix) {
+ string = string + this._opt.format.suffix;
+ }
}
if(format == "HTML") {
- output += '<p style="margin-left:0.5in;text-indent:-0.5in">'+string+'</p>';
+ output += '<p style="margin-left:0.5in;text-indent:-0.5in">';
+
+ if(this._class == "note") {
+ // add superscript number for footnotes
+ output += (parseInt(i)+1).toString()+". ";
+ }
+
+ output += string+'</p>';
}
}
@@ -383,15 +445,17 @@ CSL.prototype._parseFields = function(ref, type) {
this._parseFieldAttrChildren(element, itemDesc);
// add defaults, but only if we're parsing as a reference type
- if(type) {
+ if(type != undefined) {
var fieldDefaults = this._getFieldDefaults(itemDesc.name);
itemDesc = this._merge(fieldDefaults, itemDesc);
- itemDesc = this._merge(this._opt.format, itemDesc);
+ if(this._opt.inheritFormat) {
+ itemDesc = this._merge(this._opt.inheritFormat, itemDesc);
+ }
// create serialized representation
itemDesc._serialized = this._serializeElement(itemDesc.name, itemDesc);
// add to serialization for type
- this._serializations[itemDesc._serialized] = itemDesc;
+ this._serializations[type][itemDesc._serialized] = itemDesc;
}
// parse group children
@@ -400,12 +464,12 @@ CSL.prototype._parseFields = function(ref, type) {
// don't bother merging fieldDefaults
itemDesc.children[i] = this._merge(this._getFieldDefaults(itemDesc.children[i].name),
itemDesc.children[i]);
- if(type) {
+ if(type != undefined) {
// serialize children
itemDesc.children[i]._serialized = this._serializeElement(itemDesc.children[i].name,
itemDesc.children[i]);
// add to serialization for type
- this._serializations[itemDesc._serialized] = itemDesc;
+ this._serializations[type][itemDesc._serialized] = itemDesc;
}
}
}
@@ -416,22 +480,61 @@ CSL.prototype._parseFields = function(ref, type) {
return typeDesc;
}
+CSL.prototype._parseEtAl = function(etAl) {
+ if(etAl.length()) {
+ this._opt.etAl = new Object();
+
+ if(etAl.length() > 1) {
+ // separate first and subsequent et als
+ for each(var etAlElement in etAl) {
+ if(etAlElement.@position == "subsequent") {
+ this._opt.subsequentEtAl = new Object();
+ this._opt.subsequentEtAl.minCreators = parseInt(etAlElement['@min-authors']);
+ this._opt.subsequentEtAl.useFirst = parseInt(etAlElement['@use-first']);
+ } else {
+ var parseElement = etAlElement;
+ }
+ }
+ } else {
+ var parseElement = etAl;
+ }
+
+ this._opt.etAl.minCreators = parseInt(parseElement['@min-authors']);
+ this._opt.etAl.useFirst = parseInt(parseElement['@use-first']);
+ }
+}
+
/*
* parses cs-format attributes into just a prefix and a suffix; accepts an
* optional array of cs-format
*/
-CSL.prototype._parseOptions = function(bibliography) {
- var opt = new Object();
+CSL.prototype._parseBibliographyOptions = function() {
+ var bibliography = this._csl.bibliography;
+ this._opt = new Object();
+
+ // global prefix and suffix format information
+ this._opt.inheritFormat = new Array();
+ for each(var attribute in bibliography.layout.item.attributes()) {
+ this._opt.inheritFormat[attribute.name()] = attribute.toString();
+ }
+
+ // sections (TODO)
+ this._opt.sections = [{groupBy:"default",
+ heading:bibliography.layout.heading.text["@term-name"].toString()}];
+ for each(var section in bibliography.layout.section) {
+ this._opt.sections.push([{groupBy:section["@group-by"].toString(),
+ heading:section.heading.text["@term-name"].toString()}]);
+ }
// subsequent author substitute
// replaces subsequent occurances of an author with a given string
if(bibliography['@subsequent-author-substitute']) {
- opt.subsequentAuthorSubstitute = bibliography['@subsequent-author-substitute'].toString();
+ this._opt.subsequentAuthorSubstitute = bibliography['@subsequent-author-substitute'].toString();
}
// hanging indent
if(bibliography['@hanging-indent']) {
- opt.hangingIndent = true;
+ this._opt.hangingIndent = true;
}
// sort order
@@ -439,50 +542,48 @@ CSL.prototype._parseOptions = function(bibliography) {
if(algorithm) {
// for classes, use the sort order that
if(algorithm == "author-date") {
- opt.sortOrder = [this._getFieldDefaults("author"),
+ this._opt.sortOrder = [this._getFieldDefaults("author"),
this._getFieldDefaults("date")];
- opt.sortOrder[0].name = "author";
- opt.sortOrder[1].name = "date";
+ this._opt.sortOrder[0].name = "author";
+ this._opt.sortOrder[1].name = "date";
} else if(algorithm == "label") {
- opt.sortOrder = [this._getFieldDefaults("label")];
- opt.sortOrder[0].name = "label";
+ this._opt.sortOrder = [this._getFieldDefaults("label")];
+ this._opt.sortOrder[0].name = "label";
} else if(algorithm == "cited") {
- opt.sortOrder = [this._getFieldDefaults("cited")];
- opt.sortOrder[0].name = "cited";
+ this._opt.sortOrder = [this._getFieldDefaults("cited")];
+ this._opt.sortOrder[0].name = "cited";
}
} else {
- opt.sortOrder = this._parseFields(bibliography.sort, false);
+ this._opt.sortOrder = this._parseFields(bibliography.sort, false);
}
- // et al
- if(bibliography['use-et_al'].length()) {
- opt.etAl = new Object();
- opt.etAl.minCreators = parseInt(bibliography['use-et_al']['@min-authors']);
- opt.etAl.useFirst = parseInt(bibliography['use-et_al']['@use-first']);
- }
+ // parse et al
+ this._parseEtAl(bibliography["use-et_al"]);
+}
+
+/*
+ * parses cs-format attributes into just a prefix and a suffix; accepts an
+ * optional array of cs-format
+ */
+CSL.prototype._parseCitationOptions = function() {
+ var citation = this._csl.citation;
+ this._opt = new Object();
- // sections (TODO)
- opt.sections = [{groupBy:"default",
- heading:bibliography.layout.heading.text["@term-name"].toString()}];
- for each(var section in bibliography.layout.section) {
- opt.sections.push([{groupBy:section["@group-by"].toString(),
- heading:section.heading.text["@term-name"].toString()}]);
- }
+ // parse et al
+ this._parseEtAl(citation["use-et_al"]);
- // global prefix and suffix format information
- opt.format = new Array();
- for each(var attribute in bibliography.layout.item.attributes()) {
- opt.format[attribute.name()] = attribute.toString();
+ // global format information
+ this._opt.format = new Array();
+ for each(var attribute in citation.attributes()) {
+ this._opt.format[attribute.name()] = attribute.toString();
}
-
- return opt;
}
/*
* convert reference types to native structures for speed
*/
CSL.prototype._parseReferenceType = function(reftype) {
- var ref = this._csl.bibliography.layout.item.choose.type.(@name==reftype).children();
+ var ref = this._itemElement.choose.type.(@name==reftype).children();
this._types[reftype] = this._parseFields(ref, reftype);
}
@@ -819,6 +920,9 @@ CSL.prototype._disambiguateItems = function(items) {
usedCitations[citation] = item;
}
+ // add numbers to each
+ item._csl.number = i;
+
// handle subsequent author substitutes
if(this._opt.subsequentAuthorSubstitute && lastAuthor == author) {
item._csl.subsequentAuthorSubstitute = true;
@@ -896,11 +1000,11 @@ CSL.prototype._processCreators = function(type, element, creators, format) {
}
lastName = creators[i].lastName;
- if(((i == 0 && element["name-as-sort-order"] == "first-author")
+ if(((i == 0 && element["name-as-sort-order"] == "first")
|| element["name-as-sort-order"] == "all")
&& child["sort-separator"]) {
- // if this is the first author and author-as-sort-order="first-author"
- // or if this is a subsequent author and author-as-sort-order="all"
+ // if this is the first author and name-as-sort="first"
+ // or if this is a subsequent author and name-as-sort="all"
// then the name gets inverted
authorStrings.push(lastName+child["sort-separator"]+firstName);
} else {
@@ -924,8 +1028,9 @@ 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
- if(maxCreators == 2) {
+ // et al, and name as sort is no
+ if(maxCreators == 2 && element["name-as-sort"] != "first"
+ && element["name-as-sort"] != "all") {
joinString = " ";
}
}
@@ -1068,6 +1173,8 @@ CSL.prototype._getFieldValue = function(name, element, item, format, typeName) {
data = this._formatLocator(null, element, item.ISBN, format);
} else if(name == "doi") {
data = this._formatLocator(null, element, item.DOI, format);
+ } else if(name == "number") {
+ data = this._csl.number;
}
if(data) {
@@ -1086,7 +1193,7 @@ CSL.prototype._getFieldValue = function(name, element, item, format, typeName) {
inheritElement = element;
} else {
// search for elements with the same serialization
- if(typeName && this._serializations[typeName]
+ if(typeName != undefined && this._serializations[typeName]
&& this._serializations[typeName][serialization]) {
inheritElement = this._serializations[typeName][serialization];
} else {
diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js
@@ -36,7 +36,11 @@
* location - the location of the target (read-only; set with setLocation)
* for import/export - this is an instance of nsILocalFile
* for web - this is a URL
- * item - item to be used for searching (read-only; set with setItem)
+ * search - item (in toArray() format) to extrapolate data for (read-only; set
+ * with setSearch).
+ * items - items (in Scholar.Item format) to be exported. if this is empty,
+ * Scholar will export all items in the library (read-only; set with
+ * setItems). setting items disables export of collections.
* path - the path to the target; for web, this is the same as location
* string - the string content to be used as a file.
* saveItem - whether new items should be saved to the database. defaults to
@@ -119,8 +123,15 @@ Scholar.Translate.prototype.setBrowser = function(browser) {
/*
* sets the item to be used for searching
*/
-Scholar.Translate.prototype.setItem = function(item) {
- this.item = item;
+Scholar.Translate.prototype.setSearch = function(search) {
+ this.search = search;
+}
+
+/*
+ * sets the item to be used for export
+ */
+Scholar.Translate.prototype.setItems = function(items) {
+ this.items = items;
}
/*
@@ -278,7 +289,7 @@ Scholar.Translate.prototype.getTranslators = function() {
var sql = "SELECT translatorID, label, target, detectCode FROM translators WHERE type IN ("+this._numericTypes+") ORDER BY target IS NULL";
var translators = Scholar.DB.query(sql);
- if(!this.location && !this.item) {
+ if(!this.location && !this.search) {
return translators; // no need to see which can translate, because
// we don't have a location yet (for export or
// import dialog)
@@ -575,7 +586,7 @@ Scholar.Translate.prototype._canTranslate = function(translator, ignoreExtension
if(this.type == "web") {
returnValue = this._sandbox.detectWeb(this.browser.contentDocument, this.location);
} else if(this.type == "search") {
- returnValue = this._sandbox.detectSearch(this.item);
+ returnValue = this._sandbox.detectSearch(this.search);
} else if(this.type == "import") {
returnValue = this._sandbox.detectImport();
} else if(this.type == "export") {
@@ -707,11 +718,28 @@ Scholar.Translate.prototype._translationComplete = function(returnValue) {
} else {
Scholar.debug("translation complete");
- // call handler
- this._runHandler("done", returnValue);
+ // serialize RDF and unregister dataSource
+ if(this._rdf) {
+ if(this._rdf.serializer) {
+ this._rdf.serializer.Serialize(this._streams[0]);
+ }
+
+ try {
+ var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].
+ getService(Components.interfaces.nsIRDFService);
+ rdfService.UnregisterDataSource(this._rdf.dataSource);
+ } catch(e) {
+ Scholar.debug("could not unregister data source");
+ }
+
+ delete this._rdf.dataSource;
+ }
// close open streams
this._closeStreams();
+
+ // call handlers
+ this._runHandler("done", returnValue);
}
}
}
@@ -940,7 +968,7 @@ Scholar.Translate.prototype._web = function() {
*/
Scholar.Translate.prototype._search = function() {
try {
- this._sandbox.doSearch(this.item);
+ this._sandbox.doSearch(this.search);
} catch(e) {
Scholar.debug(e+' in executing code for '+this.translator[0].label);
return false;
@@ -971,6 +999,8 @@ Scholar.Translate.prototype._import = function() {
Scholar.Translate.prototype._importConfigureIO = function() {
if(this._storageStream) {
if(this._configOptions.dataMode == "rdf") {
+ this._rdf = new Object();
+
// read string out of storage stream
var sStream = Components.classes["@mozilla.org/scriptableinputstream;1"].
createInstance(Components.interfaces.nsIScriptableInputStream);
@@ -980,7 +1010,7 @@ Scholar.Translate.prototype._importConfigureIO = function() {
var IOService = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService);
- var dataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
+ this._rdf.dataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
createInstance(Components.interfaces.nsIRDFDataSource);
var parser = Components.classes["@mozilla.org/rdf/xml-parser;1"].
createInstance(Components.interfaces.nsIRDFXMLParser);
@@ -990,7 +1020,7 @@ Scholar.Translate.prototype._importConfigureIO = function() {
parser.parseString(dataSource, baseURI, str);
// make an instance of the RDF handler
- this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(dataSource);
+ this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(this._rdf.dataSource);
} else {
this._storageStreamFunctions(true);
@@ -1003,6 +1033,8 @@ Scholar.Translate.prototype._importConfigureIO = function() {
}
} else {
if(this._configOptions.dataMode == "rdf") {
+ this._rdf = new Object()
+
var IOService = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService);
var fileHandler = IOService.getProtocolHandler("file")
@@ -1011,10 +1043,10 @@ Scholar.Translate.prototype._importConfigureIO = function() {
var RDFService = Components.classes['@mozilla.org/rdf/rdf-service;1']
.getService(Components.interfaces.nsIRDFService);
- var dataSource = RDFService.GetDataSourceBlocking(URL);
+ this._rdf.dataSource = RDFService.GetDataSourceBlocking(URL);
// make an instance of the RDF handler
- this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(dataSource);
+ this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(this._rdf.dataSource);
} else {
// open file and set read methods
var fStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
@@ -1059,12 +1091,16 @@ Scholar.Translate.prototype._export = function() {
this._exportConfigureIO();
// get items
- this._itemsLeft = Scholar.getItems();
+ if(this.items) {
+ this._itemsLeft = this.items;
+ } else {
+ this._itemsLeft = Scholar.getItems();
+ }
// run handler for items available
this._runHandler("itemCount", this._itemsLeft.length);
// get collections, if requested
- if(this._configOptions.getCollections) {
+ if(this._configOptions.getCollections && !this.items) {
this._collectionsLeft = Scholar.getCollections();
}
@@ -1090,19 +1126,19 @@ Scholar.Translate.prototype._exportConfigureIO = function() {
this._streams.push(fStream);
if(this._configOptions.dataMode == "rdf") { // rdf io
+ this._rdf = new Object();
+
// create data source
- var dataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=xml-datasource"].
+ this._rdf.dataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=xml-datasource"].
createInstance(Components.interfaces.nsIRDFDataSource);
// create serializer
- var serializer = Components.classes["@mozilla.org/rdf/xml-serializer;1"].
+ this._rdf.serializer = Components.classes["@mozilla.org/rdf/xml-serializer;1"].
createInstance(Components.interfaces.nsIRDFXMLSerializer);
- serializer.init(dataSource);
- serializer.QueryInterface(Components.interfaces.nsIRDFXMLSource);
+ this._rdf.serializer.init(this._rdf.dataSource);
+ this._rdf.serializer.QueryInterface(Components.interfaces.nsIRDFXMLSource);
// make an instance of the RDF handler
- this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(dataSource, serializer);
-
- this.setHandler("done", function() { serializer.Serialize(fStream) });
+ this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(this._rdf.dataSource, this._rdf.serializer);
} else { // regular io; write just writes to file
this._sandbox.Scholar.write = function(data) { fStream.write(data, data.length) };
}
@@ -1125,11 +1161,11 @@ Scholar.Translate.prototype._exportGetItem = function() {
* gets the next item to collection (called as Scholar.nextCollection() from code)
*/
Scholar.Translate.prototype._exportGetCollection = function() {
- if(!this._collectionsLeft) {
+ if(!this._configOptions.getCollections) {
throw("getCollections configure option not set; cannot retrieve collection");
}
- if(this._collectionsLeft.length != 0) {
+ if(this._collectionsLeft && this._collectionsLeft.length != 0) {
var returnItem = this._collectionsLeft.shift();
var collection = new Object();
collection.id = returnItem.getID();
@@ -1149,11 +1185,11 @@ Scholar.Translate.prototype._initializeInternalIO = function() {
if(this.type == "import" || this.type == "export") {
if(this._configOptions.dataMode == "rdf") {
// use an in-memory data source for internal IO
- var dataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
+ this._rdf.dataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
createInstance(Components.interfaces.nsIRDFDataSource);
// make an instance of the RDF handler
- this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(dataSource);
+ this._sandbox.Scholar.RDF = new Scholar.Translate.RDF(this._rdf.dataSource);
} else {
this._createStorageStream();
this._storageStreamFunctions(true, true);
diff --git a/scrapers.sql b/scrapers.sql
@@ -1,4 +1,4 @@
--- 46
+-- 47
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-11 11:18:00'));
@@ -2414,7 +2414,7 @@ function retrieveNextCOinS(needFullItems, newItems) {
search.setHandler("done", function() {
retrieveNextCOinS(needFullItems, newItems);
});
- search.setItem(item);
+ search.setSearch(item);
// look for translators
var translators = search.getTranslators();
@@ -4848,7 +4848,7 @@ function doImport(url) { // the URL is actually here for other translators
}
}');
-REPLACE INTO "csl" VALUES('id-not-yet-given', '2006-08-12 19:22:00', 'American Psychological Association',
+REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2006-08-12 19:22:00', 'APA',
'<?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">
@@ -5001,4 +5001,110 @@ REPLACE INTO "csl" VALUES('id-not-yet-given', '2006-08-12 19:22:00', 'American P
</item>
</layout>
</bibliography>
+</style>');
+
+REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl', '2006-08-12 19:22:00', 'Chicago (Footnote)',
+'<?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">
+ <info>
+ <title>Chicago Note Sans Reference List</title>
+ <id>http://purl.org/net/xbiblio/csl/styles/chicago-note.csl</id>
+ <author>
+ <name>Bruce D’Arcus</name>
+ <email>bdarcus@sourceforge.net</email>
+ </author>
+ <updated>2006-08-03T04:35:20-07:00</updated>
+ <summary>The note-without-bibliography variant of the Chicago style.</summary>
+ </info>
+ <defaults>
+ <contributor>
+ <label suffix=". " text-transform="lowercase"/>
+ <name and="text"/>
+ </contributor>
+ <author>
+ <name and="text"/>
+ <label prefix = ", " suffix="." text-transform="lowercase"/>
+ <substitute>
+ <choose>
+ <editor/>
+ <translator/>
+ </choose>
+ </substitute>
+ </author>
+ <locator>
+ <number/>
+ </locator>
+ <titles>
+ <title/>
+ </titles>
+ <date>
+ <year/>
+ </date>
+ <publisher>
+ <place suffix=": "/>
+ <name/>
+ </publisher>
+ <access>
+ <url/>
+ <date prefix=" "/>
+ </access>
+ </defaults>
+ <citation suffix=".">
+ <et-al min-authors="4" use-first="1"/>
+ <layout>
+ <item>
+ <choose>
+ <type name="book">
+ <author suffix=", "/>
+ <titles font-style="italic"/>
+ <editor prefix=", "/>
+ <translator prefix=", "/>
+ <group prefix=" (" suffix=")" delimiter=", ">
+ <publisher/>
+ <date/>
+ </group>
+ <pages prefix=", "/>
+ </type>
+ <type name="chapter">
+ <author suffix=", "/>
+ <titles prefix="“" suffix=",” "/>
+ <group class="container">
+ <text term-name="in" text-transform="lowercase"/>
+ <titles relation="container" prefix=" " font-style="italic"/>
+ <editor prefix=", "/>
+ <translator prefix=", "/>
+ <pages prefix=", "/>
+ <group prefix=" (" suffix=")" delimiter=", ">
+ <publisher/>
+ <date/>
+ </group>
+ </group>
+ </type>
+ <type name="journal-article">
+ <author suffix=", "/>
+ <titles prefix="“" suffix=",” "/>
+ <titles relation="container" font-style="italic"/>
+ <volume prefix=" "/>
+ <issue prefix=" (" suffix=")"/>
+ <pages prefix=": "/>
+ </type>
+ <type name="article">
+ <author suffix=", "/>
+ <titles prefix="“" suffix=",” "/>
+ <titles relation="container" font-style="italic"/>
+ <date prefix=", ">
+ <day suffix=" "/>
+ <month suffix=" " text-transform="capitalize"/>
+ <year/>
+ </date>
+ </type>
+ </choose>
+ </item>
+ <item position="subsequent" ibid="true">
+ <author/>
+ <title prefix=", "/>
+ </item>
+ </layout>
+ </citation>
</style>');
\ No newline at end of file