commit 60422e032e427c60983f3c0324f9fe7eb7e915c6
parent 539957a93b7ff3d0c0444cf73dadd4fd38e97f4e
Author: Simon Kornblith <simon@simonster.com>
Date: Fri, 8 Sep 2006 22:26:59 +0000
- closes #261, work around content-disposition: attachment on endnote links. this workaround is far from the most elegant, but it seemed nicer than writing a stream converter component that didn't really convert streams
- fixes bugs in RIS import
Diffstat:
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/ingester.js b/chrome/chromeFiles/content/scholar/xpcom/ingester.js
@@ -46,6 +46,20 @@ Scholar.Ingester.ProxyMonitor = new function() {
function observe(channel) {
channel.QueryInterface(Components.interfaces.nsIHttpChannel);
try {
+ // remove content-disposition headers for endnote, etc.
+ var contentType = channel.getResponseHeader("Content-Type").toLowerCase();
+ for each(var desiredContentType in Scholar.Ingester.MIMEHandler.URIContentListener.desiredContentTypes) {
+ if(contentType.length < desiredContentType.length) {
+ break;
+ } else {
+ if(contentType.substr(0, desiredContentType.length) == desiredContentType) {
+ channel.setResponseHeader("Content-Disposition", "", false);
+ break;
+ }
+ }
+ }
+
+ // find ezproxies
if(channel.getResponseHeader("Server") == "EZproxy") {
// We're connected to an EZproxy
if(channel.responseStatus != "302") {
@@ -479,7 +493,10 @@ Scholar.Ingester.MIMEHandler = new function() {
* nsIURIContentListener interface to grab MIME types
*/
Scholar.Ingester.MIMEHandler.URIContentListener = new function() {
- var _desiredContentTypes = ["application/x-endnote-refer", "application/x-research-info-systems"];
+ // list of content types to capture
+ // NOTE: must be from shortest to longest length
+ this.desiredContentTypes = ["application/x-endnote-refer",
+ "application/x-research-info-systems"];
this.QueryInterface = QueryInterface;
this.canHandleContent = canHandleContent;
@@ -497,7 +514,7 @@ Scholar.Ingester.MIMEHandler.URIContentListener = new function() {
}
function canHandleContent(contentType, isContentPreferred, desiredContentType) {
- if(Scholar.inArray(contentType, _desiredContentTypes)) {
+ if(Scholar.inArray(contentType, this.desiredContentTypes)) {
return true;
}
return false;
@@ -510,7 +527,7 @@ Scholar.Ingester.MIMEHandler.URIContentListener = new function() {
}
function isPreferred(contentType, desiredContentType) {
- if(Scholar.inArray(contentType, _desiredContentTypes)) {
+ if(Scholar.inArray(contentType, this.desiredContentTypes)) {
return true;
}
return false;
@@ -537,6 +554,8 @@ Scholar.Ingester.MIMEHandler.StreamListener = function(request, contentType) {
getService(Components.interfaces.nsIWindowWatcher);
this._frontWindow = windowWatcher.activeWindow;
this._frontWindow.Scholar_Ingester_Interface.Progress.show();
+
+ Scholar.debug("EndNote prepared to grab content type "+contentType);
}
Scholar.Ingester.MIMEHandler.StreamListener.prototype.QueryInterface = function(iid) {
diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js
@@ -745,7 +745,9 @@ Scholar.Date = new function(){
Scholar.debug("DATE: got year ("+date.year+", "+date.part+")");
// get short month strings from CSL interpreter
- var months = CSL.getMonthStrings("short");
+ if(!months) {
+ var months = CSL.getMonthStrings("short");
+ }
if(!_monthRe) {
// then, see if have anything resembling a month anywhere
_monthRe = new RegExp("^(.*)\\b("+months.join("|")+")[^ ]* (.*)$", "i");
@@ -791,6 +793,9 @@ Scholar.Date = new function(){
string += date.part+" ";
}
+ if(!months) {
+ var months = CSL.getMonthStrings("short");
+ }
if(date.month != undefined && months[date.month]) {
// get short month strings from CSL interpreter
var months = CSL.getMonthStrings("long");
diff --git a/scrapers.sql b/scrapers.sql
@@ -1,4 +1,4 @@
--- 85
+-- 86
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-31 22:44:00'));
@@ -5747,7 +5747,7 @@ Scholar.addOption("exportNotes", true);
function detectImport() {
var line;
- while(line = Scholar.read()) {
+ while((line = Scholar.read()) !== "false") {
line = line.replace(/^\s+/, "");
if(line != "") {
if(line.substr(0, 6) == "TY - ") {