From 330356043df8e9c08fb3a408c74fe54bc2b9813d Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Fri, 21 Dec 2018 23:12:04 +0100 Subject: [PATCH] credits: Allow customization --- config/config.default.php | 7 ++++ resources/views/pages/credits.twig | 34 +++++++------------ src/Controllers/CreditsController.php | 16 +++++++-- .../Controllers/CreditsControllerTest.php | 6 ++-- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index 219ac56b..8467e144 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -163,4 +163,11 @@ return [ //'Strict-Transport-Security' => 'max-age=7776000', //'Expect-CT' => 'max-age=7776000,enforce,report-uri="[uri]"', ], + + // A list of credits + 'credits' => [ + 'Contribution' => 'Please visit [engelsystem/engelsystem](https://github.com/engelsystem/engelsystem) if ' + . 'you want to to contribute, have found any [bugs](https://github.com/engelsystem/engelsystem/issues) ' + . 'or need help.' + ] ]; diff --git a/resources/views/pages/credits.twig b/resources/views/pages/credits.twig index ff2bf873..eb98c7e7 100644 --- a/resources/views/pages/credits.twig +++ b/resources/views/pages/credits.twig @@ -6,35 +6,25 @@

Credits

+ {% for title, credit in credits %} +
+

{{ title }}

+ {{ credit|markdown }} +
+ {% endfor %} +

Source code

- The original system was written by cookie. + The original engelsystem was written by + cookie. It was then completely rewritten and enhanced by - msquare (maintainer), - MyIgel, - mortzu, - jplitza and - gnomus. + msquare (maintainer) and + MyIgel.

Please look at the - contributor list on github for a more complete version. -

-
-
-

Hosting

-

- Webspace, development platform and domain on engelsystem.de - is currently provided by would you buy this? (ichdasich) - and adminstrated by mortzu, - derf and ichdasich. -

-
-
-

Translation

-

- Many thanks for the german translation: e7p + contributor list on GitHub for a complete list.

diff --git a/src/Controllers/CreditsController.php b/src/Controllers/CreditsController.php index 568811c7..b2805b84 100644 --- a/src/Controllers/CreditsController.php +++ b/src/Controllers/CreditsController.php @@ -2,15 +2,24 @@ namespace Engelsystem\Controllers; +use Engelsystem\Config\Config; use Engelsystem\Http\Response; class CreditsController extends BaseController { + /** @var Config */ + protected $config; + /** @var Response */ protected $response; - public function __construct(Response $response) + /** + * @param Response $response + * @param Config $config + */ + public function __construct(Response $response, Config $config) { + $this->config = $config; $this->response = $response; } @@ -19,6 +28,9 @@ class CreditsController extends BaseController */ public function index() { - return $this->response->withView('pages/credits.twig'); + return $this->response->withView( + 'pages/credits.twig', + ['credits' => $this->config->get('credits')] + ); } } diff --git a/tests/Unit/Controllers/CreditsControllerTest.php b/tests/Unit/Controllers/CreditsControllerTest.php index 6f0200f2..3ce92cb1 100644 --- a/tests/Unit/Controllers/CreditsControllerTest.php +++ b/tests/Unit/Controllers/CreditsControllerTest.php @@ -2,6 +2,7 @@ namespace Unit\Controllers; +use Engelsystem\Config\Config; use Engelsystem\Controllers\CreditsController; use Engelsystem\Http\Response; use PHPUnit\Framework\MockObject\MockObject; @@ -17,12 +18,13 @@ class CreditsControllerTest extends TestCase { /** @var Response|MockObject $response */ $response = $this->createMock(Response::class); + $config = new Config(['foo' => 'bar', 'credits' => ['lor' => 'em']]); $response->expects($this->once()) ->method('withView') - ->with('pages/credits.twig'); + ->with('pages/credits.twig', ['credits' => ['lor' => 'em']]); - $controller = new CreditsController($response); + $controller = new CreditsController($response, $config); $controller->index(); } }