minimal implementation, opens vs:// and vss:// URLs

This commit is contained in:
Sami Samhuri 2012-11-14 23:36:29 -08:00
parent 911c59fe62
commit 479beb603e
6 changed files with 70 additions and 35 deletions

View file

@ -333,6 +333,7 @@
7B00EC8F1654BBEB00531FBD /* Release */, 7B00EC8F1654BBEB00531FBD /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
}; };
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };

View file

@ -97,6 +97,7 @@
- (void) connection: (NSURLConnection *)connection didReceiveResponse: (NSURLResponse *)response - (void) connection: (NSURLConnection *)connection didReceiveResponse: (NSURLResponse *)response
{ {
NSLog(@"response: %@ (%d, %@)", response, [(NSHTTPURLResponse *)response statusCode], [(NSHTTPURLResponse *)response allHeaderFields]);
if ([response respondsToSelector: @selector(statusCode)]) if ([response respondsToSelector: @selector(statusCode)])
{ {
_statusCode = [(NSHTTPURLResponse *)response statusCode]; _statusCode = [(NSHTTPURLResponse *)response statusCode];

View file

@ -12,8 +12,10 @@
@implementation VSAppDelegate @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]]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch. // Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
@ -22,7 +24,8 @@
self.viewController = [[VSViewController alloc] initWithNibName:@"VSViewController_iPad" bundle:nil]; 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); NSRange scrollRange = NSMakeRange(0, 0);
VSSource *source = [VSSource sourceWithURL: url scrollRange: scrollRange]; VSSource *source = [VSSource sourceWithURL: url scrollRange: scrollRange];
[self.viewController loadSource: source]; [self.viewController loadSource: source];
@ -32,29 +35,40 @@
return YES; 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. // 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. // 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. // 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. // 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. // 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. // 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:. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} }

View file

@ -2,6 +2,18 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>net.samhuri.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>vs</string>
<string>vss</string>
</array>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>

View file

@ -36,7 +36,7 @@
<reference key="NSNextResponder"/> <reference key="NSNextResponder"/>
<int key="NSvFlags">274</int> <int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews"> <array class="NSMutableArray" key="NSSubviews">
<object class="IBUITextView" id="49274661"> <object class="IBUITextView" id="122258636">
<reference key="NSNextResponder" ref="766721923"/> <reference key="NSNextResponder" ref="766721923"/>
<int key="NSvFlags">274</int> <int key="NSvFlags">274</int>
<string key="NSFrameSize">{768, 1004}</string> <string key="NSFrameSize">{768, 1004}</string>
@ -51,18 +51,21 @@
<bool key="IBUIMultipleTouchEnabled">YES</bool> <bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string> <string key="targetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBUIShowsHorizontalScrollIndicator">NO</bool> <bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
<bool key="IBUIEditable">NO</bool>
<string key="IBUIText">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.</string> <string key="IBUIText">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.</string>
<object class="IBUITextInputTraits" key="IBUITextInputTraits"> <object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocapitalizationType">2</int> <int key="IBUIAutocapitalizationType">2</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object> </object>
<object class="IBUIFontDescription" key="IBUIFontDescription"> <object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int> <string key="name">CourierNewPSMT</string>
<double key="pointSize">14</double> <string key="family">Courier New</string>
<int key="traits">0</int>
<double key="pointSize">13</double>
</object> </object>
<object class="NSFont" key="IBUIFont"> <object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string> <string key="NSName">CourierNewPSMT</string>
<double key="NSSize">14</double> <double key="NSSize">13</double>
<int key="NSfFlags">16</int> <int key="NSfFlags">16</int>
</object> </object>
</object> </object>
@ -70,6 +73,7 @@
<string key="NSFrame">{{0, 20}, {768, 1004}}</string> <string key="NSFrame">{{0, 20}, {768, 1004}}</string>
<reference key="NSSuperview"/> <reference key="NSSuperview"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="122258636"/>
<object class="NSColor" key="IBUIBackgroundColor"> <object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int> <int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes> <bytes key="NSWhite">MQA</bytes>
@ -97,7 +101,7 @@
<object class="IBCocoaTouchOutletConnection" key="connection"> <object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">sourceView</string> <string key="label">sourceView</string>
<reference key="source" ref="841351856"/> <reference key="source" ref="841351856"/>
<reference key="destination" ref="49274661"/> <reference key="destination" ref="122258636"/>
</object> </object>
<int key="connectionID">9</int> <int key="connectionID">9</int>
</object> </object>
@ -125,9 +129,9 @@
<int key="objectID">2</int> <int key="objectID">2</int>
<reference key="object" ref="766721923"/> <reference key="object" ref="766721923"/>
<array class="NSMutableArray" key="children"> <array class="NSMutableArray" key="children">
<reference ref="49274661"/> <reference ref="122258636"/>
<object class="IBNSLayoutConstraint" id="743327192"> <object class="IBNSLayoutConstraint" id="740801057">
<reference key="firstItem" ref="49274661"/> <reference key="firstItem" ref="122258636"/>
<int key="firstAttribute">3</int> <int key="firstAttribute">3</int>
<int key="relation">0</int> <int key="relation">0</int>
<reference key="secondItem" ref="766721923"/> <reference key="secondItem" ref="766721923"/>
@ -142,8 +146,8 @@
<float key="scoringTypeFloat">29</float> <float key="scoringTypeFloat">29</float>
<int key="contentType">3</int> <int key="contentType">3</int>
</object> </object>
<object class="IBNSLayoutConstraint" id="561193563"> <object class="IBNSLayoutConstraint" id="458783990">
<reference key="firstItem" ref="49274661"/> <reference key="firstItem" ref="122258636"/>
<int key="firstAttribute">5</int> <int key="firstAttribute">5</int>
<int key="relation">0</int> <int key="relation">0</int>
<reference key="secondItem" ref="766721923"/> <reference key="secondItem" ref="766721923"/>
@ -158,8 +162,8 @@
<float key="scoringTypeFloat">29</float> <float key="scoringTypeFloat">29</float>
<int key="contentType">3</int> <int key="contentType">3</int>
</object> </object>
<object class="IBNSLayoutConstraint" id="122218691"> <object class="IBNSLayoutConstraint" id="27314349">
<reference key="firstItem" ref="49274661"/> <reference key="firstItem" ref="122258636"/>
<int key="firstAttribute">4</int> <int key="firstAttribute">4</int>
<int key="relation">0</int> <int key="relation">0</int>
<reference key="secondItem" ref="766721923"/> <reference key="secondItem" ref="766721923"/>
@ -174,8 +178,8 @@
<float key="scoringTypeFloat">29</float> <float key="scoringTypeFloat">29</float>
<int key="contentType">3</int> <int key="contentType">3</int>
</object> </object>
<object class="IBNSLayoutConstraint" id="519000636"> <object class="IBNSLayoutConstraint" id="894549202">
<reference key="firstItem" ref="49274661"/> <reference key="firstItem" ref="122258636"/>
<int key="firstAttribute">6</int> <int key="firstAttribute">6</int>
<int key="relation">0</int> <int key="relation">0</int>
<reference key="secondItem" ref="766721923"/> <reference key="secondItem" ref="766721923"/>
@ -195,27 +199,27 @@
</object> </object>
<object class="IBObjectRecord"> <object class="IBObjectRecord">
<int key="objectID">4</int> <int key="objectID">4</int>
<reference key="object" ref="49274661"/> <reference key="object" ref="122258636"/>
<reference key="parent" ref="766721923"/> <reference key="parent" ref="766721923"/>
</object> </object>
<object class="IBObjectRecord"> <object class="IBObjectRecord">
<int key="objectID">5</int> <int key="objectID">5</int>
<reference key="object" ref="519000636"/> <reference key="object" ref="894549202"/>
<reference key="parent" ref="766721923"/> <reference key="parent" ref="766721923"/>
</object> </object>
<object class="IBObjectRecord"> <object class="IBObjectRecord">
<int key="objectID">6</int> <int key="objectID">6</int>
<reference key="object" ref="122218691"/> <reference key="object" ref="27314349"/>
<reference key="parent" ref="766721923"/> <reference key="parent" ref="766721923"/>
</object> </object>
<object class="IBObjectRecord"> <object class="IBObjectRecord">
<int key="objectID">7</int> <int key="objectID">7</int>
<reference key="object" ref="561193563"/> <reference key="object" ref="458783990"/>
<reference key="parent" ref="766721923"/> <reference key="parent" ref="766721923"/>
</object> </object>
<object class="IBObjectRecord"> <object class="IBObjectRecord">
<int key="objectID">8</int> <int key="objectID">8</int>
<reference key="object" ref="743327192"/> <reference key="object" ref="740801057"/>
<reference key="parent" ref="766721923"/> <reference key="parent" ref="766721923"/>
</object> </object>
</array> </array>
@ -227,10 +231,10 @@
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<array key="2.IBViewMetadataConstraints"> <array key="2.IBViewMetadataConstraints">
<reference ref="519000636"/> <reference ref="894549202"/>
<reference ref="122218691"/> <reference ref="27314349"/>
<reference ref="561193563"/> <reference ref="458783990"/>
<reference ref="743327192"/> <reference ref="740801057"/>
</array> </array>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<boolean value="NO" key="4.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/> <boolean value="NO" key="4.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>

View file

@ -49,18 +49,21 @@
<bool key="IBUIClipsSubviews">YES</bool> <bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIMultipleTouchEnabled">YES</bool> <bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIEditable">NO</bool>
<string key="IBUIText">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.</string> <string key="IBUIText">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.</string>
<object class="IBUITextInputTraits" key="IBUITextInputTraits"> <object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocapitalizationType">2</int> <int key="IBUIAutocapitalizationType">2</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object> </object>
<object class="IBUIFontDescription" key="IBUIFontDescription"> <object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int> <string key="name">CourierNewPSMT</string>
<double key="pointSize">14</double> <string key="family">Courier New</string>
<int key="traits">0</int>
<double key="pointSize">13</double>
</object> </object>
<object class="NSFont" key="IBUIFont"> <object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string> <string key="NSName">CourierNewPSMT</string>
<double key="NSSize">14</double> <double key="NSSize">13</double>
<int key="NSfFlags">16</int> <int key="NSfFlags">16</int>
</object> </object>
</object> </object>