5ffc625bb01fb2fdcf172fbb7f2ebf6013154aba
Author: gwoo
Date: 2009-07-30 16:12:54 -0700
diff --git a/config/routes.php b/config/routes.php
index 31c2ea0..8f3747e 100755
--- a/config/routes.php
+++ b/config/routes.php
@@ -46,7 +46,7 @@
);
Router::connect('/:controller/:action/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects',
- 'action' => 'branches|branch|logs|view|start|add|edit|modify|delete|remove|activate|forgotten|verify|change|login|account|logout|forks',
+ 'action' => 'branches|history|branch|logs|view|start|add|edit|modify|delete|remove|activate|forgotten|verify|change|login|account|logout|forks',
'project' => false)
);
Router::connect('/:controller/*', array(), array(
@@ -60,7 +60,7 @@
Router::connect('/forks/:fork/:project/:controller', array('action' => 'index'), array('action' => 'index'));
Router::connect('/forks/:fork/:project/:controller/:action/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects|repo',
- 'action' => 'branches|branch|logs|fast_forward|view|add|edit|modify|delete|remove|parent')
+ 'action' => 'branches|history|branch|logs|fast_forward|view|add|edit|modify|delete|remove|parent')
);
Router::connect('/forks/:fork/:project/:controller/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects',
@@ -73,7 +73,7 @@
Router::connect('/:project/:controller', array('action' => 'index'), array('action' => 'index'));
Router::connect('/:project/:controller/:action/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects|repo',
- 'action' => 'branches|branch|logs|merge|view|add|edit|modify|delete|remove|forks')
+ 'action' => 'branches|history|branch|logs|merge|view|add|edit|modify|delete|remove|forks')
);
Router::connect('/:project/:controller/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects',
diff --git a/controllers/commits_controller.php b/controllers/commits_controller.php
index 0f1314c..4d57f94 100755
--- a/controllers/commits_controller.php
+++ b/controllers/commits_controller.php
@@ -44,7 +44,7 @@ class CommitsController extends AppController {
function logs($commits = null) {
$Source = ClassRegistry::init('Source');
$this->paginate = array('order' => 'asc');
- $commits = $this->paginate($this->Project->Repo, array($commits));
+ $commits = $this->paginate($this->Project->Repo, array($commits));
$this->set(compact('commits', 'args', 'current'));
}
@@ -60,11 +60,30 @@ class CommitsController extends AppController {
$Source = ClassRegistry::init('Source');
list($args, $path, $current) = $Source->initialize($this->Project->Repo, $args);
- $commits = $this->paginate($this->Project->Repo, array('path' => $path));
+ $this->paginate['branch'] = $current;
+ $commits = $this->paginate($this->Project->Repo);
$this->set(compact('commits', 'branches', 'args', 'current'));
}
+ function history() {
+ $args = func_get_args();
+ if ($this->Project->Repo->type == 'git') {
+ if (empty($args)) {
+ $this->Project->Repo->branch('master', true);
+ } else {
+ array_shift($args);
+ }
+ }
+
+ $Source = ClassRegistry::init('Source');
+
+ list($args, $path, $current) = $Source->initialize($this->Project->Repo, $args);
+ $this->paginate = array_merge(array('path' => $path, 'branch' => $args[1]), $this->paginate);
+ $commits = $this->paginate($this->Project->Repo);
+ $this->set(compact('commits', 'args', 'current'));
+ }
+
function remove($id = null) {
if (!$id || empty($this->params['isAdmin'])) {
$this->redirect($this->referer());
diff --git a/views/commits/history.ctp b/views/commits/history.ctp
new file mode 100644
index 0000000..2376df9
--- /dev/null
+++ b/views/commits/history.ctp
@@ -0,0 +1,69 @@
+<?php
+$script = '
+$(document).ready(function(){
+ $(".message").each(function () {
+ $(this).html(converter.makeHtml(jQuery.trim($(this).text())))
+ });
+});
+';
+$javascript->codeBlock($script, array('inline' => false));
+?>
+<h2>
+ <?php __('Commits for') ?>
+
+ <?php
+ $title = null;
+ if (!empty($CurrentProject->fork)) {
+ $title = "forks / {$CurrentProject->fork} / ";
+ }
+ $title .= $CurrentProject->url;
+ echo $html->link($title, array('controller' => 'source', 'action' => 'index'));
+ ?>
+ <?php
+ $path = '/';
+ foreach ((array)$args as $part):
+ $path .= $part . '/';
+ echo '/' . $html->link(' ' . $part . ' ', array('controller' => 'source', 'action' => 'index', $path));
+ endforeach;
+ echo '/ ' . $html->link($current, array('controller' => 'source', 'action' => 'index', $path, $current));
+ ?>
+</h2>
+
+<div class="commits history">
+
+ <?php $i = 0; foreach ((array)$commits as $commit): $zebra = ($i++ % 2) ? ' zebra' : null?>
+
+ <div class="commit <?php echo $zebra?>">
+ <strong>
+ <?php echo $chaw->commit($commit['Repo']['revision'], (array)$CurrentProject);?>
+ </strong>
+
+ <div class="right">
+ <p>
+ <strong><?php __('Author') ?>:</strong> <?php echo $commit['Repo']['author'];?>
+ </p>
+
+ <p>
+ <strong><?php __('Date') ?>:</strong> <?php echo $commit['Repo']['commit_date'];?>
+ </p>
+ </div>
+
+ <p class="message">
+ <?php echo $commit['Repo']['message'];?>
+ </p>
+
+ <div class="clear"><!----></div>
+
+ </div>
+
+ <?php endforeach;?>
+
+</div>
+<div class="paging">
+<?php
+ $paginator->options(array('url' => $this->passedArgs));
+ echo $paginator->prev();
+ echo $paginator->numbers(array('before' => ' | ', 'after' => ' | '));
+ echo $paginator->next();
+?>
+</div>
\ No newline at end of file
diff --git a/views/source/view.ctp b/views/source/view.ctp
index 043c1e4..b949c8a 100755
--- a/views/source/view.ctp
+++ b/views/source/view.ctp
@@ -3,17 +3,16 @@ $html->css('highlight/idea', null, null, false);
$javascript->link('ghighlight.min', false);
?>
<div class="source view">
- <span class="history">
- <?php
+ <span class="history"><?php
if (!empty($branch)) {
$path = "branches/{$branch}/{$path}";
}
- echo $html->link(__('history',true), array(
+ echo $html->link(__('history',true), $chaw->url((array) $CurrentProject, array(
'controller' => 'commits', 'action' => 'history', $path
- ));?>
- </span>
+ )));
+ ?></span>
<?php
echo $html->tag('pre', $html->tag('code', h($data['Content'])));
