Added the visualisation of a commit.
This commit is contained in:
		@@ -228,7 +228,7 @@ class IDF_Git
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        $out = self::parseLog($log, 4);
 | 
			
		||||
        $out[0]->changes = $change;
 | 
			
		||||
        $out[0]->changes = implode("\n", $change);
 | 
			
		||||
        return $out[0];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,7 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag
 | 
			
		||||
            return $m[0];
 | 
			
		||||
        }
 | 
			
		||||
        $co = $this->git->getCommit($m[2]);
 | 
			
		||||
        return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase', array($this->project->shortname, $co->commit)).'">'.$m[1].$m[2].'</a>';
 | 
			
		||||
        return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Source::commit', array($this->project->shortname, $co->commit)).'">'.$m[1].$m[2].'</a>';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -145,6 +145,40 @@ class IDF_Views_Source
 | 
			
		||||
        }
 | 
			
		||||
        return '<span class="breadcrumb">'.implode('<span class="sep">'.$sep.'</span>', $out).'</span>';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function commit($request, $match)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $git = new IDF_Git(Pluf::f('git_repository'));
 | 
			
		||||
        $commit = $match[2];
 | 
			
		||||
        $branches = $git->getBranches();
 | 
			
		||||
        if ('commit' != $git->testHash($commit)) {
 | 
			
		||||
            // Redirect to the first branch
 | 
			
		||||
            $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
 | 
			
		||||
                                            array($request->project->shortname,
 | 
			
		||||
                                                  $branches[0]));
 | 
			
		||||
            return new Pluf_HTTP_Response_Redirect($url);
 | 
			
		||||
        }
 | 
			
		||||
        $title = sprintf('%s Commit Details', (string) $request->project);
 | 
			
		||||
        $page_title = sprintf('%s Commit Details - %s', (string) $request->project, $commit);
 | 
			
		||||
        $cobject = $git->getCommit($commit);
 | 
			
		||||
        require_once 'Text/Highlighter.php';
 | 
			
		||||
        $th = new Text_Highlighter();
 | 
			
		||||
        $h = $th->factory('DIFF');
 | 
			
		||||
        $changes = $h->highlight($cobject->changes);
 | 
			
		||||
        return Pluf_Shortcuts_RenderToResponse('source/commit.html',
 | 
			
		||||
                                               array(
 | 
			
		||||
                                                     'page_title' => $page_title,
 | 
			
		||||
                                                     'title' => $title,
 | 
			
		||||
                                                     'changes' => $changes,
 | 
			
		||||
                                                     'cobject' => $cobject,
 | 
			
		||||
                                                     'commit' => $commit,
 | 
			
		||||
                                                     'branches' => $branches,
 | 
			
		||||
                                                     ),
 | 
			
		||||
                                               $request);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function IDF_Views_Source_PrettySize($size)
 | 
			
		||||
 
 | 
			
		||||
@@ -116,6 +116,12 @@ $ctl[] = array('regex' => '#^/p/(\w+)/source/changes/(\w+)/$#',
 | 
			
		||||
               'model' => 'IDF_Views_Source',
 | 
			
		||||
               'method' => 'changeLog');
 | 
			
		||||
 | 
			
		||||
$ctl[] = array('regex' => '#^/p/(\w+)/source/commit/(\w+)/$#',
 | 
			
		||||
               'base' => $base,
 | 
			
		||||
               'priority' => 4,
 | 
			
		||||
               'model' => 'IDF_Views_Source',
 | 
			
		||||
               'method' => 'commit');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// ---------- ADMIN --------------------------------------
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
<div id="sub-tabs">
 | 
			
		||||
<a {if $inSourceTree}class="active" {/if}href="{url 'IDF_Views_Source::treeBase', array($project.shortname, 'master')}">{trans 'Source Tree'}</a> |
 | 
			
		||||
<a {if $inChangeLog}class="active" {/if}href="{url 'IDF_Views_Source::changeLog', array($project.shortname, 'master')}">{trans 'Change Log'}</a>
 | 
			
		||||
{if $inCommit}| {trans 'Commit'}{/if}
 | 
			
		||||
</div>
 | 
			
		||||
{/block}
 | 
			
		||||
{block title}{$title}{/block}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
</thead>
 | 
			
		||||
<tbody>
 | 
			
		||||
{foreach $changes as $change}
 | 
			
		||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $change.commit)}
 | 
			
		||||
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $change.commit)}
 | 
			
		||||
<tr class="log">
 | 
			
		||||
<td><a href="{$url}">{$change.date|dateago:"wihtout"}</a></td>
 | 
			
		||||
<td>{$change.title}{if $change.full_message}<br /><br />{$change.full_message}{/if}</td>
 | 
			
		||||
@@ -23,9 +23,6 @@
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
</td>
 | 
			
		||||
{* <td><span class="smaller">{trans 'Tree:'} <a href="{$url}">{$change.commit}</a><br />
 | 
			
		||||
{trans 'By:'} {$change.author|strip_tags} 
 | 
			
		||||
</span></td> *}
 | 
			
		||||
</tr>
 | 
			
		||||
{/foreach}
 | 
			
		||||
</tbody>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								src/IDF/templates/source/commit.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/IDF/templates/source/commit.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
{extends "source/base.html"}
 | 
			
		||||
{block docclass}yui-t1{assign $inCommit=true}{/block}
 | 
			
		||||
{block body}
 | 
			
		||||
<table class="commit" summary="">
 | 
			
		||||
<tr>
 | 
			
		||||
<th><strong>{trans 'Date:'}</strong></th><td>{$cobject.date|date:"%Y-%m-%d %H:%M:%S"} ({$cobject.date|dateago})</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<th><strong>{trans 'Author:'}</strong></th><td>{$cobject.author|strip_tags}</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<th><strong>{trans 'Commit:'}</strong></th><td class="mono">{$cobject.commit}</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<th><strong>{trans 'Tree:'}</strong></th><td class="mono"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{$cobject.tree}</a><br /><br /></td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<th><strong>{trans 'Message:'}</strong></th><td>{issuetext $cobject.title, $project}{if isset($cobject.full_message)}<br /><br />{issuetext $cobject.full_message, $project}{/if}</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</table>
 | 
			
		||||
<h2>{trans 'Change Details'}</h2>
 | 
			
		||||
{$changes|safe}
 | 
			
		||||
{/block}
 | 
			
		||||
{block context}
 | 
			
		||||
<p><strong>{trans 'Branches:'}</strong><br />
 | 
			
		||||
{foreach $branches as $branch}
 | 
			
		||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
 | 
			
		||||
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
 | 
			
		||||
{/foreach}
 | 
			
		||||
</p>
 | 
			
		||||
{/block}
 | 
			
		||||
 | 
			
		||||
@@ -11,9 +11,9 @@
 | 
			
		||||
<th>{trans 'Size'}</th>
 | 
			
		||||
</tr>
 | 
			
		||||
</thead>{if !$tree_in}
 | 
			
		||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $commit)} 
 | 
			
		||||
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)} 
 | 
			
		||||
<tfoot>
 | 
			
		||||
<tr><th colspan="5">{blocktrans}In commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br />
 | 
			
		||||
<tr><th colspan="5">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br />
 | 
			
		||||
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
 | 
			
		||||
</th></tr>
 | 
			
		||||
</tfoot>
 | 
			
		||||
 
 | 
			
		||||
@@ -363,3 +363,43 @@ table td.fileicon {
 | 
			
		||||
  background-color: #4e9a06;
 | 
			
		||||
  color: white;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Commit
 | 
			
		||||
 */
 | 
			
		||||
table.commit th, table.commit td { 
 | 
			
		||||
  border: none;
 | 
			
		||||
  vertical-align: top;
 | 
			
		||||
}
 | 
			
		||||
table.commit th { 
 | 
			
		||||
  text-align: right;
 | 
			
		||||
  font-weight: normal;
 | 
			
		||||
}
 | 
			
		||||
table.commit td, table.commit th { 
 | 
			
		||||
  padding: 3px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * syntax highlighting of diffs
 | 
			
		||||
 */
 | 
			
		||||
div.hl-main { 
 | 
			
		||||
  font-family: monospace; 
 | 
			
		||||
  white-space: pre;
 | 
			
		||||
  border: 1px solid #d3d7cf;
 | 
			
		||||
  padding: 1em;
 | 
			
		||||
}
 | 
			
		||||
span.hl-string { 
 | 
			
		||||
  background-color: #dfd;
 | 
			
		||||
}
 | 
			
		||||
span.hl-quotes { 
 | 
			
		||||
  background-color: #fdd;
 | 
			
		||||
}
 | 
			
		||||
span.hl-reserved, span.hl-var { 
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
}
 | 
			
		||||
span.hl-default { 
 | 
			
		||||
  color: #888a85;
 | 
			
		||||
}
 | 
			
		||||
div.hl-main span { 
 | 
			
		||||
  line-height: 1.3;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user