Revision: 21938
          http://sourceforge.net/p/bibdesk/svn/21938
Author:   hofman
Date:     2018-02-17 11:03:02 +0000 (Sat, 17 Feb 2018)
Log Message:
-----------
rename mathsiteparser files to projecteuclidparser

Modified Paths:
--------------
    trunk/bibdesk/BDSKWebParser.m
    trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/bibdesk/BDSKProjectEuclidParser.h
    trunk/bibdesk/BDSKProjectEuclidParser.m

Removed Paths:
-------------
    trunk/bibdesk/BDSKMathSiteParser.h
    trunk/bibdesk/BDSKMathSiteParser.m

Deleted: trunk/bibdesk/BDSKMathSiteParser.h
===================================================================
--- trunk/bibdesk/BDSKMathSiteParser.h  2018-02-17 11:00:49 UTC (rev 21937)
+++ trunk/bibdesk/BDSKMathSiteParser.h  2018-02-17 11:03:02 UTC (rev 21938)
@@ -1,45 +0,0 @@
-//
-//  BDSKProjectEuclidParser.h
-//  Bibdesk
-//
-//  Created by Sven-S. Porst on 2009-04-08.
-/*
- This software is Copyright (c) 2009-2018 Sven-S. Porst. 
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Sven-S. Porst nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-#import "BDSKAsynchronousWebParser.h"
-
-
-@interface BDSKProjectEuclidParser : BDSKAsynchronousWebParser
-@end
-

Deleted: trunk/bibdesk/BDSKMathSiteParser.m
===================================================================
--- trunk/bibdesk/BDSKMathSiteParser.m  2018-02-17 11:00:49 UTC (rev 21937)
+++ trunk/bibdesk/BDSKMathSiteParser.m  2018-02-17 11:03:02 UTC (rev 21938)
@@ -1,198 +0,0 @@
-//
-//  BDSKProjectEuclidParser.m
-//  Bibdesk
-//
-//  Created by Sven-S. Porst on 2009-04-08.
-/*
- This software is Copyright (c) 2009-2018
- Sven-S. Porst. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
-
- - Neither the name of Sven-S. Porst nor the names of any
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "BDSKProjectEuclidParser.h"
-#import "BDSKMathSciNetParser.h"
-#import "BDSKZentralblattParser.h"
-#import "NSError_BDSKExtensions.h"
-#import "BibItem.h"
-#import "BDSKComplexString.h"
-#import <AGRegex/AGRegex.h>
-
-
-@implementation BDSKProjectEuclidParser
-
-/*
- Recognise Project Euclid pages by their server name ending in 
projecteuclid.org.
-*/
-+ (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument 
*)xmlDocument fromURL:(NSURL *)url{
-       BOOL result = NO;
-       NSString * hostName = [url host];
-       if (hostName) {
-               result = ([hostName rangeOfString:@"projecteuclid.org" options: 
(NSAnchoredSearch | NSCaseInsensitiveSearch | NSBackwardsSearch)].location != 
NSNotFound);
-       }
-       return result;
-}
-
-/*
- Find references for Mathematical Reviews and Zentralblatt Math in the page. 
Then look them up, giving preference to MSN if both are available.
-*/
-- (void)startWithDelegate:(id<BDSKWebParserDelegate>)aDelegate {
-    [super startWithDelegate:aDelegate];
-    
-       NSError * error;
-    
-       NSArray * identifiers = [[[self xmlDocument] rootElement] 
nodesForXPath:@".//div[@id='identifier']/p" error:&error];
-       if ( [identifiers count] == 0 ) {
-        if (error == nil) {
-            error = [NSError mutableLocalErrorWithCode:kBDSKWebParserFailed 
localizedDescription:NSLocalizedString(@"No search results found", @"Web parser 
error")];
-            [error setValue:NSLocalizedString(@"Unable to parse this page.  
Please report this to BibDesk's developers and provide the URL.", @"Web parser 
error") forKey:NSLocalizedRecoverySuggestionErrorKey];
-        }
-        [[self delegate] webParser:self didFinishWithSuccess:NO error:error];
-        return;
-    } // no identifier on this page => probably a non-article page on the site 
=> return empty array
-       
-       NSXMLElement * identifier = [identifiers objectAtIndex:0];
-       NSString * identifierString = [identifier stringValue];
-       
-       AGRegex * MRRegexp = [AGRegex regexWithPattern:@"MR([1-9][0-9]*)" 
options:0];
-       AGRegex * ZMathRegexp = [AGRegex regexWithPattern:@"Zentralblatt.* 
([0-9.]+)" options:0];
-       AGRegexMatch * match;
-       
-    NSString * myMRID = nil;
-    NSString * myZMathID = nil;
-    
-       // find IDs for the item itself
-       match = [MRRegexp findInString:identifierString];
-    myMRID = [[match string] substringWithRange:[match rangeAtIndex:1]];
-    if (myMRID == nil) {
-        match = [ZMathRegexp findInString:identifierString];
-        myZMathID = [[match string] substringWithRange:[match rangeAtIndex:1]];
-    }
-    
-       // Set up arrays for the lists of MathSciNet and Zentralblatt IDs. 
These will have the ID for the current element at position 0 and contain NSNull 
when no ID is found for the respective service.
-       NSArray * references = [[[self xmlDocument] rootElement] 
nodesForXPath:@".//div[@id='references']/div[@class='ref-block']" error:&error];
-    NSMutableArray * MRIDs = [NSMutableArray arrayWithObjects:myMRID, nil];
-       NSMutableArray * ZMathIDs = [NSMutableArray arrayWithObjects:myZMathID, 
nil];
-       
-       for (NSXMLElement * reference in references) {
-               NSString * referenceString = [reference stringValue];
-
-               match = [MRRegexp findInString:referenceString];
-               NSString * referenceID = [[match string] 
substringWithRange:[match rangeAtIndex:1]];
-        if (referenceID) {
-            [MRIDs addObject:referenceID];
-        } else {
-            match = [ZMathRegexp findInString:referenceString];
-            referenceID = [[match string] substringWithRange:[match 
rangeAtIndex:1]];
-            if (referenceID)
-                [ZMathIDs addObject:referenceID];
-        }
-       }
-       
-    NSArray *MRRequests = [BDSKMathSciNetParser bibTeXRequestsForMRIDs:MRIDs 
referrer:[self URL] error:&error];
-    
-    NSString *myIdentifier = myMRID ? identifierString : nil;
-    for (NSURLRequest *request in MRRequests) {
-        BDSKCitationDownload *download = [[BDSKCitationDownload alloc] 
initWithRequest:request delegate:self];
-        [self addDownload:download];
-        NSDictionary *contextInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:[BDSKMathSciNetParser class], @"parserClass", 
myIdentifier, @"identifier", nil];
-        [download setContextInfo:contextInfo];
-        [download release];
-        myIdentifier = nil;
-    }
-    
-    NSArray *ZMathRequests = [BDSKZentralblattParser 
bibTeXRequestsForZMathIDs:ZMathIDs referrer:[self URL] error:&error];
-    
-    myIdentifier = myZMathID ? identifierString : nil;
-    for (NSURLRequest *request in ZMathRequests) {
-        BDSKCitationDownload *download = [[BDSKCitationDownload alloc] 
initWithRequest:request delegate:self];
-        [self addDownload:download];
-        NSDictionary *contextInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:[BDSKZentralblattParser class], @"parserClass", 
myIdentifier, @"myIdentifier", nil];
-        [download setContextInfo:contextInfo];
-        [download release];
-        myIdentifier = nil;
-    }
-    
-    BOOL success = [MRRequests count] > 0 || [ZMathRequests count] > 0;
-    [self setFinishedSending:YES];
-    if ([self hasDownloads] == NO)
-        [[self delegate] webParser:self didFinishWithSuccess:success 
error:error];
-}
-
-- (void)downloadDidFinish:(BDSKCitationDownload *)download {
-    NSArray *results = nil;
-    NSError *error = nil;
-    NSArray *bibtexItems = nil;
-    NSString *bibTeXString = [download string];
-    NSDictionary *contextInfo = [download contextInfo];
-    Class parserClass = (Class)[contextInfo objectForKey:@"parserClass"];
-    NSString *myIdentifier = [contextInfo objectForKey:@"myIdentifier"];
-    
-    if (bibTeXString) {
-        // parse the bibTeX string with the correct parser
-        results = [parserClass bibItemsFromBibTeXString:bibTeXString 
fromURL:[download URL] error:&error];
-        
-        if (myIdentifier && [results count] > 0) {
-            // add Project Euclid URL to item's own record
-            NSObject * item = [results objectAtIndex:0];
-            if ( [item isKindOfClass:[BibItem class]] ) {
-                AGRegex * ProjectEuclidRegexp = [AGRegex 
regexWithPattern:@"(https://projecteuclid.org/[^\\s]*)" options:0];
-                AGRegexMatch * match = [ProjectEuclidRegexp 
findInString:myIdentifier];
-                NSString * projectEuclidURLString = [[match string] 
substringWithRange:[match rangeAtIndex:1]];
-                NSURL * projectEuclidURL = [NSURL 
URLWithString:projectEuclidURLString];
-                
-                if ( projectEuclidURL ) {
-                    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];
-                    }
-                }
-            }
-        }
-    }
-    
-    if ([results count])
-        [[self delegate] webParser:self didFindItems:results];
-    
-    [self removeDownload:download];
-    
-    if ([self finishedSending] && [self hasDownloads] == NO)
-        [[self delegate] webParser:self didFinishWithSuccess:YES error:nil];
-    
-}
-
-
-+ (NSDictionary *)parserInfo {
-       NSString * parserDescription = NSLocalizedString(@"Project Euclid 
provides a publishing platform for \342\200\230independent and society 
journals\342\200\231 in mathematics and statistics. BibDesk can provide 
bibliographic information for its articles if you have access to MathSciNet or 
Zentralblatt Math.", @"Description for Project Euclid site");
-       return [BDSKWebParser parserInfoWithName:@"Project Euclid" 
address:@"http://projecteuclid.org/";  description: parserDescription 
feature:BDSKParserFeatureSubscription];
-}
-
-@end
-

Copied: trunk/bibdesk/BDSKProjectEuclidParser.h (from rev 21937, 
trunk/bibdesk/BDSKMathSiteParser.h)
===================================================================
--- trunk/bibdesk/BDSKProjectEuclidParser.h                             (rev 0)
+++ trunk/bibdesk/BDSKProjectEuclidParser.h     2018-02-17 11:03:02 UTC (rev 
21938)
@@ -0,0 +1,45 @@
+//
+//  BDSKProjectEuclidParser.h
+//  Bibdesk
+//
+//  Created by Sven-S. Porst on 2009-04-08.
+/*
+ This software is Copyright (c) 2009-2018 Sven-S. Porst. 
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Sven-S. Porst nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import "BDSKAsynchronousWebParser.h"
+
+
+@interface BDSKProjectEuclidParser : BDSKAsynchronousWebParser
+@end
+

Copied: trunk/bibdesk/BDSKProjectEuclidParser.m (from rev 21937, 
trunk/bibdesk/BDSKMathSiteParser.m)
===================================================================
--- trunk/bibdesk/BDSKProjectEuclidParser.m                             (rev 0)
+++ trunk/bibdesk/BDSKProjectEuclidParser.m     2018-02-17 11:03:02 UTC (rev 
21938)
@@ -0,0 +1,198 @@
+//
+//  BDSKProjectEuclidParser.m
+//  Bibdesk
+//
+//  Created by Sven-S. Porst on 2009-04-08.
+/*
+ This software is Copyright (c) 2009-2018
+ Sven-S. Porst. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Sven-S. Porst nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "BDSKProjectEuclidParser.h"
+#import "BDSKMathSciNetParser.h"
+#import "BDSKZentralblattParser.h"
+#import "NSError_BDSKExtensions.h"
+#import "BibItem.h"
+#import "BDSKComplexString.h"
+#import <AGRegex/AGRegex.h>
+
+
+@implementation BDSKProjectEuclidParser
+
+/*
+ Recognise Project Euclid pages by their server name ending in 
projecteuclid.org.
+*/
++ (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument 
*)xmlDocument fromURL:(NSURL *)url{
+       BOOL result = NO;
+       NSString * hostName = [url host];
+       if (hostName) {
+               result = ([hostName rangeOfString:@"projecteuclid.org" options: 
(NSAnchoredSearch | NSCaseInsensitiveSearch | NSBackwardsSearch)].location != 
NSNotFound);
+       }
+       return result;
+}
+
+/*
+ Find references for Mathematical Reviews and Zentralblatt Math in the page. 
Then look them up, giving preference to MSN if both are available.
+*/
+- (void)startWithDelegate:(id<BDSKWebParserDelegate>)aDelegate {
+    [super startWithDelegate:aDelegate];
+    
+       NSError * error;
+    
+       NSArray * identifiers = [[[self xmlDocument] rootElement] 
nodesForXPath:@".//div[@id='identifier']/p" error:&error];
+       if ( [identifiers count] == 0 ) {
+        if (error == nil) {
+            error = [NSError mutableLocalErrorWithCode:kBDSKWebParserFailed 
localizedDescription:NSLocalizedString(@"No search results found", @"Web parser 
error")];
+            [error setValue:NSLocalizedString(@"Unable to parse this page.  
Please report this to BibDesk's developers and provide the URL.", @"Web parser 
error") forKey:NSLocalizedRecoverySuggestionErrorKey];
+        }
+        [[self delegate] webParser:self didFinishWithSuccess:NO error:error];
+        return;
+    } // no identifier on this page => probably a non-article page on the site 
=> return empty array
+       
+       NSXMLElement * identifier = [identifiers objectAtIndex:0];
+       NSString * identifierString = [identifier stringValue];
+       
+       AGRegex * MRRegexp = [AGRegex regexWithPattern:@"MR([1-9][0-9]*)" 
options:0];
+       AGRegex * ZMathRegexp = [AGRegex regexWithPattern:@"Zentralblatt.* 
([0-9.]+)" options:0];
+       AGRegexMatch * match;
+       
+    NSString * myMRID = nil;
+    NSString * myZMathID = nil;
+    
+       // find IDs for the item itself
+       match = [MRRegexp findInString:identifierString];
+    myMRID = [[match string] substringWithRange:[match rangeAtIndex:1]];
+    if (myMRID == nil) {
+        match = [ZMathRegexp findInString:identifierString];
+        myZMathID = [[match string] substringWithRange:[match rangeAtIndex:1]];
+    }
+    
+       // Set up arrays for the lists of MathSciNet and Zentralblatt IDs. 
These will have the ID for the current element at position 0 and contain NSNull 
when no ID is found for the respective service.
+       NSArray * references = [[[self xmlDocument] rootElement] 
nodesForXPath:@".//div[@id='references']/div[@class='ref-block']" error:&error];
+    NSMutableArray * MRIDs = [NSMutableArray arrayWithObjects:myMRID, nil];
+       NSMutableArray * ZMathIDs = [NSMutableArray arrayWithObjects:myZMathID, 
nil];
+       
+       for (NSXMLElement * reference in references) {
+               NSString * referenceString = [reference stringValue];
+
+               match = [MRRegexp findInString:referenceString];
+               NSString * referenceID = [[match string] 
substringWithRange:[match rangeAtIndex:1]];
+        if (referenceID) {
+            [MRIDs addObject:referenceID];
+        } else {
+            match = [ZMathRegexp findInString:referenceString];
+            referenceID = [[match string] substringWithRange:[match 
rangeAtIndex:1]];
+            if (referenceID)
+                [ZMathIDs addObject:referenceID];
+        }
+       }
+       
+    NSArray *MRRequests = [BDSKMathSciNetParser bibTeXRequestsForMRIDs:MRIDs 
referrer:[self URL] error:&error];
+    
+    NSString *myIdentifier = myMRID ? identifierString : nil;
+    for (NSURLRequest *request in MRRequests) {
+        BDSKCitationDownload *download = [[BDSKCitationDownload alloc] 
initWithRequest:request delegate:self];
+        [self addDownload:download];
+        NSDictionary *contextInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:[BDSKMathSciNetParser class], @"parserClass", 
myIdentifier, @"identifier", nil];
+        [download setContextInfo:contextInfo];
+        [download release];
+        myIdentifier = nil;
+    }
+    
+    NSArray *ZMathRequests = [BDSKZentralblattParser 
bibTeXRequestsForZMathIDs:ZMathIDs referrer:[self URL] error:&error];
+    
+    myIdentifier = myZMathID ? identifierString : nil;
+    for (NSURLRequest *request in ZMathRequests) {
+        BDSKCitationDownload *download = [[BDSKCitationDownload alloc] 
initWithRequest:request delegate:self];
+        [self addDownload:download];
+        NSDictionary *contextInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:[BDSKZentralblattParser class], @"parserClass", 
myIdentifier, @"myIdentifier", nil];
+        [download setContextInfo:contextInfo];
+        [download release];
+        myIdentifier = nil;
+    }
+    
+    BOOL success = [MRRequests count] > 0 || [ZMathRequests count] > 0;
+    [self setFinishedSending:YES];
+    if ([self hasDownloads] == NO)
+        [[self delegate] webParser:self didFinishWithSuccess:success 
error:error];
+}
+
+- (void)downloadDidFinish:(BDSKCitationDownload *)download {
+    NSArray *results = nil;
+    NSError *error = nil;
+    NSArray *bibtexItems = nil;
+    NSString *bibTeXString = [download string];
+    NSDictionary *contextInfo = [download contextInfo];
+    Class parserClass = (Class)[contextInfo objectForKey:@"parserClass"];
+    NSString *myIdentifier = [contextInfo objectForKey:@"myIdentifier"];
+    
+    if (bibTeXString) {
+        // parse the bibTeX string with the correct parser
+        results = [parserClass bibItemsFromBibTeXString:bibTeXString 
fromURL:[download URL] error:&error];
+        
+        if (myIdentifier && [results count] > 0) {
+            // add Project Euclid URL to item's own record
+            NSObject * item = [results objectAtIndex:0];
+            if ( [item isKindOfClass:[BibItem class]] ) {
+                AGRegex * ProjectEuclidRegexp = [AGRegex 
regexWithPattern:@"(https://projecteuclid.org/[^\\s]*)" options:0];
+                AGRegexMatch * match = [ProjectEuclidRegexp 
findInString:myIdentifier];
+                NSString * projectEuclidURLString = [[match string] 
substringWithRange:[match rangeAtIndex:1]];
+                NSURL * projectEuclidURL = [NSURL 
URLWithString:projectEuclidURLString];
+                
+                if ( projectEuclidURL ) {
+                    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];
+                    }
+                }
+            }
+        }
+    }
+    
+    if ([results count])
+        [[self delegate] webParser:self didFindItems:results];
+    
+    [self removeDownload:download];
+    
+    if ([self finishedSending] && [self hasDownloads] == NO)
+        [[self delegate] webParser:self didFinishWithSuccess:YES error:nil];
+    
+}
+
+
++ (NSDictionary *)parserInfo {
+       NSString * parserDescription = NSLocalizedString(@"Project Euclid 
provides a publishing platform for \342\200\230independent and society 
journals\342\200\231 in mathematics and statistics. BibDesk can provide 
bibliographic information for its articles if you have access to MathSciNet or 
Zentralblatt Math.", @"Description for Project Euclid site");
+       return [BDSKWebParser parserInfoWithName:@"Project Euclid" 
address:@"http://projecteuclid.org/";  description: parserDescription 
feature:BDSKParserFeatureSubscription];
+}
+
+@end
+

Modified: trunk/bibdesk/BDSKWebParser.m
===================================================================
--- trunk/bibdesk/BDSKWebParser.m       2018-02-17 11:00:49 UTC (rev 21937)
+++ trunk/bibdesk/BDSKWebParser.m       2018-02-17 11:03:02 UTC (rev 21938)
@@ -47,10 +47,10 @@
 #import "BDSKIACRParser.h"
 #import "BDSKJSTORWebParser.h"
 #import "BDSKSpringerParser.h"
+#import "BDSKScienceDirectParser.h"
 #import "BDSKMathSciNetParser.h"
-#import "BDSKScienceDirectParser.h"
 #import "BDSKZentralblattParser.h"
-#import "BDSKMathSiteParser.h"
+#import "BDSKProjectEuclidParser.h"
 #import "BDSKNumdamParser.h"
 #import "BDSKSIAMParser.h"
 #import "BDSKIUCrParser.h"

Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2018-02-17 11:00:49 UTC 
(rev 21937)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2018-02-17 11:03:02 UTC 
(rev 21938)
@@ -63,7 +63,7 @@
                45DB3E8F0CAAFED5001EACDA /* BDSKHubmedParser.m in Sources */ = 
{isa = PBXBuildFile; fileRef = 45DB3E8D0CAAFED5001EACDA /* BDSKHubmedParser.m 
*/; };
                6C567DBA0F8189F500DE285D /* BDSKZentralblattParser.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = 6C567DB80F8189F500DE285D /* 
BDSKZentralblattParser.m */; };
                6C567DBF0F818A1600DE285D /* BDSKMathSciNetParser.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = 6C567DBD0F818A1600DE285D /* 
BDSKMathSciNetParser.m */; };
-               6C5DE3E80F8FC33B00E02D5F /* BDSKMathSiteParser.m in Sources */ 
= {isa = PBXBuildFile; fileRef = 6C5DE3E60F8FC33B00E02D5F /* 
BDSKMathSiteParser.m */; };
+               6C5DE3E80F8FC33B00E02D5F /* BDSKProjectEuclidParser.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 6C5DE3E60F8FC33B00E02D5F /* 
BDSKProjectEuclidParser.m */; };
                6CAEE4CD0F98EC63009EA5FE /* BDSKCOinSParser.m in Sources */ = 
{isa = PBXBuildFile; fileRef = 6CAEE4CB0F98EC63009EA5FE /* BDSKCOinSParser.m 
*/; };
                6CD26A240F928EEE0089FDFD /* BDSKBibDeskProtocol.m in Sources */ 
= {isa = PBXBuildFile; fileRef = 6CD26A220F928EEE0089FDFD /* 
BDSKBibDeskProtocol.m */; };
                8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = 
{isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings 
*/; };
@@ -809,8 +809,8 @@
                6C567DB80F8189F500DE285D /* BDSKZentralblattParser.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = BDSKZentralblattParser.m; sourceTree = "<group>"; };
                6C567DBD0F818A1600DE285D /* BDSKMathSciNetParser.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKMathSciNetParser.m; sourceTree = "<group>"; };
                6C567DBE0F818A1600DE285D /* BDSKMathSciNetParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKMathSciNetParser.h; sourceTree = "<group>"; };
-               6C5DE3E50F8FC33B00E02D5F /* BDSKMathSiteParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKMathSiteParser.h; sourceTree = "<group>"; };
-               6C5DE3E60F8FC33B00E02D5F /* BDSKMathSiteParser.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKMathSiteParser.m; sourceTree = "<group>"; };
+               6C5DE3E50F8FC33B00E02D5F /* BDSKProjectEuclidParser.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path 
= BDSKProjectEuclidParser.h; sourceTree = "<group>"; };
+               6C5DE3E60F8FC33B00E02D5F /* BDSKProjectEuclidParser.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = BDSKProjectEuclidParser.m; sourceTree = "<group>"; };
                6CAEE4CA0F98EC63009EA5FE /* BDSKCOinSParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKCOinSParser.h; sourceTree = "<group>"; };
                6CAEE4CB0F98EC63009EA5FE /* BDSKCOinSParser.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKCOinSParser.m; sourceTree = "<group>"; };
                6CD26A210F928EEE0089FDFD /* BDSKBibDeskProtocol.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKBibDeskProtocol.h; sourceTree = "<group>"; };
@@ -2290,7 +2290,7 @@
                                CD50E5F911A2190E00848756 /* 
BDSKJSTORWebParser.m */,
                                CE0AB6FF14BB019400638C8F /* BDSKMASParser.m */,
                                6C567DBD0F818A1600DE285D /* 
BDSKMathSciNetParser.m */,
-                               6C5DE3E60F8FC33B00E02D5F /* 
BDSKMathSiteParser.m */,
+                               6C5DE3E60F8FC33B00E02D5F /* 
BDSKProjectEuclidParser.m */,
                                CE6CF9992038413C000B73D3 /* BDSKNumdamParser.m 
*/,
                                CE624DB52030BCAE004B6E0B /* BDSKSIAMParser.m */,
                                CE624DA52030B35A004B6E0B /* 
BDSKScienceDirectParser.m */,
@@ -2604,7 +2604,7 @@
                                CE34A5710B249E0B00755730 /* BDSKMARCParser.h */,
                                CE0AB6FE14BB019400638C8F /* BDSKMASParser.h */,
                                6C567DBE0F818A1600DE285D /* 
BDSKMathSciNetParser.h */,
-                               6C5DE3E50F8FC33B00E02D5F /* 
BDSKMathSiteParser.h */,
+                               6C5DE3E50F8FC33B00E02D5F /* 
BDSKProjectEuclidParser.h */,
                                CE8DAD8D1098976400896F69 /* 
BDSKMetadataCacheOperation.h */,
                                F9D0E5340BF92768001C6C22 /* BDSKMODSParser.h */,
                                CEF536681192EFE400027C3C /* 
BDSKNotesOutlineView.h */,
@@ -3625,7 +3625,7 @@
                                6C567DBA0F8189F500DE285D /* 
BDSKZentralblattParser.m in Sources */,
                                6C567DBF0F818A1600DE285D /* 
BDSKMathSciNetParser.m in Sources */,
                                CE1EF2940F8E0D54004E7AE8 /* BDSKParentGroup.m 
in Sources */,
-                               6C5DE3E80F8FC33B00E02D5F /* 
BDSKMathSiteParser.m in Sources */,
+                               6C5DE3E80F8FC33B00E02D5F /* 
BDSKProjectEuclidParser.m in Sources */,
                                CEDED0952032450B003FA44D /* BDSKIUCrParser.m in 
Sources */,
                                6CD26A240F928EEE0089FDFD /* 
BDSKBibDeskProtocol.m in Sources */,
                                6CAEE4CD0F98EC63009EA5FE /* BDSKCOinSParser.m 
in Sources */,

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
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to