Nginx config example and relative path
This commit is contained in:
parent
3dd723309d
commit
477efe8486
25
README.md
25
README.md
|
@ -12,11 +12,36 @@ Then you can run it using for example the PHP Development Server with:
|
||||||
php -S localhost:8080
|
php -S localhost:8080
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
### .env
|
||||||
|
Move the .env.example file to .env and modify it.
|
||||||
|
|
||||||
|
### Apache
|
||||||
|
If you are using Apache you don't have to do anything more
|
||||||
|
|
||||||
|
### Nginx
|
||||||
|
Add the following to your config (you can modify the tiktok-viewer part if you have or not a subdir):
|
||||||
|
```
|
||||||
|
location /tiktok-viewer {
|
||||||
|
return 302 $scheme://$host/tiktok-viewer/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /tiktok-viewer/ {
|
||||||
|
try_files $uri $uri/ /tiktok-viewer/index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /tiktok-viewer/.env {
|
||||||
|
deny all;
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
* Right now there is an error when trying to fetch the desired user, there is already a pull request not merged yet fixing this issue on the TikTokApi repo, you can check it out [here](https://github.com/ssovit/TikTok-API-PHP/pull/43)
|
* Right now there is an error when trying to fetch the desired user, there is already a pull request not merged yet fixing this issue on the TikTokApi repo, you can check it out [here](https://github.com/ssovit/TikTok-API-PHP/pull/43)
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
* Allow searching for just one video using the ID
|
* Allow searching for just one video using the ID
|
||||||
|
* Code cleanup
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
* [TikTok-API-PHP](https://github.com/ssovit/TikTok-API-PHP)
|
* [TikTok-API-PHP](https://github.com/ssovit/TikTok-API-PHP)
|
||||||
|
|
10
index.php
10
index.php
|
@ -9,7 +9,7 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||||
$dotenv->load();
|
$dotenv->load();
|
||||||
|
|
||||||
function getSubdir(): string {
|
function getSubdir(): string {
|
||||||
return $_ENV['APP_SUBDIR'] ? $_ENV['APP_SUBDIR'] : '/';
|
return $_ENV['APP_SUBDIR'] ? $_ENV['APP_SUBDIR'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getApi(array $proxy_elements): \Sovit\TikTok\Api {
|
function getApi(array $proxy_elements): \Sovit\TikTok\Api {
|
||||||
|
@ -25,13 +25,17 @@ function getApi(array $proxy_elements): \Sovit\TikTok\Api {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLatte(): \Latte\Engine {
|
function getLatte(): \Latte\Engine {
|
||||||
|
$subdir = getSubdir();
|
||||||
$latte = new Latte\Engine;
|
$latte = new Latte\Engine;
|
||||||
$latte->setTempDirectory('./cache/views');
|
$latte->setTempDirectory('./cache/views');
|
||||||
$latte->addFunction('assets', function (string $name, string $type) {
|
$latte->addFunction('assets', function (string $name, string $type) use ($subdir) {
|
||||||
$subdir = getSubdir();
|
|
||||||
$path = "{$subdir}/{$type}/{$name}";
|
$path = "{$subdir}/{$type}/{$name}";
|
||||||
return $path;
|
return $path;
|
||||||
});
|
});
|
||||||
|
$latte->addFunction('path', function (string $name) use ($subdir) {
|
||||||
|
$path = "{$subdir}/{$name}";
|
||||||
|
return $path;
|
||||||
|
});
|
||||||
return $latte;
|
return $latte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
<div id="navbar-menu" class="navbar-menu">
|
<div id="navbar-menu" class="navbar-menu">
|
||||||
<div class="navbar-start">
|
<div class="navbar-start">
|
||||||
<a href="./home" class="navbar-item">Home</a>
|
<a href="{path('home')}" class="navbar-item">Home</a>
|
||||||
<a href="./settings" class="navbar-item">Settings</a>
|
<a href="{path('settings')}" class="navbar-item">Settings</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Reference in a new issue