RIS update from Sean (pushed to repo) (ignore some extra whitespace differences)

This commit is contained in:
Dan Stillman 2007-01-20 00:21:58 +00:00
parent 1112fcf1ff
commit 61dba96bf8

View File

@ -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-01-18 23:00:00')); REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-01-20 00:20:00'));
REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b3.r1', '', '2006-12-15 03:40:00', 1, 100, 4, 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon', REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b3.r1', '', '2006-12-15 03:40:00', 1, 100, 4, 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon',
'function detectWeb(doc, url) { 'function detectWeb(doc, url) {
@ -8153,7 +8153,7 @@ function doImport() {
} }
}'); }');
REPLACE INTO translators VALUES ('32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7', '1.0.0b3.r1', '', '2007-01-12 00:30:00', 1, 100, 3, 'RIS', 'Simon Kornblith', 'ris', REPLACE INTO translators VALUES ('32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7', '1.0.0b3.r1', '', '2007-01-20 00:20:00', '1', '100', '3', 'RIS', 'Simon Kornblith', 'ris',
'Zotero.configure("dataMode", "line"); 'Zotero.configure("dataMode", "line");
Zotero.addOption("exportNotes", true); Zotero.addOption("exportNotes", true);
@ -8172,7 +8172,7 @@ function detectImport() {
} }
} }
} }
}', }',
'var fieldMap = { 'var fieldMap = {
ID:"itemID", ID:"itemID",
T1:"title", T1:"title",
@ -8189,7 +8189,6 @@ function detectImport() {
var inputFieldMap = { var inputFieldMap = {
TI:"title", TI:"title",
CT:"title", CT:"title",
JO:"publicationTitle",
CY:"place" CY:"place"
}; };
@ -8197,6 +8196,7 @@ var inputFieldMap = {
var typeMap = { var typeMap = {
book:"BOOK", book:"BOOK",
bookSection:"CHAP", bookSection:"CHAP",
conferencePaper:"CONF",
journalArticle:"JOUR", journalArticle:"JOUR",
magazineArticle:"MGZN", magazineArticle:"MGZN",
newspaperArticle:"NEWS", newspaperArticle:"NEWS",
@ -8210,7 +8210,7 @@ var typeMap = {
}; };
// supplements outputTypeMap for importing // supplements outputTypeMap for importing
// TODO: BILL, CASE, COMP, CONF, DATA, HEAR, MUSIC, PAT, SOUND, STAT // TODO: BILL, CASE, COMP, DATA, HEAR, MUSIC, PAT, SOUND, STAT
var inputTypeMap = { var inputTypeMap = {
ABST:"journalArticle", ABST:"journalArticle",
ADVS:"film", ADVS:"film",
@ -8234,7 +8234,7 @@ function processTag(item, tag, value) {
item[inputFieldMap[tag]] = value; item[inputFieldMap[tag]] = value;
} else if(tag == "TY") { } else if(tag == "TY") {
// look for type // look for type
// first check typeMap // first check typeMap
for(var i in typeMap) { for(var i in typeMap) {
if(value == typeMap[i]) { if(value == typeMap[i]) {
@ -8250,6 +8250,12 @@ function processTag(item, tag, value) {
item.itemType = inputTypeMap["GEN"]; item.itemType = inputTypeMap["GEN"];
} }
} }
} else if(tag == "JO") {
if (item.itemType == "conferencePaper"){
item.conferenceName = value;
} else {
item.publicationTitle = value;
}
} else if(tag == "BT") { } else if(tag == "BT") {
// ignore, unless this is a book or unpublished work, as per spec // ignore, unless this is a book or unpublished work, as per spec
if(item.itemType == "book" || item.itemType == "manuscript") { if(item.itemType == "book" || item.itemType == "manuscript") {
@ -8270,25 +8276,25 @@ function processTag(item, tag, value) {
} else if(tag == "Y1" || tag == "PY") { } else if(tag == "Y1" || tag == "PY") {
// year or date // year or date
var dateParts = value.split("/"); var dateParts = value.split("/");
if(dateParts.length == 1) { if(dateParts.length == 1) {
// technically, if there''s only one date part, the file isn''t valid // technically, if there''s only one date part, the file isn''t valid
// RIS, but EndNote writes this, so we have to too // RIS, but EndNote writes this, so we have to too
item.date = value; item.date = value;
} else { } else {
// in the case that we have a year and other data, format that way // in the case that we have a year and other data, format that way
var month = parseInt(dateParts[1]); var month = parseInt(dateParts[1]);
if(month) { if(month) {
month--; month--;
} else { } else {
month = undefined; month = undefined;
} }
item.date = Zotero.Utilities.formatDate({year:dateParts[0], item.date = Zotero.Utilities.formatDate({year:dateParts[0],
month:month, month:month,
day:dateParts[2], day:dateParts[2],
part:dateParts[3]}); part:dateParts[3]});
} }
} else if(tag == "Y2") { } else if(tag == "Y2") {
// the secondary date field can mean two things, a secondary date, or an // the secondary date field can mean two things, a secondary date, or an
@ -8304,7 +8310,7 @@ function processTag(item, tag, value) {
} }
} else if(tag == "N1" || tag == "AB") { } else if(tag == "N1" || tag == "AB") {
// notes // notes
if(value != item.title) { // why does EndNote do this!? if(value != item.title) { // why does EndNote do this!?
item.notes.push({note:value}); item.notes.push({note:value});
} }
} else if(tag == "N2") { } else if(tag == "N2") {
@ -8316,7 +8322,7 @@ function processTag(item, tag, value) {
// start page // start page
if(!item.pages) { if(!item.pages) {
item.pages = value; item.pages = value;
} else if(item.pages[0] == "-") { // already have ending page } else if(item.pages[0] == "-") { // already have ending page
item.pages = value + item.pages; item.pages = value + item.pages;
} else { // multiple ranges? hey, it''s a possibility } else { // multiple ranges? hey, it''s a possibility
item.pages += ", "+value; item.pages += ", "+value;
@ -8343,7 +8349,7 @@ function processTag(item, tag, value) {
if(!item.url) { if(!item.url) {
item.url = value; item.url = value;
} }
if(tag == "UR") { if(tag == "UR") {
item.attachments.push({url:value}); item.attachments.push({url:value});
} else if(tag == "L1") { } else if(tag == "L1") {
@ -8368,7 +8374,6 @@ function completeItem(item) {
} }
item.backupPublicationTitle = undefined; item.backupPublicationTitle = undefined;
} }
item.complete(); item.complete();
} }
@ -8376,25 +8381,25 @@ function doImport(attachments) {
// this is apparently the proper character set for RIS, although i''m not // this is apparently the proper character set for RIS, although i''m not
// sure how many people follow this // sure how many people follow this
Zotero.setCharacterSet("IBM850"); Zotero.setCharacterSet("IBM850");
var line = true; var line = true;
var tag = data = false; var tag = data = false;
do { // first valid line is type do { // first valid line is type
Zotero.debug("ignoring "+line); Zotero.debug("ignoring "+line);
line = Zotero.read(); line = Zotero.read();
line = line.replace(/^\s+/, ""); line = line.replace(/^\s+/, "");
} while(line !== false && line.substr(0, 6) != "TY - "); } while(line !== false && line.substr(0, 6) != "TY - ");
var item = new Zotero.Item(); var item = new Zotero.Item();
var i = 0; var i = 0;
if(attachments && attachments[i]) { if(attachments && attachments[i]) {
item.attachments = attachments[i]; item.attachments = attachments[i];
} }
var tag = "TY"; var tag = "TY";
var data = line.substr(6); var data = line.substr(6);
var rawLine; var rawLine;
while((rawLine = Zotero.read()) !== false) { // until EOF while((rawLine = Zotero.read()) !== false) { // until EOF
// trim leading space if this line is not part of a note // trim leading space if this line is not part of a note
line = rawLine.replace(/^\s+/, ""); line = rawLine.replace(/^\s+/, "");
Zotero.debug("line is "+rawLine); Zotero.debug("line is "+rawLine);
@ -8404,14 +8409,14 @@ function doImport(attachments) {
if(tag) { if(tag) {
processTag(item, tag, data); processTag(item, tag, data);
} }
// then fetch the tag and data from this line // then fetch the tag and data from this line
tag = line.substr(0,2); tag = line.substr(0,2);
data = line.substr(6); data = line.substr(6);
Zotero.debug("tag: ''"+tag+"''; data: ''"+data+"''"); Zotero.debug("tag: ''"+tag+"''; data: ''"+data+"''");
if(tag == "ER") { // ER signals end of reference if(tag == "ER") { // ER signals end of reference
// unset info // unset info
tag = data = false; tag = data = false;
// new item // new item
@ -8438,7 +8443,7 @@ function doImport(attachments) {
} }
} }
} }
if(tag && tag != "ER") { // save any unprocessed tags if(tag && tag != "ER") { // save any unprocessed tags
Zotero.debug(tag); Zotero.debug(tag);
processTag(item, tag, data); processTag(item, tag, data);
@ -8456,23 +8461,23 @@ function doExport() {
// this is apparently the proper character set for RIS, although i''m not // this is apparently the proper character set for RIS, although i''m not
// sure how many people follow this // sure how many people follow this
Zotero.setCharacterSet("IBM850"); Zotero.setCharacterSet("IBM850");
var item; var item;
while(item = Zotero.nextItem()) { while(item = Zotero.nextItem()) {
// can''t store independent notes in RIS // can''t store independent notes in RIS
if(item.itemType == "note" || item.itemType == "attachment") { if(item.itemType == "note" || item.itemType == "attachment") {
continue; continue;
} }
// type // type
addTag("TY", typeMap[item.itemType]); addTag("TY", typeMap[item.itemType]);
// use field map // use field map
for(var j in fieldMap) { for(var j in fieldMap) {
addTag(j, item[fieldMap[j]]); addTag(j, item[fieldMap[j]]);
} }
// creators // creators
for(var j in item.creators) { for(var j in item.creators) {
// only two types, primary and secondary // only two types, primary and secondary
@ -8480,10 +8485,10 @@ function doExport() {
if(item.creators[j].creatorType != "author") { if(item.creators[j].creatorType != "author") {
risTag = "A2"; risTag = "A2";
} }
addTag(risTag, item.creators[j].lastName+","+item.creators[j].firstName); addTag(risTag, item.creators[j].lastName+","+item.creators[j].firstName);
} }
// date // date
if(item.date) { if(item.date) {
var date = Zotero.Utilities.strToDate(item.date); var date = Zotero.Utilities.strToDate(item.date);
@ -8505,23 +8510,23 @@ function doExport() {
} }
addTag("PY", string); addTag("PY", string);
} }
// notes // notes
if(Zotero.getOption("exportNotes")) { if(Zotero.getOption("exportNotes")) {
for(var j in item.notes) { for(var j in item.notes) {
addTag("N1", item.notes[j].note.replace(/(?:\r\n?|\n)/g, "\r\n")); addTag("N1", item.notes[j].note.replace(/(?:\r\n?|\n)/g, "\r\n"));
} }
} }
if(item.abstractNote) { if(item.abstractNote) {
addTag("N2", item.abstractNote.replace(/(?:\r\n?|\n)/g, "\r\n")); addTag("N2", item.abstractNote.replace(/(?:\r\n?|\n)/g, "\r\n"));
} }
// tags // tags
for(var j in item.tags) { for(var j in item.tags) {
addTag("KY", item.tags[j]); addTag("KY", item.tags[j]);
} }
// pages // pages
if(item.pages) { if(item.pages) {
if(item.itemType == "book") { if(item.itemType == "book") {
@ -8532,18 +8537,18 @@ function doExport() {
addTag("EP", range[1]); addTag("EP", range[1]);
} }
} }
// ISBN/ISSN // ISBN/ISSN
addTag("SN", item.ISBN); addTag("SN", item.ISBN);
addTag("SN", item.ISSN); addTag("SN", item.ISSN);
// URL // URL
if(item.url) { if(item.url) {
addTag("UR", item.url); addTag("UR", item.url);
} else if(item.source && item.source.substr(0, 7) == "http://") { } else if(item.source && item.source.substr(0, 7) == "http://") {
addTag("UR", item.source); addTag("UR", item.source);
} }
Zotero.write("ER - \r\n\r\n"); Zotero.write("ER - \r\n\r\n");
} }
}'); }');