Files
gitx/PBWebGitController.m
T
Pieter de Bie ede8892dc9 PBGitRepository: Abstract revision walking to new class PBGitRevList
The revision walking code made the PBGitRepository unclean. Especially if
we want to keep multiple PBGitRepository objects around (e.g. persistent
data store), it needs to be more simple. This neatly extracts the revision
walking code from the repository code.
2008-06-17 19:32:38 +02:00

82 lines
2.1 KiB
Objective-C

//
// PBWebGitController.m
// GitTest
//
// Created by Pieter de Bie on 14-06-08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "PBWebGitController.h"
@implementation PBWebGitController
@synthesize diff;
- (void) awakeFromNib
{
[detailController addObserver:self forKeyPath:@"webCommit" options:0 context:@"ChangedCommit"];
NSLog([[NSBundle mainBundle] resourcePath]);
NSString* file = [[NSBundle mainBundle] pathForResource:@"commit" ofType:@"html"];
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:file]];
currentSha = @"Not Loaded";
[[view mainFrame] loadRequest:request];
}
- (void) webView:(id) v didFinishLoadForFrame:(id) frame
{
id script = [view windowScriptObject];
[script setValue: self forKey:@"Controller"];
currentSha = @"";
[self changeContentTo: detailController.webCommit];
}
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (context == @"ChangedCommit") {
[self changeContentTo: detailController.webCommit];
}
else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
- (void) changeContentTo: (PBGitCommit *) content
{
if (content == nil)
return;
if ([currentSha isEqualToString: content.sha] || [currentSha isEqualToString:@"Not Loaded"])
return;
currentSha = content.sha;
id script = [view windowScriptObject];
[script setValue: content forKey:@"CommitObject"];
[script callWebScriptMethod:@"doeHet" withArguments: nil];
}
- (void) log: (NSString*) logMessage
{
NSLog(logMessage);
}
- (void) selectCommit: (NSString*) sha
{
NSPredicate* selection = [NSPredicate predicateWithFormat:@"sha == %@", sha];
NSArray* selectedCommits = [controller.repository.revisionList.commits filteredArrayUsingPredicate:selection];
// TODO: reimplement this. How can we set the new commit? Our detailscontroller is read-only
}
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
return NO;
}
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name {
return NO;
}
@end