- made doGet handle multiple urls, with processor/done style interface (as in processDocuments). this should be backwards compatible

- beginnings of mapping for new item types
- fixes for Word integration (because i was using it to write a paper)
This commit is contained in:
Simon Kornblith 2006-11-21 07:14:27 +00:00
parent 3d6bfbe6d5
commit 445ff98277
7 changed files with 93 additions and 74 deletions

View file

@ -127,7 +127,7 @@ var Zotero_Citation_Dialog = new function () {
}
function accept() {
var io = window.arguments[0];
var io = window.arguments[0].wrappedJSObject;
if(_multipleSourcesOn) {
treeItemSelected(); // store locator info

View file

@ -40,6 +40,9 @@ var Zotero_File_Interface_Bibliography = new function() {
*/
function init() {
_io = window.arguments[0];
if(_io.wrappedJSObject){
_io = _io.wrappedJSObject;
}
var listbox = document.getElementById("style-popup");
var styleMenu = document.getElementById("style-menu");

View file

@ -1660,7 +1660,25 @@ Zotero.CSL.FormattedString.prototype.appendDate = function(date, element) {
interview:"interview",
film:"motion picture",
artwork:"graphic",
website:"webpage"
webpage:"webpage",
report:"paper-conference", // ??
bill:"bill",
case:"legal case",
hearing:"bill", // ??
patent:"patent",
statute:"bill", // ??
email:"personal communication",
map:"map",
blogPost:"webpage",
instantMessage:"personal communication",
forumPost:"webpage",
audioRecording:"song", // ??
presentation:"paper-conference",
videoRecording:"motion picture",
tvBroadcast:"motion picture",
radioBroadcast:"motion picture",
podcast:"speech", // ??
computerProgram:"book" // ??
};
// TODO: check with Elena/APA/MLA on this
Zotero.CSL.Global.fallbackTypeMappings = {
@ -1675,7 +1693,24 @@ Zotero.CSL.Global.fallbackTypeMappings = {
interview:"book",
film:"book",
artwork:"book",
website:"article"
webpage:"article",
report:"book",
bill:"book",
case:"book",
hearing:"book",
patent:"book",
statute:"book",
email:"article",
map:"article",
blogPost:"article",
instantMessage:"article",
audioRecording:"book",
presentation:"article",
videoRecording:"book",
tvBroadcast:"book",
radioBroadcast:"book",
podcast:"book",
computerProgram:"book"
};
Zotero.CSL.prototype._getTypeFromItem = function(item) {
@ -1699,8 +1734,10 @@ Zotero.CSL.prototype._separateItemCreators = function(item) {
var translatorID = Zotero.CreatorTypes.getID("translator");
var creators = item.getCreators();
for(var j in creators) {
var creator = creators[j];
Zotero.debug("here come the creators");
Zotero.debug(creators);
for each(var creator in creators) {
Zotero.debug(creator);
if(creator.creatorTypeID == editorID) {
editors.push(creator);

View file

@ -361,12 +361,11 @@ Zotero.Integration.SOAP = new function() {
this.setDocPrefs = setDocPrefs;
var _sessions = new Array();
var window;
var watcher;
function init() {
window = Components.classes["@mozilla.org/appshell/appShellService;1"]
.getService(Components.interfaces.nsIAppShellService)
.hiddenDOMWindow;
watcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
}
/*
@ -391,9 +390,12 @@ Zotero.Integration.SOAP = new function() {
for(var i=3; i<vars.length; i+=2) {
if(vars[i+1] == "X") {
// get a new citation for a field with an X
var io = new Object();
window.openDialog('chrome://zotero/content/addCitationDialog.xul','',
'chrome,popup,modal', io, true);
var io = new function() {
this.wrappedJSObject = this;
}
watcher.openWindow(null, 'chrome://zotero/content/addCitationDialog.xul', '',
'chrome,modal'+(Zotero.isMac ? '' : ',popup'), io, true);
citation = new Zotero.Integration.Citation(vars[i], "!");
updatedCitations[citation.index] = true;
@ -531,7 +533,9 @@ Zotero.Integration.SOAP = new function() {
* RETURNS: sessionID, styleID, style-class
*/
function setDocPrefs(vars) {
var io = new Object();
var io = new function() {
this.wrappedJSObject = this;
}
if(!vars || !vars[0] || vars[0] == "!") {
// no session ID; generate a new one
@ -548,8 +552,8 @@ Zotero.Integration.SOAP = new function() {
io.style = originalStyle;
}
window.openDialog('chrome://zotero/content/integrationDocPrefs.xul','',
'chrome,popup,modal',io);
watcher.openWindow(null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
'chrome,modal'+(Zotero.isMac ? '' : ',popup'), io);
session.setStyle(io.style);
return [sessionID, io.style, session.style.class];

View file

@ -551,7 +551,7 @@ Zotero.Translate.prototype._generateSandbox = function() {
if(this.type == "web" || this.type == "search") {
// get sandbox URL
var sandboxURL = "";
var sandboxURL = "http://www.example.com/";
if(this.type == "web") {
// use real URL, not proxied version, to create sandbox
sandboxURL = this.document.location.href;

View file

@ -352,7 +352,16 @@ Zotero.Utilities.Ingester.HTTP = function(translate) {
this.translate = translate;
}
Zotero.Utilities.Ingester.HTTP.prototype.doGet = function(url, onDone) {
Zotero.Utilities.Ingester.HTTP.prototype.doGet = function(urls, processor, done) {
var callAgain = false;
if(typeof(urls) == "string") {
var url = urls;
} else {
if(urls.length > 1) callAgain = true;
var url = urls.shift();
}
if(this.translate.locationIsProxied) {
url = Zotero.Ingester.ProxyMonitor.properToProxy(url);
}
@ -361,9 +370,20 @@ Zotero.Utilities.Ingester.HTTP.prototype.doGet = function(url, onDone) {
}
var translate = this.translate;
var me = this;
Zotero.Utilities.HTTP.doGet(url, function(xmlhttp) {
try {
onDone(xmlhttp.responseText, xmlhttp);
if(processor) {
processor(xmlhttp.responseText, xmlhttp);
}
// call again if multiple urls were passed
if(callAgain) {
me.doGet(urls, processor, done);
} else if(done) {
done();
}
} catch(e) {
translate._translationComplete(false, e);
}

View file

@ -1,4 +1,4 @@
-- 103
-- 104
-- ***** 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', '2006-11-01 16:30:00'));
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-11-20 23:10:00'));
REPLACE INTO "translators" VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '2006-10-02 17:00:00', 1, 100, 4, 'Amazon.com', 'Simon Kornblith', '^http://www\.amazon\.com/',
'function detectWeb(doc, url) {
@ -482,7 +482,7 @@ REPLACE INTO "translators" VALUES ('88915634-1af6-c134-0171-56fd198235ed', '2006
Zotero.wait();
}');
REPLACE INTO "translators" VALUES ('d921155f-0186-1684-615c-ca57682ced9b', '2006-10-02 17:00:00', 1, 100, 4, 'JSTOR', 'Simon Kornblith', '^http://www\.jstor\.org/(?:view|browse|search/)',
REPLACE INTO "translators" VALUES ('d921155f-0186-1684-615c-ca57682ced9b', '2006-11-20 23:10:00', 1, 100, 4, 'JSTOR', 'Simon Kornblith', '^http://www\.jstor\.org/(?:view|browse|search/)',
'function detectWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
@ -501,22 +501,7 @@ REPLACE INTO "translators" VALUES ('d921155f-0186-1684-615c-ca57682ced9b', '2006
return "journalArticle";
}
}',
'function getList(urls, each, done) {
var url = urls.shift();
Zotero.Utilities.HTTP.doGet(url, function(text) {
if(each) {
each(text);
}
if(urls.length) {
getList(urls, each, done);
} else if(done) {
done(text);
}
});
}
function getJSTORAttachment(viewURL) {
'function getJSTORAttachment(viewURL) {
var viewRe = new RegExp("(^http://[^/]+/)view([^?]+)");
var m = viewRe.exec(viewURL);
if(m) {
@ -615,7 +600,7 @@ function doWeb(doc, url) {
Zotero.Utilities.HTTP.doGet(''http://www.jstor.org/browse?citationAction=removeAll&confirmRemAll=on&viewCitations=1'', function() { // clear marked
// Mark all our citations
getList(saveCitations, null, function() { // mark this
Zotero.Utilities.HTTP.doGet(saveCitations, null, function() { // mark this
Zotero.Utilities.HTTP.doGet(''http://www.jstor.org/browse/citations.txt?exportAction=Save+as+Text+File&exportFormat=cm&viewCitations=1'', function(text) {
// get marked
var k = 0;
@ -3065,26 +3050,11 @@ REPLACE INTO "translators" VALUES ('3e684d82-73a3-9a34-095f-19b112d88bbf', '2006
Zotero.wait();
}');
REPLACE INTO "translators" VALUES ('57a00950-f0d1-4b41-b6ba-44ff0fc30289', '2006-08-26 1:10:00', 1, 100, 4, 'Google Zotero', 'Simon Kornblith', '^http://scholar\.google\.com/scholar',
REPLACE INTO "translators" VALUES ('57a00950-f0d1-4b41-b6ba-44ff0fc30289', '2006-11-20 23:00:00', 1, 100, 4, 'Google Scholar', 'Simon Kornblith', '^http://scholar\.google\.com/scholar',
'function detectWeb(doc, url) {
return "multiple";
}',
'function getList(urls, each, done) {
var url = urls.shift();
Zotero.Utilities.HTTP.doGet(url, function(text) {
if(each) {
each(text);
}
if(urls.length) {
getList(urls, each, done);
} else if(done) {
done(text);
}
});
}
function doWeb(doc, url) {
'function doWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == ''x'') return namespace; else return null;
@ -3168,7 +3138,7 @@ function doWeb(doc, url) {
item.complete();
});
getList(urls, function(text) {
Zotero.Utilities.HTTP.doGet(urls, function(text) {
translator.setString(text);
translator.translate();
}, function() { Zotero.done() });
@ -3419,7 +3389,7 @@ function doWeb(doc, url) {
Zotero.wait();
}');
REPLACE INTO "translators" VALUES ('ce7a3727-d184-407f-ac12-52837f3361ff', '2006-10-02 17:00:00', 1, 100, 4, 'New York Times', 'Simon Kornblith', '^http://(?:query\.nytimes\.com/search/query|(?:www\.)?nytimes\.com/.+)',
REPLACE INTO "translators" VALUES ('ce7a3727-d184-407f-ac12-52837f3361ff', '2006-11-20 23:10:00', 1, 100, 4, 'New York Times', 'Simon Kornblith', '^http://(?:query\.nytimes\.com/search/query|(?:www\.)?nytimes\.com/.+)',
'function detectWeb(doc, url) {
if(doc.title.substr(0, 30) == "The New York Times: Search for") {
var namespace = doc.documentElement.namespaceURI;
@ -3439,22 +3409,7 @@ REPLACE INTO "translators" VALUES ('ce7a3727-d184-407f-ac12-52837f3361ff', '2006
}
}
}',
'function getList(urls, each, done) {
var url = urls.shift();
Zotero.Utilities.HTTP.doGet(url, function(text) {
if(each) {
each(text, url);
}
if(urls.length) {
getList(urls, each, done);
} else if(done) {
done(text);
}
});
}
function associateMeta(newItem, metaTags, field, zoteroField) {
'function associateMeta(newItem, metaTags, field, zoteroField) {
if(metaTags[field]) {
newItem[zoteroField] = metaTags[field];
}
@ -3566,7 +3521,7 @@ function doWeb(doc, url) {
urls.push(i);
}
getList(urls, scrape, function() { Zotero.done(); }, null);
Zotero.Utilities.HTTP.doGet(urls, scrape, function() { Zotero.done(); }, null);
Zotero.wait();
} else {