Skip to content

Commit 872f379

Browse files
ISSUE-117: Improve app.php by using autoloading and twig template
1 parent c8f96aa commit 872f379

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

public/app.php

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,18 @@
22

33
declare(strict_types=1);
44

5+
use Twig\Environment;
6+
use Twig\Loader\FilesystemLoader;
7+
8+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
9+
510
// This is the index that will be used to bootstrap the actual app in /build.
611
$index = dirname(__DIR__).'/build/html/index.html';
712
if (file_exists($index)) {
813
echo file_get_contents($index);
9-
1014
exit(0);
1115
}
1216

13-
echo '<!DOCTYPE html>
14-
<head>
15-
<link href="assets/flowbite/tailwind.min.css" rel="stylesheet"/>
16-
</head>
17-
<body class="bg-gray-50 h-screen flex justify-center items-center">
18-
<div>
19-
<p class="text-2xl font-semibold pb-5">Looks like you still need to import your Strava statistics</p>
20-
21-
<dl class="text-gray-900 divide-y divide-gray-200">
22-
<div class="flex flex-col pb-3">
23-
<dt class="mb-1 text-gray-500 md:text-lg">Import Strava data</dt>
24-
<dd class="font-semibold"><code>docker compose exec app bin/console app:strava:import-data</code></dd>
25-
</div>
26-
<div class="flex flex-col py-3">
27-
<dt class="mb-1 text-gray-500 md:text-lg">Build static HTML files</dt>
28-
<dd class="font-semibold"><code>docker compose exec app bin/console app:strava:build-files</code></dd>
29-
</div>
30-
</dl>
31-
</div>
32-
33-
</body>
34-
</html>';
17+
$twig = new Environment(new FilesystemLoader(dirname(__DIR__).'/templates'));
18+
echo $twig->render('html/setup.html.twig');
19+
exit(0);

templates/html/setup.html.twig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<link href="assets/flowbite/tailwind.min.css" rel="stylesheet"/>
4+
</head>
5+
<body class="bg-gray-50 h-screen flex justify-center items-center">
6+
<div>
7+
<p class="text-2xl font-semibold pb-5">Looks like you still need to import your Strava data</p>
8+
9+
<dl class="text-gray-900 divide-y divide-gray-200">
10+
<div class="flex flex-col pb-3">
11+
<dt class="mb-1 text-gray-500 md:text-lg">Import Strava data</dt>
12+
<dd class="font-semibold"><code>docker compose exec app bin/console app:strava:import-data</code></dd>
13+
</div>
14+
<div class="flex flex-col py-3">
15+
<dt class="mb-1 text-gray-500 md:text-lg">Build static HTML files</dt>
16+
<dd class="font-semibold"><code>docker compose exec app bin/console app:strava:build-files</code></dd>
17+
<dd class="text-gray-500 text-sm">⚠️ You can only build these files if all your Strava data has been imported</dd>
18+
</div>
19+
</dl>
20+
</div>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)