Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Several changes.

More Cocoa like now, with delegates and stuff.
  • Loading branch information...
commit dfe59cb267009b1202c29ca8638915fa64d4ffaa 1 parent 7469ee0
Igor Sutton authored
View
21 TKTumblrReader.h → NSDictionary+TumblrKit.h
@@ -15,27 +15,14 @@
// You should have received a copy of the GNU General Public License
// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
//
-// TKProvider.h by Igor Sutton on 7/13/10.
+// NSDictionary+TumblrKit.h by Igor Sutton on 9/7/10.
//
-#import <Foundation/Foundation.h>
-#import "TKPost.h"
+#import <Cocoa/Cocoa.h>
-#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
-@interface TKTumblrReader : NSObject
-#else
-@interface TKTumblrReader : NSObject <NSXMLParserDelegate>
-#endif
-{
- NSMutableArray *posts;
- NSString *currentElementName;
- id currentPost;
-}
+@interface NSDictionary (TumblrKit)
-@property (copy) NSString *currentElementName;
-@property (assign) id currentPost;
-
-- (NSArray *)posts;
+- (NSString *)multipartMIMEString;
@end
View
54 NSDictionary+TumblrKit.m
@@ -0,0 +1,54 @@
+//
+//
+// This file is part of TumblrKit
+//
+// TumblrKit is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
+//
+// NSDictionary+TumblrKit.m by Igor Sutton on 9/7/10.
+//
+
+#import "NSDictionary+TumblrKit.h"
+#import "NSString+TumblrKit.h"
+
+
+@implementation NSDictionary (TumblrKit)
+
+- (NSString *)multipartMIMEString
+{
+ NSString *format = @"--%@\nContent-Disposition: form-data; name=\"%@\"\n\n%@\n";
+ NSMutableString *result = [NSMutableString string];
+ NSMutableDictionary *dict_ = [self mutableCopy];
+
+ // Hack: it seems the order we send the data in the HTTP post body matter
+ // in the Tumblr API. We'll remove the "type" object from the dictionary
+ // we copied and append its value as first thing, then we'll iterate the
+ // remaining keys. The impressive part is it worked directly when TumblrKit
+ // was compiled in 32 bit mode (where "type" was the first item to be encoded)
+ // but didn't work in 64 bit mode. It seems the architecture affects the
+ // sort of the keys, but we should not rely on that anyway (nor should the
+ // Tumblr API engineers :-)
+
+ id value = [dict_ objectForKey:@"type"];
+ [dict_ removeObjectForKey:@"type"];
+ [result appendFormat:format, [NSString MIMEBoundary], @"type", value];
+
+ for (NSString *key in dict_) {
+ [result appendFormat:format, [NSString MIMEBoundary], key, [dict_ objectForKey:key]];
+ }
+
+ [result appendFormat:@"\n--%@--\n", [NSString MIMEBoundary]];
+ return result;
+}
+
+@end
View
22 NSString+MIME.h
@@ -1,22 +0,0 @@
-//
-// NSString+MIME.h
-// TumblrKit
-//
-// Created by Igor Sutton on 9/2/10.
-// Copyright 2010 StrayDev.com. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-//
-// The following code (and its implementation) was found in:
-//
-// http://stackoverflow.com/questions/2326071/sending-a-post-request-from-cocoa-to-tumblr
-//
-
-@interface NSString (MIME)
-
-+ (NSString *)MIMEBoundary;
-+ (NSString *)multipartMIMEStringWithDictionary:(NSDictionary *)dict;
-
-@end
View
54 NSString+MIME.m
@@ -1,54 +0,0 @@
-//
-// NSString+MIME.m
-// TumblrKit
-//
-// Created by Igor Sutton on 9/2/10.
-// Copyright 2010 StrayDev.com. All rights reserved.
-//
-
-#import "NSString+MIME.h"
-
-
-@implementation NSString (MIME)
-
-+ (NSString *)MIMEBoundary
-{
- static NSString *MIMEBoundary = nil;
-
- if (!MIMEBoundary) {
- MIMEBoundary = [[NSString alloc] initWithFormat:
- @"----_=_MIMEBoundary_%@_=_----",
- [[NSProcessInfo processInfo] globallyUniqueString]];
- }
-
- return MIMEBoundary;
-}
-
-+ (NSString *)multipartMIMEStringWithDictionary:(NSDictionary *)dict
-{
- NSString *format = @"--%@\nContent-Disposition: form-data; name=\"%@\"\n\n%@\n";
- NSMutableString *result = [NSMutableString string];
- NSMutableDictionary *dict_ = [dict mutableCopy];
-
- // Hack: it seems the order we send the data in the HTTP post body matter
- // in the Tumblr API. We'll remove the "type" object from the dictionary
- // we copied and append its value as first thing, then we'll iterate the
- // remaining keys. The impressive part is it worked directly when TumblrKit
- // was compiled in 32 bit mode (where "type" was the first item to be encoded)
- // but didn't work in 64 bit mode. It seems the architecture affects the
- // sort of the keys, but we should not rely on that anyway (nor should the
- // Tumblr API engineers :-)
-
- id value = [dict_ objectForKey:@"type"];
- [dict_ removeObjectForKey:@"type"];
- [result appendFormat:format, [NSString MIMEBoundary], @"type", value];
-
- for (NSString *key in dict_) {
- [result appendFormat:format, [NSString MIMEBoundary], key, [dict_ objectForKey:key]];
- }
-
- [result appendFormat:@"\n--%@--\n", [NSString MIMEBoundary]];
- return result;
-}
-
-@end
View
1  NSString+TumblrKit.h
@@ -23,5 +23,6 @@
@interface NSString (TumblrKit)
- (NSString *)stringByAddingQueryPercentEscapesUsingEncoding:(NSStringEncoding)encoding;
++ (NSString *)MIMEBoundary;
@end
View
13 NSString+TumblrKit.m
@@ -33,4 +33,17 @@ - (NSString *)stringByAddingQueryPercentEscapesUsingEncoding:(NSStringEncoding)e
return [result autorelease];
}
++ (NSString *)MIMEBoundary
+{
+ static NSString *MIMEBoundary = nil;
+
+ if (!MIMEBoundary) {
+ MIMEBoundary = [[NSString alloc] initWithFormat:
+ @"----_=_MIMEBoundary_%@_=_----",
+ [[NSProcessInfo processInfo] globallyUniqueString]];
+ }
+
+ return MIMEBoundary;
+}
+
@end
View
53 README.md
@@ -0,0 +1,53 @@
+TumblrKit
+=========
+
+TumblrKit is a light-weight wrapper around Tumblr's API in Objective-C.
+
+Currently you can:
+
+* Fetch posts from Tumblr (regular, conversation, quote and link)
+* Upload posts to Tumblr (regular, conversation, quote and link)
+
+Usage
+-----
+
+You can fetch a post with a specific POST_ID using the following:
+
+ TKTumblr *tumblr = [[TKTumblr alloc] initWithEmail:EMAIL andPassword:PASSWORD];
+ TKPost *thePost = [tumblr postWithID:[NSNumber numberWithInt:POST_ID] andDomain:@"example.tumblr.com"];
+ NSLog(@"thePost: %@", thePost);
+
+If you want to fetch more than one post:
+
+ // Instantiate a new TKTumblr object.
+ TKTumblr *tumblr = [[TKTumblr alloc] initWithEmail:EMAIL andPassword:PASSWORD];
+
+ // Configure a delegate implementing the TKTumblrDelegate protocol.
+ tumblr.delegate = aDelegate;
+
+ // Configure the read request object.
+ TKTumblrReadRequest *theReadRequest = [[TKTumblrReadRequest alloc] init];
+
+ // Return the post in raw text (if you wrote using Markdown).
+ theReadRequest.filter = TKPostFilterNone;
+
+ // Execute the read request. For each post, TKTumblr will send the
+ // tumblrDidReceivePost:withDomain: message to the delegate object.
+ [tumblr postsWithReadRequest:theReadRequest];
+
+To upload a TKPost:
+
+ // Create a new TKPost
+ TKPostRegular *thePost = [[TKPostRegular alloc] init];
+ thePost.title = @"The title";
+ thePost.body = @"The body";
+
+ // Upload it to Tumblr. The delegate will receive either
+ // tumblrDidUploadPost:withDomain:postId: or
+ // tumblrDidFailToUploadPost:withDomain:returnCode:
+ [tumblr uploadPost:thePost withDomain:@"another-example.tumblr.com"];
+
+ // If you're lazy, you can dismiss the withDomain to upload to your main
+ // Tumblelog.
+ [tumblr uploadPost:thePost];
+
View
8 TKPost.h
@@ -22,6 +22,14 @@
typedef enum
{
+ TKPostStateAll,
+ TKPostStateDraft,
+ TKPostStateQueue,
+ TKPostStateSubmission
+} TKPostState;
+
+typedef enum
+{
TKPostTypeAll,
TKPostTypeRegular,
TKPostTypeLink,
View
4 TKPost.m
@@ -82,6 +82,7 @@ - (id)init
reblogKey = nil;
date = nil;
url = nil;
+ group = nil;
format = TKPostFormatHTML;
}
@@ -91,9 +92,6 @@ - (id)init
- (id)initWithAttributes:(NSDictionary *)attributeDict
{
if ((self = [self init]) != nil) {
-
- // Deliberate use of "self." here, since we want to retain/copy as
- // appropriate.
self.postID = [attributeDict objectForKey:@"id"];
self.url = [attributeDict objectForKey:@"url"];
self.date = [attributeDict objectForKey:@"date"];
View
52 TKTumblr.h
@@ -18,5 +18,55 @@
// TKTumblr.h by Igor Sutton on 7/14/10.
//
+#import "TKPost.h"
+#import "TKTumblrReadRequest.h"
+
+
+#define Log(format, ...) NSLog(@"%s:%@", __PRETTY_FUNCTION__, [NSString stringWithFormat:format, ## __VA_ARGS__]);
+
+typedef enum {
+ TKTumblrCreated = 201,
+ TKTumblrBadRequest = 400,
+ TKTumblrForbidden = 403
+} TKTumblrResponseReturnCode;
+
+
+@protocol TKTumblrDelegate
+
+@optional
+- (void)tumblrDidReceivePost:(TKPost *)thePost withDomain:(NSString *)theDomain;
+
+- (void)tumblrWillUploadPost:(TKPost *)thePost withDomain:(NSString *)theDomain;
+- (void)tumblrDidUploadPost:(TKPost *)thePost withDomain:(NSString *)theDomain postID:(NSNumber *)thePostID;
+- (void)tumblrDidFailToUploadPost:(TKPost *)thePost withDomain:(NSString *)theDomain returnCode:(TKTumblrResponseReturnCode)theReturnCode;
+
+@end
+
+@interface TKTumblr : NSObject <NSXMLParserDelegate,TKTumblrDelegate>
+{
+ id<TKTumblrDelegate,NSObject> delegate;
+
+ NSString *email;
+ NSString *password;
+
+ TKPost *currentPost;
+ TKPost *requestedPost;
+ NSString *currentElementName;
+}
+
+@property (assign) id<TKTumblrDelegate,NSObject> delegate;
+@property (nonatomic,copy) NSString *email;
+@property (nonatomic,copy) NSString *password;
+@property (nonatomic,retain) TKPost *currentPost;
+@property (nonatomic,retain) TKPost *requestedPost;
+@property (nonatomic,copy) NSString *currentElementName;
+
+- (id)initWithEmail:(NSString *)theEmail andPassword:(NSString *)thePassword;
+- (BOOL)uploadPost:(TKPost *)thePost;
+- (BOOL)uploadPost:(TKPost *)thePost withDomain:(NSString *)theDomain;
+- (void)postsWithReadRequest:(TKTumblrReadRequest *)theReadRequest;
+- (TKPost *)postWithID:(NSNumber *)thePostID andDomain:(NSString *)theDomain;
+- (NSDictionary *)attributesAsDictionary;
+
+@end
-#define Log(format, ...) NSLog(@"%s:%@", __PRETTY_FUNCTION__, [NSString stringWithFormat:format, ## __VA_ARGS__]);
View
211 TKTumblr.m
@@ -0,0 +1,211 @@
+//
+//
+// This file is part of TumblrKit
+//
+// TumblrKit is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
+//
+// TKTumblr.m by Igor Sutton on 9/7/10.
+//
+
+#include "TKTumblr.h"
+#include "NSString+TumblrKit.h"
+#include "NSDictionary+TumblrKit.h"
+
+
+@implementation TKTumblr
+
+@synthesize delegate, email, password, currentPost, currentElementName, requestedPost;
+
+- (id)initWithEmail:(NSString *)theEmail andPassword:(NSString *)thePassword
+{
+ if ((self = [super init]) != nil) {
+ self.email = theEmail;
+ self.password = thePassword;
+ self.currentPost = nil;
+ self.currentElementName = nil;
+ self.requestedPost = nil;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ self.email = nil;
+ self.password = nil;
+ self.currentPost = nil;
+ self.currentElementName = nil;
+ self.requestedPost = nil;
+ [super dealloc];
+}
+
+- (TKPost *)postWithID:(NSNumber *)thePostID andDomain:(NSString *)theDomain
+{
+ TKTumblrReadRequest *theReadRequest = [[TKTumblrReadRequest alloc] initWithPostID:thePostID andDomain:theDomain];
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:[theReadRequest endpoint]];
+ [theReadRequest release];
+ id previousDelegate = [self delegate];
+ [self setDelegate:self];
+ [parser setDelegate:self];
+ [parser parse];
+ [parser release];
+ [self setDelegate:previousDelegate];
+
+ TKPost *thePost = nil;
+
+ if (requestedPost) {
+ thePost = [self requestedPost];
+ [self setRequestedPost:nil];
+ }
+
+ return thePost;
+}
+
+- (void)postsWithReadRequest:(TKTumblrReadRequest *)theReadRequest
+{
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:[theReadRequest endpoint]];
+ [parser setDelegate:self];
+ [parser parse];
+ [parser release];
+}
+
+
+- (BOOL)uploadPost:(TKPost *)thePost
+{
+ return [self uploadPost:thePost withDomain:nil];
+}
+
+- (BOOL)uploadPost:(TKPost *)thePost withDomain:(NSString *)theDomain
+{
+ NSMutableDictionary *postDict = (NSMutableDictionary *)[self attributesAsDictionary];
+
+ if (theDomain)
+ [postDict setObject:theDomain forKey:@"group"];
+
+ [postDict addEntriesFromDictionary:[thePost attributesAsDictionary]];
+
+ NSString *postString = [postDict multipartMIMEString];
+
+ NSMutableURLRequest *theURLRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.tumblr.com/api/write"]];
+
+ [theURLRequest setHTTPMethod:@"POST"];
+
+ [theURLRequest setValue:@"8bit"
+ forHTTPHeaderField:@"Content-Transfer-Encoding"];
+
+ [theURLRequest setValue:[NSString stringWithFormat:@"%d", [postString length]]
+ forHTTPHeaderField:@"Content-Length"];
+
+ [theURLRequest setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", [NSString MIMEBoundary]]
+ forHTTPHeaderField:@"Content-Type"];
+
+ [theURLRequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
+
+ NSError *error = nil;
+ NSHTTPURLResponse *theURLResponse = nil;
+ NSData *responseData = [NSURLConnection sendSynchronousRequest:theURLRequest
+ returningResponse:&theURLResponse
+ error:&error];
+
+ // Release the request before we can enter some potentially danger
+ // code path.
+ [theURLRequest release];
+
+ // Bail out quickly if NSURLConnection populated error.
+ if (([theURLResponse statusCode] != TKTumblrCreated)) {
+ if (delegate && [delegate respondsToSelector:@selector(tumblrDidFailToUploadPost:withDomain:returnCode:)]) {
+ [delegate tumblrDidFailToUploadPost:thePost
+ withDomain:theDomain
+ returnCode:[theURLResponse statusCode]];
+ }
+ return NO;
+ }
+
+ // The following code will only execute when we get a TKTumblrCreated response, so it's
+ // safe to assume that responseData will have only the postID of the post we created.
+ NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
+ [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
+ NSNumber *postID = [formatter numberFromString:[[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] autorelease]];
+ [formatter release];
+
+ if (delegate && [delegate respondsToSelector:@selector(tumblrDidUploadPost:withDomain:postID:)]) {
+ [delegate tumblrDidUploadPost:thePost
+ withDomain:theDomain
+ postID:postID];
+ }
+
+ return YES;
+}
+
+- (NSDictionary *)attributesAsDictionary
+{
+ NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ email, @"email",
+ password, @"password",
+ nil];
+ return dict;
+}
+
+#pragma mark NSXMLParserDelegate
+
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
+{
+ self.currentElementName = elementName;
+
+ if ([elementName isEqualToString:@"post"]) {
+ self.currentPost = [TKPost postWithAttributes:attributeDict];
+ }
+}
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
+{
+ if ([elementName isEqualToString:@"post"]) {
+ if (currentPost != nil) {
+ if (delegate && [delegate respondsToSelector:@selector(tumblrDidReceivePost:withDomain:)]) {
+ [delegate tumblrDidReceivePost:currentPost withDomain:@""];
+ }
+ }
+ self.currentPost = nil;
+ }
+}
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
+{
+ static NSDictionary *elementToSelectorDict = nil;
+
+ if (!elementToSelectorDict) {
+ elementToSelectorDict = [NSDictionary dictionaryWithObjectsAndKeys:
+ @"appendToText:", @"text",
+ @"appendToCaption:",@"caption",
+ @"appendToPlayer:", @"player",
+ @"appendToBody:", @"body",
+ @"setURLWithString:", @"url",
+ nil];
+ }
+
+ NSString *key = [[currentElementName componentsSeparatedByString:@"-"] lastObject];
+ SEL selector = NSSelectorFromString([elementToSelectorDict objectForKey:key]);
+ if (selector) {
+ [currentPost performSelector:selector withObject:string];
+ }
+}
+
+#pragma mark TKTumblrDelegate
+
+- (void)tumblrDidReceivePost:(TKPost *)thePost withDomain:(NSString *)theDomain
+{
+ [self setRequestedPost:thePost];
+}
+
+@end
View
108 TKTumblrConnection.m
@@ -1,108 +0,0 @@
-//
-//
-// This file is part of TumblrKit
-//
-// TumblrKit is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Foobar is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
-//
-// TKTumblrConnection.m by Igor Sutton on 7/13/10.
-//
-
-#import "TKTumblrConnection.h"
-#import "TKTumblrReader.h"
-
-
-@implementation TKTumblrConnection
-
-- (BOOL)sendSynchronousRequest:(TKTumblrRequest *)req returningResponse:(TKTumblrResponse **)res error:(NSError **)error
-{
-
- //
- // If req.post is not nil, then we're adding/editing some post, otherwise
- // we'll be consulting the read api using the parameters specified in the
- // request.
- //
-
- if ([req isWrite])
- return [self sendSynchronousWriteRequest:req returningResponse:res error:error];
-
- return [self sendSynchronousReadRequest:req returningResponse:res error:error];
-}
-
-- (BOOL)sendSynchronousReadRequest:(TKTumblrRequest *)aRequest returningResponse:(TKTumblrResponse **)aResponse error:(NSError **)error
-{
- NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:[aRequest URLForRead]];
- TKTumblrReader *reader = [[TKTumblrReader alloc] init];
- [parser setDelegate:reader];
- [parser parse];
- if (aResponse) {
- *aResponse = [TKTumblrResponse responseWithPosts:reader.posts];
- }
- [reader release];
- [parser release];
-
- return YES;
-}
-
-- (BOOL)sendSynchronousWriteRequest:(TKTumblrRequest *)theRequest returningResponse:(TKTumblrResponse **)theResponse error:(NSError **)error
-{
- NSMutableDictionary *postDict = (NSMutableDictionary *)[theRequest attributesAsDictionary];
-
- [postDict addEntriesFromDictionary:[theRequest.post attributesAsDictionary]];
-
- NSString *postString = [NSString multipartMIMEStringWithDictionary:postDict];
-
- NSMutableURLRequest *theURLRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.tumblr.com/api/write"]];
-
- [theURLRequest setHTTPMethod:@"POST"];
-
- [theURLRequest setValue:@"8bit"
- forHTTPHeaderField:@"Content-Transfer-Encoding"];
-
- [theURLRequest setValue:[NSString stringWithFormat:@"%d", [postString length]]
- forHTTPHeaderField:@"Content-Length"];
-
- [theURLRequest setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", [NSString MIMEBoundary]]
- forHTTPHeaderField:@"Content-Type"];
-
- [theURLRequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
-
- NSHTTPURLResponse *theURLResponse = nil;
- NSData *responseData = [NSURLConnection sendSynchronousRequest:theURLRequest returningResponse:&theURLResponse error:error];
-
- // Release the request before we can enter some potentially danger
- // code path.
- [theURLRequest release];
-
- // Bail out quickly if NSURLConnection populated error.
- if (([theURLResponse statusCode] != TKTumblrCreated)) {
- if (theResponse)
- *theResponse = [TKTumblrResponse responseWithReturnCode:[theURLResponse statusCode]];
- return NO;
- }
-
- // If we don't have a response to fill in, just leave.
- if (!theResponse)
- return YES;
-
- // The following code will only execute when we get a TKTumblrCreated response, so it's
- // safe to assume that responseData will have only the postID of the post we created.
- NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
- [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
- *theResponse = [TKTumblrResponse responseWithPostID:[formatter numberFromString:[[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] autorelease]]];
- [formatter release];
-
- return YES;
-}
-
-@end
View
32 TKTumblrConnection.h → TKTumblrReadRequest.h
@@ -15,22 +15,36 @@
// You should have received a copy of the GNU General Public License
// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
//
-// TKTumblrConnection.h by Igor Sutton on 7/13/10.
+// TKTumblrReadRequest.h by Igor Sutton on 9/7/10.
//
#import <Foundation/Foundation.h>
-#import "TKTumblrRequest.h"
-#import "TKTumblrResponse.h"
+#import "TKPost.h"
-#import "NSString+MIME.h"
-
-@interface TKTumblrConnection : NSObject
+@interface TKTumblrReadRequest : NSObject
{
+ NSNumber *start;
+ NSNumber *numOfPosts;
+ NSNumber *postID;
+ NSString *search;
+ NSString *group;
+ TKPostType type;
+ TKPostFilter filter;
+ TKPostState state;
}
-- (BOOL)sendSynchronousRequest:(TKTumblrRequest *)req returningResponse:(TKTumblrResponse **)res error:(NSError **)error;
-- (BOOL)sendSynchronousWriteRequest:(TKTumblrRequest *)theRequest returningResponse:(TKTumblrResponse **)theResponse error:(NSError **)error;
-- (BOOL)sendSynchronousReadRequest:(TKTumblrRequest *)aRequest returningResponse:(TKTumblrResponse **)aResponse error:(NSError **)error;
+@property (copy) NSNumber *start;
+@property (copy) NSNumber *numOfPosts;
+@property (copy) NSNumber *postID;
+@property (copy) NSString *search;
+@property (copy) NSString *group;
+
+@property (assign) TKPostType type;
+@property (assign) TKPostFilter filter;
+@property (assign) TKPostState state;
+
+- (id)initWithPostID:(NSNumber *)thePostID andDomain:(NSString *)theDomain;
+- (NSURL *)endpoint;
@end
View
106 TKTumblrReadRequest.m
@@ -0,0 +1,106 @@
+//
+//
+// This file is part of TumblrKit
+//
+// TumblrKit is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
+//
+// TKTumblrReadRequest.m by Igor Sutton on 9/7/10.
+//
+
+#import "TKTumblrReadRequest.h"
+
+
+static NSString *TKPostTypeAsQueryString[] =
+{
+ @"all",
+ @"text",
+ @"link",
+ @"quote",
+ @"photo",
+ @"chat",
+ @"video",
+ @"audio",
+ @"answer"
+};
+
+static NSString *TKPostFilterAsQueryString[] =
+{
+ @"html",
+ @"text",
+ @"none"
+};
+
+@implementation TKTumblrReadRequest
+
+@synthesize start, numOfPosts, postID, search, type, filter, state, group;
+
+- (id)init
+{
+ if ((self = [super init]) != nil) {
+ self.start = [NSNumber numberWithInt:0];
+ self.numOfPosts = [NSNumber numberWithInt:20];
+ self.postID = nil;
+ self.search = nil;
+ self.group = nil;
+ self.type = TKPostTypeAll;
+ self.state = TKPostStateAll;
+ self.filter = TKPostFilterNone;
+ }
+
+ return self;
+}
+
+- (id)initWithPostID:(NSNumber *)thePostID andDomain:(NSString *)theDomain
+{
+ if ((self = [self init]) != nil) {
+ self.postID = thePostID;
+ self.group = theDomain;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ self.start = nil;
+ self.numOfPosts = nil;
+ self.postID = nil;
+ self.search = nil;
+ self.group = nil;
+ [super dealloc];
+}
+
+- (NSURL *)endpoint
+{
+ NSMutableString *endpointString = [[NSMutableString alloc] initWithFormat:@"http://%@/api/read", group];
+ NSURL *endpoint = nil;
+
+ if (postID) {
+ [endpointString appendFormat:@"?id=%@&", postID];
+ }
+ else {
+ [endpointString appendFormat:@"?start=%@&num=%@&", start, numOfPosts];
+
+ if (type != TKPostTypeAll && type != TKPostTypeAnswer) {
+ [endpointString appendFormat:@"type=%@&", TKPostTypeAsQueryString[type]];
+ }
+ }
+
+ [endpointString appendFormat:@"filter=%@", TKPostFilterAsQueryString[filter]];
+ endpoint = [NSURL URLWithString:endpointString];
+ [endpointString release];
+ return endpoint;
+}
+
+@end
View
89 TKTumblrReader.m
@@ -1,89 +0,0 @@
-//
-//
-// This file is part of TumblrKit
-//
-// TumblrKit is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Foobar is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
-//
-// TKProvider.m by Igor Sutton on 7/13/10.
-//
-
-#import "TKTumblrReader.h"
-
-
-@implementation TKTumblrReader
-
-@synthesize currentElementName, currentPost;
-
-- (id)init
-{
- if ((self = [super init]) != nil) {
- posts = [[NSMutableArray alloc] init];
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [posts release];
- [currentElementName release];
- [currentPost release];
- [super dealloc];
-}
-
-- (NSArray *)posts
-{
- return posts;
-}
-
-- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
-{
- self.currentElementName = elementName;
-
- if ([elementName isEqualToString:@"post"]) {
- self.currentPost = [TKPost postWithAttributes:attributeDict];
- }
-}
-
-- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
-{
- if ([elementName isEqualToString:@"post"]) {
- if (currentPost != nil)
- [posts addObject:currentPost];
- self.currentPost = nil;
- }
-}
-
-- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
-{
- static NSDictionary *elementToSelectorDict = nil;
-
- if (!elementToSelectorDict) {
- elementToSelectorDict = [NSDictionary dictionaryWithObjectsAndKeys:
- @"appendToText:", @"text",
- @"appendToCaption:",@"caption",
- @"appendToPlayer:", @"player",
- @"appendToBody:", @"body",
- @"setURLWithString:", @"url",
- nil];
- }
-
- NSString *key = [[currentElementName componentsSeparatedByString:@"-"] lastObject];
- SEL selector = NSSelectorFromString([elementToSelectorDict objectForKey:key]);
- if (selector) {
- [currentPost performSelector:selector withObject:string];
- }
-}
-
-@end
View
58 TKTumblrRequest.h
@@ -1,58 +0,0 @@
-//
-//
-// This file is part of TumblrKit
-//
-// TumblrKit is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Foobar is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
-//
-// TKTumblrRequest.h by Igor Sutton on 7/13/10.
-//
-
-#import <Foundation/Foundation.h>
-#import "TKPost.h"
-
-@interface TKTumblrRequest : NSObject
-{
- NSURL *URL;
- NSString *email;
- NSString *password;
- NSUInteger startIndex;
- NSUInteger numberOfPosts;
- NSUInteger postID;
- TKPostFilter postFilter;
- TKPostType postType;
- TKPost *post;
- NSString *tag;
-}
-
-@property (copy) NSURL *URL;
-@property (copy) NSString *email;
-@property (copy) NSString *password;
-@property (assign) NSUInteger startIndex;
-@property (assign) NSUInteger numberOfPosts;
-@property (assign) NSUInteger postID;
-@property (assign) TKPostFilter postFilter;
-@property (assign) TKPostType postType;
-@property (assign) TKPost *post;
-@property (copy) NSString *tag;
-
-+ (id)requestWithURL:(NSURL *)theURL;
-
-- (id)initWithURL:(NSURL *)theURL;
-- (id)initWithDomain:(NSString *)theDomain;
-- (BOOL)isWrite;
-- (NSURL *)URLForRead;
-- (NSURL *)URLForWrite;
-- (NSDictionary *)attributesAsDictionary;
-
-@end
View
140 TKTumblrRequest.m
@@ -1,140 +0,0 @@
-//
-//
-// This file is part of TumblrKit
-//
-// TumblrKit is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Foobar is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
-//
-// TKTumblrRequest.m by Igor Sutton on 7/13/10.
-//
-
-#import "TKTumblrRequest.h"
-
-static NSString *TKPostTypeAsQueryString[] =
-{
- @"all",
- @"text",
- @"link",
- @"quote",
- @"photo",
- @"chat",
- @"video",
- @"audio",
- @"answer"
-};
-
-static NSString *TKPostFilterAsQueryString[] =
-{
- @"html",
- @"text",
- @"none"
-};
-
-@implementation TKTumblrRequest
-
-@synthesize URL, email, password, startIndex, numberOfPosts, postID, postFilter, postType, post, tag;
-
-+ (id)requestWithURL:(NSURL *)theURL
-{
- return [[[TKTumblrRequest alloc] initWithURL:theURL] autorelease];
-}
-
-+ (id)requestWithDomain:(NSString *)theDomain
-{
- return [[[TKTumblrRequest alloc] initWithDomain:theDomain] autorelease];
-}
-
-- (id)initWithDomain:(NSString *)theDomain
-{
- NSURL *theURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@", theDomain]];
- return [self initWithURL:theURL];
-}
-
-- (id)initWithURL:(NSURL *)theURL
-{
- if ((self = [super init]) != nil) {
- self.URL = theURL;
- self.startIndex = 0;
- self.numberOfPosts = 20;
- self.postID = 0;
- self.postFilter = TKPostFilterNone;
- self.postType = TKPostTypeAll;
- self.post = nil;
- self.tag = nil;
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [URL release];
- [post release];
- [tag release];
- [super dealloc];
-}
-
-- (NSURL *)URLForRead
-{
- NSMutableString *URLString = [[URL description] mutableCopy];
-
- [URLString appendString:@"/api/read"];
-
- //
- // We can have either postId or combination of startIndex, numberOfPosts and
- // postType. If postId has precedence if present.
- //
- if (postID > 0) {
- [URLString appendFormat:@"?id=%i&", postID];
- }
- else {
- [URLString appendFormat:@"?start=%i&num=%i&", startIndex, numberOfPosts];
-
- //
- // Currently Tumblr doesn't support "answer" for the type filter, so
- // we disconsider both TKPostTypeAnswer and TKPostTypeAll.
- //
- if (postType != TKPostTypeAll && postType != TKPostTypeAnswer) {
- [URLString appendFormat:@"type=%@&", TKPostTypeAsQueryString[postType]];
- }
-
- if (tag) {
- [URLString appendFormat:@"tagged=%@&", tag];
- }
- }
-
- [URLString appendFormat:@"filter=%@", TKPostFilterAsQueryString[postFilter]];
-
- return [[[NSURL alloc] initWithString:URLString] autorelease];
-}
-
-- (NSURL *)URLForWrite
-{
- return [[[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@/api/write", [URL description]]] autorelease];
-}
-
-- (BOOL)isWrite
-{
- return self.post != nil;
-}
-
-- (NSDictionary *)attributesAsDictionary
-{
- NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
- email, @"email",
- password, @"password",
- nil];
- return dict;
-}
-
-@end
View
48 TKTumblrResponse.h
@@ -1,48 +0,0 @@
-//
-//
-// This file is part of TumblrKit
-//
-// TumblrKit is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Foobar is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
-//
-// TKTumblrResponse.h by Igor Sutton on 7/13/10.
-//
-
-#import <Foundation/Foundation.h>
-#import "TKPost.h"
-
-typedef enum {
- TKTumblrCreated = 201,
- TKTumblrBadRequest = 400,
- TKTumblrForbidden = 403
-} TKTumblrResponseReturnCode;
-
-@interface TKTumblrResponse : NSObject
-{
- NSArray *posts;
- NSNumber *postID;
- TKTumblrResponseReturnCode returnCode;
-}
-
-@property (retain) NSArray *posts;
-@property (copy) NSNumber *postID;
-@property (assign) TKTumblrResponseReturnCode returnCode;
-
-+ (id)responseWithPosts:(NSArray *)somePosts;
-+ (id)responseWithPostID:(NSNumber *)postID;
-+ (id)responseWithReturnCode:(TKTumblrResponseReturnCode)theReturnCode;
-- (id)initWithPosts:(NSArray *)somePosts postID:(NSNumber *)thePostID returnCode:(TKTumblrResponseReturnCode)theReturnCode;
-- (id)initWithPosts:(NSArray *)somePosts postID:(NSNumber *)thePostID;
-- (NSString *)returnCodeAsString;
-
-@end
View
80 TKTumblrResponse.m
@@ -1,80 +0,0 @@
-//
-//
-// This file is part of TumblrKit
-//
-// TumblrKit is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Foobar is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with TumblrKit. If not, see <http://www.gnu.org/licenses/>.
-//
-// TKTumblrResponse.m by Igor Sutton on 7/13/10.
-//
-
-#import "TKTumblrResponse.h"
-
-
-@implementation TKTumblrResponse
-
-@synthesize posts, returnCode, postID;
-
-+ (id)responseWithPosts:(NSArray *)somePosts
-{
- return [[[self alloc] initWithPosts:somePosts postID:nil] autorelease];
-}
-
-+ (id)responseWithPostID:(NSNumber *)thePostID
-{
- return [[[self alloc] initWithPosts:nil postID:thePostID] autorelease];
-}
-
-+ (id)responseWithReturnCode:(TKTumblrResponseReturnCode)theReturnCode
-{
- return [[self alloc] initWithPosts:nil postID:nil returnCode:theReturnCode];
-}
-
-- (id)initWithPosts:(NSArray *)somePosts postID:(NSNumber *)thePostID
-{
- return [self initWithPosts:somePosts postID:thePostID returnCode:TKTumblrCreated];
-}
-
-- (id)initWithPosts:(NSArray *)somePosts postID:(NSNumber *)thePostID returnCode:(TKTumblrResponseReturnCode)theReturnCode
-{
- if ((self = [super init]) != nil) {
- self.posts = somePosts;
- self.postID = thePostID;
- self.returnCode = theReturnCode;
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [posts release];
- [super dealloc];
-}
-
-- (NSString *)description
-{
- return [NSString stringWithFormat:@"Posts: %@, Post ID: %@, Return Code: %@", self.posts, self.postID, [self returnCodeAsString]];
-}
-
-- (NSString *)returnCodeAsString
-{
- if (self.returnCode == TKTumblrCreated)
- return @"Created";
- else if (self.returnCode == TKTumblrBadRequest)
- return @"Bad Request";
- else
- return @"Forbidden";
-}
-
-@end
View
144 TumblrKit.xcodeproj/project.pbxproj
@@ -6,6 +6,20 @@
objectVersion = 45;
objects = {
+/* Begin PBXAggregateTarget section */
+ 82B09E70123543700006D003 /* Documentation */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = 82B09E781235438A0006D003 /* Build configuration list for PBXAggregateTarget "Documentation" */;
+ buildPhases = (
+ 82B09E6F123543700006D003 /* ShellScript */,
+ );
+ dependencies = (
+ );
+ name = Documentation;
+ productName = Documentation;
+ };
+/* End PBXAggregateTarget section */
+
/* Begin PBXBuildFile section */
826CD95E11EDDAD600F5CB24 /* NSString+TumblrKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 826CD95C11EDDAD600F5CB24 /* NSString+TumblrKit.h */; };
826CD95F11EDDAD600F5CB24 /* NSString+TumblrKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 826CD95D11EDDAD600F5CB24 /* NSString+TumblrKit.m */; };
@@ -13,24 +27,16 @@
827E467911EB0D9100684466 /* TKPost.m in Sources */ = {isa = PBXBuildFile; fileRef = 827E467711EB0D9100684466 /* TKPost.m */; };
827E46DE11EB1BDD00684466 /* Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 827E46DD11EB1BDD00684466 /* Test.m */; };
827E470E11EB1D4100684466 /* TumblrKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* TumblrKit.framework */; };
- 82A53CC711ED0D99006BA92A /* TKTumblrConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 82A53CC511ED0D99006BA92A /* TKTumblrConnection.h */; };
- 82A53CC811ED0D99006BA92A /* TKTumblrConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A53CC611ED0D99006BA92A /* TKTumblrConnection.m */; };
- 82A53CCB11ED0DB1006BA92A /* TKTumblrRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 82A53CC911ED0DB1006BA92A /* TKTumblrRequest.h */; };
- 82A53CCC11ED0DB1006BA92A /* TKTumblrRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A53CCA11ED0DB1006BA92A /* TKTumblrRequest.m */; };
- 82A53CCF11ED0DBE006BA92A /* TKTumblrResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 82A53CCD11ED0DBE006BA92A /* TKTumblrResponse.h */; };
- 82A53CD011ED0DBE006BA92A /* TKTumblrResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A53CCE11ED0DBE006BA92A /* TKTumblrResponse.m */; };
- 82A53D7111ED1CE7006BA92A /* TKTumblrReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 82A53C2711EC9E97006BA92A /* TKTumblrReader.m */; };
82A53DD111ED938C006BA92A /* TKTumblr.h in Headers */ = {isa = PBXBuildFile; fileRef = 82A53DD011ED938C006BA92A /* TKTumblr.h */; };
82B09D4A12352EBF0006D003 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
82B09D89123531FF0006D003 /* TKPost.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 827E467611EB0D9100684466 /* TKPost.h */; };
- 82B09D8A123531FF0006D003 /* TKTumblrReader.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 82A53C2611EC9E97006BA92A /* TKTumblrReader.h */; };
- 82B09D8B123531FF0006D003 /* TKTumblrRequest.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 82A53CC911ED0DB1006BA92A /* TKTumblrRequest.h */; };
- 82B09D8C123531FF0006D003 /* TKTumblrResponse.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 82A53CCD11ED0DBE006BA92A /* TKTumblrResponse.h */; };
82B09D8D123531FF0006D003 /* TKTumblr.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 82A53DD011ED938C006BA92A /* TKTumblr.h */; };
82B09D8E123531FF0006D003 /* NSString+TumblrKit.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 826CD95C11EDDAD600F5CB24 /* NSString+TumblrKit.h */; };
- 82B09D8F123531FF0006D003 /* NSString+MIME.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 82F8B630122FC144005B5045 /* NSString+MIME.h */; };
- 82F8B632122FC144005B5045 /* NSString+MIME.h in Headers */ = {isa = PBXBuildFile; fileRef = 82F8B630122FC144005B5045 /* NSString+MIME.h */; };
- 82F8B633122FC144005B5045 /* NSString+MIME.m in Sources */ = {isa = PBXBuildFile; fileRef = 82F8B631122FC144005B5045 /* NSString+MIME.m */; };
+ 82B09EB0123643A70006D003 /* TKTumblr.m in Sources */ = {isa = PBXBuildFile; fileRef = 82B09EAF123643A70006D003 /* TKTumblr.m */; };
+ 82B09F42123664CD0006D003 /* NSDictionary+TumblrKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 82B09F40123664CD0006D003 /* NSDictionary+TumblrKit.h */; };
+ 82B09F43123664CD0006D003 /* NSDictionary+TumblrKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 82B09F41123664CD0006D003 /* NSDictionary+TumblrKit.m */; };
+ 82B0A019123675EF0006D003 /* TKTumblrReadRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 82B0A017123675EF0006D003 /* TKTumblrReadRequest.h */; };
+ 82B0A01A123675EF0006D003 /* TKTumblrReadRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 82B0A018123675EF0006D003 /* TKTumblrReadRequest.m */; };
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
/* End PBXBuildFile section */
@@ -52,12 +58,8 @@
dstSubfolderSpec = 1;
files = (
82B09D89123531FF0006D003 /* TKPost.h in CopyFiles */,
- 82B09D8A123531FF0006D003 /* TKTumblrReader.h in CopyFiles */,
- 82B09D8B123531FF0006D003 /* TKTumblrRequest.h in CopyFiles */,
- 82B09D8C123531FF0006D003 /* TKTumblrResponse.h in CopyFiles */,
82B09D8D123531FF0006D003 /* TKTumblr.h in CopyFiles */,
82B09D8E123531FF0006D003 /* NSString+TumblrKit.h in CopyFiles */,
- 82B09D8F123531FF0006D003 /* NSString+MIME.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -73,17 +75,13 @@
827E467711EB0D9100684466 /* TKPost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKPost.m; sourceTree = "<group>"; };
827E46D611EB1BA000684466 /* Test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Test; sourceTree = BUILT_PRODUCTS_DIR; };
827E46DD11EB1BDD00684466 /* Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Test.m; sourceTree = "<group>"; };
- 82A53C2611EC9E97006BA92A /* TKTumblrReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKTumblrReader.h; sourceTree = "<group>"; };
- 82A53C2711EC9E97006BA92A /* TKTumblrReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKTumblrReader.m; sourceTree = "<group>"; };
- 82A53CC511ED0D99006BA92A /* TKTumblrConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKTumblrConnection.h; sourceTree = "<group>"; };
- 82A53CC611ED0D99006BA92A /* TKTumblrConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKTumblrConnection.m; sourceTree = "<group>"; };
- 82A53CC911ED0DB1006BA92A /* TKTumblrRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKTumblrRequest.h; sourceTree = "<group>"; };
- 82A53CCA11ED0DB1006BA92A /* TKTumblrRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKTumblrRequest.m; sourceTree = "<group>"; };
- 82A53CCD11ED0DBE006BA92A /* TKTumblrResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKTumblrResponse.h; sourceTree = "<group>"; };
- 82A53CCE11ED0DBE006BA92A /* TKTumblrResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKTumblrResponse.m; sourceTree = "<group>"; };
82A53DD011ED938C006BA92A /* TKTumblr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKTumblr.h; sourceTree = "<group>"; };
- 82F8B630122FC144005B5045 /* NSString+MIME.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MIME.h"; sourceTree = "<group>"; };
- 82F8B631122FC144005B5045 /* NSString+MIME.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MIME.m"; sourceTree = "<group>"; };
+ 82B09EAF123643A70006D003 /* TKTumblr.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKTumblr.m; sourceTree = "<group>"; };
+ 82B09F40123664CD0006D003 /* NSDictionary+TumblrKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+TumblrKit.h"; sourceTree = "<group>"; };
+ 82B09F41123664CD0006D003 /* NSDictionary+TumblrKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+TumblrKit.m"; sourceTree = "<group>"; };
+ 82B0A017123675EF0006D003 /* TKTumblrReadRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKTumblrReadRequest.h; sourceTree = "<group>"; };
+ 82B0A018123675EF0006D003 /* TKTumblrReadRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKTumblrReadRequest.m; sourceTree = "<group>"; };
+ 82B0A044123678940006D003 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* TumblrKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TumblrKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -143,6 +141,7 @@
children = (
8DC2EF5A0486A6940098B216 /* Info.plist */,
089C1666FE841158C02AAC07 /* InfoPlist.strings */,
+ 82B0A044123678940006D003 /* README.md */,
);
name = Resources;
sourceTree = "<group>";
@@ -150,21 +149,13 @@
08FB77AEFE84172EC02AAC07 /* Classes */ = {
isa = PBXGroup;
children = (
+ 82B0A029123676790006D003 /* TumblrKit Additions */,
827E467611EB0D9100684466 /* TKPost.h */,
827E467711EB0D9100684466 /* TKPost.m */,
- 82A53C2611EC9E97006BA92A /* TKTumblrReader.h */,
- 82A53C2711EC9E97006BA92A /* TKTumblrReader.m */,
- 82A53CC511ED0D99006BA92A /* TKTumblrConnection.h */,
- 82A53CC611ED0D99006BA92A /* TKTumblrConnection.m */,
- 82A53CC911ED0DB1006BA92A /* TKTumblrRequest.h */,
- 82A53CCA11ED0DB1006BA92A /* TKTumblrRequest.m */,
- 82A53CCD11ED0DBE006BA92A /* TKTumblrResponse.h */,
- 82A53CCE11ED0DBE006BA92A /* TKTumblrResponse.m */,
82A53DD011ED938C006BA92A /* TKTumblr.h */,
- 826CD95C11EDDAD600F5CB24 /* NSString+TumblrKit.h */,
- 826CD95D11EDDAD600F5CB24 /* NSString+TumblrKit.m */,
- 82F8B630122FC144005B5045 /* NSString+MIME.h */,
- 82F8B631122FC144005B5045 /* NSString+MIME.m */,
+ 82B09EAF123643A70006D003 /* TKTumblr.m */,
+ 82B0A017123675EF0006D003 /* TKTumblrReadRequest.h */,
+ 82B0A018123675EF0006D003 /* TKTumblrReadRequest.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -193,6 +184,17 @@
name = "Other Sources";
sourceTree = "<group>";
};
+ 82B0A029123676790006D003 /* TumblrKit Additions */ = {
+ isa = PBXGroup;
+ children = (
+ 82B09F40123664CD0006D003 /* NSDictionary+TumblrKit.h */,
+ 82B09F41123664CD0006D003 /* NSDictionary+TumblrKit.m */,
+ 826CD95C11EDDAD600F5CB24 /* NSString+TumblrKit.h */,
+ 826CD95D11EDDAD600F5CB24 /* NSString+TumblrKit.m */,
+ );
+ name = "TumblrKit Additions";
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@@ -201,12 +203,10 @@
buildActionMask = 2147483647;
files = (
827E467811EB0D9100684466 /* TKPost.h in Headers */,
- 82A53CC711ED0D99006BA92A /* TKTumblrConnection.h in Headers */,
- 82A53CCB11ED0DB1006BA92A /* TKTumblrRequest.h in Headers */,
- 82A53CCF11ED0DBE006BA92A /* TKTumblrResponse.h in Headers */,
82A53DD111ED938C006BA92A /* TKTumblr.h in Headers */,
826CD95E11EDDAD600F5CB24 /* NSString+TumblrKit.h in Headers */,
- 82F8B632122FC144005B5045 /* NSString+MIME.h in Headers */,
+ 82B09F42123664CD0006D003 /* NSDictionary+TumblrKit.h in Headers */,
+ 82B0A019123675EF0006D003 /* TKTumblrReadRequest.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -265,6 +265,7 @@
targets = (
8DC2EF4F0486A6940098B216 /* TumblrKit */,
827E46D511EB1BA000684466 /* Test */,
+ 82B09E70123543700006D003 /* Documentation */,
);
};
/* End PBXProject section */
@@ -280,6 +281,22 @@
};
/* End PBXResourcesBuildPhase section */
+/* Begin PBXShellScriptBuildPhase section */
+ 82B09E6F123543700006D003 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# Build the doxygen documentation for the project and load the docset into Xcode.\n\n# Use the following to adjust the value of the $DOXYGEN_PATH User-Defined Setting:\n# Binary install location: /Applications/Doxygen.app/Contents/Resources/doxygen\n# Source build install location: /usr/local/bin/doxygen\n\n# If the config file doesn't exist, run 'doxygen -g $SOURCE_ROOT/doxygen.config' to \n# a get default file.\n\nif ! [ -f $SOURCE_ROOT/doxygen.config ] \nthen \n echo doxygen config file does not exist\n $DOXYGEN_PATH -g $SOURCE_ROOT/doxygen.config\nfi\n\n# Append the proper input/output directories and docset info to the config file.\n# This works even though values are assigned higher up in the file. Easier than sed.\n\ncp -a $SOURCE_ROOT/doxygen.config $TEMP_DIR/doxygen.config\n\necho \"INPUT = $SOURCE_ROOT\" >> $TEMP_DIR/doxygen.config\necho \"OUTPUT_DIRECTORY = $SOURCE_ROOT/DoxygenDocs.docset\" >> $TEMP_DIR/doxygen.config\necho \"GENERATE_DOCSET = YES\" >> $TEMP_DIR/doxygen.config\necho \"DOCSET_BUNDLE_ID = com.mycompany.DoxygenExample\" >> $TEMP_DIR/doxygen.config\n\n# Run doxygen on the updated config file.\n# Note: doxygen creates a Makefile that does most of the heavy lifting.\n\n$DOXYGEN_PATH $TEMP_DIR/doxygen.config\n\n# make will invoke docsetutil. Take a look at the Makefile to see how this is done.\n\nmake -C $SOURCE_ROOT/DoxygenDocs.docset/html install\n\n# Construct a temporary applescript file to tell Xcode to load a docset.\n\nrm -f $TEMP_DIR/loadDocSet.scpt\n\necho \"tell application \\\"Xcode\\\"\" >> $TEMP_DIR/loadDocSet.scpt\necho \"load documentation set with path \\\"/Users/$USER/Library/Developer/Shared/Documentation/DocSets/\\\"\" \n >> $TEMP_DIR/loadDocSet.scpt\necho \"end tell\" >> $TEMP_DIR/loadDocSet.scpt\n\n# Run the load-docset applescript command.\n\nosascript $TEMP_DIR/loadDocSet.scpt\n\nexit 0";
+ };
+/* End PBXShellScriptBuildPhase section */
+
/* Begin PBXSourcesBuildPhase section */
827E46D311EB1BA000684466 /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -294,12 +311,10 @@
buildActionMask = 2147483647;
files = (
827E467911EB0D9100684466 /* TKPost.m in Sources */,
- 82A53CC811ED0D99006BA92A /* TKTumblrConnection.m in Sources */,
- 82A53D7111ED1CE7006BA92A /* TKTumblrReader.m in Sources */,
- 82A53CCC11ED0DB1006BA92A /* TKTumblrRequest.m in Sources */,
- 82A53CD011ED0DBE006BA92A /* TKTumblrResponse.m in Sources */,
826CD95F11EDDAD600F5CB24 /* NSString+TumblrKit.m in Sources */,
- 82F8B633122FC144005B5045 /* NSString+MIME.m in Sources */,
+ 82B09EB0123643A70006D003 /* TKTumblr.m in Sources */,
+ 82B09F43123664CD0006D003 /* NSDictionary+TumblrKit.m in Sources */,
+ 82B0A01A123675EF0006D003 /* TKTumblrReadRequest.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -351,6 +366,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DOXYGEN_PATH = /Applications/Doxygen.app/Contents/Resources/doxygen;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
@@ -436,6 +452,29 @@
};
name = Release;
};
+ 82B09E71123543700006D003 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COPY_PHASE_STRIP = NO;
+ DOXYGEN_PATH = /Applications/Doxygen.app/Contents/Resources/doxygen;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ PRODUCT_NAME = Documentation;
+ };
+ name = Debug;
+ };
+ 82B09E72123543700006D003 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DOXYGEN_PATH = /Applications/Doxygen.app/Contents/Resources/doxygen;
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ PRODUCT_NAME = Documentation;
+ ZERO_LINK = NO;
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -466,6 +505,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 82B09E781235438A0006D003 /* Build configuration list for PBXAggregateTarget "Documentation" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 82B09E71123543700006D003 /* Debug */,
+ 82B09E72123543700006D003 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
Please sign in to comment.
Something went wrong with that request. Please try again.