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 = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||||
$dotenv->load();
|
$dotenv->load();
|
||||||
|
|
||||||
|
function getSubdir(): string {
|
||||||
|
return $_ENV['APP_SUBDIR'] ? $_ENV['APP_SUBDIR'] : '/';
|
||||||
|
}
|
||||||
|
|
||||||
function getApi(array $proxy_elements): \Sovit\TikTok\Api {
|
function getApi(array $proxy_elements): \Sovit\TikTok\Api {
|
||||||
$options = [];
|
$options = [];
|
||||||
// Proxy config
|
// Proxy config
|
||||||
|
@ -23,6 +27,11 @@ function getApi(array $proxy_elements): \Sovit\TikTok\Api {
|
||||||
function getLatte(): \Latte\Engine {
|
function getLatte(): \Latte\Engine {
|
||||||
$latte = new Latte\Engine;
|
$latte = new Latte\Engine;
|
||||||
$latte->setTempDirectory('./cache/views');
|
$latte->setTempDirectory('./cache/views');
|
||||||
|
$latte->addFunction('assets', function (string $name, string $type) {
|
||||||
|
$subdir = getSubdir();
|
||||||
|
$path = "{$subdir}/{$type}/{$name}";
|
||||||
|
return $path;
|
||||||
|
});
|
||||||
return $latte;
|
return $latte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,5 +155,4 @@ Route::add("/settings", function () use ($proxy_elements) {
|
||||||
header('Location: ./home');
|
header('Location: ./home');
|
||||||
}, 'POST');
|
}, 'POST');
|
||||||
|
|
||||||
$subdir = getenv('APP_SUBDIR');
|
|
||||||
Route::run($subdir);
|
Route::run($subdir);
|
||||||
|
|
|
@ -48,4 +48,4 @@
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="../scripts/feed.js"></script>
|
<script src="{assets('feed.js', 'scripts')"></script>
|
||||||
|
|
|
@ -14,4 +14,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</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">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>Trending - TikTok</title>
|
<title>Trending - TikTok</title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/bulmaswatch/superhero/bulmaswatch.min.css">
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{include 'navbar.latte'}
|
{include 'navbar.latte'}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>{$feed->info->detail->user->nickname} - TikTok</title>
|
<title>{$feed->info->detail->user->nickname} - TikTok</title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/bulmaswatch/superhero/bulmaswatch.min.css">
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{include 'navbar.latte'}
|
{include 'navbar.latte'}
|
||||||
|
|
Loading…
Reference in a new issue