Handling subdir assets
This commit is contained in:
parent
b33c35db27
commit
5b75dd84f4
10
index.php
10
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);
|
||||
|
|
|
@ -48,4 +48,4 @@
|
|||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../scripts/feed.js"></script>
|
||||
<script src="{assets('feed.js', 'scripts')"></script>
|
||||
|
|
|
@ -14,4 +14,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<script src="./scripts/navbar.js"></script>
|
||||
<script src="{assets('navbar.js', 'scripts')}"></script>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Trending - TikTok</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/bulmaswatch/superhero/bulmaswatch.min.css">
|
||||
<link rel="stylesheet" href="../styles/feed.css">
|
||||
<link rel="stylesheet" href="{assets('feed.css', 'styles')">
|
||||
</head>
|
||||
<body>
|
||||
{include 'navbar.latte'}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>{$feed->info->detail->user->nickname} - TikTok</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/bulmaswatch/superhero/bulmaswatch.min.css">
|
||||
<link rel="stylesheet" href="../styles/feed.css">
|
||||
<link rel="stylesheet" href="{assets('feed.css', 'styles')">
|
||||
</head>
|
||||
<body>
|
||||
{include 'navbar.latte'}
|
||||
|
|
Loading…
Reference in a new issue