Revision: 28119
http://sourceforge.net/p/bibdesk/svn/28119
Author: hofman
Date: 2022-12-15 15:14:02 +0000 (Thu, 15 Dec 2022)
Log Message:
-----------
pass server name rather than whole URL to method to get download requests for
MathSciNet and Zentralblatt web parsers. Also pass server name in contextInfo
of download so we don't need the download URL.
Modified Paths:
--------------
trunk/bibdesk/BDSKMathSciNetParser.h
trunk/bibdesk/BDSKMathSciNetParser.m
trunk/bibdesk/BDSKNumdamParser.m
trunk/bibdesk/BDSKProjectEuclidParser.m
trunk/bibdesk/BDSKZentralblattParser.h
trunk/bibdesk/BDSKZentralblattParser.m
Modified: trunk/bibdesk/BDSKMathSciNetParser.h
===================================================================
--- trunk/bibdesk/BDSKMathSciNetParser.h 2022-12-15 11:10:59 UTC (rev
28118)
+++ trunk/bibdesk/BDSKMathSciNetParser.h 2022-12-15 15:14:02 UTC (rev
28119)
@@ -41,6 +41,6 @@
@interface BDSKMathSciNetParser : BDSKAsynchronousWebParser
-+ (NSArray *)bibTeXRequestsForMRIDs:(NSArray *)IDs referrer:(NSURL *)URL
error:(NSError **)outError;
++ (NSArray *)bibTeXRequestsForMRIDs:(NSArray *)IDs serverName:(NSString
*)serverName error:(NSError **)outError;
+ (NSArray *)itemsFromDownload:(BDSKCitationDownload *)download
parser:(BDSKWebParser *)parser error:(NSError **)outError;
@end
Modified: trunk/bibdesk/BDSKMathSciNetParser.m
===================================================================
--- trunk/bibdesk/BDSKMathSciNetParser.m 2022-12-15 11:10:59 UTC (rev
28118)
+++ trunk/bibdesk/BDSKMathSciNetParser.m 2022-12-15 15:14:02 UTC (rev
28119)
@@ -78,10 +78,18 @@
}
}
- requests = [BDSKMathSciNetParser bibTeXRequestsForMRIDs:IDArray
referrer:[self URL] error:outError];
+ // Determine the server name to use.
+ // If the referring URL's server name contains 'ams', assume we were
using a mirror server before and continue using that.
+ // If not, we're processing MR IDs not coming from a MathSciNet page
and use the default 'ams.org' server.
+ NSString * serverName = [[[self URL] host] lowercaseString];
+ if ([serverName rangeOfString:@"ams"].location == NSNotFound)
+ serverName = @"www.ams.org";
+ NSDictionary *contextInfo = [NSDictionary
dictionaryWithObjectsAndKeys:serverName, @"serverName", nil];
+ requests = [BDSKMathSciNetParser bibTeXRequestsForMRIDs:IDArray
serverName:serverName error:outError];
+
for (NSURLRequest *request in requests)
- [self addDownloadWithRequest:request contextInfo:nil];
+ [self addDownloadWithRequest:request contextInfo:contextInfo];
}
@@ -93,14 +101,11 @@
}
// Turns an array of MR ID numbers into an array of NSURLRequest objects to
download the bibTeX citations.
-// The referrer: URL argument is used to send requests to the same mirror that
was used originally.
-+ (NSArray *)bibTeXRequestsForMRIDs:(NSArray *)IDs referrer:(NSURL *)URL
error:(NSError **)outError {
+// The serverName argument is used to send requests to the same mirror that
was used originally.
++ (NSArray *)bibTeXRequestsForMRIDs:(NSArray *)IDs serverName:(NSString
*)serverName error:(NSError **)outError {
- // Determine the server name to use.
- // If the referring URL's server name contains 'ams', assume we were using
a mirror server before and continue using that.
- // If not, we're processing MR IDs not coming from a MathSciNet page and
use the default 'ams.org' server.
- if (URL == nil || [[URL host] rangeOfString:@"ams"
options:NSCaseInsensitiveSearch].location == NSNotFound)
- URL = [NSURL URLWithString:@"https://www.ams.org"];
+ if (serverName == nil)
+ serverName = @"www.ams.org";
// Loop through IDs in batches of MSNBATCHSIZE. */
NSUInteger count = [IDs count];
@@ -112,10 +117,10 @@
firstElement += MSNBATCHSIZE;
NSString * queryString = [processArray
componentsJoinedByString:@"%20or%20"];
- NSString * URLString =
[@"/mathscinet/search/publications.html?&fmt=bibtex&pg1=MR&s1="
stringByAppendingString:queryString];
- NSURL * bibTeXBatchDownloadURL = [NSURL URLWithString:URLString
relativeToURL:URL];
+ NSString * URLString = [NSString
stringWithFormat:@"https://%@/mathscinet/search/publications.html?&fmt=bibtex&pg1=MR&s1=%@",
serverName, queryString];
+ NSURL * bibTeXBatchDownloadURL = [NSURL URLWithString:URLString];
- NSURLRequest * request = [NSURLRequest
requestWithURL:bibTeXBatchDownloadURL
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60.0];
+ NSURLRequest * request = [NSURLRequest
requestWithURL:bibTeXBatchDownloadURL];
[results addObject:request];
@@ -155,19 +160,22 @@
for (NSXMLNode *node in preArray) {
NSString * preContent = [node stringValue];
- NSString * cleanedRecord = [preContent
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
+ NSString * cleanedRecord = [preContent
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
cleanedRecord = [umlautFixer replaceWithString:@"{$1}"
inString:cleanedRecord];
[results addObjectsFromArray:[parser
itemsFromBibTeXString:cleanedRecord error:NULL]];
}
+ NSDictionary *contextInfo = [download contextInfo];
+ NSString *serverName = [contextInfo objectForKey:@"serverName"] ?:
@"www.ams.org";
// The extra URL can be passed by the BDSKProjectEuclidParser or
BDSKNumdamParser
+ // The extra URL can be passed by the BDSKProjectEuclidParser or
BDSKNumdamParser
NSString * URLString = [[download contextInfo] objectForKey:@"URLString"];
// Add a URL reference pointing to the review's web page to each record.
for (BibItem * item in results) {
NSString * MRNumber = [[item citeKey] stringByRemovingPrefix:@"MR"];
- NSString * MRItemURL = [[NSURL
URLWithString:[@"/mathscinet-getitem?mr=" stringByAppendingString:MRNumber]
relativeToURL:[download URL]] absoluteString];
+ NSString * MRItemURL = [NSString
stringWithFormat:@"https://%@/mathscinet-getitem?mr=%@", serverName, MRNumber];
if ( URLString )
[item addURLString:URLString];
[item addURLString:MRItemURL];
Modified: trunk/bibdesk/BDSKNumdamParser.m
===================================================================
--- trunk/bibdesk/BDSKNumdamParser.m 2022-12-15 11:10:59 UTC (rev 28118)
+++ trunk/bibdesk/BDSKNumdamParser.m 2022-12-15 15:14:02 UTC (rev 28119)
@@ -123,7 +123,7 @@
URLString = [match groupAtIndex:1];
/*
- NSArray * MRRequests = [BDSKMathSciNetParser
bibTeXRequestsForMRIDs:ZMathReferences referrer:[self URL] error:outError];
+ NSArray * MRRequests = [BDSKMathSciNetParser
bibTeXRequestsForMRIDs:ZMathReferences serverName:nil error:outError];
for (NSURLRequest *request in MRRequests) {
NSDictionary *contextInfo = [NSDictionary
dictionaryWithObjectsAndKeys:[BDSKMathSciNetParser class], @"parserClass",
firstMRIDIsOwnId ? URLString : nil, @"URLString", nil];
@@ -132,7 +132,7 @@
}
*/
- NSArray * ZMathRequests = [BDSKZentralblattParser
bibTeXRequestsForZMathIDs:ZMathReferences referrer:[self URL] error:outError];
+ NSArray * ZMathRequests = [BDSKZentralblattParser
bibTeXRequestsForZMathIDs:ZMathReferences serverName:nil error:outError];
for (NSURLRequest *request in ZMathRequests) {
NSDictionary *contextInfo = [NSDictionary
dictionaryWithObjectsAndKeys:[BDSKZentralblattParser class], @"parserClass",
firstZMathIDIsOwnId ? URLString : nil, @"URLString", nil];
Modified: trunk/bibdesk/BDSKProjectEuclidParser.m
===================================================================
--- trunk/bibdesk/BDSKProjectEuclidParser.m 2022-12-15 11:10:59 UTC (rev
28118)
+++ trunk/bibdesk/BDSKProjectEuclidParser.m 2022-12-15 15:14:02 UTC (rev
28119)
@@ -109,7 +109,7 @@
match = [ProjectEuclidRegexp findInString:identifierString];
NSString * projectEuclidURLString = [match groupAtIndex:1];
- MRRequests = [BDSKMathSciNetParser bibTeXRequestsForMRIDs:MRIDs
referrer:[self URL] error:outError];
+ MRRequests = [BDSKMathSciNetParser bibTeXRequestsForMRIDs:MRIDs
serverName:nil error:outError];
NSString *URLString = myMRID ? projectEuclidURLString : nil;
for (NSURLRequest *request in MRRequests) {
@@ -118,7 +118,7 @@
URLString = nil;
}
- ZMathRequests = [BDSKZentralblattParser
bibTeXRequestsForZMathIDs:ZMathIDs referrer:[self URL] error:outError];
+ ZMathRequests = [BDSKZentralblattParser
bibTeXRequestsForZMathIDs:ZMathIDs serverName:nil error:outError];
URLString = myZMathID ? projectEuclidURLString : nil;
for (NSURLRequest *request in ZMathRequests) {
Modified: trunk/bibdesk/BDSKZentralblattParser.h
===================================================================
--- trunk/bibdesk/BDSKZentralblattParser.h 2022-12-15 11:10:59 UTC (rev
28118)
+++ trunk/bibdesk/BDSKZentralblattParser.h 2022-12-15 15:14:02 UTC (rev
28119)
@@ -41,6 +41,6 @@
@interface BDSKZentralblattParser : BDSKAsynchronousWebParser
-+ (NSArray *)bibTeXRequestsForZMathIDs:(NSArray *)IDs referrer:(NSURL
*)referrer error:(NSError **) outError;
++ (NSArray *)bibTeXRequestsForZMathIDs:(NSArray *)IDs serverName:(NSString
*)serverName error:(NSError **)outError;
+ (NSArray *)itemsFromDownload:(BDSKCitationDownload *)download
parser:(BDSKWebParser *)parser error:(NSError **)outError;
@end
Modified: trunk/bibdesk/BDSKZentralblattParser.m
===================================================================
--- trunk/bibdesk/BDSKZentralblattParser.m 2022-12-15 11:10:59 UTC (rev
28118)
+++ trunk/bibdesk/BDSKZentralblattParser.m 2022-12-15 15:14:02 UTC (rev
28119)
@@ -39,6 +39,7 @@
#import "BDSKZentralblattParser.h"
#import "BibItem.h"
#import "NSURL_BDSKExtensions.h"
+#import "NSString_BDSKExtensions.h"
#import <AGRegex/AGRegex.h>
#define ZMATHBATCHSIZE 100u
@@ -78,10 +79,19 @@
}
}
- requests = [BDSKZentralblattParser bibTeXRequestsForZMathIDs:IDArray
referrer:[self URL] error:outError];
+ // Determine the server name to use.
+ // If the referring URL's path begins with '/zmath', assume we are
using a Zentralblatt mirror server before and continue using that.
+ // If not, use the default server instead.
+ NSString * serverName = [[[self URL] host] lowercaseString];
+ if ( [[[self URL] path] hasCaseInsensitivePrefix:@"/ZMATH/zmath"] )
+ // some mirrors' paths begin with /ZMATH, add that
+ serverName = [serverName stringByAppendingString:@"/ZMATH"];
+ NSDictionary *contextInfo = [NSDictionary
dictionaryWithObjectsAndKeys:serverName, @"serverName", nil];
+ requests = [BDSKZentralblattParser bibTeXRequestsForZMathIDs:IDArray
serverName:serverName error:outError];
+
for (NSURLRequest *request in requests)
- [self addDownloadWithRequest:request contextInfo:nil];
+ [self addDownloadWithRequest:request contextInfo:contextInfo];
}
return nil;
@@ -92,21 +102,10 @@
}
// Turns an array of Zentralblatt Math IDs into an array of NSURLRequest
objects for bibtex data.
-+ (NSArray *)bibTeXRequestsForZMathIDs:(NSArray *)IDs referrer:(NSURL
*)referrer error:(NSError **)outError {
++ (NSArray *)bibTeXRequestsForZMathIDs:(NSArray *)IDs serverName:(NSString
*)serverName error:(NSError **)outError {
- // Determine the server name to use.
- // If the referring URL's path begins with '/zmath', assume we are using a
Zentralblatt mirror server before and continue using that.
- // If not, use the default server instead.
- NSString * serverName = [[referrer host] lowercaseString];
- if ( [BDSKZentralblattParser canParseDocument:nil fromURL:referrer] ) {
- if ( [[referrer path] hasPrefix:@"/zmath/ZMATH"] ) {
- // some mirrors' paths begin with /ZMATH, add that
- serverName = [serverName stringByAppendingString:@"/ZMATH"];
- }
- }
- else {
+ if (serverName == nil)
serverName = @"www.zentralblatt-math.org";
- }
// Loop through IDs in batches of ZMATHBATCHSIZE.
NSUInteger count = [IDs count];
@@ -142,13 +141,15 @@
bibTeXString = [umlautFixer replaceWithString:@"{$1}"
inString:bibTeXString];
NSArray * results = [parser itemsFromBibTeXString:bibTeXString
error:outError];
+ NSDictionary *contextInfo = [download contextInfo];
+ NSString *serverName = [contextInfo objectForKey:@"serverName"] ?:
@"zbmath.org";
// The extra URL can be passed by the BDSKProjectEuclidParser or
BDSKNumdamParser
- NSString * URLString = [[download contextInfo] objectForKey:@"URLString"];
+ NSString * URLString = [contextInfo objectForKey:@"URLString"];
// Add a URL reference to the review's web page to each record.
for (BibItem * item in results) {
NSString * ZMathID = [item citeKey];
- NSString * ZMathItemURLString = [NSString
stringWithFormat:@"https://zbmath.org/search/?format=complete&q=an:%@",
ZMathID];
+ NSString * ZMathItemURLString = [NSString
stringWithFormat:@"https://%@/search/?format=complete&q=an:%@", serverName,
ZMathID];
if ( URLString )
[item addURLString:URLString];
[item addURLString:ZMathItemURLString];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit