From dd3671186fd4a93385698077b7477adce33131b8 Mon Sep 17 00:00:00 2001 From: japaveh Date: Sat, 13 Jul 2013 00:19:43 +0200 Subject: [PATCH 01/14] Included support for PhpLoc and Pdepend --- PHPCI/Plugin/Pdepend.php | 104 +++++++++++++++++++++++++++++++++++++++ PHPCI/Plugin/PhpLoc.php | 52 ++++++++++++++++++++ composer.json | 3 +- 3 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 PHPCI/Plugin/Pdepend.php create mode 100644 PHPCI/Plugin/PhpLoc.php diff --git a/PHPCI/Plugin/Pdepend.php b/PHPCI/Plugin/Pdepend.php new file mode 100644 index 00000000..95a7a8c0 --- /dev/null +++ b/PHPCI/Plugin/Pdepend.php @@ -0,0 +1,104 @@ + + * @package PHPCI + * @subpackage Plugins + */ +class Pdepend implements \PHPCI\Plugin +{ + protected $args; + /** + * @var \PHPCI\Builder + */ + protected $phpci; + /** + * @var string Directory which needs to be scanned + */ + protected $directory; + /** + * @var string File where the summary.xml is stored + */ + protected $summary; + /** + * @var string File where the chart.svg is stored + */ + protected $chart; + /** + * @var string File where the pyramid.svg is stored + */ + protected $pyramid; + /** + * @var string Location on the server where the files are stored. Preferably in the webroot for inclusion + * in the readme.md of the repository + */ + protected $location; + + + public function __construct(\PHPCI\Builder $phpci, array $options = array()) + { + $this->phpci = $phpci; + + $this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath; + + $this->summary = $phpci->getBuildProjectTitle() . '-summary.xml'; + $this->pyramid = $phpci->getBuildProjectTitle() . '-pyramid.svg'; + $this->chart = $phpci->getBuildProjectTitle() . '-chart.svg'; + $this->location = $this->phpci->buildPath . '..' . DIRECTORY_SEPARATOR . 'pdepend'; + } + + /** + * Runs Pdepend with the given criteria as arguments + */ + public function execute() + { + if (!is_writable($this->location)) { + throw new \Exception(sprintf('The location %s is not writable.', $this->location)); + } + + $cmd = PHPCI_BIN_DIR . 'pdepend --summary-xml=%s --jdepend-chart=%s --overview-pyramid=%s "%s"'; + + //Remove the created files first + unlink($this->location . DIRECTORY_SEPARATOR . $this->summary); + unlink($this->location . DIRECTORY_SEPARATOR . $this->chart); + unlink($this->location . DIRECTORY_SEPARATOR . $this->pyramid); + + $success = $this->phpci->executeCommand( + $cmd, + $this->location . DIRECTORY_SEPARATOR . $this->summary, + $this->location . DIRECTORY_SEPARATOR . $this->chart, + $this->location . DIRECTORY_SEPARATOR . $this->pyramid, + $this->directory + ); + + $config = $this->phpci->getSystemConfig('phpci'); + + if ($success) { + $this->phpci->logSuccess( + sprintf( + "Pdepend successful. You can use %s\n, ![Chart](%s \"Pdepend Chart\")\n + and ![Pyramid](%s \"Pdepend Pyramid\")\n + for inclusion in the readme.md file", + $config['url'] . '/build/pdepend/' . $this->summary, + $config['url'] . '/build/pdepend/' . $this->chart, + $config['url'] . '/build/pdepend/' . $this->pyramid + ) + ); + } else { + $this->phpci->logFailure(sprintf("The function '%s' failed")); + } + + + return $success; + } +} \ No newline at end of file diff --git a/PHPCI/Plugin/PhpLoc.php b/PHPCI/Plugin/PhpLoc.php new file mode 100644 index 00000000..0ae62200 --- /dev/null +++ b/PHPCI/Plugin/PhpLoc.php @@ -0,0 +1,52 @@ + + * @package PHPCI + * @subpackage Plugins + */ +class PhpLoc implements \PHPCI\Plugin +{ + /** + * @var string + */ + protected $directory; + /** + * @var \PHPCI\Builder + */ + protected $phpci; + + public function __construct(\PHPCI\Builder $phpci, array $options = array()) + { + $this->phpci = $phpci; + $this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath; + } + + /** + * Runs PHP Copy/Paste Detector in a specified directory. + */ + public function execute() + { + $ignore = ''; + if (count($this->phpci->ignore)) { + $map = function ($item) { + return ' --exclude ' . (substr($item, -1) == '/' ? substr($item, 0, -1) : $item); + }; + $ignore = array_map($map, $this->phpci->ignore); + + $ignore = implode('', $ignore); + } + + return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phploc %s "%s"', $ignore, $this->phpci->buildPath); + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index a4424830..a6368878 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "symfony/yaml" : "2.2.x-dev", "symfony/console" : "2.2.*", "fabpot/php-cs-fixer" : "0.3.*@dev", - "swiftmailer/swiftmailer" : "v5.0.0" + "swiftmailer/swiftmailer" : "v5.0.0", + "phploc/phploc": "*" } } From cadcdcd3d252cde1ad8d2c6e0e961553b072f1ef Mon Sep 17 00:00:00 2001 From: Alex Russell Date: Mon, 29 Jul 2013 17:34:21 +0100 Subject: [PATCH 02/14] Added new controller to accept Gitlab-like webhooks --- PHPCI/Application.php | 2 +- PHPCI/Controller/GitlabController.php | 61 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 PHPCI/Controller/GitlabController.php diff --git a/PHPCI/Application.php b/PHPCI/Application.php index 3378a050..d7d0a4fe 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -32,7 +32,7 @@ class Application extends b8\Application // Validate the user's session unless it is a login/logout action or a web hook: $sessionAction = ($this->controllerName == 'Session' && in_array($this->action, array('login', 'logout'))); - $externalAction = in_array($this->controllerName, array('Bitbucket', 'Github', 'BuildStatus')); + $externalAction = in_array($this->controllerName, array('Bitbucket', 'Github', 'Gitlab', 'BuildStatus')); $skipValidation = ($externalAction || $sessionAction); if($skipValidation || $this->validateSession()) { diff --git a/PHPCI/Controller/GitlabController.php b/PHPCI/Controller/GitlabController.php new file mode 100644 index 00000000..f3c1dd35 --- /dev/null +++ b/PHPCI/Controller/GitlabController.php @@ -0,0 +1,61 @@ +, Dan Cryer +* @package PHPCI +* @subpackage Web +*/ +class GitlabController extends \PHPCI\Controller +{ + public function init() + { + $this->_buildStore = Store\Factory::getStore('Build'); + } + + /** + * Called by Gitlab Webhooks: + */ + public function webhook($project) + { + $payload = json_decode(file_get_contents("php://input"), true); + + try { + $build = new Build(); + $build->setProjectId($project); + $build->setCommitId($payload['after']); + $build->setStatus(0); + $build->setLog(''); + $build->setCreated(new \DateTime()); + $build->setBranch(str_replace('refs/heads/', '', $payload['ref'])); + } catch (\Exception $ex) { + header('HTTP/1.1 400 Bad Request'); + header('Ex: ' . $ex->getMessage()); + die('FAIL'); + } + + try { + $build = $this->_buildStore->save($build); + $build->sendStatusPostback(); + } catch (\Exception $ex) { + header('HTTP/1.1 500 Internal Server Error'); + header('Ex: ' . $ex->getMessage()); + die('FAIL'); + } + + die('OK'); + } +} From b47dfbd0b34235226010bce6bb35f3b68480a124 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Tue, 30 Jul 2013 02:55:29 +0100 Subject: [PATCH 03/14] Various bug fixes --- PHPCI/Application.php | 7 --- PHPCI/Builder.php | 6 +-- PHPCI/Controller/BuildController.php | 1 - PHPCI/Controller/GithubController.php | 5 +++ PHPCI/Controller/ProjectController.php | 3 +- PHPCI/Controller/UserController.php | 1 - PHPCI/Model/Base/BuildBase.php | 59 +++++++++++++++++++++----- PHPCI/Model/Base/ProjectBase.php | 12 +++--- PHPCI/Model/Base/UserBase.php | 10 ++--- PHPCI/Model/Build/GithubBuild.php | 2 +- PHPCI/Model/Build/RemoteGitBuild.php | 9 +++- PHPCI/View/ProjectForm.phtml | 2 +- PHPCI/View/SummaryTable.phtml | 4 +- bootstrap.php | 2 - index.php | 2 +- 15 files changed, 82 insertions(+), 43 deletions(-) diff --git a/PHPCI/Application.php b/PHPCI/Application.php index 3378a050..e7ce142b 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -10,7 +10,6 @@ namespace PHPCI; use b8; -use b8\Registry; use b8\Http\Response\RedirectResponse; use b8\View; @@ -25,9 +24,6 @@ class Application extends b8\Application */ public function handleRequest() { - // Registry legacy: - $registry = new b8\Registry($this->config, $this->request); - $this->initRequest(); // Validate the user's session unless it is a login/logout action or a web hook: @@ -36,9 +32,6 @@ class Application extends b8\Application $skipValidation = ($externalAction || $sessionAction); if($skipValidation || $this->validateSession()) { - if ( !empty($_SESSION['user']) ) { - Registry::getInstance()->set('user', $_SESSION['user']); - } parent::handleRequest(); } diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index f943a092..b8979452 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -11,7 +11,7 @@ namespace PHPCI; use PHPCI\Model\Build; use b8\Store; -use Symfony\Component\Yaml\Parser as YamlParser; +use b8\Config; /** * PHPCI Build Runner @@ -123,7 +123,7 @@ class Builder */ public function getSystemConfig($key) { - return \b8\Registry::getInstance()->get($key); + return Config::getInstance()->get($key); } /** @@ -319,7 +319,7 @@ class Builder { $commitId = $this->build->getCommitId(); $buildId = 'project' . $this->build->getProject()->getId() . '-build' . $this->build->getId(); - $this->ciDir = realpath(dirname(__FILE__) . '/../') . '/'; + $this->ciDir = dirname(__FILE__) . '/../'; $this->buildPath = $this->ciDir . 'build/' . $buildId . '/'; $this->setInterpolationVars(); diff --git a/PHPCI/Controller/BuildController.php b/PHPCI/Controller/BuildController.php index 56bde07c..b907b9bc 100644 --- a/PHPCI/Controller/BuildController.php +++ b/PHPCI/Controller/BuildController.php @@ -10,7 +10,6 @@ namespace PHPCI\Controller; use b8; -use b8\Registry; use PHPCI\Model\Build; /** diff --git a/PHPCI/Controller/GithubController.php b/PHPCI/Controller/GithubController.php index 90bc37fe..71ae0e3b 100644 --- a/PHPCI/Controller/GithubController.php +++ b/PHPCI/Controller/GithubController.php @@ -41,6 +41,11 @@ class GithubController extends \PHPCI\Controller $build->setLog(''); $build->setCreated(new \DateTime()); $build->setBranch(str_replace('refs/heads/', '', $payload['ref'])); + + if (!empty($payload['pusher']['email'])) { + $build->setCommitterEmail($payload['pusher']['email']); + } + } catch (\Exception $ex) { header('HTTP/1.1 400 Bad Request'); header('Ex: ' . $ex->getMessage()); diff --git a/PHPCI/Controller/ProjectController.php b/PHPCI/Controller/ProjectController.php index eaad90a1..47894266 100644 --- a/PHPCI/Controller/ProjectController.php +++ b/PHPCI/Controller/ProjectController.php @@ -15,7 +15,6 @@ use b8; use b8\Controller; use b8\Store; use b8\Form; -use b8\Registry; /** * Project Controller - Allows users to create, edit and view projects. @@ -175,7 +174,7 @@ class ProjectController extends \PHPCI\Controller */ protected function handleGithubResponse() { - $github = \b8\Registry::getInstance()->get('github_app'); + $github = \b8\Config::getInstance()->get('phpci.github'); $code = $this->getParam('code', null); if (!is_null($code)) { diff --git a/PHPCI/Controller/UserController.php b/PHPCI/Controller/UserController.php index 402c8792..0a814b9c 100644 --- a/PHPCI/Controller/UserController.php +++ b/PHPCI/Controller/UserController.php @@ -10,7 +10,6 @@ namespace PHPCI\Controller; use b8; -use b8\Registry; use PHPCI\Model\User; use b8\Form; diff --git a/PHPCI/Model/Base/BuildBase.php b/PHPCI/Model/Base/BuildBase.php index e051aac4..b681c110 100644 --- a/PHPCI/Model/Base/BuildBase.php +++ b/PHPCI/Model/Base/BuildBase.php @@ -42,6 +42,7 @@ class BuildBase extends Model 'started' => null, 'finished' => null, 'plugins' => null, + 'committer_email' => null, ); /** @@ -58,6 +59,7 @@ class BuildBase extends Model 'started' => 'getStarted', 'finished' => 'getFinished', 'plugins' => 'getPlugins', + 'committer_email' => 'getCommitterEmail', 'Project' => 'getProject', ); @@ -75,6 +77,7 @@ class BuildBase extends Model 'started' => 'setStarted', 'finished' => 'setFinished', 'plugins' => 'setPlugins', + 'committer_email' => 'setCommitterEmail', 'Project' => 'setProject', ); @@ -129,6 +132,11 @@ class BuildBase extends Model 'length' => '', 'nullable' => true, ), + 'committer_email' => array( + 'type' => 'varchar', + 'length' => '512', + 'nullable' => true, + ), ); /** @@ -299,6 +307,19 @@ class BuildBase extends Model return $rtn; } + /** + * Get the value of CommitterEmail / committer_email. + * + * @return string + */ + public function getCommitterEmail() + { + $rtn = $this->data['committer_email']; + + + return $rtn; + } + /** * Set the value of Id / id. * @@ -309,7 +330,7 @@ class BuildBase extends Model { $this->_validateNotNull('Id', $value); $this->_validateInt('Id', $value); - if ($this->data['id'] === $value) { + if ($this->data['id'] == $value) { return; } @@ -328,7 +349,7 @@ class BuildBase extends Model { $this->_validateNotNull('ProjectId', $value); $this->_validateInt('ProjectId', $value); - if ($this->data['project_id'] === $value) { + if ($this->data['project_id'] == $value) { return; } @@ -347,7 +368,7 @@ class BuildBase extends Model { $this->_validateNotNull('CommitId', $value); $this->_validateString('CommitId', $value); - if ($this->data['commit_id'] === $value) { + if ($this->data['commit_id'] == $value) { return; } @@ -366,7 +387,7 @@ class BuildBase extends Model { $this->_validateNotNull('Status', $value); $this->_validateInt('Status', $value); - if ($this->data['status'] === $value) { + if ($this->data['status'] == $value) { return; } @@ -384,7 +405,7 @@ class BuildBase extends Model { $this->_validateString('Log', $value); - if ($this->data['log'] === $value) { + if ($this->data['log'] == $value) { return; } @@ -403,7 +424,7 @@ class BuildBase extends Model { $this->_validateNotNull('Branch', $value); $this->_validateString('Branch', $value); - if ($this->data['branch'] === $value) { + if ($this->data['branch'] == $value) { return; } @@ -421,7 +442,7 @@ class BuildBase extends Model { $this->_validateDate('Created', $value); - if ($this->data['created'] === $value) { + if ($this->data['created'] == $value) { return; } @@ -439,7 +460,7 @@ class BuildBase extends Model { $this->_validateDate('Started', $value); - if ($this->data['started'] === $value) { + if ($this->data['started'] == $value) { return; } @@ -457,7 +478,7 @@ class BuildBase extends Model { $this->_validateDate('Finished', $value); - if ($this->data['finished'] === $value) { + if ($this->data['finished'] == $value) { return; } @@ -475,7 +496,7 @@ class BuildBase extends Model { $this->_validateString('Plugins', $value); - if ($this->data['plugins'] === $value) { + if ($this->data['plugins'] == $value) { return; } @@ -484,6 +505,24 @@ class BuildBase extends Model $this->_setModified('plugins'); } + /** + * Set the value of CommitterEmail / committer_email. + * + * @param $value string + */ + public function setCommitterEmail($value) + { + + $this->_validateString('CommitterEmail', $value); + if ($this->data['committer_email'] == $value) { + return; + } + + $this->data['committer_email'] = $value; + + $this->_setModified('committer_email'); + } + /** * Get the Project model for this Build by Id. * diff --git a/PHPCI/Model/Base/ProjectBase.php b/PHPCI/Model/Base/ProjectBase.php index 45481dd5..c9d577af 100644 --- a/PHPCI/Model/Base/ProjectBase.php +++ b/PHPCI/Model/Base/ProjectBase.php @@ -199,7 +199,7 @@ class ProjectBase extends Model { $this->_validateNotNull('Id', $value); $this->_validateInt('Id', $value); - if ($this->data['id'] === $value) { + if ($this->data['id'] == $value) { return; } @@ -218,7 +218,7 @@ class ProjectBase extends Model { $this->_validateNotNull('Title', $value); $this->_validateString('Title', $value); - if ($this->data['title'] === $value) { + if ($this->data['title'] == $value) { return; } @@ -237,7 +237,7 @@ class ProjectBase extends Model { $this->_validateNotNull('Reference', $value); $this->_validateString('Reference', $value); - if ($this->data['reference'] === $value) { + if ($this->data['reference'] == $value) { return; } @@ -256,7 +256,7 @@ class ProjectBase extends Model { $this->_validateNotNull('GitKey', $value); $this->_validateString('GitKey', $value); - if ($this->data['git_key'] === $value) { + if ($this->data['git_key'] == $value) { return; } @@ -275,7 +275,7 @@ class ProjectBase extends Model { $this->_validateNotNull('Type', $value); $this->_validateString('Type', $value); - if ($this->data['type'] === $value) { + if ($this->data['type'] == $value) { return; } @@ -293,7 +293,7 @@ class ProjectBase extends Model { $this->_validateString('Token', $value); - if ($this->data['token'] === $value) { + if ($this->data['token'] == $value) { return; } diff --git a/PHPCI/Model/Base/UserBase.php b/PHPCI/Model/Base/UserBase.php index 7ce2759c..aab1e21b 100644 --- a/PHPCI/Model/Base/UserBase.php +++ b/PHPCI/Model/Base/UserBase.php @@ -179,7 +179,7 @@ class UserBase extends Model { $this->_validateNotNull('Id', $value); $this->_validateInt('Id', $value); - if ($this->data['id'] === $value) { + if ($this->data['id'] == $value) { return; } @@ -198,7 +198,7 @@ class UserBase extends Model { $this->_validateNotNull('Email', $value); $this->_validateString('Email', $value); - if ($this->data['email'] === $value) { + if ($this->data['email'] == $value) { return; } @@ -217,7 +217,7 @@ class UserBase extends Model { $this->_validateNotNull('Hash', $value); $this->_validateString('Hash', $value); - if ($this->data['hash'] === $value) { + if ($this->data['hash'] == $value) { return; } @@ -236,7 +236,7 @@ class UserBase extends Model { $this->_validateNotNull('IsAdmin', $value); $this->_validateInt('IsAdmin', $value); - if ($this->data['is_admin'] === $value) { + if ($this->data['is_admin'] == $value) { return; } @@ -255,7 +255,7 @@ class UserBase extends Model { $this->_validateNotNull('Name', $value); $this->_validateString('Name', $value); - if ($this->data['name'] === $value) { + if ($this->data['name'] == $value) { return; } diff --git a/PHPCI/Model/Build/GithubBuild.php b/PHPCI/Model/Build/GithubBuild.php index 35ce439b..6518da92 100644 --- a/PHPCI/Model/Build/GithubBuild.php +++ b/PHPCI/Model/Build/GithubBuild.php @@ -67,7 +67,7 @@ class GithubBuild extends RemoteGitBuild break; } - $url = \b8\Registry::getInstance()->get('install_url'); + $url = \b8\Config::getInstance()->get('phpci.url'); $params = array( 'state' => $status, 'target_url' => $url . '/build/view/' . $this->getId()); $headers = array( diff --git a/PHPCI/Model/Build/RemoteGitBuild.php b/PHPCI/Model/Build/RemoteGitBuild.php index d1fe1c74..490b92ef 100644 --- a/PHPCI/Model/Build/RemoteGitBuild.php +++ b/PHPCI/Model/Build/RemoteGitBuild.php @@ -74,7 +74,14 @@ class RemoteGitBuild extends Build protected function cloneBySsh(Builder $builder, $to) { // Copy the project's keyfile to disk: - $keyFile = realpath($to) . '.key'; + $keyPath = realpath($to); + + if ($keyPath === false) { + $keyPath = dirname($to); + } + + $keyFile = $keyPath . '.key'; + file_put_contents($keyFile, $this->getProject()->getGitKey()); chmod($keyFile, 0600); diff --git a/PHPCI/View/ProjectForm.phtml b/PHPCI/View/ProjectForm.phtml index f59a461b..e52cbd9e 100644 --- a/PHPCI/View/ProjectForm.phtml +++ b/PHPCI/View/ProjectForm.phtml @@ -25,7 +25,7 @@ window.return_url = ; get('github_app', null); +$gh = \b8\Config::getInstance()->get('phpci.github', null); if($gh) { print 'window.github_app_id = ' . json_encode($gh['id']) . ';' . PHP_EOL; diff --git a/PHPCI/View/SummaryTable.phtml b/PHPCI/View/SummaryTable.phtml index de374e2c..3db900b2 100644 --- a/PHPCI/View/SummaryTable.phtml +++ b/PHPCI/View/SummaryTable.phtml @@ -80,8 +80,8 @@ foreach($projects as $projectId => $project): break; } - $health = ($project['health'] < 0 ? 'Stormy': ($project['health'] < 5? 'Overcast': 'Sunny')); - $subcls = ($project['health'] < 0 ? 'important': ($project['health'] < 5? 'warning': 'success')); + $health = ($project['health'] <= 0 ? 'Stormy': ($project['successes'] < $project['count']? 'Overcast': 'Sunny')); + $subcls = ($project['health'] <= 0 ? 'important': ($project['successes'] < $project['count']? 'warning': 'success')); ?> diff --git a/bootstrap.php b/bootstrap.php index a2b0e8d3..9cd035e9 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -42,8 +42,6 @@ $conf['b8']['app']['default_controller'] = 'Index'; $conf['b8']['view']['path'] = dirname(__FILE__) . '/PHPCI/View/'; $config = new b8\Config($conf); -$request = new b8\Http\Request(); -$registry = new b8\Registry($config, $request); if (file_exists(APPLICATION_PATH . 'config.php')) { require(APPLICATION_PATH . 'config.php'); diff --git a/index.php b/index.php index cab4239d..b4685c7d 100644 --- a/index.php +++ b/index.php @@ -14,5 +14,5 @@ ini_set('display_errors', 'on'); require_once('bootstrap.php'); -$fc = new PHPCI\Application($config, $request); +$fc = new PHPCI\Application($config, new b8\Http\Request()); print $fc->handleRequest(); From 4133bb79055fba9cfe5a5b93ca763724abb6897a Mon Sep 17 00:00:00 2001 From: Alex Russell Date: Tue, 30 Jul 2013 14:58:00 +0100 Subject: [PATCH 04/14] Extended phpcs plugin to allow for extra commandline arguments. - Now accepts paths in the --standards argument (and correctly prepends the build directory) so it actually works - Now accepts the --tabwidth argument so that if your project favours tabs over spaces you can still just use PSR2 and you don't have to sacrifice using the Generic.WhiteSpace.ScopeIndent rule because it is spaces-only - Now accpets the --encoding argument. I haven't used this before, but looking in the phpcs documentation it looks like a very useful one to have as most people code in utf-8 but phpcs defaults to iso-8859-1 and it can apparently "cause double-encoding problems when generating UTF-8 encoded XML reports" --- PHPCI/Plugin/PhpCodeSniffer.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/PHPCI/Plugin/PhpCodeSniffer.php b/PHPCI/Plugin/PhpCodeSniffer.php index 4c3c2680..8e28fd22 100644 --- a/PHPCI/Plugin/PhpCodeSniffer.php +++ b/PHPCI/Plugin/PhpCodeSniffer.php @@ -26,6 +26,8 @@ class PhpCodeSniffer implements \PHPCI\Plugin $this->phpci = $phpci; $this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath; $this->standard = isset($options['standard']) ? $options['standard'] : 'PSR2'; + $this->tab_width = isset($options['tab_width']) ? $options['tab_width'] : ''; + $this->encoding = isset($options['encoding']) ? $options['encoding'] : ''; } /** @@ -39,7 +41,27 @@ class PhpCodeSniffer implements \PHPCI\Plugin $ignore = ' --ignore=' . implode(',', $this->phpci->ignore); } - $cmd = PHPCI_BIN_DIR . 'phpcs --standard=%s %s "%s"'; - return $this->phpci->executeCommand($cmd, $this->standard, $ignore, $this->phpci->buildPath); + $standard = ''; + + if (strpos($this->standard, '/') !== false) { + $standard = ' --standard='.$this->directory.$this->standard; + } else { + $standard = ' --standard='.$this->standard; + } + + $tab_width = ''; + + if (strlen($this->tab_width)) { + $tab_width = ' --tab-width='.$this->tab_width; + } + + $encoding = ''; + + if (strlen($this->encoding)) { + $encoding = ' --encoding='.$this->encoding; + } + + $cmd = PHPCI_BIN_DIR . 'phpcs %s %s %s %s "%s"'; + return $this->phpci->executeCommand($cmd, $standard, $ignore, $tab_width, $encoding, $this->phpci->buildPath); } } From 05908905115c822b53be91accf97201081bc8802 Mon Sep 17 00:00:00 2001 From: Tobias Tom Date: Tue, 30 Jul 2013 19:45:27 +0200 Subject: [PATCH 05/14] Some fixes for subdirectory support. --- PHPCI/Application.php | 2 +- PHPCI/Controller/SessionController.php | 6 +++--- PHPCI/Controller/UserController.php | 2 +- assets/css/phpci.css | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PHPCI/Application.php b/PHPCI/Application.php index 1c89c44e..bfae830c 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -65,7 +65,7 @@ class Application extends b8\Application $this->response->setContent(''); } else { $this->response = new RedirectResponse($this->response); - $this->response->setHeader('Location', '/session/login'); + $this->response->setHeader('Location', PHPCI_URL.'session/login'); } return false; diff --git a/PHPCI/Controller/SessionController.php b/PHPCI/Controller/SessionController.php index 214f9921..e2bb0aa1 100644 --- a/PHPCI/Controller/SessionController.php +++ b/PHPCI/Controller/SessionController.php @@ -21,7 +21,7 @@ class SessionController extends \PHPCI\Controller { public function init() { - $this->response->disableLayout(); + $this->response->disableLayout(); $this->_userStore = b8\Store\Factory::getStore('User'); } @@ -29,7 +29,7 @@ class SessionController extends \PHPCI\Controller * Handles user login (form and processing) */ public function login() - { + { if ($this->request->getMethod() == 'POST') { $user = $this->_userStore->getByEmail($this->getParam('email')); @@ -42,7 +42,7 @@ class SessionController extends \PHPCI\Controller $form = new b8\Form(); $form->setMethod('POST'); - $form->setAction('/session/login'); + $form->setAction(PHPCI_URL.'session/login'); $email = new b8\Form\Element\Email('email'); $email->setLabel('Email Address'); diff --git a/PHPCI/Controller/UserController.php b/PHPCI/Controller/UserController.php index 0a814b9c..92f1ed46 100644 --- a/PHPCI/Controller/UserController.php +++ b/PHPCI/Controller/UserController.php @@ -129,7 +129,7 @@ class UserController extends \PHPCI\Controller { $form = new Form(); $form->setMethod('POST'); - $form->setAction('/user/' . $type); + $form->setAction(PHPCI_URL.'user/' . $type); $form->addField(new Form\Element\Csrf('csrf')); $field = new Form\Element\Email('email'); diff --git a/assets/css/phpci.css b/assets/css/phpci.css index cfb886d4..71071625 100644 --- a/assets/css/phpci.css +++ b/assets/css/phpci.css @@ -57,22 +57,22 @@ td .label { margin-right: 5px; } .icon-build-ok { - background: url('/assets/img/icon-build-ok.png') no-repeat top left; + background: url('../img/icon-build-ok.png') no-repeat top left; } .icon-build-failed { - background: url('/assets/img/icon-build-failed.png') no-repeat top left; + background: url('../img/icon-build-failed.png') no-repeat top left; } .icon-build-pending { - background: url('/assets/img/icon-build-pending.png') no-repeat top left; + background: url('../img/icon-build-pending.png') no-repeat top left; } .icon-build-running { - background: url('/assets/img/icon-build-running.png') no-repeat top left; + background: url('../img/icon-build-running.png') no-repeat top left; } h3 From aa90f747fd36cc583b334246e2c16fa32e21ca3b Mon Sep 17 00:00:00 2001 From: Tobias Tom Date: Wed, 31 Jul 2013 08:08:19 +0200 Subject: [PATCH 06/14] Removed magix execution of composer. --- console | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/console b/console index f571c454..dd71d058 100755 --- a/console +++ b/console @@ -14,14 +14,9 @@ define('ENABLE_SHELL_PLUGIN', false); // If this is the first time ./console has been run, we probably don't have Composer or any of our dependencies yet. // So we need to install and run Composer. -if (!file_exists(PHPCI_DIR . 'vendor/autoload.php') || !file_exists(PHPCI_DIR . 'composer.phar')) { - print 'INSTALLING: Composer' . PHP_EOL; - file_put_contents(PHPCI_DIR . 'composerinstaller.php', file_get_contents('https://getcomposer.org/installer')); - shell_exec('php ' . escapeshellarg(PHPCI_DIR . 'composerinstaller.php')); - unlink(PHPCI_DIR . 'composerinstaller.php'); - - print 'RUNNING: Composer' . PHP_EOL; - shell_exec('php '.escapeshellarg(PHPCI_DIR.'composer.phar').' install'); +if (!file_exists(PHPCI_DIR . 'vendor/autoload.php')) { + file_put_contents('php://stderr', 'Please install PHPCI with "composer install" before using console'); + exit( 1 ); } require('bootstrap.php'); From 695d57c68cd86d5dd83d911c47b4045c9b3f1089 Mon Sep 17 00:00:00 2001 From: Tobias Tom Date: Wed, 31 Jul 2013 08:15:07 +0200 Subject: [PATCH 07/14] Added additional installation step. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aa1eff8a..7acf5f4c 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ _**Please be aware that PHPCI is a beta-release project, so whilst it is very st ####Installing from Github: * Step 1: `git clone https://github.com/Block8/PHPCI.git` * Step 2: `cd PHPCI` -* Step 3: `chmod +x ./console && ./console phpci:install` +* Step 3: `composer install` +* Step 4: `chmod +x ./console && ./console phpci:install` * When prompted, enter your database host, username, password and the database name that PHPCI should use. * The script will attempt to create the database if it does not exist already. * If you intend to use the MySQL plugin to create / destroy databases, the user you entered above will need CREATE / DELETE permissions on the server. From e4685b9c297ea0f21c120aafb82d43d63e554740 Mon Sep 17 00:00:00 2001 From: Tobias Tom Date: Wed, 31 Jul 2013 08:55:19 +0200 Subject: [PATCH 08/14] Added initial version of the grunt plugin. --- PHPCI/Plugin/Grunt.php | 56 ++++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 2 files changed, 58 insertions(+) create mode 100644 PHPCI/Plugin/Grunt.php diff --git a/PHPCI/Plugin/Grunt.php b/PHPCI/Plugin/Grunt.php new file mode 100644 index 00000000..892d8303 --- /dev/null +++ b/PHPCI/Plugin/Grunt.php @@ -0,0 +1,56 @@ + +* @package PHPCI +* @subpackage Plugins +*/ +class Grunt implements \PHPCI\Plugin +{ + protected $directory; + protected $task; + protected $preferDist; + protected $phpci; + protected $grunt; + protected $gruntfile; + + public function __construct(\PHPCI\Builder $phpci, array $options = array()) + { + $path = $phpci->buildPath; + $this->phpci = $phpci; + $this->directory = isset($options['directory']) ? $path . '/' . $options['directory'] : $path; + $this->task = isset($options['task']) ? $options['task'] : null; + $this->grunt = isset($options['grunt']) ? $options['grunt'] : 'grunt'; + $this->gruntfile = isset($options['gruntfile']) ? $options['gruntfile'] : 'Gruntfile.js'; + } + + /** + * Executes grunt and runs a specified command (e.g. install / update) + */ + public function execute() + { + // if npm does not work, we cannot use grunt, so we return false + if ( !$this->phpci->executeCommand( 'cd %s && npm install', $this->directory ) ) { + return false; + } + + // build the grunt command + $cmd = 'cd %s && ' . $this->grunt; + $cmd .= ' --no-color'; + $cmd .= ' --gruntfile %s'; + $cmd .= ' %s'; // the task that will be executed + + // and execute it + return $this->phpci->executeCommand($cmd, $this->directory, $this->gruntfile, $this->task); + } +} diff --git a/README.md b/README.md index aa1eff8a..2bdffefe 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,8 @@ Similar to Travis CI, to support PHPCI in your project, you simply need to add a standard: "PSR2" php_cpd: allow_failures: true + grunt: + task: "build" complete: mysql: From 7fccd56c2b3a08504a4d901140ae922a9f11d450 Mon Sep 17 00:00:00 2001 From: Tobias Tom Date: Wed, 31 Jul 2013 11:30:20 +0200 Subject: [PATCH 09/14] Created one directory where all web-accessible files are located. --- {assets => public/assets}/css/bootstrap.min.css | 0 {assets => public/assets}/css/phpci.css | 0 {assets => public/assets}/img/build-failed.png | Bin {assets => public/assets}/img/build-ok.png | Bin .../assets}/img/glyphicons-halflings-white.png | Bin .../assets}/img/glyphicons-halflings.png | Bin {assets => public/assets}/img/icon-build-failed.png | Bin {assets => public/assets}/img/icon-build-ok.png | Bin .../assets}/img/icon-build-pending.png | Bin .../assets}/img/icon-build-running.png | Bin {assets => public/assets}/js/bootstrap.min.js | 0 {assets => public/assets}/js/phpci.js | 0 index.php => public/index.php | 2 +- 13 files changed, 1 insertion(+), 1 deletion(-) rename {assets => public/assets}/css/bootstrap.min.css (100%) rename {assets => public/assets}/css/phpci.css (100%) rename {assets => public/assets}/img/build-failed.png (100%) rename {assets => public/assets}/img/build-ok.png (100%) rename {assets => public/assets}/img/glyphicons-halflings-white.png (100%) rename {assets => public/assets}/img/glyphicons-halflings.png (100%) rename {assets => public/assets}/img/icon-build-failed.png (100%) rename {assets => public/assets}/img/icon-build-ok.png (100%) rename {assets => public/assets}/img/icon-build-pending.png (100%) rename {assets => public/assets}/img/icon-build-running.png (100%) rename {assets => public/assets}/js/bootstrap.min.js (100%) rename {assets => public/assets}/js/phpci.js (100%) rename index.php => public/index.php (91%) diff --git a/assets/css/bootstrap.min.css b/public/assets/css/bootstrap.min.css similarity index 100% rename from assets/css/bootstrap.min.css rename to public/assets/css/bootstrap.min.css diff --git a/assets/css/phpci.css b/public/assets/css/phpci.css similarity index 100% rename from assets/css/phpci.css rename to public/assets/css/phpci.css diff --git a/assets/img/build-failed.png b/public/assets/img/build-failed.png similarity index 100% rename from assets/img/build-failed.png rename to public/assets/img/build-failed.png diff --git a/assets/img/build-ok.png b/public/assets/img/build-ok.png similarity index 100% rename from assets/img/build-ok.png rename to public/assets/img/build-ok.png diff --git a/assets/img/glyphicons-halflings-white.png b/public/assets/img/glyphicons-halflings-white.png similarity index 100% rename from assets/img/glyphicons-halflings-white.png rename to public/assets/img/glyphicons-halflings-white.png diff --git a/assets/img/glyphicons-halflings.png b/public/assets/img/glyphicons-halflings.png similarity index 100% rename from assets/img/glyphicons-halflings.png rename to public/assets/img/glyphicons-halflings.png diff --git a/assets/img/icon-build-failed.png b/public/assets/img/icon-build-failed.png similarity index 100% rename from assets/img/icon-build-failed.png rename to public/assets/img/icon-build-failed.png diff --git a/assets/img/icon-build-ok.png b/public/assets/img/icon-build-ok.png similarity index 100% rename from assets/img/icon-build-ok.png rename to public/assets/img/icon-build-ok.png diff --git a/assets/img/icon-build-pending.png b/public/assets/img/icon-build-pending.png similarity index 100% rename from assets/img/icon-build-pending.png rename to public/assets/img/icon-build-pending.png diff --git a/assets/img/icon-build-running.png b/public/assets/img/icon-build-running.png similarity index 100% rename from assets/img/icon-build-running.png rename to public/assets/img/icon-build-running.png diff --git a/assets/js/bootstrap.min.js b/public/assets/js/bootstrap.min.js similarity index 100% rename from assets/js/bootstrap.min.js rename to public/assets/js/bootstrap.min.js diff --git a/assets/js/phpci.js b/public/assets/js/phpci.js similarity index 100% rename from assets/js/phpci.js rename to public/assets/js/phpci.js diff --git a/index.php b/public/index.php similarity index 91% rename from index.php rename to public/index.php index b4685c7d..134e9a7b 100644 --- a/index.php +++ b/public/index.php @@ -12,7 +12,7 @@ session_start(); error_reporting(E_ALL); ini_set('display_errors', 'on'); -require_once('bootstrap.php'); +require_once('../bootstrap.php'); $fc = new PHPCI\Application($config, new b8\Http\Request()); print $fc->handleRequest(); From 664f0d7d8eb2074701499ea1ad68798c2a1764af Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Wed, 31 Jul 2013 11:00:57 +0100 Subject: [PATCH 10/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b08e3c2..917ec901 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ _**Please be aware that PHPCI is a beta-release project, so whilst it is very st **Apache Example**: RewriteEngine On - RewriteBase /path-to-phpci + RewriteBase /path-to-phpci/public RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*)? index.php [L,E=PATH_INFO:/$1] From 8b5abc1f986406900b9e1bd6734804b84cc8ed84 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Thu, 1 Aug 2013 11:55:10 +0100 Subject: [PATCH 11/14] Initial work on upgrading to Bootstrap v3 --- PHPCI/Controller/ProjectController.php | 11 +- PHPCI/Controller/SessionController.php | 4 +- PHPCI/Helper/Build.php | 24 + PHPCI/View/Build/view.phtml | 15 +- PHPCI/View/BuildsTable.phtml | 16 +- PHPCI/View/Index/index.phtml | 23 +- PHPCI/View/Project/view.phtml | 17 +- PHPCI/View/ProjectForm.phtml | 6 +- PHPCI/View/SummaryTable.phtml | 2 +- PHPCI/View/layout.phtml | 28 +- assets/css/bootstrap.min.css | 840 +------------------------ assets/js/bootstrap.min.js | 9 +- assets/js/phpci.js | 17 +- index.php | 1 + 14 files changed, 110 insertions(+), 903 deletions(-) create mode 100644 PHPCI/Helper/Build.php mode change 100755 => 100644 assets/css/bootstrap.min.css mode change 100755 => 100644 assets/js/bootstrap.min.js diff --git a/PHPCI/Controller/ProjectController.php b/PHPCI/Controller/ProjectController.php index 47894266..bd11f846 100644 --- a/PHPCI/Controller/ProjectController.php +++ b/PHPCI/Controller/ProjectController.php @@ -262,13 +262,13 @@ class ProjectController extends \PHPCI\Controller $field->setPattern('^(github|bitbucket|remote|local)'); $field->setOptions($options); $field->setLabel('Where is your project hosted?'); - $field->setClass('span4'); + $field->setClass('col-lg-4 form-control'); $form->addField($field); if (isset($_SESSION['github_token'])) { $field = new Form\Element\Select('github'); $field->setLabel('Choose a Github repository:'); - $field->setClass('span4'); + $field->setClass('col-lg-4 form-control'); $field->setOptions($this->getGithubRepositories()); $form->addField($field); } @@ -302,24 +302,25 @@ class ProjectController extends \PHPCI\Controller $field->setRequired(true); $field->setValidator($referenceValidator); $field->setLabel('Repository Name / URL (Remote) or Path (Local)'); - $field->setClass('span4'); + $field->setClass('col-lg-4 form-control'); $form->addField($field); $field = new Form\Element\Text('title'); $field->setRequired(true); $field->setLabel('Project Title'); - $field->setClass('span4'); + $field->setClass('col-lg-4 form-control'); $form->addField($field); $field = new Form\Element\TextArea('key'); $field->setRequired(false); $field->setLabel('Private key to use to access repository (leave blank for local and/or anonymous remotes)'); - $field->setClass('span7'); + $field->setClass('col-lg-7 form-control'); $field->setRows(6); $form->addField($field); $field = new Form\Element\Submit(); $field->setValue('Save Project'); + $field->setContainerClass('form-group'); $field->setClass('btn-success'); $form->addField($field); diff --git a/PHPCI/Controller/SessionController.php b/PHPCI/Controller/SessionController.php index 214f9921..b6fd0a43 100644 --- a/PHPCI/Controller/SessionController.php +++ b/PHPCI/Controller/SessionController.php @@ -47,13 +47,13 @@ class SessionController extends \PHPCI\Controller $email = new b8\Form\Element\Email('email'); $email->setLabel('Email Address'); $email->setRequired(true); - $email->setClass('span3'); + $email->setContainerClass('form-group'); $form->addField($email); $pwd = new b8\Form\Element\Password('password'); $pwd->setLabel('Password'); $pwd->setRequired(true); - $pwd->setClass('span3'); + $pwd->setContainerClass('form-group'); $form->addField($pwd); $pwd = new b8\Form\Element\Submit(); diff --git a/PHPCI/Helper/Build.php b/PHPCI/Helper/Build.php new file mode 100644 index 00000000..3aa7403f --- /dev/null +++ b/PHPCI/Helper/Build.php @@ -0,0 +1,24 @@ + + * @package PHPCI + * @subpackage Web + */ +class Build +{ + public function formatPluginName($name) + { + return str_replace('Php', 'PHP', ucwords(str_replace('_', ' ', $name))); + } +} diff --git a/PHPCI/View/Build/view.phtml b/PHPCI/View/Build/view.phtml index f57a1a45..25ea8809 100644 --- a/PHPCI/View/Build/view.phtml +++ b/PHPCI/View/Build/view.phtml @@ -4,21 +4,20 @@
-
-
-
-
+
diff --git a/PHPCI/View/BuildsTable.phtml b/PHPCI/View/BuildsTable.phtml index 34a5ca72..aa177832 100644 --- a/PHPCI/View/BuildsTable.phtml +++ b/PHPCI/View/BuildsTable.phtml @@ -48,28 +48,20 @@ switch($build->getStatus()) $plugins = array(); } if ( 0 === count($plugins) ) { - ?> - - - - $pluginstatus): $subcls = $pluginstatus?'label label-success':'label label-important'; - ?> - - - - + ?> Build()->formatPluginName($plugin); ?>
- View + View User()->getIsAdmin()): ?> -
-
-
-
-
+ +
+

Project Overview

@@ -49,7 +50,7 @@ - + @@ -66,7 +67,7 @@ - + diff --git a/PHPCI/View/Project/view.phtml b/PHPCI/View/Project/view.phtml index 77d488fc..3067f5ed 100644 --- a/PHPCI/View/Project/view.phtml +++ b/PHPCI/View/Project/view.phtml @@ -3,13 +3,13 @@
-
-
-
-
+
Last Success Last Failure Success/Failures
Commit Branch Status
@@ -49,7 +48,7 @@ - + @@ -59,7 +58,7 @@
    '; + print '
      '; $pages = ceil($total / 10); $pages = $pages == 0 ? 1 : $pages; diff --git a/PHPCI/View/ProjectForm.phtml b/PHPCI/View/ProjectForm.phtml index e52cbd9e..d683bff1 100644 --- a/PHPCI/View/ProjectForm.phtml +++ b/PHPCI/View/ProjectForm.phtml @@ -3,7 +3,7 @@
    -
    +

    To make it easier to get started, we've generated a public / private key pair for you to use for this project. To use it, just add the following public key to the "deploy keys" section of your repository settings on Github / Bitbucket.

    @@ -16,8 +16,8 @@
    -
    - +
    +
    diff --git a/PHPCI/View/SummaryTable.phtml b/PHPCI/View/SummaryTable.phtml index 3db900b2..416f61e0 100644 --- a/PHPCI/View/SummaryTable.phtml +++ b/PHPCI/View/SummaryTable.phtml @@ -109,6 +109,6 @@ foreach($projects as $projectId => $project):
- + \ No newline at end of file diff --git a/PHPCI/View/layout.phtml b/PHPCI/View/layout.phtml index 2db749d3..30d789d5 100644 --- a/PHPCI/View/layout.phtml +++ b/PHPCI/View/layout.phtml @@ -15,19 +15,27 @@ ').addClass(data.plugins[plugin] ? 'success' : 'error'); - var name = $('
Commit Branch Status
/buildbuild now »
').html('' + plugin + ''); + var name = $('').html('' + formatPluginName(plugin) + ''); var status = $('').text(data.plugins[plugin] ? 'OK' : 'Failed'); row.append(name); @@ -168,4 +168,19 @@ function setupProjectForm() $('#element-token').val(''); } }); +} + + +function formatPluginName (name) { + name = name.replace(new RegExp('_', 'g'), ' '); + name = ucwords(name); + name = name.replace(new RegExp('Php', 'g'), 'PHP'); + + return name; +} + +function ucwords (str) { + return (str + '').replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function ($1) { + return $1.toUpperCase(); + }); } \ No newline at end of file diff --git a/index.php b/index.php index b4685c7d..a0b81e9d 100644 --- a/index.php +++ b/index.php @@ -16,3 +16,4 @@ require_once('bootstrap.php'); $fc = new PHPCI\Application($config, new b8\Http\Request()); print $fc->handleRequest(); + From eac86ff2bd6d06699bffcd16c11d271cfd536e5e Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Wed, 31 Jul 2013 21:04:34 +0100 Subject: [PATCH 12/14] Finishing updates to make PHPCI use Bootstrap v3, as per issue #99 --- PHPCI/Controller/ProjectController.php | 15 ++++++++++----- PHPCI/Controller/SessionController.php | 2 ++ PHPCI/Controller/UserController.php | 10 +++++++--- PHPCI/View/ProjectForm.phtml | 2 +- PHPCI/View/User/index.phtml | 16 +++++++--------- PHPCI/View/UserForm.phtml | 4 ++-- bootstrap.php | 23 ----------------------- 7 files changed, 29 insertions(+), 43 deletions(-) diff --git a/PHPCI/Controller/ProjectController.php b/PHPCI/Controller/ProjectController.php index bd11f846..3406cbd6 100644 --- a/PHPCI/Controller/ProjectController.php +++ b/PHPCI/Controller/ProjectController.php @@ -262,13 +262,15 @@ class ProjectController extends \PHPCI\Controller $field->setPattern('^(github|bitbucket|remote|local)'); $field->setOptions($options); $field->setLabel('Where is your project hosted?'); - $field->setClass('col-lg-4 form-control'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $form->addField($field); if (isset($_SESSION['github_token'])) { $field = new Form\Element\Select('github'); $field->setLabel('Choose a Github repository:'); - $field->setClass('col-lg-4 form-control'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $field->setOptions($this->getGithubRepositories()); $form->addField($field); } @@ -302,19 +304,22 @@ class ProjectController extends \PHPCI\Controller $field->setRequired(true); $field->setValidator($referenceValidator); $field->setLabel('Repository Name / URL (Remote) or Path (Local)'); - $field->setClass('col-lg-4 form-control'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Text('title'); $field->setRequired(true); $field->setLabel('Project Title'); - $field->setClass('col-lg-4 form-control'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\TextArea('key'); $field->setRequired(false); $field->setLabel('Private key to use to access repository (leave blank for local and/or anonymous remotes)'); - $field->setClass('col-lg-7 form-control'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $field->setRows(6); $form->addField($field); diff --git a/PHPCI/Controller/SessionController.php b/PHPCI/Controller/SessionController.php index 4dd87d81..af13cfc4 100644 --- a/PHPCI/Controller/SessionController.php +++ b/PHPCI/Controller/SessionController.php @@ -48,12 +48,14 @@ class SessionController extends \PHPCI\Controller $email->setLabel('Email Address'); $email->setRequired(true); $email->setContainerClass('form-group'); + $email->setClass('form-control'); $form->addField($email); $pwd = new b8\Form\Element\Password('password'); $pwd->setLabel('Password'); $pwd->setRequired(true); $pwd->setContainerClass('form-group'); + $pwd->setClass('form-control'); $form->addField($pwd); $pwd = new b8\Form\Element\Submit(); diff --git a/PHPCI/Controller/UserController.php b/PHPCI/Controller/UserController.php index 92f1ed46..c866fc52 100644 --- a/PHPCI/Controller/UserController.php +++ b/PHPCI/Controller/UserController.php @@ -135,25 +135,29 @@ class UserController extends \PHPCI\Controller $field = new Form\Element\Email('email'); $field->setRequired(true); $field->setLabel('Email Address'); - $field->setClass('span4'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Text('name'); $field->setRequired(true); $field->setLabel('Name'); - $field->setClass('span4'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Password('password'); $field->setRequired(true); $field->setLabel('Password' . ($type == 'edit' ? ' (leave blank to keep current password)' : '')); - $field->setClass('span4'); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Checkbox('admin'); $field->setRequired(false); $field->setCheckedValue(1); $field->setLabel('Is this user an administrator?'); + $field->setContainerClass('form-group'); $form->addField($field); $field = new Form\Element\Submit(); diff --git a/PHPCI/View/ProjectForm.phtml b/PHPCI/View/ProjectForm.phtml index d683bff1..f5c43e77 100644 --- a/PHPCI/View/ProjectForm.phtml +++ b/PHPCI/View/ProjectForm.phtml @@ -17,7 +17,7 @@
- +
diff --git a/PHPCI/View/User/index.phtml b/PHPCI/View/User/index.phtml index 9ac17fe7..318cfad6 100644 --- a/PHPCI/View/User/index.phtml +++ b/PHPCI/View/User/index.phtml @@ -3,25 +3,23 @@
-
-
-
-
+
- + @@ -47,8 +45,8 @@ @@ -71,4 +71,4 @@ switch($build->getStatus()) - \ No newline at end of file + diff --git a/PHPCI/View/SummaryTable.phtml b/PHPCI/View/SummaryTable.phtml index 416f61e0..d927e6af 100644 --- a/PHPCI/View/SummaryTable.phtml +++ b/PHPCI/View/SummaryTable.phtml @@ -60,12 +60,12 @@ foreach($projects as $projectId => $project): switch($project['lastbuildstatus']) { case 0: - $cls = 'info'; + $cls = 'active'; $status = 'Pending'; break; case 1: - $cls = 'warning'; + $cls = 'danger'; $status = 'Running'; break; @@ -81,7 +81,7 @@ foreach($projects as $projectId => $project): } $health = ($project['health'] <= 0 ? 'Stormy': ($project['successes'] < $project['count']? 'Overcast': 'Sunny')); - $subcls = ($project['health'] <= 0 ? 'important': ($project['successes'] < $project['count']? 'warning': 'success')); + $subcls = ($project['health'] <= 0 ? 'danger': ($project['successes'] < $project['count']? 'warning': 'success')); ?> - \ No newline at end of file + diff --git a/PHPCI/View/User/index.phtml b/PHPCI/View/User/index.phtml index 318cfad6..aacffcf0 100644 --- a/PHPCI/View/User/index.phtml +++ b/PHPCI/View/User/index.phtml @@ -60,4 +60,4 @@
Email Address Name Administrator
User()->getIsAdmin()): ?>
- Edit -
-
+

Fill in the form to the right to add a new user.

@@ -12,7 +12,7 @@
-
+
\ No newline at end of file diff --git a/bootstrap.php b/bootstrap.php index 9cd035e9..175bba00 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -43,29 +43,6 @@ $conf['b8']['view']['path'] = dirname(__FILE__) . '/PHPCI/View/'; $config = new b8\Config($conf); -if (file_exists(APPLICATION_PATH . 'config.php')) { - require(APPLICATION_PATH . 'config.php'); - - $conf = $config->get(null); - unset($conf['b8']['app']); - unset($conf['b8']['view']); - - $conf['phpci']['url'] = $conf['install_url']; - - if (isset($conf['github_app'])) { - $conf['phpci']['github'] = $conf['github_app']; - } - - unset($conf['install_url']); - unset($conf['github_app']); - - $dumper = new Symfony\Component\Yaml\Dumper(); - $yaml = $dumper->dump($conf); - - file_put_contents(APPLICATION_PATH . 'PHPCI/config.yml', $yaml); - unlink(APPLICATION_PATH . 'config.php'); -} - if (file_exists(APPLICATION_PATH . 'PHPCI/config.yml')) { $config->loadYaml(APPLICATION_PATH . 'PHPCI/config.yml'); From 9bb21fc01a471a4bb5d6b5e9bed76ea5da7ff76c Mon Sep 17 00:00:00 2001 From: Alex Russell Date: Thu, 1 Aug 2013 16:37:21 +0100 Subject: [PATCH 13/14] Fixed bootstrap table and label classes (mainly the danger ones) --- PHPCI/View/BuildsTable.phtml | 10 +++++----- PHPCI/View/SummaryTable.phtml | 8 ++++---- PHPCI/View/User/index.phtml | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PHPCI/View/BuildsTable.phtml b/PHPCI/View/BuildsTable.phtml index aa177832..98cdce91 100644 --- a/PHPCI/View/BuildsTable.phtml +++ b/PHPCI/View/BuildsTable.phtml @@ -10,7 +10,7 @@ switch($build->getStatus()) { case 0: - $cls = 'info'; + $cls = 'active'; $subcls = 'info'; $status = 'Pending'; @@ -29,8 +29,8 @@ switch($build->getStatus()) break; case 3: - $cls = 'error'; - $subcls = 'important'; + $cls = 'danger'; + $subcls = 'danger'; $status = 'Failed'; break; } @@ -53,7 +53,7 @@ switch($build->getStatus()) ?> $pluginstatus): - $subcls = $pluginstatus?'label label-success':'label label-important'; + $subcls = $pluginstatus?'label label-success':'label label-danger'; ?> Build()->formatPluginName($plugin); ?>
@@ -111,4 +111,4 @@ foreach($projects as $projectId => $project): / build now »
-
\ No newline at end of file +
From 0723c5d964fa9dd4e436f1e8aed254887f3abb4f Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Fri, 2 Aug 2013 08:54:28 +0100 Subject: [PATCH 14/14] Updating PHPCI to use its new logo --- PHPCI/Controller/SessionController.php | 2 +- PHPCI/View/Session/login.phtml | 56 +++++++++++++++++++++---- PHPCI/View/layout.phtml | 2 +- public/assets/css/phpci.css | 4 ++ public/assets/img/logo-large.png | Bin 0 -> 4373 bytes public/assets/img/logo.png | Bin 0 -> 1711 bytes 6 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 public/assets/img/logo-large.png create mode 100644 public/assets/img/logo.png diff --git a/PHPCI/Controller/SessionController.php b/PHPCI/Controller/SessionController.php index af13cfc4..06773305 100644 --- a/PHPCI/Controller/SessionController.php +++ b/PHPCI/Controller/SessionController.php @@ -59,7 +59,7 @@ class SessionController extends \PHPCI\Controller $form->addField($pwd); $pwd = new b8\Form\Element\Submit(); - $pwd->setValue('Login »'); + $pwd->setValue('Log in »'); $pwd->setClass('btn-success'); $form->addField($pwd); diff --git a/PHPCI/View/Session/login.phtml b/PHPCI/View/Session/login.phtml index 4d48892e..168d9625 100644 --- a/PHPCI/View/Session/login.phtml +++ b/PHPCI/View/Session/login.phtml @@ -1,7 +1,7 @@ - Log in + Log in to PHPCI @@ -11,39 +11,77 @@
+
- +
diff --git a/PHPCI/View/layout.phtml b/PHPCI/View/layout.phtml index 30d789d5..7dda7489 100644 --- a/PHPCI/View/layout.phtml +++ b/PHPCI/View/layout.phtml @@ -22,7 +22,7 @@ - PHPCI 1.0 Beta +