Skip to content
Browse files

Syntax highlighting via JavaScript now works in the simulator.

  • Loading branch information...
1 parent 4cef7e8 commit bff0d2d4f663155bc43980e764bd2f25f25e303e @oalders oalders committed
Showing with 50 additions and 26 deletions.
  1. +3 −0 xcode/Classes/MasterViewController.m
  2. +31 −10 xcode/Classes/iCPANAppDelegate.m
  3. +16 −16 xcode/iCPAN.xcodeproj/project.pbxproj
View
3 xcode/Classes/MasterViewController.m
@@ -155,6 +155,9 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
self.navigationItem.rightBarButtonItem = nil;
self.title = [url absoluteString];
}
+
+ //NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:appDelegate.cpanpod];
+ //NSLog(@"contents %@", dirContents);
return TRUE;
}
View
41 xcode/Classes/iCPANAppDelegate.m
@@ -61,27 +61,48 @@ - (NSArray *)getRecentlyViewed {
}
+// When the application launches, we'll clear out the cpanpod folder by
+// removing it completely. We'll then recreate it and copy over the files
+// we care about. This means that we'll have a cache of files per session,
+// but that we don't have to worry about these files when the app is upgraded
+
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
-
- //NSLog(@"Path: %@", [self applicationDocumentsDirectory]);
-
+
NSFileManager *NSFm= [NSFileManager defaultManager];
+
+ //start clean each time
+ if ([NSFm removeItemAtPath: [self cpanpod] error: NULL] == YES) {
+ //NSLog (@"Remove successful");
+ }
+ else {
+ NSLog (@"Remove failed");
+ }
+
[NSFm createDirectoryAtPath:[self cpanpod] attributes:nil];
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
- NSString *source = [bundlePath stringByAppendingString:@"/style.css"];
- NSString *destination = [self.cpanpod stringByAppendingString:@"/style.css"];
+ bundlePath = [bundlePath stringByAppendingString:@"/"];
NSError *error = nil;
- if ( [[NSFileManager defaultManager] fileExistsAtPath:destination] ) {
- return;
+ // Not sure of the best way to handle this, but it seems like we can't reliably predict where the cpanpod
+ // folder will be, so we'll just copy over some resource files when needed
+ NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
+ NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:bundleRoot];
+ NSArray *css = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH 's'"]];
+
+ NSEnumerator *e = [css objectEnumerator];
+ id file;
+ while (file = [e nextObject]) {
+
+ NSString *src = [bundlePath stringByAppendingString:file];
+ NSString *dest = [self.cpanpod stringByAppendingString:file];
+
+ if ( [[NSFileManager defaultManager] isReadableFileAtPath:src] )
+ [[NSFileManager defaultManager] copyItemAtPath:src toPath:dest error:&error];
}
-
- if ( [[NSFileManager defaultManager] isReadableFileAtPath:source] )
- [[NSFileManager defaultManager] copyItemAtPath:source toPath:destination error:&error];
}
View
32 xcode/iCPAN.xcodeproj/project.pbxproj
@@ -43,12 +43,12 @@
D8F9C1A7118CCEFE00CDA6DF /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = D8F9C1A6118CCEFE00CDA6DF /* style.css */; };
D8F9C1D1118CD34A00CDA6DF /* ModuleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D8F9C1D0118CD34A00CDA6DF /* ModuleTableViewCell.m */; };
ED3211D111F6B3E200D66A76 /* iCPAN.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = ED3211D011F6B3E200D66A76 /* iCPAN.sqlite */; };
- ED6977C511FE3C2C00895FE2 /* jquery.min.js in Sources */ = {isa = PBXBuildFile; fileRef = ED6977BF11FE3C2C00895FE2 /* jquery.min.js */; };
- ED6977C611FE3C2C00895FE2 /* shBrushJScript.js in Sources */ = {isa = PBXBuildFile; fileRef = ED6977C011FE3C2C00895FE2 /* shBrushJScript.js */; };
- ED6977C711FE3C2C00895FE2 /* shBrushPerl.js in Sources */ = {isa = PBXBuildFile; fileRef = ED6977C111FE3C2C00895FE2 /* shBrushPerl.js */; };
ED6977C811FE3C2C00895FE2 /* shCore.css in Resources */ = {isa = PBXBuildFile; fileRef = ED6977C211FE3C2C00895FE2 /* shCore.css */; };
- ED6977C911FE3C2C00895FE2 /* shCore.js in Sources */ = {isa = PBXBuildFile; fileRef = ED6977C311FE3C2C00895FE2 /* shCore.js */; };
ED6977CA11FE3C2C00895FE2 /* shThemeEmacs.css in Resources */ = {isa = PBXBuildFile; fileRef = ED6977C411FE3C2C00895FE2 /* shThemeEmacs.css */; };
+ ED77C3DC11FE740100252EA8 /* shBrushJScript.js in Resources */ = {isa = PBXBuildFile; fileRef = ED77C3DB11FE740100252EA8 /* shBrushJScript.js */; };
+ ED77C3E911FE743800252EA8 /* jquery.min.js in Resources */ = {isa = PBXBuildFile; fileRef = ED77C3E611FE743800252EA8 /* jquery.min.js */; };
+ ED77C3EA11FE743800252EA8 /* shBrushPerl.js in Resources */ = {isa = PBXBuildFile; fileRef = ED77C3E711FE743800252EA8 /* shBrushPerl.js */; };
+ ED77C3EB11FE743800252EA8 /* shCore.js in Resources */ = {isa = PBXBuildFile; fileRef = ED77C3E811FE743800252EA8 /* shCore.js */; };
ED87466411659335003DCD57 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = ED87466311659335003DCD57 /* Settings.bundle */; };
/* End PBXBuildFile section */
@@ -100,12 +100,12 @@
D8F9C1CF118CD34A00CDA6DF /* ModuleTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleTableViewCell.h; sourceTree = "<group>"; };
D8F9C1D0118CD34A00CDA6DF /* ModuleTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModuleTableViewCell.m; sourceTree = "<group>"; };
ED3211D011F6B3E200D66A76 /* iCPAN.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; name = iCPAN.sqlite; path = ../iCPAN.sqlite; sourceTree = SOURCE_ROOT; };
- ED6977BF11FE3C2C00895FE2 /* jquery.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jquery.min.js; sourceTree = "<group>"; };
- ED6977C011FE3C2C00895FE2 /* shBrushJScript.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shBrushJScript.js; sourceTree = "<group>"; };
- ED6977C111FE3C2C00895FE2 /* shBrushPerl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shBrushPerl.js; sourceTree = "<group>"; };
ED6977C211FE3C2C00895FE2 /* shCore.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = shCore.css; sourceTree = "<group>"; };
- ED6977C311FE3C2C00895FE2 /* shCore.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shCore.js; sourceTree = "<group>"; };
ED6977C411FE3C2C00895FE2 /* shThemeEmacs.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = shThemeEmacs.css; sourceTree = "<group>"; };
+ ED77C3DB11FE740100252EA8 /* shBrushJScript.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shBrushJScript.js; sourceTree = "<group>"; };
+ ED77C3E611FE743800252EA8 /* jquery.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jquery.min.js; sourceTree = "<group>"; };
+ ED77C3E711FE743800252EA8 /* shBrushPerl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shBrushPerl.js; sourceTree = "<group>"; };
+ ED77C3E811FE743800252EA8 /* shCore.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shCore.js; sourceTree = "<group>"; };
ED87466311659335003DCD57 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -177,11 +177,11 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
- ED6977BF11FE3C2C00895FE2 /* jquery.min.js */,
- ED6977C011FE3C2C00895FE2 /* shBrushJScript.js */,
- ED6977C111FE3C2C00895FE2 /* shBrushPerl.js */,
+ ED77C3E611FE743800252EA8 /* jquery.min.js */,
+ ED77C3E711FE743800252EA8 /* shBrushPerl.js */,
+ ED77C3E811FE743800252EA8 /* shCore.js */,
+ ED77C3DB11FE740100252EA8 /* shBrushJScript.js */,
ED6977C211FE3C2C00895FE2 /* shCore.css */,
- ED6977C311FE3C2C00895FE2 /* shCore.js */,
ED6977C411FE3C2C00895FE2 /* shThemeEmacs.css */,
ED3211D011F6B3E200D66A76 /* iCPAN.sqlite */,
D8097B6D118803420062EACA /* BookmarksView.xib */,
@@ -309,6 +309,10 @@
ED3211D111F6B3E200D66A76 /* iCPAN.sqlite in Resources */,
ED6977C811FE3C2C00895FE2 /* shCore.css in Resources */,
ED6977CA11FE3C2C00895FE2 /* shThemeEmacs.css in Resources */,
+ ED77C3E911FE743800252EA8 /* jquery.min.js in Resources */,
+ ED77C3DC11FE740100252EA8 /* shBrushJScript.js in Resources */,
+ ED77C3EB11FE743800252EA8 /* shCore.js in Resources */,
+ ED77C3EA11FE743800252EA8 /* shBrushPerl.js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -328,10 +332,6 @@
D8097B871188036F0062EACA /* Author.m in Sources */,
D8097B881188036F0062EACA /* Module.m in Sources */,
D8F9C1D1118CD34A00CDA6DF /* ModuleTableViewCell.m in Sources */,
- ED6977C511FE3C2C00895FE2 /* jquery.min.js in Sources */,
- ED6977C611FE3C2C00895FE2 /* shBrushJScript.js in Sources */,
- ED6977C711FE3C2C00895FE2 /* shBrushPerl.js in Sources */,
- ED6977C911FE3C2C00895FE2 /* shCore.js in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit bff0d2d

Please sign in to comment.
Something went wrong with that request. Please try again.