Layout system

This commit is contained in:
Pablo Ferreiro 2022-01-25 14:08:31 +01:00
parent ba719e45b2
commit dde4185ad7
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
22 changed files with 228 additions and 274 deletions

21
layouts/default.latte Normal file
View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
{include '../components/head.latte'}
<body>
{include '../components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container has-text-centered">
{block header}{/block}
</div>
</div>
</section>
<section class="section">
{block content}{/block}
</section>
{include '../components/footer.latte'}
</body>
{block extra}{/block}
</html>

23
layouts/hero.latte Normal file
View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
{include '../components/head.latte'}
<body>
<section class="hero is-fullheight">
<div class="hero-head">
{include '../components/navbar.latte'}
</div>
<div class="hero-body">
<div class="container has-text-centered">
{block content}{/block}
</div>
</div>
<div class="hero-foot">
{include '../components/footer.latte'}
</div>
</section>
{block extra}{/block}
</body>
</html>

View file

@ -28,5 +28,9 @@ Route::add('/following', function () {
'hasMore' => false
];
$latte = Misc::latte();
$latte->render(Misc::getView('following'), ['following' => $following, 'feed' => $feed]);
$latte->render(Misc::getView('following'), [
'following' => $following,
'feed' => $feed,
'title' => 'Following'
]);
});

View file

@ -8,12 +8,12 @@ use Helpers\Error;
Route::add('/', function () {
$latte = Misc::latte();
$latte->render(Misc::getView('home'));
$latte->render(Misc::getView('home'), ['title' => 'Home']);
});
Route::add('/about', function () {
$latte = Misc::latte();
$latte->render(Misc::getView('about'));
$latte->render(Misc::getView('about'), ['title' => 'About']);
});
Route::add("/trending", function () {
@ -25,7 +25,10 @@ Route::add("/trending", function () {
$feed = $api->getTrendingFeed($cursor);
if ($feed->meta->success) {
$latte = Misc::latte();
$latte->render(Misc::getView('trending'), ['feed' => $feed]);
$latte->render(Misc::getView('trending'), [
'feed' => $feed,
'title' => 'Trending'
]);
} else {
Error::show($feed->meta);
}
@ -44,7 +47,10 @@ Route::add("/@([^/]+)", function (string $username) {
return 'Private account detected! Not supported';
}
$latte = Misc::latte();
$latte->render(Misc::getView('user'), ['feed' => $feed]);
$latte->render(Misc::getView('user'), [
'feed' => $feed,
'title' => $feed->info->detail->user->nickname
]);
} else {
Error::show($feed->meta);
}
@ -55,7 +61,10 @@ Route::add('/video/([^/]+)', function (string $video_id) {
$item = $api->getVideoByID($video_id);
if ($item->meta->success) {
$latte = Misc::latte();
$latte->render(Misc::getView('video'), ['item' => $item]);
$latte->render(Misc::getView('video'), [
'item' => $item,
'title' => $item->info->detail->user->nickname
]);
} else {
Error::show($item->meta);
}
@ -71,7 +80,10 @@ Route::add('/music/([^/]+)', function (string $music_id) {
$feed = $api->getMusicFeed($music_id, $cursor);
if ($feed->meta->success) {
$latte = Misc::latte();
$latte->render(Misc::getView('music'), ['feed' => $feed]);
$latte->render(Misc::getView('music'), [
'feed' => $feed,
'title' => 'Music'
]);
} else {
Error::show($feed->meta);
}
@ -86,7 +98,10 @@ Route::add('/tag/(\w+)', function (string $name) {
$feed = $api->getChallengeFeed($name, $cursor);
if ($feed->meta->success) {
$latte = Misc::latte();
$latte->render(Misc::getView('tag'), ['feed' => $feed]);
$latte->render(Misc::getView('tag'), [
'feed' => $feed,
'title' => 'Tag'
]);
} else {
Error::show($feed->meta);
}

View file

@ -7,7 +7,11 @@ use Steampixel\Route;
Route::add("/settings", function () {
$latte = Misc::latte();
$latte->render(Misc::getView('settings'), ["proxy_elements" => Settings::PROXY, "following" => Following::get()]);
$latte->render(Misc::getView('settings'), [
"proxy_elements" => Settings::PROXY,
"following" => Following::get(),
"title" => "Settings"
]);
});
Route::add("/settings/proxy", function () {

View file

@ -1,20 +1,9 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/default.latte'}
{include 'components/head.latte', title: 'About'}
<body>
{include 'components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container">
{block header}
<p class="title">About</p>
</div>
</div>
</section>
<section class="section">
{/block}
{block content}
<p>TODO</p>
</section>
{include 'components/footer.latte'}
</body>
</html>
{/block}

View file

@ -1,25 +1,9 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/hero.latte'}
{include 'components/head.latte', title: 'ERROR'}
<body>
<section class="hero is-danger is-fullheight">
<div class="hero-head">
{include 'components/navbar.latte'}
</div>
<div class="hero-body">
<div class="container">
{block content}
<p class="title">There was an error processing your request!</p>
<p class="subtitle">HTTP Code: {$error->http_code}</p>
{if $error->tiktok_code}
<p class="subtitle">API error code {$error->tiktok_code} ({$error->tiktok_msg})</p>
{/if}
</div>
</div>
<div class="hero-foot is-danger">
{include 'components/footer.latte'}
</div>
</section>
</body>
</html>
{/block}

View file

@ -1,24 +1,13 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/default.latte'}
{include 'components/head.latte', title: 'Following'}
<body>
{include 'components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container has-text-centered">
{block header}
<p class="title">Following</p>
</div>
</div>
</section>
<section class="section">
{/block}
{block content}
<p class="title">Following:</p>
{include 'components/following_tags.latte'}
{include '../components/following_tags.latte'}
<p>You can add/remove follows on settings</p>
</section>
<hr />
{include 'components/feed.latte'}
{include 'components/footer.latte'}
</body>
</html>
{include '../components/feed.latte'}
{/block}

View file

@ -1,15 +1,6 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/hero.latte'}
{include 'components/head.latte', title: 'Home'}
<body>
<section class="hero is-fullheight">
<div class="hero-head">
{include 'components/navbar.latte'}
</div>
<div class="hero-body">
<div class="container has-text-centered">
{block content}
<p class="title">Welcome to ProxiTok!</p>
<p class="subtitle">An alternative open source frontend for TikTok</p>
<p>Search user:</p>
@ -62,13 +53,8 @@
<hr />
<p>Trending:</p>
<a class="button is-success" href="./trending">Go</a>
</div>
</div>
<div class="hero-foot">
{include 'components/footer.latte'}
</div>
</section>
<script src="{assets('home.js', 'scripts')}"></script>
</body>
{/block}
</html>
{block extra}
<script src="{assets('home.js', 'scripts')}"></script>
{/block}

View file

@ -1,20 +1,11 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/default.latte'}
{include 'components/head.latte', title: 'Music'}
<body>
{include 'components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container has-text-centered">
{block header}
<p class="title">{$feed->info->detail->music->title}</p>
<p class="subtitle">{$feed->info->detail->music->desc}</p>
<p>Videos: {number($feed->info->detail->stats->videoCount)}</p>
</div>
</div>
</section>
{include 'components/feed.latte'}
{include 'components/footer.latte'}
</body>
</html>
{/block}
{block content}
{include '../components/feed.latte'}
{/block}

View file

@ -1,26 +1,15 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/default.latte'}
{include 'components/head.latte', title: 'Settings'}
<body>
{include 'components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container">
{block header}
<p class="title">Settings</p>
</div>
</div>
</section>
<section class="section">
{/block}
{block content}
<!-- Proxy settings -->
<p class="title">Proxy</p>
{include 'components/settings/proxy.latte'}
{include '../components/settings/proxy.latte'}
<hr />
<!-- Following -->
<p class="title">Following</p>
{include 'components/settings/following.latte'}
</section>
{include 'components/footer.latte'}
</body>
</html>
{include '../components/settings/following.latte'}
{/block}

View file

@ -1,20 +1,11 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/default.latte'}
{include 'components/head.latte', title: 'Tag'}
<body>
{include 'components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container has-text-centered">
{block header}
<p class="title">{$feed->info->detail->challenge->title}</p>
<p class="subtitle">{$feed->info->detail->challenge->desc}</p>
<p>Videos: {number($feed->info->detail->stats->videoCount)} / Views: {number($feed->info->detail->stats->viewCount)}</p>
</div>
</div>
</section>
{include 'components/feed.latte'}
{include 'components/footer.latte'}
</body>
</html>
{/block}
{block content}
{include '../components/feed.latte'}
{/block}

View file

@ -1,18 +1,9 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/default.latte'}
{include 'components/head.latte', title: 'Trending'}
<body>
{include 'components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container has-text-centered">
{block header}
<p class="title">Trending</p>
</div>
</div>
</section>
{include 'components/feed.latte'}
{include 'components/footer.latte'}
</body>
</html>
{/block}
{block content}
{include '../components/feed.latte'}
{/block}

View file

@ -1,13 +1,6 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/default.latte'}
{include 'components/head.latte', title: $feed->info->detail->user->nickname}
<body>
{include 'components/navbar.latte'}
<section class="hero is-primary">
<div class="hero-body">
<div class="container has-text-centered">
{block header}
<figure class="figure is-96x96">
<img src="{path('stream?url=' . urlencode($feed->info->detail->user->avatarThumb))}" />
</figure>
@ -15,10 +8,8 @@
<p class="subtitle">{$feed->info->detail->user->signature}</p>
<p>Following: {number($feed->info->detail->stats->followingCount)} / Followers: {number($feed->info->detail->stats->followerCount)}</p>
<p>Hearts: {number($feed->info->detail->stats->heartCount)} / Videos: {$feed->info->detail->stats->videoCount}</p>
</div>
</div>
</section>
{include 'components/feed.latte'}
{include 'components/footer.latte'}
</body>
</html>
{/block}
{block content}
{include '../components/feed.latte'}
{/block}

View file

@ -1,20 +1,12 @@
<!DOCTYPE html>
<html lang="en">
{layout '../layouts/hero.latte'}
{include 'components/head.latte', title: $item->info->detail->user->nickname}
<body>
<section class="hero is-fullheight">
<div class="hero-head">
{include 'components/navbar.latte'}
</div>
<div class="hero-body">
<div class="columns">
<div class="column has-text-centered">
{block content}
<div class="columns is-centered is-vcentered">
<div class="column">
<video autoplay controls src="{path('stream?url=' . urlencode($item->items[0]->video->playAddr))}"></video>
</div>
<div class="column is-one-quarter">
<div class="box container">
<div class="column has-text-centered">
<div class="box">
<p class="title">Video by <a href="{path('@'.$item->info->detail->user->uniqueId)}">{$item->info->detail->user->uniqueId}</a></p>
<p class="subtitle">{$item->items[0]->desc}</p>
<p>Played {number($item->info->detail->stats->playCount)} times</p>
@ -26,10 +18,4 @@
</div>
</div>
</div>
</div>
<div class="hero-foot">
{include 'components/footer.latte'}
</div>
</section>
</body>
</html>
{/block}