Permalink
Browse files

Merge branch 'master' of git://github.com/Caged/gitnub

  • Loading branch information...
2 parents a54ffbd + f2c235a commit 219db37edea6a8d006f8c936f9f5d523514739af @mattetti committed Mar 9, 2008
@@ -5,20 +5,25 @@
# Created by Justin Palmer on 3/1/08.
# Copyright (c) 2008 Active Reload, LLC. All rights reserved.
#
-
+$VERBOSE = nil
require 'rubygems'
require 'osx/cocoa'
+require 'mime-types/lib/mime/types'
require 'grit/lib/grit'
+require 'InfoWindowController'
-include OSX
OSX.ns_import 'ImageTextCell'
+include OSX
+
+REPOSITORY_LOCATION = ENV['PWD'].nil? ? '' : ENV['PWD']
-class ApplicationController < OSX::NSObject
+class ApplicationController < OSX::NSObject
ib_outlet :commits_table
- ib_outlet :commits_controller
+ ib_outlet :commits_controller
ib_outlet :window
ib_outlet :main_canvas
ib_outlet :main_view
+ ib_outlet :info_button
def applicationDidFinishLaunching(sender)
@window.makeKeyAndOrderFront(self)
@@ -28,7 +33,13 @@ def applicationShouldTerminateAfterLastWindowClosed(notification)
return true
end
- def awakeFromNib
+ def awakeFromNib
+ begin
+ @repo = Grit::Repo.new(REPOSITORY_LOCATION)
+ rescue Grit::InvalidGitRepositoryError
+ return false
+ end
+
@window.delegate = self
column = @commits_table.tableColumns[0]
cell = ImageTextCell.alloc.init
@@ -38,4 +49,12 @@ def awakeFromNib
@main_view.setFrameSize(@main_canvas.frame.size)
@main_canvas.addSubview(@main_view)
end
+
+ ib_action :show_info_panel
+ def show_info_panel(sender)
+ if @info_controller.nil?
+ @info_controller = InfoWindowController.alloc.init_with_repository(@repo)
+ end
+ @info_controller.showWindow(self)
+ end
end
View
@@ -17,7 +17,6 @@ class CommitsController < OSX::NSObject
ib_outlet :commit_details
def awakeFromNib
- @repo_location = ENV['PWD'].nil? ? '' : ENV['PWD']
@current_commit_offset = 0
@offset = 50
@active_commit = nil
@@ -75,20 +74,35 @@ def tableViewSelectionDidChange(notification)
diff_list = doc.getElementById('diffs')
diff_list.setInnerHTML("")
file_list.setInnerHTML("")
+
active_commit.diffs.each_with_index do |diff, i|
li = doc.createElement('li')
li.setAttribute__('id', "item-#{i}")
li.setAttribute__('class', 'add') if diff.new_file
li.setAttribute__('class', 'delete') if diff.deleted_file
li.setInnerHTML(%(<a href="#diff-#{i}" class="">#{diff.b_path}</a>))
file_list.appendChild(li)
+
unless diff.deleted_file
diff_div = doc.createElement('div')
diff_div.setAttribute__('class', 'diff')
diff_div.setAttribute__('id', "diff-#{i}")
+
+ colored_diff = []
+ html = CGI.escapeHTML(diff.diff)
+ html.each_line do |line|
+ if line =~ /^\+{1}/
+ colored_diff << %(<div class="addline">#{line}</div>)
+ elsif line =~ /^\-{1}/
+ colored_diff << %(<div class="removeline">#{line}</div>)
+ else
+ colored_diff << line
+ end
+ end
+
diff_div.setInnerHTML(%(
<h3>#{File.basename(diff.b_path)}</h3>
- <pre><code>#{CGI.escapeHTML(diff.diff)}</pre></code>
+ <pre><code class="diffcode">#{colored_diff}</pre></code>
))
diff_list.appendChild(diff_div)
end
@@ -118,27 +132,14 @@ def secondaryTextForCell_data(cell, data)
def iconForCell_data(icon, data)
gravatar = NSURL.URLWithString("http://www.gravatar.com/avatar.php?gravatar_id=#{MD5.hexdigest(data.committer.email)}&size=36")
- NSImage.alloc.initWithContentsOfURL(gravatar)
+ @icons[MD5.hexdigest(data.committer.email)] ||= NSImage.alloc.initWithContentsOfURL(gravatar)
+ #NSImage.imageNamed('committer')
end
def dataElementForCell(cell)
@commit
end
- # def connection_didRecieveResponse(connection, response)
- # @image_data.length = 0
- # end
- #
- # def connection_didReceiveData(connection, data)
- # @image_data.appendData(data)
- # end
- #
- # def connectionDidFinishLoading(connection)
- #
- # @commits_table.reloadData
- # @connection.release
- # @image_data.release
- # end
private
@@ -148,7 +149,7 @@ def active_commit
def fetch_git_repository
begin
- @repo = Grit::Repo.new(@repo_location)
+ @repo = Grit::Repo.new(REPOSITORY_LOCATION)
rescue Grit::InvalidGitRepositoryError
return false
end
Binary file not shown.
Oops, something went wrong.

0 comments on commit 219db37

Please sign in to comment.