Skip to content

Commit

Permalink
added compare diffs feature and fixed a couple of css issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxtons Web Design committed Apr 8, 2010
1 parent 0ad8d19 commit 71eba67
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 3 deletions.
10 changes: 10 additions & 0 deletions root/fragment/ref/history.tt2
@@ -1,19 +1,24 @@
[% BLOCK history_table_headfoot %]
[% SET cell = type == 'head' ? 'th' : 'td' %]
[%# FIXME: should c.req.arguments.0 be path instead? %]
<tr>
<[% cell %] colspan="2"><a href="#" onclick="compareDiffs('[% Repository.name %]','[% c.req.arguments.0 %]');return false;">Compare</a></[% cell %]>
<[% cell %]>sha1</[% cell %]>
<[% cell %]>time</[% cell %]>
<[% cell %]>message</[% cell %]>
<[% cell %]>author</[% cell %]>
<[% cell %]>actions</[% cell %]>
</tr>
[% END %]
<form name="theform">
<table class='listing'>
<thead>[% PROCESS history_table_headfoot type = 'head' %]</thead

<tbody>
[% FOREACH line IN log_lines %]
<tr [% "class='invert'" IF loop.count % 2 %]>
<td><input type="radio" name="sha1_a" value="[% line.sha1 %]" [% "checked" IF loop.count == 2 %] /></td>
<td><input type="radio" name="sha1_b" value="[% line.sha1 %]" [% "checked" IF loop.count == 1 %]/></td>
<td class='sha1' title='[% line.sha1 %]'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = line.sha1.substr(0, 7) %]</td>
<td class='time-since' title='[% line.authored_time %]'>[% time_since(line.authored_time) %]</td>

Expand All @@ -35,8 +40,13 @@
</td>
</tr>
[% END %]
<tr>
<td colspan="2"><a href="#" onclick="compareDiffs('[% Repository.name %]');return false;">Compare</a></td>
<td colspan="5"></td>
</tr>
</tbody>
</table>
</form>
[%
INCLUDE 'inc/log_pager.tt2';
%]
9 changes: 9 additions & 0 deletions root/fragment/repository/shortlog.tt2
@@ -1,6 +1,7 @@
[% BLOCK shortlog_table_headfoot %]
[% SET cell = type == 'head' ? 'th' : 'td' %]
<tr>
<[% cell %] colspan="2"><a href="#" onclick="compareDiffs('[% Repository.name %]');return false;">Compare</a></[% cell %]>
<[% cell %]>ID (sha1)</[% cell %]>
<[% cell %]>Last change</[% cell %]>
<[% cell %]>Message</[% cell %]>
Expand All @@ -9,11 +10,14 @@
</tr>
[% END %]

<form name="theform">
<table class='listing'>
<thead>[% PROCESS shortlog_table_headfoot type = 'head' %]</thead>
<tbody>
[% FOREACH line IN log_lines %]
<tr [% "class='invert'" IF loop.count % 2 %]>
<td><input type="radio" name="sha1_a" value="[% line.sha1 %]" [% "checked" IF loop.count == 2 %] /></td>
<td><input type="radio" name="sha1_b" value="[% line.sha1 %]" [% "checked" IF loop.count == 1 %]/></td>
<td class='sha1' title='[% line.sha1 %]'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = line.sha1.substr(0, 7) %]</td>
<td class='time-since' title='[% line.authored_time %]'>[% time_since(line.authored_time) %]</td>
<td>
Expand All @@ -32,7 +36,12 @@
</td>
</tr>
[% END %]
<tr>
<td colspan="2"><a href="#" onclick="compareDiffs('[% Repository.name %]');return false;">Compare</a></td>
<td colspan="5"></td>
</tr>
</tbody>
</table>
</form>

[% INCLUDE 'inc/log_pager.tt2' %]
14 changes: 12 additions & 2 deletions root/static/css/core.css
@@ -1,6 +1,6 @@
#debug_holder{

display:none;
adisplay:none;

clear:both;
padding-top:30px;
Expand Down Expand Up @@ -79,7 +79,7 @@ a img{

/* nav tabs */
#nav_logs{
width:80%;
width:100%;
clear:both;
float:right;
margin:-5px 10px 0 0;
Expand Down Expand Up @@ -303,13 +303,22 @@ th{
th a{
color:#fff;
}
th a:hover{
color:#f0f0f0;
}
.summary tr{
background-color:#FAFAFA;
border-bottom:1px solid #fff;
}
.summary td{
vertical-align:middle !important;
}
tr{
background-color:#fff;
}
thead tr{
background-color:transparent !important;
}
tr.invert{
background-color:#f0f0f0;
}
Expand Down Expand Up @@ -369,6 +378,7 @@ table.listing{
padding:10px;
border:1px solid #ddd;
background-color:#f0f0f0;
min-height:40px;
}
.diff-head{
background-color:#666;
Expand Down
Binary file modified root/static/i/bg_top.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified root/static/i/icons/Thumbs.db
Binary file not shown.
24 changes: 24 additions & 0 deletions root/static/js/common.js
@@ -0,0 +1,24 @@
function compareDiffs(repo, path){
var f = document.theform;
if(!repo){
var repo = "";
}
if(!path){
var path = "";
}
var sha1,sha2;
for(var i=0,len=f.length;i<len;i++){
if(f[i].name == "sha1_a"){
if(f[i].checked){
sha1 = f[i].value;
}
}
if(f[i].name == "sha1_b"){
if(f[i].checked){
sha2 = f[i].value;
}
}
}
//document.location.href = [% c.uri_for("/" + repo + "/"+ sha1 + "/diff/" + sha2 + "/" + path) %];
document.location.href = "/" + repo + "/"+ sha1 + "/diff/" + sha2 + "/" + path;
}
28 changes: 27 additions & 1 deletion root/wrapper.tt2
Expand Up @@ -21,6 +21,32 @@

<link rel="stylesheet" type="text/css" href="[% c.uri_for('/core.css') %]" />
<link rel="shortcut icon" href="[% c.uri_for('/static/git-favicon.png') %]" type="image/png" />
<script type="text/javascript">
// FIXME: this should be in an external js file once c.uri_for works in js files
function compareDiffs(repo, path){
var f = document.theform;
if(!repo){
var repo = "";
}
if(!path){
var path = "";
}
var sha1,sha2;
for(var i=0,len=f.length;i<len;i++){
if(f[i].name == "sha1_a"){
if(f[i].checked){
sha1 = f[i].value;
}
}
if(f[i].name == "sha1_b"){
if(f[i].checked){
sha2 = f[i].value;
}
}
}
document.location.href = "[% c.uri_for("/") %]" + repo + "/"+ sha1 + "/diff/" + sha2 + "/" + path;
}
</script>
</head>

<body>
Expand Down Expand Up @@ -142,7 +168,7 @@
[% USE Dumper %]
<pre>
[% Repository.path %]
[%# Dumper.dump(c.req.path) %]
[%# Dumper.dump(c.req.arguments.0) %]
</pre>

</div>
Expand Down

0 comments on commit 71eba67

Please sign in to comment.