This commit is contained in:
German Laullon
2010-06-15 08:54:22 -07:00
parent 5a7dd3fac1
commit 8b357d40e9
7 changed files with 34 additions and 21 deletions
+2 -2
View File
@@ -21,11 +21,11 @@
NSString *sha;
PBGitRepository *repository;
id controller;
bool commit;
}
- (id)initWithRepository:(PBGitRepository *)theRepository;
- (id)initWithRepository:(PBGitRepository *)theRepository andController:(id)theController;
- (void)showFile:(NSString *)file sha:(NSString *)sha;
- (NSString*)refSpec;
+22 -6
View File
@@ -7,6 +7,7 @@
//
#import "FileViewerController.h"
#import "PBGitHistoryController.h"
#define GROUP_LABEL @"Label" // string
#define GROUP_SEPARATOR @"HasSeparator" // BOOL as NSNumber
@@ -20,9 +21,10 @@
#pragma mark Setup and teardown
- (id)initWithRepository:(PBGitRepository *)theRepository
- (id)initWithRepository:(PBGitRepository *)theRepository andController:(id)theController;
{
repository=theRepository;
controller=theController;
return [self initWithNibName:@"FileViewer" bundle:[NSBundle mainBundle]];
}
@@ -65,6 +67,21 @@
}
#pragma mark JavaScript log.js methods
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)sel
{
if (sel == @selector(selectCommit:)) return NO;
return YES;
}
- (void) selectCommit:(NSString*)c
{
NSLog(@"[FileViewerController controller:%@]",controller);
if([(PBGitHistoryController *)controller selectCommit:sha])
NSLog(@"---");
NSLog(@"[FileViewerController selectCommit:%@]",c);
}
#pragma mark MGScopeBarDelegate methods
@@ -133,7 +150,7 @@
NSString *testFile = [NSString stringWithFormat:@"%@/test.html",NSHomeDirectory()];
NSString *format;
if(formatFile!=nil)
format=[NSString stringWithContentsOfURL:[NSURL fileURLWithPath:formatFile] encoding:nil error:nil];
format=[NSString stringWithContentsOfURL:[NSURL fileURLWithPath:formatFile] encoding:NSUTF8StringEncoding error:nil];
NSString *txt;
if(show==@"source")
@@ -147,15 +164,14 @@
else
return; // XXXX controlar mejor.
NSLog(@"didFinishLoadForFrame -> txt: '%@'",[txt substringToIndex:80]);
NSLog(@"didFinishLoadForFrame -> path: '%@'",path);
NSLog(@"didFinishLoadForFrame -> testFile: '%@'",testFile);
NSLog(@"didFinishLoadForFrame -> txt: '%@'",([txt length]>180)?[txt substringToIndex:180]:txt);
id script = [webViewFileViwer windowScriptObject];
[script setValue:self forKey:@"Controler"];
[script callWebScriptMethod:@"showFile"
withArguments:[NSArray arrayWithObjects:txt, nil]];
[[[[[sender mainFrame] DOMDocument] documentElement] outerHTML] writeToFile:testFile atomically:YES encoding:NSUTF8StringEncoding error:nil];
//[[[[[sender mainFrame] DOMDocument] documentElement] outerHTML] writeToFile:testFile atomically:YES encoding:NSUTF8StringEncoding error:nil];
}
- (NSString*)refSpec