From e724504610fa68fdb1fb7b9effba2fea8789da9a Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Thu, 25 Aug 2016 22:54:06 +0700 Subject: [PATCH] Improved status action (shield.io image) and docs --- docs/en/status.md | 12 ++++++++++ .../Controller/BuildStatusController.php | 22 +++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/en/status.md b/docs/en/status.md index 1408a195..2af6466a 100644 --- a/docs/en/status.md +++ b/docs/en/status.md @@ -9,6 +9,16 @@ Most Continuous Integration systems provide a simple image URL that you can use You can find the status image at the following location: `http://{PHP_CENSOR_URL}/build-status/image/{PROJECT ID}` So for example, our instance of PHP Censor is at `php-censor.local`, and our PHP Censor project ID is `2`, so the image URL is: `http://php-censor.local/build-status/image/2`. +You can use additional parameters: + +* style: plastic | flat (default) | flat-squared | social +* label: build (default) +* logo +* logoWidth +* link +* maxAge + +[See more on shields.io site](http://shields.io) Example: @@ -25,10 +35,12 @@ Example: http://php-censor.local/build-status/view/2 ### Where do I find my project ID? + Go to your instance of PHP Censor, and open the project you are interested in. The project ID is the number in the last part of the URL in your browser. Example: http://php-censor.local/project/view/2 ~> PROJECT ID: `2` ### Enable/disable status image and page + You can enable or disable access to the public status image and page in your project's settings. diff --git a/src/PHPCensor/Controller/BuildStatusController.php b/src/PHPCensor/Controller/BuildStatusController.php index ec972419..a9d44523 100644 --- a/src/PHPCensor/Controller/BuildStatusController.php +++ b/src/PHPCensor/Controller/BuildStatusController.php @@ -127,12 +127,20 @@ class BuildStatusController extends Controller } /** - * Returns the appropriate build status image in SVG format for a given project. - */ + * Returns the appropriate build status image in SVG format for a given project. + */ public function image($projectId) { - $style = $this->getParam('style', 'plastic'); - $label = $this->getParam('label', 'build'); + // plastic|flat|flat-squared|social + $style = $this->getParam('style', 'flat'); + $label = $this->getParam('label', 'build'); + + $optionalParams = [ + 'logo' => $this->getParam('logo'), + 'logoWidth' => $this->getParam('logoWidth'), + 'link' => $this->getParam('link'), + 'maxAge' => $this->getParam('maxAge'), + ]; $status = $this->getStatus($projectId); @@ -150,6 +158,12 @@ class BuildStatusController extends Controller $color, $style )); + + foreach ($optionalParams as $paramName => $param) { + if ($param) { + $image .= '&' . $paramName . '=' . $param; + } + } $this->response->disableLayout(); $this->response->setHeader('Content-Type', 'image/svg+xml');