fa793e363dd67a943805eabcd5e558d3d297cc1b

Author: gwoo

Date: 2009-01-11 11:47:42 -0800

adding projects/start, fixing error in permissions, updating styles

diff --git a/config/routes.php b/config/routes.php index c7444a1..b9fd75e 100755 --- a/config/routes.php +++ b/config/routes.php @@ -16,7 +16,6 @@ */ Router::parseExtensions('rss', 'tar'); - /* Base Routes */ Router::connect('/', array('controller' => 'wiki', 'action' => 'index')); Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); @@ -34,6 +33,7 @@ Router::connect('/:project/admin/:controller/:action/*', array('admin'=> true, 'controller' => 'dashboard')); /* Specific Routes */ + Router::connect('/fork/it', array('controller' => 'repo', 'action' => 'fork_it'), array('action' => 'fork_it')); Router::connect('/:project/fork/it', array('controller' => 'repo', 'action' => 'fork_it'), array('action' => 'fork_it')); Router::connect('/download/:project', array('controller' => 'repo', 'action' => 'download', 'ext' => 'tar'), array('ext' => 'tar')); Router::connect('/download/forks/:fork/:project', array('controller' => 'repo', 'action' => 'download', 'ext' => 'tar'), array('ext' => 'tar')); @@ -66,7 +66,7 @@ ); Router::connect('/:controller/:action/*', array(), array( 'controller' => 'wiki|commits|tickets|comments|timeline|versions|users|projects', - 'action' => 'history|view|add|edit|modify|delete|remove|forgotten|verify|change|login|account|logout|forks', + 'action' => 'history|view|start|add|edit|modify|delete|remove|forgotten|verify|change|login|account|logout|forks', 'project' => false) ); Router::connect('/:controller/*', array(), array( diff --git a/controllers/commits_controller.php b/controllers/commits_controller.php index 672aba4..4a0bb4f 100644 --- a/controllers/commits_controller.php +++ b/controllers/commits_controller.php @@ -24,6 +24,13 @@ class CommitsController extends AppController { function index() { $this->Commit->recursive = 0; + $this->Commit->bindModel(array('hasOne' => array( + 'Timeline' => array( + 'className' => 'Timeline', + 'foreignKey' => 'foreign_key', + 'conditions' => array('Timeline.model = \'Commit\''), + ))), false); + $conditions = array('Commit.project_id' => $this->Project->id); $this->set('commits', $this->paginate('Commit', $conditions)); } @@ -48,7 +55,7 @@ class CommitsController extends AppController { $this->set(compact('commits', 'args', 'current')); } - function delete($id = null) { + function remove($id = null) { if (!$id || empty($this->params['isAdmin'])) { $this->redirect($this->referer()); } diff --git a/controllers/components/access.php b/controllers/components/access.php index 949c976..62b8bd0 100644 --- a/controllers/components/access.php +++ b/controllers/components/access.php @@ -89,7 +89,10 @@ class AccessComponent extends Object { if ($C->Project->initialize($C->params) === false) { if ($C->Session->read('Install') !== true) { $C->Session->setFlash('Chaw needs to be installed'); - $C->redirect(array('admin' => false, 'project' => null, 'controller' => 'pages', 'action'=> 'start')); + $C->redirect(array( + 'admin' => false, 'project' => null, + 'controller' => 'pages', 'action'=> 'start' + )); return false; } @@ -107,9 +110,14 @@ class AccessComponent extends Object { } if (!in_array($this->url, array('users/add', 'users/login'))) { - $login = Router::url(array('admin' => false, 'project' => null, 'controller' => 'users', 'action'=> 'login')); + $login = Router::url(array( + 'admin' => false, 'project' => null, 'controller' => 'users', 'action'=> 'login' + )); $C->Session->setFlash("Chaw needs to be installed. Please <a href='{$login}'>Login</a> or Register"); - $C->redirect(array('admin' => false, 'project' => null, 'controller' => 'users', 'action'=> 'add')); + $C->redirect(array( + 'admin' => false, 'project' => null, + 'controller' => 'users', 'action'=> 'add' + )); return false; } $this->allow($C->action); @@ -176,11 +184,14 @@ class AccessComponent extends Object { } if ($C->Auth->authorize == false) { - $C->Session->setFlash($C->Auth->authError, 'default', array(), 'auth'); $referer = $C->referer(); if ($referer == '/' || strpos($referer, 'login') !== false) { - $referer = array('admin' => false, 'project' => false, 'fork' => false, 'controller' => 'dashboard', 'action' => 'index'); + $referer = array( + 'admin' => false, 'project' => false, 'fork' => false, + 'controller' => 'dashboard', 'action' => 'index' + ); } + $C->Session->setFlash($C->Auth->authError); $C->redirect($referer); } return false; diff --git a/controllers/projects_controller.php b/controllers/projects_controller.php index 875e6f8..bd748b1 100644 --- a/controllers/projects_controller.php +++ b/controllers/projects_controller.php @@ -26,7 +26,7 @@ class ProjectsController extends AppController { parent::beforeFilter(); $this->Auth->mapActions(array('fork' => 'create')); $this->Auth->allow('index'); - $this->Access->allow('index'); + $this->Access->allow('index', 'start'); } function index() { @@ -88,6 +88,13 @@ class ProjectsController extends AppController { $this->set('project', $project); } + function start($type = null) { + if ($type || !empty($this->data)) { + $this->add(); + return; + } + } + function add() { $this->pageTitle = 'Project Setup'; @@ -101,10 +108,17 @@ class ProjectsController extends AppController { if ($data = $this->Project->save($this->data)) { if (empty($data['Project']['approved'])) { $this->Session->setFlash('Project is awaiting approval'); + $this->redirect(array( + 'project' => $data['Project']['url'], + 'controller' => 'projects', 'action' => 'view' + )); } else { $this->Session->setFlash('Project was created'); + $this->redirect(array( + 'project' => $data['Project']['url'], + 'controller' => 'timeline', 'action' => 'index' + )); } - $this->redirect(array('project' => $data['Project']['url'], 'controller' => 'timeline', 'action' => 'index')); } else { $this->Session->setFlash('Project was NOT created'); } @@ -117,6 +131,11 @@ class ProjectsController extends AppController { } } + if (!empty($this->passedArgs[0])) { + $this->pageTitle = Inflector::humanize($this->passedArgs[0]) . ' Project Setup'; + $this->data['Project']['private'] = ($this->passedArgs[0] == 'public') ? 0 : 1; + } + $this->set('repoTypes', $this->Project->repoTypes()); $this->set('messages', $this->Project->messages); diff --git a/models/permission.php b/models/permission.php index 873e734..49563f4 100644 --- a/models/permission.php +++ b/models/permission.php @@ -365,7 +365,7 @@ class Permission extends AppModel { function root() { $path = Configure::read("Content.base"); $File = new File($path . 'permissions.ini'); - if ($File->readable()) { + if (!$File->readable()) { return null; } return $File->read(); diff --git a/models/timeline.php b/models/timeline.php index 00fb236..f3a1dbd 100644 --- a/models/timeline.php +++ b/models/timeline.php @@ -25,19 +25,23 @@ class Timeline extends AppModel { var $belongsTo = array( 'Comment' => array( 'foreignKey' => 'foreign_key', - 'conditions' => array('Timeline.model = \'Comment\'') + 'conditions' => array('Timeline.model = \'Comment\''), + 'dependent' => true ), 'Commit' => array( 'foreignKey' => 'foreign_key', - 'conditions' => array('Timeline.model = \'Commit\'') + 'conditions' => array('Timeline.model = \'Commit\''), + 'dependent' => true ), 'Ticket' => array( 'foreignKey' => 'foreign_key', - 'conditions' => array('Timeline.model = \'Ticket\'') + 'conditions' => array('Timeline.model = \'Ticket\''), + 'dependent' => true ), 'Wiki' => array( 'foreignKey' => 'foreign_key', - 'conditions' => array('Timeline.model = \'Wiki\'') + 'conditions' => array('Timeline.model = \'Wiki\''), + 'dependent' => true ) ); @@ -45,14 +49,14 @@ class Timeline extends AppModel { foreach ($data as $key => $timeline) { $type = $timeline['Timeline']['model']; $this->{$type}->recursive = 0; - + if ($type == 'Comment') { $this->{$type}->recursive = 2; $this->{$type}->Ticket->unbindModel(array( 'hasMany' => array('Comment'), )); } - + $related = $this->{$type}->findById($timeline['Timeline']['foreign_key']); $data[$key] = array_merge($timeline, (array)$related); } diff --git a/plugins/repo/models/git.php b/plugins/repo/models/git.php index 9a1fefb..eabbd2d 100644 --- a/plugins/repo/models/git.php +++ b/plugins/repo/models/git.php @@ -23,6 +23,13 @@ App::import('Model', 'repo.Repo'); **/ class Git extends Repo { /** + * undocumented function + * + * @return void + * + **/ + var $gitDir = null; +/** * available commands for magic methods * * @var array @@ -62,15 +69,17 @@ class Git extends Repo { } $project = basename($path); - $this->response[] = $this->remote(array('add', 'origin', "{$remote}:{$project}")); + //$this->response[] = $this->remote(array('add', 'origin', "{$remote}:{$project}")); - $this->before(array( - "cd {$working}", "touch .gitignore" - )); - $this->response[] = $this->commit(array("-m", "'Initial Project Commit'")); - $this->response[] = $this->run("--bare", array('update-server-info')); - $this->response[] = $this->push(); - $this->response[] = $this->update(); + if (is_dir($working) && !file_exists($working . DS . '.gitignore')) { + $this->before(array( + "cd {$working}", "touch .gitignore" + )); + $this->response[] = $this->commit(array("-m", "'Initial Project Commit'")); + //$this->response[] = $this->run("--bare", array('update-server-info')); + $this->response[] = $this->update(); + $this->response[] = $this->push(); + } if (is_dir($path) && is_dir($working)) { return true; @@ -126,6 +135,11 @@ class Git extends Repo { return true; } + $userDir = dirname($this->config['working']);; + if (!is_dir($userDir)) { + $Fork = new Folder($userDir, true, $chmod); + } + if ($this->pull('master', array('--bare'))) { if (!empty($options['remote'])) { $remote = $options['remote']; @@ -137,7 +151,7 @@ class Git extends Repo { 'path' => $fork, 'working' => dirname($working) . DS . 'forks' . DS . $user . DS . str_replace('.git', '', $project) )); - $this->response[] = $this->remote(array('add', 'origin', "{$remote}:forks/{$user}/{$project}")); + //$this->response[] = $this->remote(array('add', 'origin', "{$remote}:forks/{$user}/{$project}")); $this->response[] = $this->pull(); } @@ -195,8 +209,12 @@ class Git extends Repo { } if (!is_dir($working)) { - $this->response[] = $this->run('clone', array_merge($params, array($path, $working))); - chmod($working, $chmod); + $base = dirname($working); + if (!is_dir($base)) { + $clone = new Folder($base, true, $chmod); + } + $this->before(array("cd {$base}")); + $this->response[] = $this->run('clone', array_merge($params, array($path))); } if (is_dir($working)) { @@ -401,11 +419,13 @@ class Git extends Repo { **/ function run($command, $args = array(), $return = false) { extract($this->config); - $before = null; - if (empty($this->_before)) { - $before = "GIT_DIR={$this->path} "; + + $gitDir = null; + if (empty($this->_before) && empty($this->gitDir)) { + $gitDir = "--git-dir={$this->path} "; } - return $this->execute("{$before}{$type} {$command}", $args, $return); + + return $this->execute("{$type} {$gitDir}{$command}", $args, $return); } } ?> \ No newline at end of file diff --git a/tests/cases/controllers/comments_controller.test.php b/tests/cases/controllers/comments_controller.test.php index bfbda8d..54a319e 100644 --- a/tests/cases/controllers/comments_controller.test.php +++ b/tests/cases/controllers/comments_controller.test.php @@ -1,4 +1,4 @@ -<?php +<?php /* SVN FILE: $Id$ */ /* CommentsController Test cases generated on: 2009-01-06 13:01:49 : 1231277809*/ App::import('Controller', 'Comments'); @@ -10,7 +10,13 @@ class TestComments extends CommentsController { class CommentsControllerTest extends CakeTestCase { var $Comments = null; - function setUp() { + var $fixtures = array( + 'app.project', 'app.permission', 'app.user', 'app.wiki', + 'app.timeline', 'app.comment', 'app.ticket', 'app.version', + 'app.tag', 'app.tags_tickets', 'app.commit' + ); + + function startTest() { $this->Comments = new TestComments(); $this->Comments->constructClasses(); } diff --git a/tests/cases/controllers/repo_controller.test.php b/tests/cases/controllers/repo_controller.test.php index 822bc66..52094fc 100644 --- a/tests/cases/controllers/repo_controller.test.php +++ b/tests/cases/controllers/repo_controller.test.php @@ -1,4 +1,4 @@ -<?php +<?php /* SVN FILE: $Id$ */ /* RepoController Test cases generated on: 2009-01-09 16:01:50 : 1231547090*/ App::import('Controller', 'Repo'); @@ -10,7 +10,14 @@ class TestRepo extends RepoController { class RepoControllerTest extends CakeTestCase { var $Repo = null; - function setUp() { + var $fixtures = array( + 'app.project', 'app.permission', 'app.user', 'app.wiki', + 'app.timeline', 'app.comment', 'app.ticket', 'app.version', + 'app.tag', 'app.tags_tickets', 'app.commit' + ); + + function startTest() { + $this->Repo = new TestRepo(); $this->Repo->constructClasses(); } diff --git a/views/commits/index.ctp b/views/commits/index.ctp index 179cdbe..38074b5 100644 --- a/views/commits/index.ctp +++ b/views/commits/index.ctp @@ -15,7 +15,9 @@ $javascript->codeBlock($script, array('inline' => false)); <?php $i = 0; foreach ((array)$commits as $commit): $zebra = ($i++ % 2) == 0 ? 'zebra' : null; - echo $this->element('timeline/commit', array('data' => $commit, 'zebra' => $zebra)); + if (!empty($commit['Commit']['revision'])) { + echo $this->element('timeline/commit', array('data' => $commit, 'zebra' => $zebra)); + } endforeach; ?> </div> diff --git a/views/elements/project_details.ctp b/views/elements/project_details.ctp index 2fd209d..d1beb65 100644 --- a/views/elements/project_details.ctp +++ b/views/elements/project_details.ctp @@ -1,5 +1,10 @@ <?php if (!empty($CurrentProject)):?> <div class="project-details"> + <?php + if (empty($project['Project']['approved'])) { + echo $html->tag('span', 'Awaiting Approval', array('class' => 'inactive')); + } + ?> <p class="description"> <strong>Description:</strong> <?php echo $CurrentProject->description;?> </p> diff --git a/views/elements/timeline/commit.ctp b/views/elements/timeline/commit.ctp index 48f79ee..1a0a5b9 100644 --- a/views/elements/timeline/commit.ctp +++ b/views/elements/timeline/commit.ctp @@ -23,8 +23,13 @@ 'controller' => 'repo', 'action' => 'merge', $data['Project']['fork'] )) . ' | ' : null; + + if ($this->name == 'Timeline') { + echo $chaw->admin('remove', array('controller' => 'timeline', 'action' => 'remove', $data['Timeline']['id'])); + } else if ($this->name == 'Commits') { + echo $chaw->admin('remove', array('controller' => 'commits', 'action' => 'remove', $data['Commit']['id'])); + } ?> - <?php echo $chaw->admin('remove', array('controller' => 'timeline', 'action' => 'remove', $data['Timeline']['id']));?> </span> <?php endif;?> diff --git a/views/pages/start.ctp b/views/pages/start.ctp index b7e7391..3035309 100644 --- a/views/pages/start.ctp +++ b/views/pages/start.ctp @@ -19,6 +19,12 @@ __('Check that your database exists and the proper settings are in APP/config/database.php'); echo '</span>'; return; + else : + $Project = ClassRegistry::init('Project'); + if ($Project->find('first')) { + echo $html->tag('h3', __('Finished', true)); + return; + } endif; endif; diff --git a/views/projects/add.ctp b/views/projects/add.ctp index af71887..cda7a72 100644 --- a/views/projects/add.ctp +++ b/views/projects/add.ctp @@ -12,7 +12,14 @@ 'error' => array('unique' => 'The project name must be unique.') )); echo $form->input('description'); - echo $form->input('private'); + + if (empty($this->passedArgs[0])) { + echo $form->input('private'); + } else if ($this->passedArgs[0] == 'public'){ + echo $form->input('ohloh_project', array( + 'after' => '<small>the url for the project on <a href="http://ohloh.net">ohloh.net</a></small>' + )); + } ?> </fieldset> <fieldset class="options"> diff --git a/views/projects/index.ctp b/views/projects/index.ctp index 1bc414e..db9f4bd 100644 --- a/views/projects/index.ctp +++ b/views/projects/index.ctp @@ -8,7 +8,7 @@ return; } ?> -<?php if (empty($this->params['project'])):?> +<?php if ($this->action != 'forks'):?> <h2> Projects @@ -29,7 +29,7 @@ echo $chaw->type('forks', array( 'controller' => 'projects', 'action' => 'index', )) . ' | '; - + echo $html->link( $html->image('feed-icon.png', array( 'width' => 14, 'height' => 14 diff --git a/views/projects/start.ctp b/views/projects/start.ctp index 200f59b..36c4682 100644 --- a/views/projects/start.ctp +++ b/views/projects/start.ctp @@ -1,3 +1,67 @@ -<div class="projects start"> - <?php echo $html->image('ohloh.png');?> +<style> + .start { + width: auto; + } + + .start .public, .start .private { + margin: 40px 0; + } + + .start div img { + float: left; + margin-right: 20px; + veritcal-align: middle; + } + + .start div .description { + float: left; + veritcal-align: middle; + } + .start div h3 { + margin: 2px 0 6px 0; + padding: 0; + } +</style> +<div class="start"> + <h2><?php __('Start A Project')?></h2> + <?php + //__(''); + + ?> + + <div class="public"> + <?php echo $html->image('ohloh.png', array('width' => 52));?> + + <div class="description"> + <h3><?php __('Public')?></h3> + <p> + Public projects are the coolest + </p> + <p> + <a href="https://www.ohloh.net/p/new"> + <?php __('Register your project on Ohloh')?> + </a>, then + <?php echo $html->link('Start a public project', array('public'))?> + </p> + </div> + + </div> + + <div class="clear"><!----></div> + + <div class="private"> + <?php echo $html->image('/css/images/lock.gif', array('width' => 50));?> + + <div class="description"> + <h3><?php __('Private')?></h3> + + <p>Private projects are cool</p> + <p><?php echo $html->link('Start a private project', array('private'))?></p> + + </div> + + </div> + + <div class="clear"><!----></div> + </div> \ No newline at end of file diff --git a/views/projects/view.ctp b/views/projects/view.ctp index 3af2741..cf6c136 100644 --- a/views/projects/view.ctp +++ b/views/projects/view.ctp @@ -1,23 +1,33 @@ <div class="project"> - - <h3 class="name"> - <?php echo $html->link($project['Project']['name'], array('controller' => 'projects', 'action' => 'view', 'project' => $project['Project']['url']));?> - </h3> - + + <h2 class="name"> + <?php echo $html->link($project['Project']['name'], array( + 'project' => $project['Project']['url'], + 'controller' => 'projects', 'action' => 'view' + ));?> + </h2> + <?php + if (empty($project['Project']['approved'])) { + echo $html->tag('span', 'Awaiting Approval', array('class' => 'inactive')); + } + ?> + <p class="description"> <?php echo $project['Project']['description'];?> </p> - - <p class="ticket-types"> - Ticket Types: <?php echo $project['Project']['ticket_types'];?> - </p> - - <p class="ticket-priorities"> - Ticket Priorites: <?php echo $project['Project']['ticket_priorities'];?> - </p> - - <p class="ticket-statuses"> - Ticket Statuses: <?php echo $project['Project']['ticket_statuses'];?> - </p> - + + <h4>Tickets</h4> + <ul> + <li> + types: <?php echo $project['Project']['ticket_types'];?> + </li> + <li> + priorities: <?php echo $project['Project']['ticket_priorities'];?> + </li> + <li> + statuses: <?php echo $project['Project']['ticket_statuses'];?> + </li> + + </ul> + </div> \ No newline at end of file diff --git a/views/wiki/index.ctp b/views/wiki/index.ctp index 413bbd5..16c198e 100644 --- a/views/wiki/index.ctp +++ b/views/wiki/index.ctp @@ -8,7 +8,7 @@ $javascript->link('ghighlight.min', false); <?php if (!empty($page['Wiki']['active'])):?> <span class="active">Active</span> <?php else: ?> - <span class="not-active">Not Active</span> + <span class="inactive">Not Active</span> <?php endif;?> <?php if ((empty($content['Wiki']['read_only']) || $CurrentUser->id == $page['Wiki']['last_changed_by'])):?> diff --git a/webroot/css/chaw.admin.css b/webroot/css/chaw.admin.css index 99d0323..e984d91 100644 --- a/webroot/css/chaw.admin.css +++ b/webroot/css/chaw.admin.css @@ -10,6 +10,7 @@ } #admin-content { width:75%; + margin-top: 20px; margin-left: 20px; margin-right: 20px; } @@ -17,8 +18,10 @@ #admin-navigation { clear: right; float: right; + position: fixed; + right: 0; width: 20%; - margin-top: 30px; + margin-top: 60px; margin-left: 20px; overflow: hidden; } diff --git a/webroot/css/chaw.css b/webroot/css/chaw.css index 4e4866a..42bc305 100644 --- a/webroot/css/chaw.css +++ b/webroot/css/chaw.css @@ -159,6 +159,7 @@ input[type=hidden] { } #page-content { + padding-top: 10px; padding-left: 20px; padding-right: 20px; } @@ -205,6 +206,8 @@ input[type=hidden] { } #current-user { + position: fixed; + right: 0; clear: both; float: right; margin: 0px; @@ -277,14 +280,14 @@ input[type=hidden] { padding-top: 10px; padding-bottom: 10px; } -.page-navigation span.active { +span.active { color: #363; } -.page-navigation span.not-active { +span.inactive { color: #600; } a.active { - color: #363; + color: #69C; font-weight: bold; } .left { @@ -582,7 +585,7 @@ fieldset.options textarea { color: #990; } .timeline .wiki h3 { - color: #69C; + color: #996; } .tickets h3 em { @@ -684,7 +687,12 @@ div.comments { font-size: 12px; height: 200px; } - +.browser { + margin-top: 50px; +} +.browser h2 { + margin-bottom: 4px; +} .browser .forks { float: right; margin-top: -20px; @@ -902,6 +910,9 @@ div.comments { border-bottom: 1px #ccc solid; margin-right: 0%; } +.form { + border-bottom: 0px; +} .projects td.actions a { font-weight: normal; } diff --git a/webroot/css/generic.css b/webroot/css/generic.css index a7b3dff..39e54f6 100644 --- a/webroot/css/generic.css +++ b/webroot/css/generic.css @@ -318,6 +318,9 @@ div.message { font-weight: bold; margin: 0.5em 0; } +#flashMessage p { + margin: 0; +} div.error-message { color: #69C; font-weight: bold; diff --git a/webroot/img/ohloh.png b/webroot/img/ohloh.png new file mode 100644 index 0000000..bd8df0e Binary files /dev/null and b/webroot/img/ohloh.png differ