Permalink
Browse files

working on pulling down all your existing gists; right now it's prett…

…y messed up
  • Loading branch information...
1 parent e99c988 commit 41b4b04c17d7f29e28ade9328831734957e51192 Greg Borenstein committed Apr 11, 2010
@@ -8,8 +8,8 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="100076"/>
<integer value="100036"/>
+ <integer value="100075"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -70,27 +70,27 @@
<object class="NSTableView" id="272686563">
<reference key="NSNextResponder" ref="89466754"/>
<int key="NSvFlags">256</int>
- <string key="NSFrameSize">{211, 646}</string>
+ <string key="NSFrameSize">{226, 646}</string>
<reference key="NSSuperview" ref="89466754"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTableHeaderView" key="NSHeaderView" id="883390192">
<reference key="NSNextResponder" ref="223576853"/>
<int key="NSvFlags">256</int>
- <string key="NSFrameSize">{211, 17}</string>
+ <string key="NSFrameSize">{226, 17}</string>
<reference key="NSSuperview" ref="223576853"/>
<reference key="NSTableView" ref="272686563"/>
</object>
<object class="_NSCornerView" key="NSCornerView" id="89919400">
<reference key="NSNextResponder" ref="638551810"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{212, 0}, {16, 17}}</string>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{-26, 0}, {16, 17}}</string>
<reference key="NSSuperview" ref="638551810"/>
</object>
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="714136400">
<string key="NSIdentifier">title</string>
- <double key="NSWidth">2.080000e+02</double>
+ <double key="NSWidth">2.230000e+02</double>
<double key="NSMinWidth">4.000000e+01</double>
<double key="NSMaxWidth">1.000000e+03</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -171,7 +171,7 @@
<bool key="NSAllowsTypeSelect">YES</bool>
</object>
</object>
- <string key="NSFrame">{{1, 17}, {211, 646}}</string>
+ <string key="NSFrame">{{1, 17}, {226, 646}}</string>
<reference key="NSSuperview" ref="638551810"/>
<reference key="NSNextKeyView" ref="272686563"/>
<reference key="NSDocView" ref="272686563"/>
@@ -180,12 +180,12 @@
</object>
<object class="NSScroller" id="138167676">
<reference key="NSNextResponder" ref="638551810"/>
- <int key="NSvFlags">256</int>
+ <int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{212, 17}, {15, 646}}</string>
<reference key="NSSuperview" ref="638551810"/>
<reference key="NSTarget" ref="638551810"/>
<string key="NSAction">_doScroller:</string>
- <double key="NSPercent">9.984710e-01</double>
+ <double key="NSPercent">9.938462e-01</double>
</object>
<object class="NSScroller" id="810367137">
<reference key="NSNextResponder" ref="638551810"/>
@@ -204,7 +204,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="883390192"/>
</object>
- <string key="NSFrame">{{1, 0}, {211, 17}}</string>
+ <string key="NSFrame">{{1, 0}, {226, 17}}</string>
<reference key="NSSuperview" ref="638551810"/>
<reference key="NSNextKeyView" ref="883390192"/>
<reference key="NSDocView" ref="883390192"/>
@@ -216,7 +216,7 @@
<string key="NSFrame">{{0, 55}, {228, 664}}</string>
<reference key="NSSuperview" ref="40838267"/>
<reference key="NSNextKeyView" ref="89466754"/>
- <int key="NSsFlags">18</int>
+ <int key="NSsFlags">530</int>
<reference key="NSVScroller" ref="138167676"/>
<reference key="NSHScroller" ref="810367137"/>
<reference key="NSContentView" ref="89466754"/>
@@ -433,6 +433,7 @@
<reference key="NSSuperview" ref="183766710"/>
<reference key="NSTarget" ref="183766710"/>
<string key="NSAction">_doScroller:</string>
+ <double key="NSCurValue">1.000000e+00</double>
<double key="NSPercent">9.411765e-01</double>
</object>
<object class="NSScroller" id="600053430">
@@ -479,18 +480,38 @@
<int key="NSPeriodicInterval">75</int>
</object>
</object>
- <object class="NSButton" id="717019038">
+ <object class="NSButton" id="800706779">
<reference key="NSNextResponder" ref="645507211"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{69, 663}, {51, 50}}</string>
<reference key="NSSuperview" ref="645507211"/>
<bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="448923075">
+ <object class="NSButtonCell" key="NSCell" id="1018465826">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134217728</int>
+ <string key="NSContents"/>
+ <reference key="NSSupport" ref="24"/>
+ <reference key="NSControlView" ref="800706779"/>
+ <int key="NSButtonFlags">-2033434369</int>
+ <int key="NSButtonFlags2">130</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ </object>
+ </object>
+ <object class="NSButton" id="571178848">
+ <reference key="NSNextResponder" ref="645507211"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{136, 663}, {51, 50}}</string>
+ <reference key="NSSuperview" ref="645507211"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="363936207">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="24"/>
- <reference key="NSControlView" ref="717019038"/>
+ <reference key="NSControlView" ref="571178848"/>
<int key="NSButtonFlags">-2033434369</int>
<int key="NSButtonFlags2">130</int>
<string key="NSAlternateContents"/>
@@ -855,18 +876,34 @@
<object class="IBOutletConnection" key="connection">
<string key="label">update_gist_button</string>
<reference key="source" ref="512844837"/>
- <reference key="destination" ref="717019038"/>
+ <reference key="destination" ref="800706779"/>
</object>
<int key="connectionID">100100</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">pullCurrentGist:</string>
<reference key="source" ref="512844837"/>
- <reference key="destination" ref="717019038"/>
+ <reference key="destination" ref="800706779"/>
</object>
<int key="connectionID">100101</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">import_gist_button</string>
+ <reference key="source" ref="512844837"/>
+ <reference key="destination" ref="571178848"/>
+ </object>
+ <int key="connectionID">100105</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">importGists:</string>
+ <reference key="source" ref="512844837"/>
+ <reference key="destination" ref="571178848"/>
+ </object>
+ <int key="connectionID">100110</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1030,7 +1067,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="183766710"/>
<reference ref="643905025"/>
- <reference ref="717019038"/>
+ <reference ref="800706779"/>
+ <reference ref="571178848"/>
</object>
<reference key="parent" ref="195632884"/>
</object>
@@ -1180,17 +1218,31 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">100098</int>
- <reference key="object" ref="717019038"/>
+ <reference key="object" ref="800706779"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="448923075"/>
+ <reference ref="1018465826"/>
</object>
<reference key="parent" ref="645507211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">100099</int>
- <reference key="object" ref="448923075"/>
- <reference key="parent" ref="717019038"/>
+ <reference key="object" ref="1018465826"/>
+ <reference key="parent" ref="800706779"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100102</int>
+ <reference key="object" ref="571178848"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="363936207"/>
+ </object>
+ <reference key="parent" ref="645507211"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100103</int>
+ <reference key="object" ref="363936207"/>
+ <reference key="parent" ref="571178848"/>
</object>
</object>
</object>
@@ -1242,6 +1294,8 @@
<string>100095.IBPluginDependency</string>
<string>100098.IBPluginDependency</string>
<string>100099.IBPluginDependency</string>
+ <string>100102.IBPluginDependency</string>
+ <string>100103.IBPluginDependency</string>
<string>5.IBEditorWindowLastContentRect</string>
<string>5.IBWindowTemplateEditedContentRect</string>
<string>5.ImportedFromIB2</string>
@@ -1297,6 +1351,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{184, 35}, {830, 719}}</string>
<string>{{184, 35}, {830, 719}}</string>
<reference ref="9"/>
@@ -1327,7 +1383,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">100101</int>
+ <int key="maxID">100110</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1339,12 +1395,14 @@
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>copyCurrentGistUrl:</string>
+ <string>importGists:</string>
<string>pullCurrentGist:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -1353,6 +1411,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>gistListScrollView</string>
<string>gist_url_copy_button</string>
+ <string>import_gist_button</string>
+ <string>import_gist_window</string>
<string>octocatView</string>
<string>progressBar</string>
<string>progressDescription</string>
@@ -1368,6 +1428,8 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
+ <string>id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
View
@@ -19,7 +19,7 @@ class GEDocument < NSDocument
attr_accessor :gistListScrollView
attr_accessor :octocatView
- attr_accessor :gist_url_copy_button, :update_gist_button
+ attr_accessor :gist_url_copy_button, :update_gist_button, :import_gist_button
def applicationDidFinishLaunching(notification)
# pass
@@ -29,6 +29,7 @@ def windowControllerDidLoadNib(windowController)
self.octocatView.setImage(GEDocument.octocat_happy)
self.gist_url_copy_button.setImage(GEDocument.copy_gist_url_button_image)
self.update_gist_button.setImage(GEDocument.update_gist_image)
+ self.import_gist_button.setImage(GEDocument.import_gist_image)
end
@@ -45,7 +46,11 @@ def self.copy_gist_url_button_image
end
def self.update_gist_image
- @@update_gist_image ||= NSImage.alloc.initWithContentsOfFile(NSBundle.mainBundle.pathForImageResource("box_download_48.png"))
+ @@update_gist_image ||= NSImage.alloc.initWithContentsOfFile(NSBundle.mainBundle.pathForImageResource("refresh_48.png"))
+ end
+
+ def self.import_gist_image
+ @@fetch_gist_image ||= NSImage.alloc.initWithContentsOfFile(NSBundle.mainBundle.pathForImageResource("box_download_48.png"))
end
def pullCurrentGist(sender)
@@ -56,6 +61,26 @@ def copyCurrentGistUrl(sender)
copy_gist_url(current_gist)
end
+
+ # HERE:
+ # TODO: new xib for sheet
+ def importGists(sender)
+ user_url = "http://gist.github.com/api/v1/xml/gists/#{preferences.user.login}"
+
+ request = NSMutableURLRequest.alloc.init
+ request.setURL(NSURL.URLWithString(user_url))
+ thisDoc = self
+ delegate = ConnectionDelegate.new(self, "Fetching") do |doc|
+ GEGist.build_multiple(doc).each do |gist|
+ gist.add(thisDoc)
+ end
+ end
+
+ NSURLConnection.connectionWithRequest(request, delegate:delegate)
+
+ end
+
+
def copy_gist_url(aGist)
if aGist
`echo "http://gist.github.com/#{aGist.gist_id}" | pbcopy`
@@ -85,6 +110,11 @@ def endProgressIndicator
def setGist(gist)
self.text_view.window.setTitle("#{gist.title} - gist.github.com/#{gist.gist_id}")
+
+ # fetch the gist body if necessary
+ if(!gist.body)
+ gist.populate
+ end
self.text_view.setString(gist.body)
self.current_gist = gist
NSLog("Gist set to: #{self.current_gist.inspect}")
@@ -114,9 +144,7 @@ def updateDocumentStateFromGist(aGist)
def getGist(aGist)
- new_contents = NSString.stringWithContentsOfURL(NSURL.URLWithString("http://gist.github.com/#{aGist.gist_id}.txt"))
- NSLog(new_contents)
- aGist.body = new_contents
+ aGist.populate_body
aGist.update(self)
updateDocumentStateFromGist(aGist)
end
View
@@ -9,13 +9,25 @@
class GEGist
attr_accessor :gist_id, :created_at, :title, :body
+ def self.build_multiple(xml)
+ xml.rootElement.nodesForXPath("//gists/gist", error:nil).collect do |gist_xml|
+ GEGist.new :gist_id => gist_xml.elementsForName("repo").first.stringValue,
+ :created_at => gist_xml.elementsForName("created-at").first.stringValue
+ end
+ end
+
+ def populate_body
+ new_contents = NSString.stringWithContentsOfURL(NSURL.URLWithString("http://gist.github.com/#{self.gist_id}.txt"))
+ self.body = new_contents
+ end
+
+
def self.new_from_xml(xml)
self.new :gist_id => self.extract_from_xml(xml, 'repo'),
:created_at => self.extract_from_xml(xml, 'created-at')
end
def self.extract_from_xml(xml, value)
- NSLog(value)
xml.rootElement.nodesForXPath("gist/#{value}", error:nil).first.stringValue
end
@@ -33,6 +45,12 @@ def to_h
:body => @body }
end
+ def add(owner)
+ if !owner.library.gists.collect{|g|g[:gist_id]}.include?(self.gist_id)
+ self.save(owner)
+ end
+ end
+
def update(owner)
owner.library.gists.reject!{|g| g[:gist_id] == self.gist_id}
self.save(owner)
Oops, something went wrong.

0 comments on commit 41b4b04

Please sign in to comment.