diff --git a/src/IDF/Git.php b/src/IDF/Git.php index 5c460c1..09a3791 100644 --- a/src/IDF/Git.php +++ b/src/IDF/Git.php @@ -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]; } diff --git a/src/IDF/Template/IssueComment.php b/src/IDF/Template/IssueComment.php index 223b917..b9608ba 100644 --- a/src/IDF/Template/IssueComment.php +++ b/src/IDF/Template/IssueComment.php @@ -88,7 +88,7 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag return $m[0]; } $co = $this->git->getCommit($m[2]); - return ''.$m[1].$m[2].''; + return ''.$m[1].$m[2].''; } /** diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index 8b41c9e..67628f4 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -145,6 +145,40 @@ class IDF_Views_Source } return ''.implode(''.$sep.'', $out).''; } + + 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) diff --git a/src/IDF/conf/views.php b/src/IDF/conf/views.php index d9a372a..eccd4dc 100644 --- a/src/IDF/conf/views.php +++ b/src/IDF/conf/views.php @@ -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 -------------------------------------- diff --git a/src/IDF/templates/source/base.html b/src/IDF/templates/source/base.html index 9c9e97a..fec2832 100644 --- a/src/IDF/templates/source/base.html +++ b/src/IDF/templates/source/base.html @@ -4,6 +4,7 @@
{trans 'Source Tree'} | {trans 'Change Log'} +{if $inCommit}| {trans 'Commit'}{/if}
{/block} {block title}{$title}{/block} diff --git a/src/IDF/templates/source/changelog.html b/src/IDF/templates/source/changelog.html index d056194..47f9a1d 100644 --- a/src/IDF/templates/source/changelog.html +++ b/src/IDF/templates/source/changelog.html @@ -11,7 +11,7 @@ {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)} {$change.date|dateago:"wihtout"} {$change.title}{if $change.full_message}

{$change.full_message}{/if} @@ -23,9 +23,6 @@ -{* {trans 'Tree:'} {$change.commit}
-{trans 'By:'} {$change.author|strip_tags} -
*} {/foreach} diff --git a/src/IDF/templates/source/commit.html b/src/IDF/templates/source/commit.html new file mode 100644 index 0000000..ff4b25b --- /dev/null +++ b/src/IDF/templates/source/commit.html @@ -0,0 +1,32 @@ +{extends "source/base.html"} +{block docclass}yui-t1{assign $inCommit=true}{/block} +{block body} + + + + + + + + + + + + + + + + +
{trans 'Date:'}{$cobject.date|date:"%Y-%m-%d %H:%M:%S"} ({$cobject.date|dateago})
{trans 'Author:'}{$cobject.author|strip_tags}
{trans 'Commit:'}{$cobject.commit}
{trans 'Tree:'}{$cobject.tree}

{trans 'Message:'}{issuetext $cobject.title, $project}{if isset($cobject.full_message)}

{issuetext $cobject.full_message, $project}{/if}
+

{trans 'Change Details'}

+{$changes|safe} +{/block} +{block context} +

{trans 'Branches:'}
+{foreach $branches as $branch} +{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)} +{$branch}
+{/foreach} +

+{/block} + diff --git a/src/IDF/templates/source/tree.html b/src/IDF/templates/source/tree.html index b63f8b3..eee2bd2 100644 --- a/src/IDF/templates/source/tree.html +++ b/src/IDF/templates/source/tree.html @@ -11,9 +11,9 @@ {trans 'Size'} {if !$tree_in} -{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $commit)} +{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)} -{blocktrans}In commit {$commit} created {$cobject.date|dateago}.{/blocktrans}
+{blocktrans}Source at commit {$commit} created {$cobject.date|dateago}.{/blocktrans}
{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index 9f12582..1d71d56 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -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; +}