Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Steve Streza <stevestreza@gmail.com>
- Loading branch information
1 parent
8a0d7fd
commit 2ec02ba
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// USIdekShrinker.h | ||
// URL Shrink | ||
// | ||
// Created by Jorge Pedroso | ||
// Twitter: http://twitter.com/jpedroso | ||
// Email: jpedroso@unsolicitedfeedback.com | ||
// All code is provided under the New BSD license. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "USURLShrinker.h" | ||
|
||
@interface USIdekShrinker : USURLShrinker { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// USIdekShrinker.m | ||
// URL Shrink | ||
// | ||
// Created by Jorge Pedroso | ||
// Twitter: http://twitter.com/jpedroso | ||
// Email: jpedroso@unsolicitedfeedback.com | ||
// All code is provided under the New BSD license. | ||
// | ||
|
||
#import "USIdekShrinker.h" | ||
|
||
#define kUSIdekAppKey @"http://github.com/amazingsyco/url-shrink" | ||
#define kUSIdekShrinkerAPIEnpoint @"http://idek.net/c.php?idek-api=true&idek-ref=%@&idek-url=%@" | ||
#define kUSIdekExpanderAPIEnpoint @"%@?idek-api=true" | ||
|
||
@implementation USIdekShrinker | ||
|
||
+ (NSString *)name | ||
{ | ||
return @"idek"; | ||
} | ||
|
||
|
||
+ (BOOL)canExpandURL:(NSURL *)URL | ||
{ | ||
return [[URL host] isEqualToString:@"idek.net"]; | ||
} | ||
|
||
|
||
- (void)performShrinkOnURL:(NSURL *)URL | ||
{ | ||
// prepare request | ||
NSString *s = [NSString stringWithFormat:kUSIdekShrinkerAPIEnpoint, | ||
kUSIdekAppKey, [URL absoluteString]]; | ||
NSURL *shrinkURL = [NSURL URLWithString:s]; // assumes that the original URL is sanitized. | ||
|
||
// do request | ||
NSString *shrinkResult = [NSString stringWithContentsOfURL:shrinkURL]; | ||
|
||
// wrap result and delegate | ||
NSURL *shrunkenURL = [NSURL URLWithString:shrinkResult]; | ||
[self doneShrinking:shrunkenURL]; | ||
} | ||
|
||
|
||
- (void)performExpandOnURL:(NSURL *)URL | ||
{ | ||
// prepare request | ||
NSString *s = [NSString stringWithFormat:kUSIdekExpanderAPIEnpoint, [URL absoluteString]]; | ||
NSURL *expandURL = [NSURL URLWithString:s]; | ||
|
||
//do request | ||
NSString *expandResult = [NSString stringWithContentsOfURL:expandURL]; | ||
|
||
// wrap result and delegate | ||
NSURL *expandedURL = [NSURL URLWithString:expandResult]; | ||
[self doneExpanding:expandedURL]; | ||
} | ||
|
||
@end |