From 479beb603e672cd1add7f81379c8b5b65e17f511 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 14 Nov 2012 23:36:29 -0800 Subject: [PATCH] minimal implementation, opens vs:// and vss:// URLs --- ViewSource.xcodeproj/project.pbxproj | 1 + ViewSource/MMHTTPRequest.m | 1 + ViewSource/VSAppDelegate.m | 28 +++++++--- ViewSource/ViewSource-Info.plist | 12 +++++ ViewSource/en.lproj/VSViewController_iPad.xib | 52 ++++++++++--------- .../en.lproj/VSViewController_iPhone.xib | 11 ++-- 6 files changed, 70 insertions(+), 35 deletions(-) diff --git a/ViewSource.xcodeproj/project.pbxproj b/ViewSource.xcodeproj/project.pbxproj index b6593cd..e264e2d 100644 --- a/ViewSource.xcodeproj/project.pbxproj +++ b/ViewSource.xcodeproj/project.pbxproj @@ -333,6 +333,7 @@ 7B00EC8F1654BBEB00531FBD /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/ViewSource/MMHTTPRequest.m b/ViewSource/MMHTTPRequest.m index a077db5..e81b619 100644 --- a/ViewSource/MMHTTPRequest.m +++ b/ViewSource/MMHTTPRequest.m @@ -97,6 +97,7 @@ - (void) connection: (NSURLConnection *)connection didReceiveResponse: (NSURLResponse *)response { + NSLog(@"response: %@ (%d, %@)", response, [(NSHTTPURLResponse *)response statusCode], [(NSHTTPURLResponse *)response allHeaderFields]); if ([response respondsToSelector: @selector(statusCode)]) { _statusCode = [(NSHTTPURLResponse *)response statusCode]; diff --git a/ViewSource/VSAppDelegate.m b/ViewSource/VSAppDelegate.m index e88aa50..0fb3110 100644 --- a/ViewSource/VSAppDelegate.m +++ b/ViewSource/VSAppDelegate.m @@ -12,8 +12,10 @@ @implementation VSAppDelegate -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +- (BOOL) application: (UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions { + NSLog(@"didFinishLaunchingWithOptions: %@", launchOptions); + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { @@ -22,7 +24,8 @@ self.viewController = [[VSViewController alloc] initWithNibName:@"VSViewController_iPad" bundle:nil]; } - NSString *url = @"http://samhuri.net"; + // TODO restore from disk + NSString *url = @"http://samhuri.net/vs"; NSRange scrollRange = NSMakeRange(0, 0); VSSource *source = [VSSource sourceWithURL: url scrollRange: scrollRange]; [self.viewController loadSource: source]; @@ -32,29 +35,40 @@ return YES; } -- (void)applicationWillResignActive:(UIApplication *)application +- (BOOL) application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation +{ + NSString *urlString = [[[url absoluteString] + stringByReplacingOccurrencesOfString: @"vs://" withString: @"http://"] + stringByReplacingOccurrencesOfString: @"vss://" withString: @"https://"]; + NSLog(@"url: %@", urlString); + VSSource *source = [VSSource sourceWithURL: urlString scrollRange: NSMakeRange(0, 0)]; + [self.viewController loadSource: source]; + return YES; +} + +- (void) applicationWillResignActive: (UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } -- (void)applicationDidEnterBackground:(UIApplication *)application +- (void) applicationDidEnterBackground: (UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } -- (void)applicationWillEnterForeground:(UIApplication *)application +- (void) applicationWillEnterForeground: (UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } -- (void)applicationDidBecomeActive:(UIApplication *)application +- (void) applicationDidBecomeActive: (UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } -- (void)applicationWillTerminate:(UIApplication *)application +- (void) applicationWillTerminate: (UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/ViewSource/ViewSource-Info.plist b/ViewSource/ViewSource-Info.plist index cfb8663..4d74f45 100644 --- a/ViewSource/ViewSource-Info.plist +++ b/ViewSource/ViewSource-Info.plist @@ -2,6 +2,18 @@ + CFBundleURLTypes + + + CFBundleURLName + net.samhuri.${PRODUCT_NAME:rfc1034identifier} + CFBundleURLSchemes + + vs + vss + + + CFBundleDevelopmentRegion en CFBundleDisplayName diff --git a/ViewSource/en.lproj/VSViewController_iPad.xib b/ViewSource/en.lproj/VSViewController_iPad.xib index d2a952d..83c326b 100644 --- a/ViewSource/en.lproj/VSViewController_iPad.xib +++ b/ViewSource/en.lproj/VSViewController_iPad.xib @@ -36,7 +36,7 @@ 274 - + 274 {768, 1004} @@ -51,18 +51,21 @@ YES IBIPadFramework NO + NO Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 2 IBCocoaTouchFramework - 1 - 14 + CourierNewPSMT + Courier New + 0 + 13 - Helvetica - 14 + CourierNewPSMT + 13 16 @@ -70,6 +73,7 @@ {{0, 20}, {768, 1004}} + 3 MQA @@ -97,7 +101,7 @@ sourceView - + 9 @@ -125,9 +129,9 @@ 2 - - - + + + 3 0 @@ -142,8 +146,8 @@ 29 3 - - + + 5 0 @@ -158,8 +162,8 @@ 29 3 - - + + 4 0 @@ -174,8 +178,8 @@ 29 3 - - + + 6 0 @@ -195,27 +199,27 @@ 4 - + 5 - + 6 - + 7 - + 8 - + @@ -227,10 +231,10 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin diff --git a/ViewSource/en.lproj/VSViewController_iPhone.xib b/ViewSource/en.lproj/VSViewController_iPhone.xib index 00f6f34..bdb932f 100644 --- a/ViewSource/en.lproj/VSViewController_iPhone.xib +++ b/ViewSource/en.lproj/VSViewController_iPhone.xib @@ -49,18 +49,21 @@ YES YES IBCocoaTouchFramework + NO Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 2 IBCocoaTouchFramework - 1 - 14 + CourierNewPSMT + Courier New + 0 + 13 - Helvetica - 14 + CourierNewPSMT + 13 16