From c6966ade4141e695159b3b38bdc60a7a82d30775 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Thu, 25 Sep 2008 22:25:46 +0200 Subject: [PATCH] HistoryView: Add a method to put a commit online --- GitX.xcodeproj/project.pbxproj | 4 +++ Images/spinner.gif | Bin 0 -> 1924 bytes PBGitCommit.h | 2 ++ PBGitCommit.m | 9 ++++++ PBGitHistoryView.xib | 49 ++++++++++++--------------------- html/commit.html | 6 ++++ html/commit.js | 42 ++++++++++++++++++++++++++++ html/commits.css | 22 +++++++++++++++ 8 files changed, 102 insertions(+), 32 deletions(-) create mode 100644 Images/spinner.gif diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 0463483..7672e99 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ F5E928550E8841FB00056E75 /* diff.js in Resources */ = {isa = PBXBuildFile; fileRef = F5E928540E8841FB00056E75 /* diff.js */; }; F5E92A1B0E88550E00056E75 /* empty_file.png in Resources */ = {isa = PBXBuildFile; fileRef = F5E92A1A0E88550E00056E75 /* empty_file.png */; }; F5E92A230E88569500056E75 /* new_file.png in Resources */ = {isa = PBXBuildFile; fileRef = F5E92A220E88569500056E75 /* new_file.png */; }; + F5EC2DAD0E8C235C000FA381 /* spinner.gif in Resources */ = {isa = PBXBuildFile; fileRef = F5EC2DAC0E8C235C000FA381 /* spinner.gif */; }; F5FF4E180E0829C20006317A /* PBGitRevList.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FF4E170E0829C20006317A /* PBGitRevList.m */; }; F5FF4E7A0E082E440006317A /* PBGitGrapher.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FF4E790E082E440006317A /* PBGitGrapher.m */; }; /* End PBXBuildFile section */ @@ -173,6 +174,7 @@ F5E928540E8841FB00056E75 /* diff.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = diff.js; path = html/diff.js; sourceTree = ""; }; F5E92A1A0E88550E00056E75 /* empty_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = empty_file.png; path = Images/empty_file.png; sourceTree = ""; }; F5E92A220E88569500056E75 /* new_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = new_file.png; path = Images/new_file.png; sourceTree = ""; }; + F5EC2DAC0E8C235C000FA381 /* spinner.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = spinner.gif; path = Images/spinner.gif; sourceTree = ""; }; F5FF4E160E0829C20006317A /* PBGitRevList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevList.h; sourceTree = ""; }; F5FF4E170E0829C20006317A /* PBGitRevList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevList.m; sourceTree = ""; }; F5FF4E780E082E440006317A /* PBGitGrapher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitGrapher.h; sourceTree = ""; }; @@ -260,6 +262,7 @@ 29B97315FDCFA39411CA2CEA /* Other Sources */ = { isa = PBXGroup; children = ( + F5EC2DAC0E8C235C000FA381 /* spinner.gif */, F5E92A1A0E88550E00056E75 /* empty_file.png */, 32CA4F630368D1EE00C91783 /* GitX_Prefix.pch */, 29B97316FDCFA39411CA2CEA /* main.m */, @@ -514,6 +517,7 @@ F59116E60E843BB50072CCB1 /* PBGitCommitView.xib in Resources */, F5E9281D0E8840CF00056E75 /* diff.html in Resources */, F5E92A230E88569500056E75 /* new_file.png in Resources */, + F5EC2DAD0E8C235C000FA381 /* spinner.gif in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Images/spinner.gif b/Images/spinner.gif new file mode 100644 index 0000000000000000000000000000000000000000..ddb7ff1aac1b2fc825667c157873c2c55bbe8db8 GIT binary patch literal 1924 zcmciDX;70#00!U)Urs41ND>$3-?7cZa-C@o`?~}E+$na_sVK~an51Y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c~EZZLz-aKH4hJ%XN<9U8*$f;BXGrEQ^o=8paJ`*iQfV=)}tj7M$B9-E(t0}WI5 ziiH<<@gb})LXWcd=N1SGi;6?d9SD)&II^XLelX2e#DZKujgFz0`cy~Oo<~(uRW#l% zG_=kVdRXZIt%P()d)_@2TRL5aa4qGGD&I4tJNR+p1a_1(jW-f!2MXqTpXs0WExsHx Pn1F;$An(;T&^-PCGf5vc literal 0 HcmV?d00001 diff --git a/PBGitCommit.h b/PBGitCommit.h index e2c87c2..7e24779 100644 --- a/PBGitCommit.h +++ b/PBGitCommit.h @@ -15,6 +15,7 @@ NSString* subject; NSString* author; NSString* details; + NSString *_patch; NSArray* parents; NSArray* refs; NSDate* date; @@ -31,6 +32,7 @@ @property (retain) NSArray* parents, *refs; @property (copy) NSDate* date; @property (readonly) NSString* dateString; +@property (readonly) NSString* patch; @property (assign) char sign; @property (readonly) NSString* details; diff --git a/PBGitCommit.m b/PBGitCommit.m index 0fef796..f60d1b1 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -44,6 +44,15 @@ return details; } +- (NSString *) patch +{ + if (_patch != nil) + return _patch; + + _patch = [repository outputForArguments:[NSArray arrayWithObjects:@"format-patch", @"-1", @"--stdout", sha, nil]]; + return _patch; +} + - (PBGitTree*) tree { return [PBGitTree rootForCommit: self]; diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 2759752..991205f 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -8,7 +8,7 @@ 352.00 YES - + YES @@ -320,7 +320,7 @@ 1 - + 256 YES @@ -346,7 +346,7 @@ public.url-name - {{1, 0}, {851, 220}} + {{1, 0}, {851, 229}} @@ -373,7 +373,8 @@ YES - {852, 220} + {852, 229} + Details @@ -645,7 +646,7 @@ Item 2 - + 256 YES @@ -768,29 +769,6 @@ 2322 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - CorePasteboardFlavorType 0x75726C20 - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - NeXT font pasteboard type - NeXT ruler pasteboard type - WebURLsWithTitlesPboardType - - {543, 112} @@ -897,21 +875,20 @@ {852, 229} - Tree - + 6 YES YES YES - + @@ -1327,6 +1304,14 @@ 107 + + + policyDelegate + + + + 109 + @@ -1859,7 +1844,7 @@ - 107 + 109 diff --git a/html/commit.html b/html/commit.html index 70fe140..58a5571 100644 --- a/html/commit.html +++ b/html/commit.html @@ -10,6 +10,12 @@ + + +
Paste online
diff --git a/html/commit.js b/html/commit.js index 155d83c..b7af418 100644 --- a/html/commit.js +++ b/html/commit.js @@ -3,6 +3,7 @@ var Commit = Class.create({ initialize: function(obj) { this.raw = obj.details; this.refs = obj.refs; + this.object = obj; var diffStart = this.raw.indexOf("\ndiff "); var messageStart = this.raw.indexOf("\n\n") + 2; @@ -37,6 +38,45 @@ var Commit = Class.create({ } }); +var notify = function(text, busy) { + var n = $("notification"); + n.style.display = ""; + if (busy) + $("spinner").style.display = ""; + else + $("spinner").style.display = "none"; + + $("notification_message").innerHTML = text; +} + +var gistie = function() { + notify("Uploading code to Gistie..", true); + + new Ajax.Request("http://gist.github.com/gists", { + method: 'post', + parameters: { + "file_ext[gistfile1]": "patch", + "file_name[gistfile1]": commit.object.subject.replace(/[^a-zA-Z0-9]/g, "-") + ".patch", + "file_contents[gistfile1]": commit.object.patch() + }, + + onSuccess: function(t) { + if (m = t.responseText.match(/gist: (\d+)/)) + notify("Code uploaded to gistie #" + m[1] + ""); + else + notify("Pasting to Gistie failed."); + }, + onFailure: function(t) { + notify("Pasting to Gistie failed."); + }, + onException: function(t) { + notify("Pasting to Gistie failed."); + }, + + }); + +} + var selectCommit = function(a) { Controller.selectCommit_(a); } @@ -51,6 +91,7 @@ var showDiffs = function() { } var reload = function() { + $("notification").style.display = "none"; commit.refs = null; showRefs(); commit.reloadRefs(); @@ -70,6 +111,7 @@ var showRefs = function() { var loadCommit = function() { commit = new Commit(CommitObject); + $("notification").style.display = "none"; $("commitID").innerHTML = commit.sha; if (commit.author_email) diff --git a/html/commits.css b/html/commits.css index ceaeeb8..3676816 100644 --- a/html/commits.css +++ b/html/commits.css @@ -3,6 +3,28 @@ font-family: Helvetica; font-size: 12px; } + +#gistie { + float: right; + margin-right: 100px; + color: rgb(20, 79, 174); + text-decoration: underline; +} + +#notification { + width: 80%; + margin: auto; + border: 1px solid #A8A159; + background-color: #FFF487; + font-size: 140%; + padding: 10px; +} + +#notification img { + vertical-align: bottom; + margin-right: 10px; +} + .property_name { width: 50px; color:#7F7F7F;
SHA: