diff --git a/FileViewer/FileViewerController.h b/FileViewer/FileViewerController.h index 0be25d1..a41b217 100644 --- a/FileViewer/FileViewerController.h +++ b/FileViewer/FileViewerController.h @@ -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; diff --git a/FileViewer/FileViewerController.m b/FileViewer/FileViewerController.m index e20ce6e..626facf 100644 --- a/FileViewer/FileViewerController.m +++ b/FileViewer/FileViewerController.m @@ -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 diff --git a/PBGitCommitController.m b/PBGitCommitController.m index fc841aa..2ee7098 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -65,7 +65,7 @@ fileViewerController=[[FileViewerController alloc] retain]; [fileViewerController setCommit:true]; - [fileViewerController initWithRepository:repository]; + [fileViewerController initWithRepository:repository andController:self]; [fileViewerController loadView]; // XXXX :( ? diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 619061e..f747852 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -119,7 +119,7 @@ // [webViewFileViwer setFrameLoadDelegate:self]; fileViewerController=[[FileViewerController alloc] retain]; - [fileViewerController initWithRepository:repository]; + [fileViewerController initWithRepository:repository andController:self]; [fileViewerController loadView]; //[fileViewer setAutoresizesSubviews:YES]; @@ -478,7 +478,7 @@ if (appController.launchedFromGitx && [appController.cliArgs isEqualToString:@"--commit"]) { return NO; } - // NSLog(@"[%@ %s]: SHA = %@", [self class], _cmd, commitSHA); + NSLog(@"[%@ %s]: SHA = %@", [self class], _cmd, commitSHA); if (!forceSelectionUpdate && [[selectedCommit realSha] isEqualToString:commitSHA]) return NO; @@ -493,7 +493,7 @@ [commitController setSelectedObjects:selectedCommits]; if (repository.currentBranchFilter != kGitXSelectedBranchFilter) { - // NSLog(@"[%@ %s] currentBranchFilter = %@", [self class], _cmd, PBStringFromBranchFilterType(repository.currentBranchFilter)); + NSLog(@"[%@ %s] currentBranchFilter = %@", [self class], _cmd, PBStringFromBranchFilterType(repository.currentBranchFilter)); [self scrollSelectionToTopOfViewFrom:oldIndex]; } diff --git a/html/views/log/format.html b/html/views/log/format.html index 7b8604f..92b50ae 100644 --- a/html/views/log/format.html +++ b/html/views/log/format.html @@ -3,8 +3,6 @@ - +
Author:%an
Date:%ar
Commit:%H
Commit:%H
- -file:///Users/laullon/xcode/gitx/build/Release/GitX.app/Contents/Resources/html/views/history/index.html \ No newline at end of file diff --git a/html/views/log/index.html b/html/views/log/index.html index 32f98f0..593d6b1 100644 --- a/html/views/log/index.html +++ b/html/views/log/index.html @@ -9,12 +9,6 @@ - - diff --git a/html/views/log/log.js b/html/views/log/log.js index 8859d80..d117f2b 100644 --- a/html/views/log/log.js +++ b/html/views/log/log.js @@ -1,3 +1,8 @@ +var selectCommit = function(a) { + window.Controler.selectCommit_(a); + return false; +} + var showFile = function(txt) { $("log").style.display = ""; $("log").innerHTML=txt;