diff --git a/GitTest.xcodeproj/project.pbxproj b/GitTest.xcodeproj/project.pbxproj index 9281838..065365d 100644 --- a/GitTest.xcodeproj/project.pbxproj +++ b/GitTest.xcodeproj/project.pbxproj @@ -13,6 +13,8 @@ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + F561727F0E056A11001DCD79 /* diff_style.css in Resources */ = {isa = PBXBuildFile; fileRef = F561727C0E056A11001DCD79 /* diff_style.css */; }; + F56173280E056ED2001DCD79 /* diffHighlighter.js in Resources */ = {isa = PBXBuildFile; fileRef = F56173270E056ED2001DCD79 /* diffHighlighter.js */; }; F56524BB0E02D22D00F03B52 /* NSFileHandleExt.m in Sources */ = {isa = PBXBuildFile; fileRef = F56524B90E02D22D00F03B52 /* NSFileHandleExt.m */; }; F56524F00E02D45200F03B52 /* PBGitCommit.m in Sources */ = {isa = PBXBuildFile; fileRef = F56524EF0E02D45200F03B52 /* PBGitCommit.m */; }; F56526240E03D85900F03B52 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F56526230E03D85900F03B52 /* WebKit.framework */; }; @@ -38,6 +40,8 @@ 77C8280C06725ACE000B614F /* GitTest_AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GitTest_AppDelegate.m; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 8D1107320486CEB800E47090 /* GitTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GitTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + F561727C0E056A11001DCD79 /* diff_style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = diff_style.css; path = html/diff_style.css; sourceTree = ""; }; + F56173270E056ED2001DCD79 /* diffHighlighter.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = diffHighlighter.js; path = html/diffHighlighter.js; sourceTree = ""; }; F56524B90E02D22D00F03B52 /* NSFileHandleExt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSFileHandleExt.m; sourceTree = ""; }; F56524BA0E02D22D00F03B52 /* NSFileHandleExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSFileHandleExt.h; sourceTree = ""; }; F56524EE0E02D45200F03B52 /* PBGitCommit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitCommit.h; sourceTree = ""; }; @@ -163,10 +167,12 @@ F58A8F250E04368A007E3FC0 /* HTML */ = { isa = PBXGroup; children = ( + F561727C0E056A11001DCD79 /* diff_style.css */, F56526590E03E71B00F03B52 /* commit.html */, F58A8F270E043698007E3FC0 /* commits.css */, F57ABDDE0E0441DE00A088B8 /* commit.js */, F57ABE180E04431D00A088B8 /* prototype.js */, + F56173270E056ED2001DCD79 /* diffHighlighter.js */, ); name = HTML; sourceTree = ""; @@ -217,6 +223,8 @@ 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, F565265A0E03E71B00F03B52 /* commit.html in Resources */, + F56173280E056ED2001DCD79 /* diffHighlighter.js in Resources */, + F561727F0E056A11001DCD79 /* diff_style.css in Resources */, F57ABE0B0E0442DD00A088B8 /* commit.js in Resources */, F57ABE2B0E04435100A088B8 /* prototype.js in Resources */, F58A8F280E043698007E3FC0 /* commits.css in Resources */, diff --git a/PBWebGitController.m b/PBWebGitController.m index 71841aa..9b4af7f 100644 --- a/PBWebGitController.m +++ b/PBWebGitController.m @@ -57,6 +57,11 @@ [script callWebScriptMethod:@"doeHet" withArguments: nil]; } +- (void) log: (NSString*) logMessage +{ + NSLog(logMessage); +} + - (void) selectCommit: (NSString*) sha { NSPredicate* selection = [NSPredicate predicateWithFormat:@"sha == %@", sha]; diff --git a/html/commit.html b/html/commit.html index 0aef794..2bf34a6 100644 --- a/html/commit.html +++ b/html/commit.html @@ -2,8 +2,10 @@
Details for commit + +
@@ -27,5 +29,5 @@
-
+
\ No newline at end of file diff --git a/html/commit.js b/html/commit.js index 898f125..8b17d28 100644 --- a/html/commit.js +++ b/html/commit.js @@ -48,8 +48,11 @@ var doeHet = function() { }); $("message").innerHTML = commit.message.replace(/\n/g,"
"); - if (commit.diff.length < 10000) { + if (commit.diff.length < 1000000) { + $("details").hide(); $("details").innerHTML = commit.diff; + highlightDiffs(); + $("details").show(); } else { $("details").innerHTML = "This diff is currently too large to watch in detailed mode"; } diff --git a/html/commits.css b/html/commits.css index af39c72..406ae17 100644 --- a/html/commits.css +++ b/html/commits.css @@ -27,11 +27,4 @@ hr { background-color: #999; } -pre { - overflow-y: auto; -} -pre code { - display: table-cell; - width: 100%; -} diff --git a/html/diffHighlighter.js b/html/diffHighlighter.js new file mode 100644 index 0000000..bc22cb7 --- /dev/null +++ b/html/diffHighlighter.js @@ -0,0 +1,29 @@ +var highlightDiffs = function() { + var diffs = document.getElementsByClassName("diffcode"); + $A(diffs).each(function(diff) { + var content = diff.innerHTML; + diff.innerHTML = ""; + + var newContent = ""; + var lines = $A(content.split("\n")); + + var start = new Date(); + lines.each(function(l) { + if (l.length > 100) + l = l.substring(0, 100); + + l = l.escapeHTML().gsub("\t", " "); + + if (l.startsWith("+")) + newContent += "
" + l + "
"; + else if (l.startsWith("-")) + newContent += "
" + l + "
"; + else if (l.startsWith("@")) + newContent += "
" + l + "
"; + else + newContent += l + "\n"; + }); + var duration = new Date() - start; + diff.innerHTML = newContent; + }); +} \ No newline at end of file diff --git a/html/diff_style.css b/html/diff_style.css new file mode 100644 index 0000000..3488f67 --- /dev/null +++ b/html/diff_style.css @@ -0,0 +1,25 @@ +code .delline { + background-color: #FEE; + color: #B00; +} + +code .addline { + background-color: #DFD; + color: #080; +} + +code .meta { + background-color: #f7f7f7; + color: #bbb; +} + +pre { + overflow-y: auto; + width: 100%; +} + +pre code { + display: table-cell; + padding: 9px; + width: 100%; +} \ No newline at end of file