Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,361 additions
and
1,915 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// PBWebGitController.h | ||
// GitTest | ||
// | ||
// Created by Pieter de Bie on 14-06-08. | ||
// Copyright 2008 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "GitTest_AppDelegate.h" | ||
#import <WebKit/WebKit.h> | ||
|
||
@interface PBWebGitController : NSObject { | ||
IBOutlet GitTest_AppDelegate* controller; | ||
IBOutlet WebView* view; | ||
IBOutlet NSArrayController* commitsController; | ||
NSString* diff; | ||
} | ||
|
||
- (void) changeContentTo: (id) content; | ||
@property (readonly) NSString* diff; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// 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 | ||
{ | ||
[commitsController addObserver:self forKeyPath:@"selection" options:0 context:@"ChangedCommit"]; | ||
NSLog(@"WebGitController activated"); | ||
NSLog([[NSBundle mainBundle] resourcePath]); | ||
NSString* file = [[NSBundle mainBundle] pathForResource:@"commit" ofType:@"html"]; | ||
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:file]]; | ||
NSLog(@"Request: %@", request); | ||
[[view mainFrame] loadRequest:request]; | ||
} | ||
|
||
- (void) webView:(id) view didFinishLoadForFrame:(id) frame | ||
{ | ||
NSLog(@"Loading done"); | ||
[self changeContentTo: [[commitsController selectedObjects] objectAtIndex:0]]; | ||
} | ||
|
||
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context | ||
{ | ||
if (context == @"ChangedCommit") { | ||
NSLog(@"SomethingChanged"); | ||
[self changeContentTo: [[commitsController selectedObjects] objectAtIndex:0]]; | ||
} | ||
else { | ||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; | ||
} | ||
} | ||
|
||
- (void) changeContentTo: (id) content | ||
{ | ||
id script = [view windowScriptObject]; | ||
[script setValue: content forKey:@"CommitObject"]; | ||
[script callWebScriptMethod:@"doeHet" withArguments: nil]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<html> | ||
<header> | ||
<title>Details for commit</title> | ||
<script type="text/JavaScript"> | ||
var doeHet = function() { | ||
document.getElementById("commitID").innerHTML = CommitObject.sha; | ||
document.getElementById("authorID").innerHTML = CommitObject.author; | ||
document.getElementById("subjectID").innerHTML = CommitObject.subject; | ||
details = CommitObject.details(); | ||
date = details.match(/Date:(.*)/)[1]; | ||
document.getElementById("date").innerHTML = date; | ||
diffStart = details.indexOf("diff"); | ||
messageStart = details.indexOf("\n\n") + 2; | ||
message = details.substring(messageStart,diffStart); | ||
details = details.substring(diffStart); | ||
document.getElementById("details").innerHTML = details; | ||
document.getElementById("message").innerHTML = message.replace(/\n/g,"<br>"); | ||
} | ||
</script> | ||
|
||
</header> | ||
|
||
<body style="padding: 0px; border: 0px"> | ||
<table style="width: 100%; font-size: 1.2em;"> | ||
<tr> | ||
<td style="width: 100px; color:#999; text-align: right; text-weight: bold;">SHA:</td> | ||
<td id="commitID"></td> | ||
</tr> | ||
<tr> | ||
<td style="width: 100px; color:#999; text-align: right; text-weight: bold;">Author:</td> | ||
<td id="authorID">Pieter de Bie</td> | ||
</tr> | ||
<tr> | ||
<td style="width: 100px; color:#999; text-align: right; text-weight: bold;">Date:</td> | ||
<td id="date">Pieter de Bie</td> | ||
</tr> | ||
<tr> | ||
<td style="width: 100px; color:#999; text-align: right; text-weight: bold;">Subject:</td> | ||
<td id="subjectID">Pieter de Bie</td> | ||
</tr> | ||
</table> | ||
<hr> | ||
<div id="message"></div> | ||
<code><pre id="details"></pre></code> | ||
</body> |