Revision: 16904
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=16904&view=rev
Author:   hofman
Date:     2010-05-18 09:37:26 +0000 (Tue, 18 May 2010)

Log Message:
-----------
add JSTOR web parser, written by Douglas Stebila

Modified Paths:
--------------
    trunk/bibdesk/BDSKWebParser.m
    trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
    trunk/bibdesk/English.lproj/BibDeskHelp/bibdesk.texi

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

Added: trunk/bibdesk/BDSKJSTORWebParser.h
===================================================================
--- trunk/bibdesk/BDSKJSTORWebParser.h                          (rev 0)
+++ trunk/bibdesk/BDSKJSTORWebParser.h  2010-05-18 09:37:26 UTC (rev 16904)
@@ -0,0 +1,44 @@
+//
+//  BDSKJSTORWebParser.h
+//  Bibdesk
+//
+//  Created by Douglas Stebila on 5/18/10.
+/*
+ This software is Copyright (c) 2010
+ Douglas Stebila. 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 Douglas Stebila 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 "BDSKWebParser.h"
+
+
+...@interface BDSKJSTORWebParser: NSObject <BDSKWebParser>
+...@end

Added: trunk/bibdesk/BDSKJSTORWebParser.m
===================================================================
--- trunk/bibdesk/BDSKJSTORWebParser.m                          (rev 0)
+++ trunk/bibdesk/BDSKJSTORWebParser.m  2010-05-18 09:37:26 UTC (rev 16904)
@@ -0,0 +1,109 @@
+//
+//  BDSKJSTORWebParser.m
+//  Bibdesk
+//
+//  Created by Douglas Stebila on 5/18/10.
+/*
+ This software is Copyright (c) 2010
+ Douglas Stebila. 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 Douglas Stebila 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 "BDSKJSTORWebParser.h"
+#import "BDSKBibTeXParser.h"
+#import "BibItem.h"
+#import "NSError_BDSKExtensions.h"
+#import "NSXMLNode_BDSKExtensions.h"
+#import <AGRegex/AGRegex.h>
+
+
+...@implementation BDSKJSTORWebParser
+
++ (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument 
*)xmlDocument fromURL:(NSURL *)url{
+    
+    if (nil == [url host] || NO == [[[url host] lowercaseString] 
hasSuffix:@"jstor.org"]){
+        return NO;
+    }
+    
+    AGRegex *absRegex = [AGRegex regexWithPattern:@"^/stable/[0-9]+"];
+       BOOL isAbstract = ([absRegex findInString:[url path]] != nil);
+       
+       return isAbstract;
+       
+}
+
++ (NSArray *)itemsFromDocument:(DOMDocument *)domDocument 
xmlDocument:(NSXMLDocument *)xmlDocument fromURL:(NSURL *)url error:(NSError 
**)outError{
+       
+    NSMutableArray *items = [NSMutableArray arrayWithCapacity:1];
+       
+       NSError *error = nil;
+       NSStringEncoding encoding = NSASCIIStringEncoding;
+       
+       // extract JSTOR article number
+       NSString *jstorNumber;
+       AGRegex *jstorRegex = [AGRegex regexWithPattern:@"^/stable/([0-9]+)"];
+       AGRegexMatch *jstorMatch = [jstorRegex findInString:[url path]];
+       if ([jstorMatch count] != 2) {
+               return items;
+       }
+       jstorNumber = [jstorMatch groupAtIndex:1];
+       
+       // download BibTeX data
+       NSString *bibtexURLString = [NSString 
stringWithFormat:@"http://www.jstor.org/action/downloadSingleCitation?format=bibtex&include=abs&singleCitation=true&suffix=%@";,
 jstorNumber];
+       NSURL *bibtexURL = [NSURL URLWithString:bibtexURLString];
+       NSString *bibtexData = [NSString stringWithContentsOfURL:bibtexURL 
usedEncoding:&encoding error:&error];
+       if (bibtexData == nil) {
+               return items;
+       }
+       
+       // remove characters before the first @ symbol
+       NSRange range = [bibtexData rangeOfString:@"@"];
+       if (range.location == NSNotFound) {
+               return items;
+       }
+       bibtexData = [bibtexData substringFromIndex:range.location];
+
+       // parse BibTeX data
+       NSArray *parsedItems = [BDSKBibTeXParser itemsFromString:bibtexData 
owner:nil isPartialData:NO error:outError];
+       if (parsedItems) {
+               [items addObjectsFromArray:parsedItems];
+       }
+       
+       return items;  
+}
+
++ (NSArray *) parserInfos {
+       NSString * parserDescription = NSLocalizedString(@"JSTOR archives.", 
@"Description for JSTOR site");
+       NSDictionary * parserInfo = [BDSKWebParser parserInfoWithName:@"JSTOR" 
address:@"http://www.jstor.org/"; description:parserDescription 
flags:BDSKParserFeatureSubscriptionMask];
+       
+       return [NSArray arrayWithObject: parserInfo];
+}
+
+...@end

Modified: trunk/bibdesk/BDSKWebParser.m
===================================================================
--- trunk/bibdesk/BDSKWebParser.m       2010-05-18 03:07:37 UTC (rev 16903)
+++ trunk/bibdesk/BDSKWebParser.m       2010-05-18 09:37:26 UTC (rev 16904)
@@ -46,6 +46,7 @@
 #import "BDSKSpiresParser.h"
 #import "BDSKArxivParser.h"
 #import "BDSKIACRParser.h"
+#import "BDSKJSTORWebParser.h"
 #import "BDSKSpringerParser.h"
 #import "BDSKMathSciNetParser.h"
 #import "BDSKZentralblattParser.h"
@@ -73,6 +74,7 @@
                         [BDSKSpiresParser class], 
                         [BDSKArxivParser class], 
                                            [BDSKIACRParser class], 
+                                           [BDSKJSTORWebParser class], 
                                            [BDSKSpringerParser class], 
                         [BDSKMathSciNetParser class], 
                         [BDSKZentralblattParser class], 

Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2010-05-18 03:07:37 UTC 
(rev 16903)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2010-05-18 09:37:26 UTC 
(rev 16904)
@@ -67,6 +67,8 @@
                8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = 
{isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings 
*/; };
                8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = 
{ATTRIBUTES = (); }; };
                8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = 
{isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; 
};
+               CD50E5FA11A2190E00848756 /* BDSKJSTORWebParser.h in Headers */ 
= {isa = PBXBuildFile; fileRef = CD50E5F811A2190E00848756 /* 
BDSKJSTORWebParser.h */; };
+               CD50E5FB11A2190E00848756 /* BDSKJSTORWebParser.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CD50E5F911A2190E00848756 /* 
BDSKJSTORWebParser.m */; };
                CD6295361140DE16002E4751 /* BDSKIACRParser.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CD6295351140DE16002E4751 /* BDSKIACRParser.m */; 
};
                CD6295381140DE1C002E4751 /* BDSKSpringerParser.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CD6295371140DE1C002E4751 /* 
BDSKSpringerParser.m */; };
                CD86BA3A1141C023005EEFDA /* BDSKBibTeXWebParser.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CD86BA391141C023005EEFDA /* 
BDSKBibTeXWebParser.m */; };
@@ -827,6 +829,8 @@
                6CD26A220F928EEE0089FDFD /* BDSKBibDeskProtocol.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKBibDeskProtocol.m; sourceTree = "<group>"; };
                8D1107310486CEB800E47090 /* Info.plist */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = 
Info.plist; sourceTree = "<group>"; };
                8D1107320486CEB800E47090 /* BibDesk.app */ = {isa = 
PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; 
path = BibDesk.app; sourceTree = BUILT_PRODUCTS_DIR; };
+               CD50E5F811A2190E00848756 /* BDSKJSTORWebParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKJSTORWebParser.h; sourceTree = "<group>"; };
+               CD50E5F911A2190E00848756 /* BDSKJSTORWebParser.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKJSTORWebParser.m; sourceTree = "<group>"; };
                CD62952F1140DDDA002E4751 /* BDSKSpringerParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKSpringerParser.h; sourceTree = "<group>"; };
                CD6295331140DE03002E4751 /* BDSKIACRParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKIACRParser.h; sourceTree = "<group>"; };
                CD6295351140DE16002E4751 /* BDSKIACRParser.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKIACRParser.m; sourceTree = "<group>"; };
@@ -2184,6 +2188,7 @@
                                CD6295351140DE16002E4751 /* BDSKIACRParser.m */,
                                454AC23C1086E07B00F2890A /* 
BDSKIEEEXploreParser.m */,
                                CEAE613D097FF60A000B618C /* BDSKJSTORParser.m 
*/,
+                               CD50E5F911A2190E00848756 /* 
BDSKJSTORWebParser.m */,
                                CE34A5720B249E0B00755730 /* BDSKMARCParser.m */,
                                6C567DBD0F818A1600DE285D /* 
BDSKMathSciNetParser.m */,
                                6C5DE3E60F8FC33B00E02D5F /* 
BDSKMathSiteParser.m */,
@@ -2527,6 +2532,7 @@
                                CE7A313F0B08EA1F00D1B333 /* 
BDSKItemPasteboardHelper.h */,
                                F9936CC30BC746C300A32DC4 /* 
BDSKItemSearchIndexes.h */,
                                CEAE613C097FF60A000B618C /* BDSKJSTORParser.h 
*/,
+                               CD50E5F811A2190E00848756 /* 
BDSKJSTORWebParser.h */,
                                CE24B35210C3E9E100818EDF /* 
BDSKLastImportGroup.h */,
                                F92405000BC5856900672839 /* 
BDSKLevelIndicatorCell.h */,
                                CE24B33210C3E13900818EDF /* BDSKLibraryGroup.h 
*/,
@@ -2808,6 +2814,7 @@
                        files = (
                                CE424A450D0F123500F824E7 /* 
BDSKCompletionServerProtocol.h in Headers */,
                                CEF5366A1192EFE400027C3C /* 
BDSKNotesOutlineView.h in Headers */,
+                               CD50E5FA11A2190E00848756 /* 
BDSKJSTORWebParser.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -3620,6 +3627,7 @@
                                CEFAD8BF1150F7A800A3D969 /* BDSKFontWell.m in 
Sources */,
                                CE17832E1158F0A000B2EBDF /* 
BDSKBookmarkSheetController.m in Sources */,
                                CEF5366B1192EFE400027C3C /* 
BDSKNotesOutlineView.m in Sources */,
+                               CD50E5FB11A2190E00848756 /* 
BDSKJSTORWebParser.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };

Modified: trunk/bibdesk/English.lproj/BibDeskHelp/bibdesk.texi
===================================================================
--- trunk/bibdesk/English.lproj/BibDeskHelp/bibdesk.texi        2010-05-18 
03:07:37 UTC (rev 16903)
+++ trunk/bibdesk/English.lproj/BibDeskHelp/bibdesk.texi        2010-05-18 
09:37:26 UTC (rev 16904)
@@ -1599,6 +1599,8 @@
 
 @uref{http://ams.org/mathscinet/,MathSciNet}: Database of Mathematical Reviews 
by the American Mathematical Society. Requires a subscription to be accessed. 
 
+...@uref{http://www.jstor.org/,JSTOR}: Database of papers from many journals. 
+
 @uref{http://www.numdam.org/?lang=en,NUMDAM} (Num@'erisation de documents 
anciens math@'ematiques): Digital versions of old mathematical papers. The site 
itself is public but BibDesk's support for it requires access to the 
Zentralblatt Math service.
 
 @uref{http://projecteuclid.org/,Project Euclid}: A publishing platform for 
'independent and society journals' in mathematics and statistics. BibDesk can 
provide bibliographic information for those articles and references mentioed on 
the site if MathSciNet or Zentralblatt Math IDs are listed for them and you   
have access to those sites.


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------

_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to