- add MLA style

- put text-only version of bibliography on the clipboard, in addition to HTML version (Windows-only).
This commit is contained in:
Simon Kornblith 2006-08-30 06:12:26 +00:00
parent f7aafec402
commit a75c5df70c
4 changed files with 170 additions and 13 deletions

View file

@ -39,6 +39,10 @@ var Scholar_File_Interface_Bibliography = new function() {
if(styleMenu.selectedIndex == -1) {
styleMenu.selectedIndex = 0;
}
if(document.getElementById("copy-to-clipboard") && navigator.appVersion.indexOf('Mac') != -1) {
document.getElementById("copy-to-clipboard").hidden = "true";
}
}
function acceptSelection() {

View file

@ -310,17 +310,23 @@ var Scholar_File_Interface = new function() {
// copy to clipboard
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard);
// add HTML
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = bibliography;
// add data
transferable.addDataFlavor("text/html");
transferable.setTransferData("text/html", str, bibliography.length*2);
// add text
var bibliography = Scholar.Cite.getBibliography(io.style, items, "Text");
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = bibliography;
transferable.addDataFlavor("text/unicode");
transferable.setTransferData("text/unicode", str, bibliography.length*2);
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard);
clipboardService.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
}
}

View file

@ -197,6 +197,7 @@ CSL.prototype.createBibliography = function(format) {
// process this._items
var output = "";
var index = 0;
if(format == "HTML") {
if(this.class == "note") {
output += '<ol>\r\n';
@ -204,7 +205,6 @@ CSL.prototype.createBibliography = function(format) {
output += '<div style="margin-left:0.5in;text-indent:-0.5in;">\r\n';
}
} else if(format == "RTF") {
var index = 0;
output += "{\\rtf\\ansi{\\fonttbl\\f0\\froman Times New Roman;}{\\colortbl;\\red255\\green255\\blue255;}\\pard\\f0";
if(this._bib.hangingIndent) {
output += "\\li720\\fi-720";
@ -216,6 +216,17 @@ CSL.prototype.createBibliography = function(format) {
var item = this._uniqueItems[i];
var string = this._getCitation(item, format, this._bib);
// add format
if(this._bib.format) {
// add citation prefix or suffix
if(this._bib.format.prefix) {
string = this._bib.format.prefix + string ;
}
if(this._bib.format.suffix) {
string += this._bib.format.suffix;
}
}
// add line feeds
if(format == "HTML") {
@ -235,7 +246,11 @@ CSL.prototype.createBibliography = function(format) {
output += index+". ";
}
output += string+"\\\r\n\\\r\n";
} else if(format == "Integration") {
} else {
if(format == "Text" && this.class == "note") {
index++;
output += index+". ";
}
output += string+"\r\n\r\n";
}
}
@ -249,6 +264,9 @@ CSL.prototype.createBibliography = function(format) {
} else if(format == "RTF") {
// drop last 6 characters of output (last two returns)
output = output.substr(0, output.length-6)+"}";
} else {
// drop last 4 characters (last two returns)
output = output.substr(0, output.length-4);
}
return output;
@ -726,6 +744,7 @@ CSL.prototype._getFieldDefaults = function(elementName) {
* gets a term, in singular or plural form
*/
CSL.prototype._getTerm = function(term, plural, form) {
Scholar.debug("CSL: looking up term "+term);
if(!form) {
form = "long";
}
@ -1012,11 +1031,13 @@ CSL.prototype._preprocessItems = function() {
// get data necessary to generate citations before sorting
for(var i in this._uniqueItems) {
var item = this._uniqueItems[i];
var dateModified = item.getField("dateModified");
if(!item._csl) {
if(!item._csl || item._csl.dateModified != dateModified) {
// namespace everything in item._csl so there's no chance of overlap
item._csl = new Object();
item._csl.ignore = new Array();
item._csl.dateModified = dateModified;
// separate item into authors, editors, translators
var creators = this._separateItemCreators(item);
@ -1187,8 +1208,8 @@ CSL.prototype._processCreators = function(type, element, creators, format, bibCi
}
// figure out if we need an "and" or an "et al"
var joinString = ", ";
if(maxCreators > 1) {
var joinString = (child["delimiter"] ? child["delimiter"] : ", ");
if(creators.length > 1) {
if(useEtAl) { // multiple creators and need et al
authorStrings.push(this._getTerm("et-al"));
} else { // multiple creators but no et al
@ -1196,7 +1217,7 @@ CSL.prototype._processCreators = function(type, element, creators, format, bibCi
if(child["and"]) {
if(child["and"] == "symbol") {
var and = "&"
} else {
} else if(child["and"] == "text") {
var and = this._getTerm("and");
}
@ -1342,7 +1363,7 @@ CSL.prototype._getFieldValue = function(name, element, item, format, bibCitEleme
} else if(child.name == "physicalLocation") {
string = item.getField("archiveLocation");
} else if(child.name == "text") {
string = this._getTerm(child["term-name"]);
string = this._getTerm(child["term-name"], false, child["form"]);
}
if(string) {
@ -1392,7 +1413,7 @@ CSL.prototype._getFieldValue = function(name, element, item, format, bibCitEleme
// implode with delimiter
data = childData.join((element["delimiter"] ? element["delimiter"] : ""));
} else if(name == "text") {
data = this._getTerm(element["term-name"]);
data = this._getTerm(element["term-name"], false, element["form"]);
dontEscape = false;
} else if(name == "isbn" || name == "doi") {
var field = item.getField(name.toUpperCase());

View file

@ -1,4 +1,4 @@
-- 63
-- 64
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-15 15:42:00'));
@ -6188,4 +6188,130 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.c
</item>
</layout>
</citation>
</style>');
REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/mla.csl', '2006-08-29 23:05:00', 'Modern Language 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" xml:lang="en">
<info>
<title>Modern Language Association</title>
<id>http://purl.org/net/xbiblio/csl/styles/mla.csl</id>
<link>http://purl.org/net/xbiblio/csl/styles/mla.csl</link>
<author>
<name>Bruce DArcus</name>
<email>bdarcus@sourceforge.net</email>
</author>
<contributor>
<name>Johan Kool</name>
<email>johankool@users.sourceforge.net</email>
</contributor>
<contributor>
<name>Simon Kornblith</name>
<email>simon@simonster.com</email>
</contributor>
<updated>2006-08-29T23:05:00+05:00</updated>
</info>
<defaults>
<contributor name-as-sort-order="first">
<name and="text" sort-separator=", " delimiter=", "/>
<label form="short" suffix="."/>
</contributor>
<author>
<substitute>
<choose>
<editor/>
<titles/>
</choose>
</substitute>
</author>
<locator>
<number/>
</locator>
<titles>
<title/>
</titles>
<date>
<year/>
</date>
<publisher>
<place suffix=": "/>
<name/>
</publisher>
<access>
<date>
<day suffix=" "/>
<month suffix=" "/>
<year/>
</date>
<url prefix=" <" suffix=">"/>
</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"/>
<layout>
<item>
<author form="short"/>
<title form="short" when-multiple-author-items="true" prefix="" suffix=""/>
<locator prefix=" "/>
</item>
</layout>
</citation>
<bibliography subsequent-author-substitute="---">
<sort algorithm="author-date"/>
<et-al min-authors="4" use-first="1"/>
<layout>
<list>
<heading>
<text term-name="references"/>
</heading>
</list>
<item>
<choose>
<type name="book">
<author suffix="."/>
<titles font-style="italic" prefix=" " suffix="."/>
<group prefix=" " suffix="." delimiter=", ">
<edition/>
<publisher/>
<date/>
</group>
<access prefix=" " suffix="."/>
</type>
<type name="chapter">
<author suffix="."/>
<titles prefix=" &#8220;" suffix=".&#8221;"/>
<group class="container" prefix=" " suffix=".">
<titles relation="container" font-style="italic" suffix="."/>
<editor prefix=" " suffix=".">
<label form="short" suffix=". " text-transform="capitalize"/>
<name and="text" delimiter=", "/>
</editor>
<titles relation="collection" prefix=" " suffix="."/>
<publisher prefix=" "/>
<date prefix=", "/>
</group>
<pages prefix=" " suffix="."/>
<access prefix=" " suffix="."/>
</type>
<type name="article">
<author suffix="."/>
<titles prefix=" &#8220;" suffix=".&#8221;"/>
<group class="container">
<editor prefix=" " suffix="."/>
<titles relation="container" font-style="italic" prefix=" " suffix="."/>
</group>
<volume prefix=" "/>
<issue prefix="."/>
<group prefix=" " suffix=".">
<date prefix=" (" suffix=")"/>
<pages prefix=": "/>
</group>
<access prefix=" " suffix="."/>
</type>
</choose>
</item>
</layout>
</bibliography>
</style>');