Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save defunkt/31366 to your computer and use it in GitHub Desktop.
Save defunkt/31366 to your computer and use it in GitHub Desktop.
From c6966ade4141e695159b3b38bdc60a7a82d30775 Mon Sep 17 00:00:00 2001
From: Pieter de Bie <pdebie@ai.rug.nl>
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 = "<group>"; };
F5E92A1A0E88550E00056E75 /* empty_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = empty_file.png; path = Images/empty_file.png; sourceTree = "<group>"; };
F5E92A220E88569500056E75 /* new_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = new_file.png; path = Images/new_file.png; sourceTree = "<group>"; };
+ F5EC2DAC0E8C235C000FA381 /* spinner.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = spinner.gif; path = Images/spinner.gif; sourceTree = "<group>"; };
F5FF4E160E0829C20006317A /* PBGitRevList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevList.h; sourceTree = "<group>"; };
F5FF4E170E0829C20006317A /* PBGitRevList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevList.m; sourceTree = "<group>"; };
F5FF4E780E082E440006317A /* PBGitGrapher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitGrapher.h; sourceTree = "<group>"; };
@@ -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>$<IY<H(l!}Qm1Op~uXvG6!aqxgpG!PI(p%Rco<Ol(R
zi8;U+z{nkl5+FiB%aI^QK+z%yD8(W&*cobVXWBodA^z!9I(4Sg?%&<nZ=d&_Z+Bl{
zz-})#1+)wF76e*ZSpk7SDJdzAj*iyW){~QyEEa2KW=5~qGnq_*Kwz5v^T4jGKj6;_
zq5B>3-?7cZa-C@o`?~}E+$na_sVK~an51Y7o6Am#OJGNBi-|v-0K)zTz!9cZZmYYj
zeiQ^4Hx2}<@9us*(zz1hB8-YDCx|yPvMXzQM{_K$!h*iJ(7x2j*bY>E<Y##L=B*_{
zt~@Tf;D$b$XAw}-;=bN;$~WyWxE|RPfkB^0hFr~hLPQ45J@u973;h#zCKAqjCS#yH
zH%lmq8|Ms7fD|8+$xF+wDXuHa9ZT|MHym=^RQqaxy3GP0O{Tex(#qS=4UIk>)v;gG
zt15c?^oIWX1BxEuJ?E}-N%%X2$C&X)nYafzWBB27BZK9$hH1k@-(v5=%efcJKAYA8
zj{X%G-GGGnp>xBKmtR{qyXkbXi>i|w&^A+i%*o~apB=fnp1EvhyA8i)zT0!ZJK|=f
zGujFu=8Q?f@YHB=vJ&Q(Q2ooMB$CxnsQ@;Cl88SakbL=c9-bR}Cd`4o_e-(kkx-G`
z1gxmM5nm)f#c{~lR_t33s5hr)1~uEaw)kjKO}BP*)>VmXx>RQ1;1H?TbtLMnaSW#;
zj9+XgO*q{nKEpjQb`O`&-Jk8B)-S0R`xoZlkUo^CY4otNIEG*Z>9xBj^;cd~XE!if
z=JK3SR%Kh!+&qgwp0nLox=TA*jYs?se%u2xUeoK&1u^$dFrFz~jrhLs@UeBBdpx|M
zY)D3CZeBjWKw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@@ -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 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="46"/>
+ <integer value="6"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -320,7 +320,7 @@
<object class="NSTabViewItem" id="375889551">
<string key="NSIdentifier">1</string>
<object class="NSView" key="NSView" id="859052736">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder" ref="135073984"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -346,7 +346,7 @@
<string>public.url-name</string>
</object>
</object>
- <string key="NSFrame">{{1, 0}, {851, 220}}</string>
+ <string key="NSFrame">{{1, 0}, {851, 229}}</string>
<reference key="NSSuperview" ref="859052736"/>
<reference key="NSNextKeyView"/>
<string key="FrameName"/>
@@ -373,7 +373,8 @@
<bool key="AllowsUndo">YES</bool>
</object>
</object>
- <string key="NSFrameSize">{852, 220}</string>
+ <string key="NSFrameSize">{852, 229}</string>
+ <reference key="NSSuperview" ref="135073984"/>
</object>
<string key="NSLabel">Details</string>
<object class="NSColor" key="NSColor" id="457244339">
@@ -645,7 +646,7 @@
<object class="NSTabViewItem" id="529992882">
<string key="NSIdentifier">Item 2</string>
<object class="NSView" key="NSView" id="657042048">
- <reference key="NSNextResponder" ref="135073984"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -768,29 +769,6 @@
<object class="NSTextView" id="75600241">
<reference key="NSNextResponder" ref="321980917"/>
<int key="NSvFlags">2322</int>
- <object class="NSMutableSet" key="NSDragTypes">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="set.sortedObjects">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>Apple HTML pasteboard type</string>
- <string>Apple PDF pasteboard type</string>
- <string>Apple PICT pasteboard type</string>
- <string>Apple PNG pasteboard type</string>
- <string>Apple URL pasteboard type</string>
- <string>CorePasteboardFlavorType 0x6D6F6F76</string>
- <string>CorePasteboardFlavorType 0x75726C20</string>
- <string>NSColor pasteboard type</string>
- <string>NSFilenamesPboardType</string>
- <string>NSStringPboardType</string>
- <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
- <string>NeXT RTFD pasteboard type</string>
- <string>NeXT Rich Text Format v1.0 pasteboard type</string>
- <string>NeXT TIFF v4.0 pasteboard type</string>
- <string>NeXT font pasteboard type</string>
- <string>NeXT ruler pasteboard type</string>
- <string>WebURLsWithTitlesPboardType</string>
- </object>
- </object>
<string key="NSFrameSize">{543, 112}</string>
<reference key="NSSuperview" ref="321980917"/>
<object class="NSTextContainer" key="NSTextContainer" id="480935218">
@@ -897,21 +875,20 @@
</object>
</object>
<string key="NSFrameSize">{852, 229}</string>
- <reference key="NSSuperview" ref="135073984"/>
</object>
<string key="NSLabel">Tree</string>
<reference key="NSColor" ref="457244339"/>
<reference key="NSTabView" ref="135073984"/>
</object>
</object>
- <reference key="NSSelectedTabViewItem" ref="529992882"/>
+ <reference key="NSSelectedTabViewItem" ref="375889551"/>
<reference key="NSFont" ref="924107556"/>
<int key="NSTvFlags">6</int>
<bool key="NSAllowTruncatedLabels">YES</bool>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="657042048"/>
+ <reference ref="859052736"/>
</object>
</object>
</object>
@@ -1327,6 +1304,14 @@
</object>
<int key="connectionID">107</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">policyDelegate</string>
+ <reference key="source" ref="676796335"/>
+ <reference key="destination" ref="568231003"/>
+ </object>
+ <int key="connectionID">109</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1859,7 +1844,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">107</int>
+ <int key="maxID">109</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
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 @@
</head>
<body style="padding: 0px; border: 0px">
+
+ <div id="notification" style="display:none;">
+ <img src="spinner.gif" width="25px" alt="Spinner" id="spinner"></img>
+ <span id="notification_message"></span>
+ </div>
+ <div id="gistie" onClick="gistie()">Paste online</div>
<table id="commit_header">
<tr>
<td class="property_name">SHA:</td>
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 <a target='_new' href='http://gist.github.com/" + m[1] + "'>#" + m[1] + "</a>");
+ 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;
--
1.6.0.2.307.gc4275
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment