diff --git a/index.php b/index.php index d1cde36..3365d34 100644 --- a/index.php +++ b/index.php @@ -8,6 +8,10 @@ use Steampixel\Route; $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); +function getSubdir(): string { + return $_ENV['APP_SUBDIR'] ? $_ENV['APP_SUBDIR'] : '/'; +} + function getApi(array $proxy_elements): \Sovit\TikTok\Api { $options = []; // Proxy config @@ -23,6 +27,11 @@ function getApi(array $proxy_elements): \Sovit\TikTok\Api { function getLatte(): \Latte\Engine { $latte = new Latte\Engine; $latte->setTempDirectory('./cache/views'); + $latte->addFunction('assets', function (string $name, string $type) { + $subdir = getSubdir(); + $path = "{$subdir}/{$type}/{$name}"; + return $path; + }); return $latte; } @@ -146,5 +155,4 @@ Route::add("/settings", function () use ($proxy_elements) { header('Location: ./home'); }, 'POST'); -$subdir = getenv('APP_SUBDIR'); Route::run($subdir); diff --git a/views/feed.latte b/views/feed.latte index d261312..4de6a3d 100644 --- a/views/feed.latte +++ b/views/feed.latte @@ -48,4 +48,4 @@ - + diff --git a/views/navbar.latte b/views/navbar.latte index c7412f8..35c6da9 100644 --- a/views/navbar.latte +++ b/views/navbar.latte @@ -14,4 +14,4 @@ - + diff --git a/views/trending.latte b/views/trending.latte index 6287d7a..7f5cf2e 100644 --- a/views/trending.latte +++ b/views/trending.latte @@ -6,7 +6,7 @@ Trending - TikTok - + {include 'navbar.latte'} diff --git a/views/user.latte b/views/user.latte index 8d3f64c..371231f 100644 --- a/views/user.latte +++ b/views/user.latte @@ -6,7 +6,7 @@ {$feed->info->detail->user->nickname} - TikTok - + {include 'navbar.latte'}