Revision: 29428
http://sourceforge.net/p/bibdesk/svn/29428
Author: hofman
Date: 2025-08-16 17:13:29 +0000 (Sat, 16 Aug 2025)
Log Message:
-----------
Separate methods to create items or add citation downloads in web parsers
Modified Paths:
--------------
trunk/bibdesk/BDSKACLParser.m
trunk/bibdesk/BDSKACMDLParser.m
trunk/bibdesk/BDSKArxivParser.m
trunk/bibdesk/BDSKAsynchronousWebParser.h
trunk/bibdesk/BDSKAsynchronousWebParser.m
trunk/bibdesk/BDSKBibTeXWebParser.m
trunk/bibdesk/BDSKCOinSParser.m
trunk/bibdesk/BDSKDOIWebParser.m
trunk/bibdesk/BDSKHCiteParser.m
trunk/bibdesk/BDSKHubmedParser.m
trunk/bibdesk/BDSKIACRParser.m
trunk/bibdesk/BDSKIEEEXploreParser.m
trunk/bibdesk/BDSKInspireParser.m
trunk/bibdesk/BDSKJSTORWebParser.m
trunk/bibdesk/BDSKMathSciNetParser.m
trunk/bibdesk/BDSKNumdamParser.m
trunk/bibdesk/BDSKProjectEuclidParser.m
trunk/bibdesk/BDSKSpringerParser.m
trunk/bibdesk/BDSKWebParser.h
trunk/bibdesk/BDSKWebParser.m
trunk/bibdesk/BDSKZentralblattParser.m
Modified: trunk/bibdesk/BDSKACLParser.m
===================================================================
--- trunk/bibdesk/BDSKACLParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKACLParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -76,21 +76,25 @@
}
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (NSArray *)itemsAndReturnError:(NSError **)outError {
+ // returning @[] indicates starting downloads
if ([[[self URL] path] hasCaseInsensitivePrefix:@"/anthology/events/"])
- return [super itemsOrAddDownloadsAndReturnError:outError];
+ return @[];
DOMNode *node = [[[self domDocument] documentElement]
singleNodeForXPath:BIBTEX_NODE_XPATH];
- if (node == nil)
- return nil;
+ if (node) {
+ NSString *bibtexString = [node textString];
+ NSArray *bibtexItems = [self itemsFromBibTeXString:bibtexString
error:outError];
+
+ if ([bibtexItems count]) {
+ [self addPDFURLsToItems:bibtexItems];
- NSString *bibtexString = [node textString];
- NSArray *bibtexItems = [self itemsFromBibTeXString:bibtexString
error:outError];
+ return bibtexItems;
+ }
+ }
- [self addPDFURLsToItems:bibtexItems];
-
- return bibtexItems;
+ return nil;
}
Modified: trunk/bibdesk/BDSKACMDLParser.m
===================================================================
--- trunk/bibdesk/BDSKACMDLParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKACMDLParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -65,7 +65,7 @@
return nil != [self citationURLStringFromNode:node];
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
NSString *doiNodeXPath = nil;
if ([[self URL] hasFirstPathComponent:@"doi"])
doiNodeXPath = @"./head/meta[@name='dc.Identifier' and
@scheme='doi']/@content";
@@ -89,8 +89,6 @@
[self addDownloadWithRequest:request contextInfo:urlString];
}
-
- return nil;
}
+ (NSString *)name {return @"ACM"; }
Modified: trunk/bibdesk/BDSKArxivParser.m
===================================================================
--- trunk/bibdesk/BDSKArxivParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKArxivParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -71,7 +71,7 @@
return node != nil;
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (NSArray *)itemsAndReturnError:(NSError **)outError {
NSURL *url = [self URL];
@@ -157,7 +157,7 @@
AGRegex *journalRegex3 = [AGRegex
regexWithPattern:@"(.+[^0-9])([0-9]+):(.*),([0-9]{4})"
options:AGRegexMultiline];
- NSMutableArray *items = [NSMutableArray arrayWithCapacity:0];
+ NSMutableArray *items = [NSMutableArray
arrayWithCapacity:[arxivSearchResults count]];
for (DOMNode *arxivSearchResult in arxivSearchResults) {
Modified: trunk/bibdesk/BDSKAsynchronousWebParser.h
===================================================================
--- trunk/bibdesk/BDSKAsynchronousWebParser.h 2025-08-16 15:37:24 UTC (rev
29427)
+++ trunk/bibdesk/BDSKAsynchronousWebParser.h 2025-08-16 17:13:29 UTC (rev
29428)
@@ -54,7 +54,7 @@
NSMutableArray *downloads;
}
-// A default implementation of -itemsOrAddDownloadsAndReturnError: and
+canParseDocument:fromURL:
+// A default implementation of -startCitationDownloads and
+canParseDocument:fromURL:
// relies on the implementation of the following subclass specific class
methods:
// An XPath to find a link(s) to bibTeX data, or an identifier that allows
creating a URL
@@ -64,7 +64,7 @@
// By default returns the href attribute of the node
+ (nullable NSString *)citationURLStringFromNode:(DOMNode *)node;
-// Subclasses can also override -itemsOrAddDownloadsAndReturnError: adding
downloads themselves using the following
+// Subclasses can also override -startCitationDownloads adding downloads
themselves using the following
- (void)addDownloadWithRequest:(NSURLRequest *)request contextInfo:(nullable
id)contextInfo;
// Main method to get items from the downloaded citations
Modified: trunk/bibdesk/BDSKAsynchronousWebParser.m
===================================================================
--- trunk/bibdesk/BDSKAsynchronousWebParser.m 2025-08-16 15:37:24 UTC (rev
29427)
+++ trunk/bibdesk/BDSKAsynchronousWebParser.m 2025-08-16 17:13:29 UTC (rev
29428)
@@ -54,7 +54,7 @@
}
- (BOOL)canFinishWithItems:(NSArray *)items success:(BOOL *)success {
- if (success) *success = [items count] > 0 || downloads != nil;
+ *success = [items count] > 0 || downloads != nil;
return [self finishedStarting] && [downloads count] == 0;
}
@@ -72,7 +72,7 @@
return nil != [self citationURLStringFromNode:node];
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
NSString *bibtexNodePath = [[self class] citationNodeXPath];
NSArray *bibtexNodes = [[[self domDocument] documentElement]
nodesForXPath:bibtexNodePath];
@@ -95,8 +95,6 @@
[self addDownloadWithRequest:request contextInfo:nil];
}
-
- return nil;
}
+ (NSString *)citationNodeXPath { return @""; }
Modified: trunk/bibdesk/BDSKBibTeXWebParser.m
===================================================================
--- trunk/bibdesk/BDSKBibTeXWebParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKBibTeXWebParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -54,10 +54,8 @@
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (NSArray *)itemsAndReturnError:(NSError **)outError {
- NSMutableArray *items = [NSMutableArray array];
-
NSString *text = [[[self domDocument] body] ?: [[self domDocument]
documentElement] textContent];
AGRegex *bibtexRegex = [AGRegex regexWithPattern:@"@[[:alpha:]]+[
\\t]*[{(]"];
@@ -64,6 +62,11 @@
NSArray *matches = [bibtexRegex findAllInString:text];
+ if ([matches count] == 0)
+ return nil;
+
+ NSMutableArray *items = [NSMutableArray array];
+
for (AGRegexMatch *match in matches) {
NSRange range = [match range];
NSUInteger closeLoc = [text
indexOfRightBracketMatchingLeftBracketAtIndex:NSMaxRange(range) - 1];
@@ -74,7 +77,7 @@
}
}
- return items;
+ return [items count] ? items : nil;
}
+ (NSString *)address { return @"https://en.wikipedia.org/wiki/BibTeX"; }
Modified: trunk/bibdesk/BDSKCOinSParser.m
===================================================================
--- trunk/bibdesk/BDSKCOinSParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKCOinSParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -317,10 +317,13 @@
}
// Process the document.
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (NSArray *)itemsAndReturnError:(NSError **)outError {
NSArray *nodes = [[[self domDocument] documentElement]
nodesForXPath:hasCOinSNodesXPath];
+ if ([nodes count] == 0)
+ return nil;
+
NSMutableArray *items = [NSMutableArray arrayWithCapacity:[nodes count]];
BibItem *bibItem;
@@ -329,7 +332,7 @@
[items addObject:bibItem];
}
- return items;
+ return [items count] ? items : nil;
}
+ (NSString *)name { return @"COinS"; }
Modified: trunk/bibdesk/BDSKDOIWebParser.m
===================================================================
--- trunk/bibdesk/BDSKDOIWebParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKDOIWebParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -62,7 +62,7 @@
return nil != [doiRegex findInString:text];
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
NSMutableArray *dois = [NSMutableArray array];
NSURL *baseURL = [NSURL URLWithString:@"https://doi.org/"];
DOMNode *rootElement = [[self domDocument] documentElement];
@@ -119,7 +119,6 @@
[self addDownloadWithRequest:request contextInfo:nil];
}
- return nil;
}
+ (NSString *)name { return @"DOI"; }
Modified: trunk/bibdesk/BDSKHCiteParser.m
===================================================================
--- trunk/bibdesk/BDSKHCiteParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKHCiteParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -63,16 +63,14 @@
return mainNode != nil;
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (NSArray *)itemsAndReturnError:(NSError **)outError {
- NSMutableArray *items = [NSMutableArray arrayWithCapacity:0];
-
// get hcite elements, avoid creating top-level refs from containers:
NSString *hciteXpath = @".//*[contains(concat(' ',normalize-space(@class),
' '),' hcite ') and not(contains(concat(' ', normalize-space(@class), ' '),'
container '))]";
NSArray *mainNodes = [[[self domDocument] documentElement]
nodesForXPath:hciteXpath];
if ([mainNodes count] == 0)
- return items;
+ return nil;
NSMutableDictionary *xpaths = [NSMutableDictionary dictionary];
[xpaths setValue:[[self domDocument]
createExpression:@".//*[contains(concat(' ',normalize-space(@class), ' '),'
creator ') and contains(concat(' ',normalize-space(@class), ' '),' vcard ')]"
resolver:nil] forKey:@"author"];
@@ -88,6 +86,8 @@
[xpaths setValue:[[self domDocument]
createExpression:@".//*[contains(concat(' ',normalize-space(@class),' '),' uri
')]" resolver:nil] forKey:@"uri"];
[xpaths setValue:[[self domDocument]
createExpression:@".//*[contains(concat(' ',normalize-space(@class),' '),' fn
')]" resolver:nil] forKey:@"fn"];
+ NSMutableArray *items = [NSMutableArray arrayWithCapacity:[mainNodes
count]];
+
for (DOMNode *obj in mainNodes) {
NSMutableDictionary *rd = nil;
NSString *type = nil;
Modified: trunk/bibdesk/BDSKHubmedParser.m
===================================================================
--- trunk/bibdesk/BDSKHubmedParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKHubmedParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -55,7 +55,7 @@
return nil != [regex findInString:[url query]];
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
// query is 'uids=<somenumber>':
// NSString *uidString = [[url query] substringWithRange:NSMakeRange(5,
[[url query] length] - 5)];
@@ -75,7 +75,6 @@
[self addDownloadWithRequest:request contextInfo:linkedURLString];
}
- return nil;
}
+ (NSString *)name {return @"HubMed"; }
Modified: trunk/bibdesk/BDSKIACRParser.m
===================================================================
--- trunk/bibdesk/BDSKIACRParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKIACRParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -71,50 +71,50 @@
+ (NSString *)citationNodeXPath { return @"./body//a[@class='paperlink']"; }
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (NSArray *)itemsAndReturnError:(NSError **)outError {
NSURL *url = [self URL];
- DOMElement *rootElement = [[self domDocument] documentElement];
AGRegex *yrnRegex = [AGRegex regexWithPattern:@"^/([0-9]{4})/([0-9]+)$"];
AGRegexMatch *yrnMatch = [yrnRegex findInString:[url path]];
- if (yrnMatch) {
- // individual article
+ // returning @[] indicates starting downloads
+ if (yrnMatch == nil)
+ return @[];
+
+ // individual article
+ DOMNode *bibtexNode = [[[self domDocument] documentElement]
singleNodeForXPath:@"./body//pre[@id='bibtex']"];
+
+ if (bibtexNode) {
+ NSString *bibtexString = [bibtexNode textString];
+ BibItem *item = [[self itemsFromBibTeXString:bibtexString
error:outError] firstObject];
- DOMNode *bibtexNode = [rootElement
singleNodeForXPath:@"./body//pre[@id='bibtex']"];
-
- if (bibtexNode) {
- NSString *bibtexString = [bibtexNode textString];
- BibItem *item = [[self itemsFromBibTeXString:bibtexString
error:outError] firstObject];
+ if (item) {
+ NSString *baseURLString = [url absoluteString];
+ [item setField:BDSKUrlString toValue:nil];
+ [item addURLString:[baseURLString
stringByAppendingPathExtension:@"pdf"]];
+ [item addURLString:baseURLString];
- if (item) {
- NSString *baseURLString = [url absoluteString];
- [item setField:BDSKUrlString toValue:nil];
- [item addURLString:[baseURLString
stringByAppendingPathExtension:@"pdf"]];
- [item addURLString:baseURLString];
-
- return @[item];
- }
+ return @[item];
}
-
- } else {
- // search results or articles of previous days
-
- NSArray *paperNodes = [rootElement nodesForXPath:[[self class]
citationNodeXPath]];
-
- for (DOMNode *paperNode in paperNodes) {
- NSString *path = [paperNode stringValueOfAttribute:@"href"];
- NSURL *bibtexURL = [[NSURL URLWithString:path relativeToURL:url]
absoluteURL];
- NSURLRequest *request = [NSURLRequest requestWithURL:bibtexURL];
- NSArray *contextInfo = @[[[bibtexURL absoluteString]
stringByAppendingPathExtension:@"pdf"], [bibtexURL absoluteString]];
-
- [self addDownloadWithRequest:request contextInfo:contextInfo];
- }
-
}
return nil;
}
+- (void)startCitationDownloads {
+ // search results or articles of previous days
+ NSURL *url = [self URL];
+ NSArray *paperNodes = [[[self domDocument] documentElement]
nodesForXPath:[[self class] citationNodeXPath]];
+
+ for (DOMNode *paperNode in paperNodes) {
+ NSString *path = [paperNode stringValueOfAttribute:@"href"];
+ NSURL *bibtexURL = [[NSURL URLWithString:path relativeToURL:url]
absoluteURL];
+ NSURLRequest *request = [NSURLRequest requestWithURL:bibtexURL];
+ NSArray *contextInfo = @[[[bibtexURL absoluteString]
stringByAppendingPathExtension:@"pdf"], [bibtexURL absoluteString]];
+
+ [self addDownloadWithRequest:request contextInfo:contextInfo];
+ }
+}
+
- (NSString *)bibTeXStringFromDownload:(BDSKCitationDownload *)download {
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:[download
data] options:NSXMLDocumentTidyHTML error:NULL];
Modified: trunk/bibdesk/BDSKIEEEXploreParser.m
===================================================================
--- trunk/bibdesk/BDSKIEEEXploreParser.m 2025-08-16 15:37:24 UTC (rev
29427)
+++ trunk/bibdesk/BDSKIEEEXploreParser.m 2025-08-16 17:13:29 UTC (rev
29428)
@@ -62,7 +62,7 @@
return [[domDocument documentElement]
singleNodeForXPath:containsAbstractPlusLinkNode] != nil;
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
/*
@@ -119,8 +119,6 @@
[self addDownloadWithRequest:request contextInfo:arnumberURLString];
}
-
- return nil;
}
- (NSString *)bibTeXStringFromDownload:(BDSKCitationDownload *)download {
Modified: trunk/bibdesk/BDSKInspireParser.m
===================================================================
--- trunk/bibdesk/BDSKInspireParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKInspireParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -56,7 +56,7 @@
return [[[url host] lowercaseString] isEqualToString:@"inspirehep.net"];
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
NSMutableString *downloadURLString = [[[self URL] absoluteString]
mutableCopy];
NSUInteger idx = [downloadURLString rangeOfString:@"/literature"].location;
@@ -68,7 +68,6 @@
[self addDownloadWithRequest:request contextInfo:nil];
}
- return nil;
}
+ (NSString *)name {return @"INSPIRE"; }
Modified: trunk/bibdesk/BDSKJSTORWebParser.m
===================================================================
--- trunk/bibdesk/BDSKJSTORWebParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKJSTORWebParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -55,7 +55,7 @@
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
// extract JSTOR article number
AGRegex *jstorRegex = [AGRegex regexWithPattern:@"^/stable/([0-9]+)"];
@@ -73,8 +73,6 @@
[self addDownloadWithRequest:request contextInfo:nil];
}
-
- return nil;
}
- (NSString *)bibTeXStringFromDownload:(BDSKCitationDownload *)download {
Modified: trunk/bibdesk/BDSKMathSciNetParser.m
===================================================================
--- trunk/bibdesk/BDSKMathSciNetParser.m 2025-08-16 15:37:24 UTC (rev
29427)
+++ trunk/bibdesk/BDSKMathSciNetParser.m 2025-08-16 17:13:29 UTC (rev
29428)
@@ -62,7 +62,7 @@
// Finds strings of type MR1234567 in the current page.
// Creates a list of their IDs (without leading zeroes), and retrieves the
BibItems for them.
// Returns an array with those BibItems.
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
AGRegex * MRRegexp = [AGRegex regexWithPattern:@"MR0*([0-9]+)"
options:AGRegexMultiline];
NSArray * regexpResults = [MRRegexp findAllInString:[[[self
domDocument] documentElement] innerHTML]];
@@ -92,9 +92,6 @@
for (NSURLRequest *request in requests)
[self addDownloadWithRequest:request contextInfo:contextInfo];
}
-
-
- return nil;
}
- (NSArray *)itemsFromDownload:(BDSKCitationDownload *)download error:(NSError
**)outError {
Modified: trunk/bibdesk/BDSKNumdamParser.m
===================================================================
--- trunk/bibdesk/BDSKNumdamParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKNumdamParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -60,7 +60,7 @@
// Find references from Zentralblatt Math referred to by the page. Then look
them up. Insert link to NUMDAM in the item's own record.
// (Support for MatSciNet is currently commented out as their lookup script
requires online-style MR1234567 identifiers and NUMDAM uses paper-style
identifiers a la 16,957b.)
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
DOMNode * tableCell = [[[self domDocument] documentElement]
singleNodeForXPath:@".//td[@id='contenu']"];
NSString * content = [tableCell textContent];
@@ -139,8 +139,6 @@
[self addDownloadWithRequest:request contextInfo:contextInfo];
firstZMathIDIsOwnId = NO;
}
-
- return nil;
}
- (NSArray *)itemsFromDownload:(BDSKCitationDownload *)download error:(NSError
**)outError {
Modified: trunk/bibdesk/BDSKProjectEuclidParser.m
===================================================================
--- trunk/bibdesk/BDSKProjectEuclidParser.m 2025-08-16 15:37:24 UTC (rev
29427)
+++ trunk/bibdesk/BDSKProjectEuclidParser.m 2025-08-16 17:13:29 UTC (rev
29428)
@@ -59,8 +59,8 @@
}
// Find references for Mathematical Reviews and Zentralblatt Math in the page.
Then look them up, giving preference to MSN if both are available.
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
-
+- (void)startCitationDownloads {
+
DOMNode * identifier = [[[self domDocument] documentElement]
singleNodeForXPath:@".//div[@id='identifier']/p"];
NSArray *MRRequests = nil;
@@ -127,9 +127,6 @@
URLString = nil;
}
}
-
-
- return nil;
}
- (NSArray *)itemsFromDownload:(BDSKCitationDownload *)download error:(NSError
**)outError {
Modified: trunk/bibdesk/BDSKSpringerParser.m
===================================================================
--- trunk/bibdesk/BDSKSpringerParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKSpringerParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -71,7 +71,7 @@
return node != nil;
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
+- (void)startCitationDownloads {
BOOL isArticle = [[self URL] hasFirstPathComponent:@"article"];
NSString *bibtexNodePath = nil;
if (isArticle)
@@ -93,8 +93,6 @@
[self addDownloadWithRequest:request contextInfo:doi];
}
-
- return nil;
}
- (NSArray *)itemsFromDownload:(BDSKCitationDownload *)download error:(NSError
**)outError {
Modified: trunk/bibdesk/BDSKWebParser.h
===================================================================
--- trunk/bibdesk/BDSKWebParser.h 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKWebParser.h 2025-08-16 17:13:29 UTC (rev 29428)
@@ -92,8 +92,12 @@
// this may be overridden by subclasses
+ (BOOL)shouldMonitorURL:(NSURL *)url;
-// main method for subclasses to implement
-- (nullable NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError;
+// main method for subclasses to implement for synchronous parsing
+// *outError may be nil even when returning nil
+- (nullable NSArray *)itemsAndReturnError:(NSError **)outError;
+// main method for subclasses to implement for asynchronous parsing
+// is called only when the previous method returns an empty array
+- (void)startCitationDownloads;
// information for the parser, to be implemented by the subclasses
@property (class, nonatomic, readonly) NSString *name;
Modified: trunk/bibdesk/BDSKWebParser.m
===================================================================
--- trunk/bibdesk/BDSKWebParser.m 2025-08-16 15:37:24 UTC (rev 29427)
+++ trunk/bibdesk/BDSKWebParser.m 2025-08-16 17:13:29 UTC (rev 29428)
@@ -185,10 +185,12 @@
NSError *error = nil;
- NSArray *items = [self itemsOrAddDownloadsAndReturnError:&error];
+ NSArray *items = [self itemsAndReturnError:&error];
if ([items count] > 0)
[[self delegate] webParser:self didFindItems:items];
+ else if (items)
+ [self startCitationDownloads];
[self setFinishedStarting:YES];
@@ -211,12 +213,14 @@
}
- (BOOL)canFinishWithItems:(NSArray *)items success:(BOOL *)success {
- if (success) *success = [items count] > 0;
+ *success = [items count] > 0;
return [self finishedStarting];
}
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError { return
nil; }
+- (NSArray *)itemsAndReturnError:(NSError **)outError { return @[]; }
+- (void)startCitationDownloads {}
+
+ (BOOL)canParseDocument:(DOMDocument *)domDocument fromURL:(NSURL *)url {
return NO; }
+ (BOOL)shouldMonitorURL:(NSURL *)url { return NO; }
Modified: trunk/bibdesk/BDSKZentralblattParser.m
===================================================================
--- trunk/bibdesk/BDSKZentralblattParser.m 2025-08-16 15:37:24 UTC (rev
29427)
+++ trunk/bibdesk/BDSKZentralblattParser.m 2025-08-16 17:13:29 UTC (rev
29428)
@@ -62,8 +62,8 @@
// Find occurrences of strings Zbl [pre]1234.56789 or JFM 12.3456.78 on the
page.
// Extract their IDs and look them up.
// Return the resulting BibItems.
-- (NSArray *)itemsOrAddDownloadsAndReturnError:(NSError **)outError {
-
+- (void)startCitationDownloads {
+
AGRegex *ZMathRegexp = [AGRegex regexWithPattern:@"(Zbl|JFM)
(pre)?([0-9.]*)" options:AGRegexMultiline];
NSArray * regexpResults = [ZMathRegexp findAllInString:[[[self
domDocument] documentElement] innerHTML]];
@@ -93,8 +93,6 @@
for (NSURLRequest *request in requests)
[self addDownloadWithRequest:request contextInfo:contextInfo];
}
-
- return nil;
}
- (NSArray *)itemsFromDownload:(BDSKCitationDownload *)download error:(NSError
**)outError {
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