Skip to content

Commit

Permalink
Add line numbers to diff. Fix scroller clipping on blame view
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Palmer committed Oct 6, 2008
1 parent da8e1a4 commit 97d7f2a
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 52 deletions.
56 changes: 28 additions & 28 deletions English.lproj/MainMenu.xib
Expand Up @@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="578"/>
<integer value="589"/>
<integer value="344"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
Expand Down Expand Up @@ -491,13 +491,13 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSSplitView" id="623515617">
<object class="NSSplitView" id="857815461">
<reference key="NSNextResponder" ref="245622268"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSScrollView" id="270857048">
<reference key="NSNextResponder" ref="623515617"/>
<reference key="NSNextResponder" ref="857815461"/>
<int key="NSvFlags">4370</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand All @@ -509,7 +509,7 @@
<object class="NSOutlineView" id="377230220">
<reference key="NSNextResponder" ref="831128914"/>
<int key="NSvFlags">4370</int>
<string key="NSFrameSize">{287, 640}</string>
<string key="NSFrameSize">{266, 640}</string>
<reference key="NSSuperview" ref="831128914"/>
<bool key="NSEnabled">YES</bool>
<object class="_NSCornerView" key="NSCornerView">
Expand All @@ -520,7 +520,7 @@
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="942471857">
<double key="NSWidth">2.840000e+02</double>
<double key="NSWidth">2.630000e+02</double>
<double key="NSMinWidth">1.600000e+01</double>
<double key="NSMaxWidth">1.000000e+03</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
Expand Down Expand Up @@ -578,7 +578,7 @@
<float key="NSOutlineViewIndentationPerLevelKey">1.400000e+01</float>
</object>
</object>
<string key="NSFrameSize">{287, 640}</string>
<string key="NSFrameSize">{266, 640}</string>
<reference key="NSSuperview" ref="270857048"/>
<reference key="NSNextKeyView" ref="377230220"/>
<reference key="NSDocView" ref="377230220"/>
Expand All @@ -605,8 +605,8 @@
<double key="NSPercent">9.955752e-01</double>
</object>
</object>
<string key="NSFrameSize">{287, 640}</string>
<reference key="NSSuperview" ref="623515617"/>
<string key="NSFrameSize">{266, 640}</string>
<reference key="NSSuperview" ref="857815461"/>
<reference key="NSNextKeyView" ref="831128914"/>
<int key="NSsFlags">528</int>
<reference key="NSVScroller" ref="443632992"/>
Expand All @@ -615,14 +615,14 @@
<bytes key="NSScrollAmts">QSAAAEEgAABBoAAAQaAAAA</bytes>
</object>
<object class="NSCustomView" id="176859736">
<reference key="NSNextResponder" ref="623515617"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{288, 0}, {710, 640}}</string>
<reference key="NSSuperview" ref="623515617"/>
<reference key="NSNextResponder" ref="857815461"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{267, 0}, {722, 640}}</string>
<reference key="NSSuperview" ref="857815461"/>
<string key="NSClassName">NSView</string>
</object>
</object>
<string key="NSFrameSize">{998, 640}</string>
<string key="NSFrameSize">{989, 640}</string>
<reference key="NSSuperview" ref="245622268"/>
<bool key="NSIsVertical">YES</bool>
<int key="NSDividerStyle">2</int>
Expand Down Expand Up @@ -2499,13 +2499,19 @@
<reference key="object" ref="245622268"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="623515617"/>
<reference ref="857815461"/>
</object>
<reference key="parent" ref="319965955"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">579</int>
<reference key="object" ref="623515617"/>
<int key="objectID">580</int>
<reference key="object" ref="869013782"/>
<reference key="parent" ref="269908025"/>
<string key="objectName">TreeController</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">589</int>
<reference key="object" ref="857815461"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="270857048"/>
Expand All @@ -2522,7 +2528,7 @@
<reference ref="530913792"/>
<reference ref="377230220"/>
</object>
<reference key="parent" ref="623515617"/>
<reference key="parent" ref="857815461"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">570</int>
Expand Down Expand Up @@ -2560,13 +2566,7 @@
<object class="IBObjectRecord">
<int key="objectID">578</int>
<reference key="object" ref="176859736"/>
<reference key="parent" ref="623515617"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">580</int>
<reference key="object" ref="869013782"/>
<reference key="parent" ref="269908025"/>
<string key="objectName">TreeController</string>
<reference key="parent" ref="857815461"/>
</object>
</object>
</object>
Expand Down Expand Up @@ -2762,8 +2762,8 @@
<reference ref="9"/>
<string>{{105, 155}, {990, 682}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="0" id="8"/>
<reference ref="9"/>
<integer value="0" id="6"/>
<reference ref="6"/>
<string>{{105, 155}, {990, 682}}</string>
<reference ref="9"/>
<reference ref="9"/>
Expand All @@ -2789,7 +2789,7 @@
<reference ref="9"/>
<string>{{70, 809}, {142, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="8"/>
<integer value="0" id="8"/>
<object class="NSColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA</bytes>
Expand Down Expand Up @@ -2921,7 +2921,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">588</int>
<int key="maxID">589</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down
2 changes: 1 addition & 1 deletion assets/blame.html
Expand Up @@ -19,7 +19,7 @@ <h2 id="date"></h2>

<div id="main">
<div id="blame">

&nbsp;
</div>
</div>
</div>
Expand Down
46 changes: 36 additions & 10 deletions assets/style.css
Expand Up @@ -182,10 +182,14 @@ pre code {
/*------------------------------------------------------------------------------------
@group blame
------------------------------------------------------------------------------------*/
#blame {
display: block;
background-color: #f7f7f7;
}

#blame-list li {
line-height: 100%;
border-bottom: 1px solid #f7f7f7;
border-bottom: 1px solid #eee;
padding: 0;
margin: 0;
position: relative;
Expand All @@ -195,31 +199,53 @@ pre code {
}

#blame pre {
line-height: 100%;
line-height: 100% !important;
overflow: visible;
border: 0 !important;
margin: 0 0 0 21px !important;
margin: 0 0 0 68px !important;
padding: 0 !important;
white-space: pre-wrap;
background: transparent !important;
}

#blame code {
line-height: 100%;
background: transparent !important;
line-height: 100% !important;
padding: 8px 0 0 0;
margin: 0;
vertical-align: middle;
}
/*



#blame .linenum {
background: #eee;
position: absolute;
top: 5px;
top: 3px;
left: 0;
width: 16px;
width: 30px;
text-align: right;
font-family: Courier, monospace;
}*/
color: #777;
font-weight: bold;
padding: 5px;
}

.image-wrapper {
vertical-align: middle;
height: 100%;
text-align: center;
min-height: 400px;
}

#blame .inline-image {

}

#blame .gravatar {
position: absolute;
top: 5px;
left: 0;
top: 3px;
left: 43px;
padding: 1px;
border: 1px solid #eee;
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/ApplicationController.rb
Expand Up @@ -127,7 +127,7 @@ def tabView_didSelectTabViewItem(tab_view, tab_item)

def swap_branch(item)
@commits_controller.swap_branch(item)
Notify.send('branch_was_changed', {:title => item.title})
#Notify.send('branch_was_changed', {:title => item.title})
end

def active_branch
Expand Down
1 change: 1 addition & 0 deletions controllers/CommitsController.rb
Expand Up @@ -155,6 +155,7 @@ def select_latest_commit
@commits_table.scrollRowToVisible(0)
end

# TODO: remove the stank
def update_main_document
return unless active_commit
diffs = []
Expand Down
31 changes: 19 additions & 12 deletions controllers/TreeController.rb
Expand Up @@ -35,14 +35,11 @@ def awakeFromNib
:name, "NSOutlineViewSelectionDidChangeNotification",
:object, @tree_outline)

Notify.on 'branch_was_changed' do |opts|
puts "BRANCH WAS CHANGED"
Notify.on 'branch_was_changed' do |info|
#working
end
end

def branch_was_changed(branch)
puts "BRANCH WAS CHANGED"
end


def item_was_selected(notification)
outline_view = notification.object
Expand All @@ -62,7 +59,7 @@ def item_was_selected(notification)

unless blob.nil?
set_html('hash', blob.id)

puts blob.mime_type
last_commit_html(app, branch, file)

if IMAGE_MIMES.include?(blob.mime_type)
Expand All @@ -74,6 +71,7 @@ def item_was_selected(notification)
blame_list = doc.createElement('ul')
blame_list.setAttribute__('id', ELEMENTS[:list])
blame_list.setInnerHTML('')
i = 1
blame.each do |commit, lines|
lines.each do |line|
line = line.empty? ? "&nbsp;" : line.escapeHTML
Expand All @@ -82,9 +80,11 @@ def item_was_selected(notification)
url = gravatar_url(commit.author.email, 16).to_s
img.setAttribute__('src', url)
img.setAttribute__('class', 'gravatar')
li.setInnerHTML(%(<pre><code>#{line}</code></pre>))
img.setAttribute__('title', commit.author.email)
li.setInnerHTML(%(<span class="linenum">#{i}</span><pre><code>#{line.chomp}</code></pre>))
li.appendChild(img)
blame_list.appendChild(li)
i += 1
end
end
element.appendChild(blame_list)
Expand All @@ -104,11 +104,18 @@ def last_commit_html(app, branch, file)
private

def display_as_image(blob, outline_item)
doc = @main_view.mainFrame.DOMDocument
img = doc.createElement('img')
url = NSURL.fileURLWithPath(outline_item.fullPath)
doc = @main_view.mainFrame.DOMDocument
wrap = doc.createElement('div')
img = doc.createElement('img')

url = NSURL.fileURLWithPath(outline_item.fullPath)
img.setAttribute__('src', url.to_s)
doc.getElementById(ELEMENT[:blame]).appendChild(img)
img.setAttribute__('class', 'inline-image')

wrap.setAttribute__('class', 'image-wrapper')
wrap.appendChild(img)

doc.getElementById(ELEMENTS[:blame]).appendChild(wrap)
end

def render_last_commit_html(blob, branch)
Expand Down

0 comments on commit 97d7f2a

Please sign in to comment.