Skip to content

Commit

Permalink
- Added support for Idek.net.
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Streza <stevestreza@gmail.com>
  • Loading branch information
jpedroso authored and stevestreza committed Apr 25, 2009
1 parent 8a0d7fd commit 2ec02ba
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Classes/Handlers/USIdekShrinker.h
@@ -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
61 changes: 61 additions & 0 deletions Classes/Handlers/USIdekShrinker.m
@@ -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

0 comments on commit 2ec02ba

Please sign in to comment.