Skip to content

Commit

Permalink
Merge pull request #1138 from NatLibFi/issue1116-generator-meta-tag
Browse files Browse the repository at this point in the history
Add generator meta tag with Skosmos version
  • Loading branch information
osma authored Mar 16, 2021
2 parents 20d994b + 7ca6765 commit e213096
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
2 changes: 0 additions & 2 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
Expand Down
4 changes: 2 additions & 2 deletions model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
7 changes: 7 additions & 0 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions view/about.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<p>{% if ServiceName != 'SERVICE_NAME' %}{{ ServiceName }}{% else %}Skosmos{% endif %} {% trans "layout designed by Hahmo" %}</p>
</div>
<div class="version">
{% set version = request.version %}
<p>{% trans %}Skosmos version {{ version }}{% endtrans %}</p>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions view/meta.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="format-detection" content="telephone=no">
<meta name="generator" content="Skosmos {{ request.version }}" />

0 comments on commit e213096

Please sign in to comment.