diff --git a/controller/WebController.php b/controller/WebController.php index bf6e50eea..afd972b56 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -305,12 +305,10 @@ public function invokeAboutPage($request) $template = $this->twig->loadTemplate('about.twig'); $this->setLanguageProperties($request->getLang()); $url = $request->getServerConstant('HTTP_HOST'); - $version = $this->model->getVersion(); echo $template->render( array( 'languages' => $this->languages, - 'version' => $version, 'server_instance' => $url, 'request' => $request, )); diff --git a/model/Model.php b/model/Model.php index a3cc27383..4230ec8e0 100644 --- a/model/Model.php +++ b/model/Model.php @@ -74,11 +74,11 @@ public function getLogger() { * it cannot be determined. The version information is based on Git tags. * @return string version */ - public function getVersion() + public function getVersion() : string { $ver = null; if (file_exists('.git')) { - $ver = shell_exec('git describe --tags --always'); + $ver = rtrim(shell_exec('git describe --tags --always')); } if ($ver === null) { diff --git a/model/Request.php b/model/Request.php index 24d73ac0f..a8bee1558 100644 --- a/model/Request.php +++ b/model/Request.php @@ -266,4 +266,14 @@ public function getPlugins() { } return new PluginRegister($this->model->getConfig()->getGlobalPlugins()); } + + /** + * Return the version of this Skosmos installation, or "unknown" if + * it cannot be determined. The version information is based on Git tags. + * @return string version + */ + public function getVersion() : string + { + return $this->model->getVersion(); + } } diff --git a/tests/RequestTest.php b/tests/RequestTest.php index b816bd705..7a432f750 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -158,4 +158,11 @@ public function testSetAndGetPage() { $this->assertEquals('index', $this->request->getPage()); } + /** + * @covers Request::getVersion + */ + public function testGetVersion() { + $version = $this->request->getVersion(); + $this->assertNotEmpty($version); + } } diff --git a/view/about.twig b/view/about.twig index 7bc8f6dca..8057e9989 100644 --- a/view/about.twig +++ b/view/about.twig @@ -15,6 +15,7 @@
{% if ServiceName != 'SERVICE_NAME' %}{{ ServiceName }}{% else %}Skosmos{% endif %} {% trans "layout designed by Hahmo" %}
{% trans %}Skosmos version {{ version }}{% endtrans %}