Revision: 22533
http://sourceforge.net/p/bibdesk/svn/22533
Author: hofman
Date: 2018-08-26 16:28:57 +0000 (Sun, 26 Aug 2018)
Log Message:
-----------
Always try to add Url field, and optionally add linked file, for URL in web
parsers
Modified Paths:
--------------
trunk/bibdesk/BDSKAsynchronousWebParser.m
trunk/bibdesk/BDSKMathSciNetParser.m
trunk/bibdesk/BDSKNumdamParser.m
trunk/bibdesk/BDSKProjectEuclidParser.m
trunk/bibdesk/BDSKZentralblattParser.m
Modified: trunk/bibdesk/BDSKAsynchronousWebParser.m
===================================================================
--- trunk/bibdesk/BDSKAsynchronousWebParser.m 2018-08-26 16:08:05 UTC (rev
22532)
+++ trunk/bibdesk/BDSKAsynchronousWebParser.m 2018-08-26 16:28:57 UTC (rev
22533)
@@ -160,8 +160,11 @@
if ([[download contextInfo] isKindOfClass:[NSString class]] &&
(bibtexItem = [bibtexItems firstObject]) &&
- [NSString isEmptyString:[bibtexItem valueOfField:BDSKUrlString
inherit:NO]])
+ [NSString isEmptyString:[bibtexItem valueOfField:BDSKUrlString
inherit:NO]]) {
[bibtexItem setField:BDSKUrlString toValue:[download contextInfo]];
+ if (NO == [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey])
+ [bibtexItem addFileForURL:[NSURL URLWithString:[download
contextInfo]] autoFile:NO runScriptHook:NO];
+ }
return bibtexItems;
}
Modified: trunk/bibdesk/BDSKMathSciNetParser.m
===================================================================
--- trunk/bibdesk/BDSKMathSciNetParser.m 2018-08-26 16:08:05 UTC (rev
22532)
+++ trunk/bibdesk/BDSKMathSciNetParser.m 2018-08-26 16:28:57 UTC (rev
22533)
@@ -170,13 +170,12 @@
}
// Add a URL reference pointing to the review's web page to each record.
- BOOL useUrl = [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
+ BOOL addLinkedFiles = [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
for (BibItem * item in results) {
NSString * MRNumber = [[item citeKey] stringByRemovingPrefix:@"MR"];
NSURL * MRItemURL = [[NSURL URLWithString:[@"/mathscinet-getitem?mr="
stringByAppendingString:MRNumber] relativeToURL:[download URL]] absoluteURL];
- if (useUrl)
- [item setField:BDSKUrlString toValue:[MRItemURL absoluteString]];
- else
+ [item setField:BDSKUrlString toValue:[MRItemURL absoluteString]];
+ if (addLinkedFiles)
[item addFileForURL:MRItemURL autoFile:NO runScriptHook:NO];
}
Modified: trunk/bibdesk/BDSKNumdamParser.m
===================================================================
--- trunk/bibdesk/BDSKNumdamParser.m 2018-08-26 16:08:05 UTC (rev 22532)
+++ trunk/bibdesk/BDSKNumdamParser.m 2018-08-26 16:28:57 UTC (rev 22533)
@@ -142,7 +142,7 @@
NSDictionary *contextInfo = [download contextInfo];
Class parserClass = (Class)[contextInfo objectForKey:@"parserClass"];
NSString *content = [contextInfo objectForKey:@"content"];
- BOOL useUrl = [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
+ BOOL addLinkedFiles = NO == [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
results = [parserClass itemsFromDownload:download parser:self
error:outError];
@@ -156,15 +156,12 @@
NSString * myURLString = [[match string]
substringWithRange:[match rangeAtIndex:1]];
NSURL * myURL = [NSURL URLWithString:myURLString];
if ( myURL ) {
- if ( useUrl ) {
- BOOL added = [(BibItem *)item addFileForURL:myURL
autoFile:NO runScriptHook:NO];
- if ( added ) {
+ if ([NSString isEmptyString:[(BibItem *)item
valueOfField:BDSKUrlString]])
+ [(BibItem *)item setField:BDSKUrlString toValue:[myURL
absoluteString]];
+ if ( addLinkedFiles && [(BibItem *)item
addFileForURL:myURL autoFile:NO runScriptHook:NO] ) {
NSIndexSet * indexSet = [NSIndexSet
indexSetWithIndex:[(BibItem *)item countOfFiles] - 1];
[(BibItem *)item moveFilesAtIndexes:indexSet
toIndex:0];
}
- } else if ([NSString isEmptyString:[(BibItem *)item
valueOfField:BDSKUrlString]]) {
- [(BibItem *)item setField:BDSKUrlString toValue:[myURL
absoluteString]];
- }
}
}
}
Modified: trunk/bibdesk/BDSKProjectEuclidParser.m
===================================================================
--- trunk/bibdesk/BDSKProjectEuclidParser.m 2018-08-26 16:08:05 UTC (rev
22532)
+++ trunk/bibdesk/BDSKProjectEuclidParser.m 2018-08-26 16:28:57 UTC (rev
22533)
@@ -134,7 +134,7 @@
NSDictionary *contextInfo = [download contextInfo];
Class parserClass = (Class)[contextInfo objectForKey:@"parserClass"];
NSString *myIdentifier = [contextInfo objectForKey:@"myIdentifier"];
- BOOL useUrl = [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
+ BOOL addLinkedFiles = NO == [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
results = [parserClass itemsFromDownload:download parser:self
error:&error];
@@ -148,14 +148,11 @@
NSURL * projectEuclidURL = [NSURL
URLWithString:projectEuclidURLString];
if ( projectEuclidURL ) {
- if (useUrl == NO) {
- BOOL added = [(BibItem *)item
addFileForURL:projectEuclidURL autoFile:NO runScriptHook:NO];
- if ( added ) {
- NSIndexSet * indexSet = [NSIndexSet
indexSetWithIndex:[(BibItem *)item countOfFiles] - 1];
- [(BibItem *)item moveFilesAtIndexes:indexSet
toIndex:0];
- }
- } else if ([NSString isEmptyString:[(BibItem *)item
valueOfField:BDSKUrlString]]) {
+ if ([NSString isEmptyString:[(BibItem *)item
valueOfField:BDSKUrlString]])
[(BibItem *)item setField:BDSKUrlString
toValue:[projectEuclidURL absoluteString]];
+ if ( addLinkedFiles && [(BibItem *)item
addFileForURL:projectEuclidURL autoFile:NO runScriptHook:NO] ) {
+ NSIndexSet * indexSet = [NSIndexSet
indexSetWithIndex:[(BibItem *)item countOfFiles] - 1];
+ [(BibItem *)item moveFilesAtIndexes:indexSet toIndex:0];
}
}
}
Modified: trunk/bibdesk/BDSKZentralblattParser.m
===================================================================
--- trunk/bibdesk/BDSKZentralblattParser.m 2018-08-26 16:08:05 UTC (rev
22532)
+++ trunk/bibdesk/BDSKZentralblattParser.m 2018-08-26 16:28:57 UTC (rev
22533)
@@ -157,7 +157,7 @@
bibTeXString = [umlautFixer replaceWithString:@"{$1}"
inString:bibTeXString];
NSArray * results = [parser itemsFromBibTeXString:bibTeXString
error:outError];
- BOOL useUrl = [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
+ BOOL addLinkedFiles = NO == [[NSUserDefaults standardUserDefaults]
boolForKey:BDSKUseLocalUrlAndUrlKey];
// Add a URL reference to the review's web page to each record.
for (BibItem * item in results) {
@@ -164,10 +164,11 @@
NSString * ZMathID = [item citeKey];
NSString * ZMathItemURLString = [NSString
stringWithFormat:@"https://zbmath.org/search/?format=complete&q=an:%@",
ZMathID];
NSURL * ZMathItemURL = [NSURL URLWithString:ZMathItemURLString];
- if ( useUrl == NO )
+ if ([NSString isEmptyString:[item valueOfField:BDSKUrlString]])
+ [item setField:BDSKUrlString toValue:ZMathItemURLString];
+ if (addLinkedFiles)
[item addFileForURL:ZMathItemURL autoFile:NO runScriptHook:NO];
- else if ([NSString isEmptyString:[item valueOfField:BDSKUrlString]])
- [item setField:BDSKUrlString toValue:[ZMathItemURL
absoluteString]];
+
}
return results;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit