Revision: 18379
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18379&view=rev
Author: hofman
Date: 2012-01-09 12:05:16 +0000 (Mon, 09 Jan 2012)
Log Message:
-----------
add web parser for Microsoft Academic Search
Modified Paths:
--------------
trunk/bibdesk/BDSKGoogleScholarParser.m
trunk/bibdesk/BDSKWebParser.m
trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
trunk/bibdesk/English.lproj/Localizable.strings
Added Paths:
-----------
trunk/bibdesk/BDSKMASParser.h
trunk/bibdesk/BDSKMASParser.m
Modified: trunk/bibdesk/BDSKGoogleScholarParser.m
===================================================================
--- trunk/bibdesk/BDSKGoogleScholarParser.m 2012-01-09 07:35:11 UTC (rev
18378)
+++ trunk/bibdesk/BDSKGoogleScholarParser.m 2012-01-09 12:05:16 UTC (rev
18379)
@@ -243,7 +243,7 @@
+ (NSDictionary *)parserInfo {
- NSString * parserDescription = NSLocalizedString(@"Google\342\200\231s
attempt to provide a universal search for and in research related literature.
Please go to \342\200\230Scholar Preferences\342\200\231 and set the
\342\200\230Bibliography Manager\342\200\231 option to \342\200\230Show links
to import citations to BibTeX\342\200\231 for it to work.", @"Description for
Google Scholar site");
+ NSString * parserDescription = NSLocalizedString(@"Microsoft Academic
Search (MAS) is a free academic search engine developed by Microsoft
Research.", @"Description for MAS site");
return [BDSKWebParser parserInfoWithName:@"Google Scholar"
address:@"http://scholar.google.com/" description: parserDescription
feature:BDSKParserFeaturePublic ];
}
Added: trunk/bibdesk/BDSKMASParser.h
===================================================================
--- trunk/bibdesk/BDSKMASParser.h (rev 0)
+++ trunk/bibdesk/BDSKMASParser.h 2012-01-09 12:05:16 UTC (rev 18379)
@@ -0,0 +1,44 @@
+//
+// BDSKMASParser.h
+// Bibdesk
+//
+// Created by Christiaan Hofman on 1/9/12.
+/*
+ This software is Copyright (c) 2012
+ Christiaan Hofman. 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 Christiaan Hofman 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 BDSKMASParser : NSObject <BDSKWebParser>
+@end
Added: trunk/bibdesk/BDSKMASParser.m
===================================================================
--- trunk/bibdesk/BDSKMASParser.m (rev 0)
+++ trunk/bibdesk/BDSKMASParser.m 2012-01-09 12:05:16 UTC (rev 18379)
@@ -0,0 +1,111 @@
+//
+// BDSKMASParser.m
+// Bibdesk
+//
+// Created by Christiaan Hofman on 1/9/12.
+/*
+ This software is Copyright (c) 2012
+ Christiaan Hofman. 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 Christiaan Hofman 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 "BDSKMASParser.h"
+#import "BDSKBibTeXParser.h"
+#import "BibItem.h"
+#import "NSString_BDSKExtensions.h"
+#import "NSXMLNode_BDSKExtensions.h"
+#import <AGRegex/AGRegex.h>
+
+
+@implementation BDSKMASParser
+
++ (BOOL)canParseDocument:(DOMDocument *)domDocument xmlDocument:(NSXMLDocument
*)xmlDocument fromURL:(NSURL *)url{
+
+ if (nil == [url host] || NO == [[url host]
isCaseInsensitiveEqual:@"academic.research.microsoft.com"])
+ return NO;
+
+ NSError *error;
+ NSArray *nodes = [xmlDocument
nodesForXPath:@".//a[starts-with(@href,'Publication/')]" error:&error];
+
+ if ([nodes count] == 0)
+ nodes = [xmlDocument
nodesForXPath:@".//a[starts-with(@href,'/Publication/')]" error:&error];
+
+ return [nodes count] > 0;
+}
+
++ (NSArray *)itemsFromDocument:(DOMDocument *)domDocument
xmlDocument:(NSXMLDocument *)xmlDocument fromURL:(NSURL *)url error:(NSError
**)outError{
+
+ NSMutableArray *items = [NSMutableArray arrayWithCapacity:1];
+
+ NSError *error = nil;
+
+ NSArray *nodes = [xmlDocument
nodesForXPath:@".//a[starts-with(@href,'Publication/')]" error:&error];
+
+ if ([nodes count] == 0) {
+ nodes = [xmlDocument
nodesForXPath:@".//a[starts-with(@href,'/Publication/')]" error:&error];
+ if ([nodes count] == 0) {
+ if (outError) *outError = error;
+ return nil;
+ }
+ }
+
+ for (NSXMLNode *node in nodes) {
+ NSString *href = [node stringValueOfAttribute:@"href"];
+
+ AGRegex *idRegex = [AGRegex
regexWithPattern:@"^/?Publication/([0-9]*)/"];
+ AGRegexMatch *match = [idRegex findInString:href];
+ if ([match count] != 2)
+ continue;
+
+ NSString *publicationID = [match groupAtIndex:1];
+
+ // download BibTeX data
+ NSString *bibtexURLString = [NSString
stringWithFormat:@"http://academic.research.microsoft.com/%@.bib?type=2&format=0",
publicationID];
+ NSURL *bibtexURL = [NSURL URLWithString:bibtexURLString];
+ NSStringEncoding encoding = NSUTF8StringEncoding;
+ NSString *bibtexString = [NSString stringWithContentsOfURL:bibtexURL
usedEncoding:&encoding error:&error];
+
+ if (bibtexString == nil)
+ continue;
+
+ NSArray *parsedItems = [BDSKBibTeXParser itemsFromString:[bibtexString
stringWithPhoneyCiteKeys:@"cite-key"] owner:nil isPartialData:NULL
error:&error];
+ if ([parsedItems count] > 0)
+ [items addObjectsFromArray:parsedItems];
+ }
+
+ return items;
+}
+
++ (NSDictionary *)parserInfo {
+ NSString *parserDescription = NSLocalizedString(@"Microsoft Academic
Search (MAS) is a free academic search engine developed by Microsoft
Research.", @"Description for the MAS microformat");
+ return [BDSKWebParser parserInfoWithName:@"MAS"
address:@"http://academic.research.microsoft.com/"
description:parserDescription feature:BDSKParserFeaturePublic];
+}
+
+@end
Modified: trunk/bibdesk/BDSKWebParser.m
===================================================================
--- trunk/bibdesk/BDSKWebParser.m 2012-01-09 07:35:11 UTC (rev 18378)
+++ trunk/bibdesk/BDSKWebParser.m 2012-01-09 12:05:16 UTC (rev 18379)
@@ -53,6 +53,7 @@
#import "BDSKMathSiteParser.h"
#import "BDSKCOinSParser.h"
#import "BDSKIEEEXploreParser.h"
+#import "BDSKMASParser.h"
#import "NSError_BDSKExtensions.h"
#import "BDSKRuntime.h"
@@ -82,6 +83,7 @@
[BDSKCOinSParser class],
[BDSKHCiteParser class],
[BDSKIEEEXploreParser class],
+ [BDSKMASParser class],
[BDSKBibTeXWebParser class], nil];
}
return webParsers;
Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2012-01-09 07:35:11 UTC
(rev 18378)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2012-01-09 12:05:16 UTC
(rev 18379)
@@ -84,6 +84,8 @@
CE0928D813FFC1DC008A6A69 /* Scroller_Background_Lion.tiff in
Resources */ = {isa = PBXBuildFile; fileRef = CE0928D713FFC1DC008A6A69 /*
Scroller_Background_Lion.tiff */; };
CE095D52135C52B5000E4396 /* BDSKSelectCommand.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE095D50135C52B5000E4396 /* BDSKSelectCommand.m
*/; };
CE09CEA70DDEF65E00F3F2FE /* BDSKCompletionManager.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CE09CEA50DDEF65E00F3F2FE /*
BDSKCompletionManager.m */; };
+ CE0AB70014BB019400638C8F /* BDSKMASParser.h in Headers */ =
{isa = PBXBuildFile; fileRef = CE0AB6FE14BB019400638C8F /* BDSKMASParser.h */;
};
+ CE0AB70114BB019400638C8F /* BDSKMASParser.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE0AB6FF14BB019400638C8F /* BDSKMASParser.m */;
};
CE0B3B3C1292E1A500BA05EB /* BDSKErrorObject.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE0B3B3A1292E1A500BA05EB /* BDSKErrorObject.m
*/; };
CE0CD73C1459812300488DE1 /* NSAttributedString+Scripting.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE0CD73A1459812300488DE1 /*
NSAttributedString+Scripting.m */; };
CE0EB4440DCFDE8A0034DF92 /* NSInvocation_BDSKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE0EB4420DCFDE8A0034DF92 /*
NSInvocation_BDSKExtensions.m */; };
@@ -875,6 +877,8 @@
CE095D50135C52B5000E4396 /* BDSKSelectCommand.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKSelectCommand.m; sourceTree = "<group>"; };
CE09CEA40DDEF65E00F3F2FE /* BDSKCompletionManager.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKCompletionManager.h; sourceTree = "<group>"; };
CE09CEA50DDEF65E00F3F2FE /* BDSKCompletionManager.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKCompletionManager.m; sourceTree = "<group>"; };
+ CE0AB6FE14BB019400638C8F /* BDSKMASParser.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKMASParser.h; sourceTree = "<group>"; };
+ CE0AB6FF14BB019400638C8F /* BDSKMASParser.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKMASParser.m; sourceTree = "<group>"; };
CE0B3B3A1292E1A500BA05EB /* BDSKErrorObject.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKErrorObject.m; sourceTree = "<group>"; };
CE0B3B3B1292E1A500BA05EB /* BDSKErrorObject.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKErrorObject.h; sourceTree = "<group>"; };
CE0CD7391459812300488DE1 /* NSAttributedString+Scripting.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = "NSAttributedString+Scripting.h"; sourceTree = "<group>"; };
@@ -2315,6 +2319,7 @@
CEAE613D097FF60A000B618C /* BDSKJSTORParser.m
*/,
CD50E5F911A2190E00848756 /*
BDSKJSTORWebParser.m */,
CE34A5720B249E0B00755730 /* BDSKMARCParser.m */,
+ CE0AB6FF14BB019400638C8F /* BDSKMASParser.m */,
6C567DBD0F818A1600DE285D /*
BDSKMathSciNetParser.m */,
6C5DE3E60F8FC33B00E02D5F /*
BDSKMathSiteParser.m */,
F9D0E5350BF92768001C6C22 /* BDSKMODSParser.m */,
@@ -2676,6 +2681,7 @@
2730077B07CF20B500F2E485 /*
BDSKMacroWindowController.h */,
CE2E78CA0D40F6BB00340B39 /*
BDSKManyToManyDictionary.h */,
CE34A5710B249E0B00755730 /* BDSKMARCParser.h */,
+ CE0AB6FE14BB019400638C8F /* BDSKMASParser.h */,
6C567DBE0F818A1600DE285D /*
BDSKMathSciNetParser.h */,
6C5DE3E50F8FC33B00E02D5F /*
BDSKMathSiteParser.h */,
CE8DAD8D1098976400896F69 /*
BDSKMetadataCacheOperation.h */,
@@ -2952,6 +2958,7 @@
buildActionMask = 2147483647;
files = (
CE424A450D0F123500F824E7 /*
BDSKCompletionServerProtocol.h in Headers */,
+ CE0AB70014BB019400638C8F /* BDSKMASParser.h in
Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3795,6 +3802,7 @@
CEA498A21481183600AB81C5 /*
BDSKAddressTextField.m in Sources */,
CEA498A61481185100AB81C5 /*
BDSKAddressTextFieldCell.m in Sources */,
CE15198214B62E47003AE698 /*
BDSKLineNumberView.m in Sources */,
+ CE0AB70114BB019400638C8F /* BDSKMASParser.m in
Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/bibdesk/English.lproj/Localizable.strings
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit