refactor: blogs_list page with bs5
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-09-26 20:55:56 +08:00
parent b779362412
commit 27387a0dea
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
4 changed files with 68 additions and 3 deletions

View File

@ -9,10 +9,16 @@
become403Page(); become403Page();
} }
if (!isset($_COOKIE['bootstrap4'])) {
$REQUIRE_LIB['bootstrap5'] = '';
}
function echoBlogCell($blog) { function echoBlogCell($blog) {
global $REQUIRE_LIB;
echo '<tr>'; echo '<tr>';
if ($blog['is_hidden']) { if ($blog['is_hidden']) {
echo '<td><span class="text-danger">[已隐藏]</span>' . getBlogLink($blog['id']) . '</td>'; echo '<td><span class="text-danger">[已隐藏]</span> ' . getBlogLink($blog['id']) . '</td>';
} else { } else {
echo '<td>' . getBlogLink($blog['id']) . '</td>'; echo '<td>' . getBlogLink($blog['id']) . '</td>';
} }
@ -29,8 +35,21 @@
EOD; EOD;
$config = array(); $config = array();
$config['table_classes'] = array('table', 'table-hover'); $config['table_classes'] = array('table', 'table-hover');
if (isset($REQUIRE_LIB['bootstrap5'])) {
$config['div_classes'] = array('card', 'my-3');
$config['table_classes'] = array('table', 'uoj-table', 'mb-0');
}
?> ?>
<?php echoUOJPageHeader(UOJLocale::get('blogs')) ?> <?php echoUOJPageHeader(UOJLocale::get('blogs')) ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="row">
<div class="col-sm-12 col-md-9">
<div class="d-flex flex-wrap justify-content-between">
<?php endif ?>
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
<?php if (Auth::check()): ?> <?php if (Auth::check()): ?>
<div class="float-right"> <div class="float-right">
<div class="btn-group"> <div class="btn-group">
@ -39,6 +58,41 @@ EOD;
</div> </div>
</div> </div>
<?php endif ?> <?php endif ?>
<?php endif ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<h1 class="h2">
<?= UOJLocale::get("blogs overview") ?>
</h1>
<div class="text-end">
<div class="btn-group">
<a href="<?= HTML::blog_url(Auth::id(), '/') ?>" class="btn btn-secondary btn-sm">
我的博客首页
</a>
<a href="<?= HTML::blog_url(Auth::id(), '/post/new/write')?>" class="btn btn-primary btn-sm">
<i class="bi bi-pencil"></i>
写新博客
</a>
</div>
</div>
<?php else: ?>
<h3>博客总览</h3> <h3>博客总览</h3>
<?php endif ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
<?php endif ?>
<?php echoLongTable(array('id', 'poster', 'title', 'post_time', 'zan', 'is_hidden'), 'blogs', isSuperUser($myUser) ? "1" : "is_hidden = 0 or poster = '{$myUser['username']}'", 'order by post_time desc', $header, 'echoBlogCell', $config); ?> <?php echoLongTable(array('id', 'poster', 'title', 'post_time', 'zan', 'is_hidden'), 'blogs', isSuperUser($myUser) ? "1" : "is_hidden = 0 or poster = '{$myUser['username']}'", 'order by post_time desc', $header, 'echoBlogCell', $config); ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
<aside class="col mt-3 mt-md-0">
<?php uojIncludeView('sidebar', array()) ?>
</aside>
</div>
<?php endif ?>
<?php echoUOJPageFooter() ?> <?php echoUOJPageFooter() ?>

View File

@ -145,9 +145,18 @@ function getContestProblemLink($problem, $contest_id, $problem_title = '!title_o
return $result; return $result;
} }
function getBlogLink($id) { function getBlogLink($id) {
global $REQUIRE_LIB;
$result = '';
if (validateUInt($id) && $blog = queryBlog($id)) { if (validateUInt($id) && $blog = queryBlog($id)) {
return '<a href="/blogs/'.$id.'">'.$blog['title'].'</a>'; $result = '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
$result .= ' class="text-decoration-none" ';
}
$result .= ' href="/blogs/'.$id.'">'.$blog['title'].'</a>';
} }
return $result;
} }
function getClickZanBlock($type, $id, $cnt, $val = null) { function getClickZanBlock($type, $id, $cnt, $val = null) {
if ($val == null) { if ($val == null) {

View File

@ -18,6 +18,7 @@ return [
'submissions' => 'Submissions', 'submissions' => 'Submissions',
'hacks' => 'Hack!', 'hacks' => 'Hack!',
'blogs' => 'Blogs', 'blogs' => 'Blogs',
'blogs overview' => 'Blogs Overview',
'announcements' => 'Announcements', 'announcements' => 'Announcements',
'all the announcements' => 'All the Announcements……', 'all the announcements' => 'All the Announcements……',
'solved' => 'Solved', 'solved' => 'Solved',

View File

@ -18,6 +18,7 @@ return [
'submissions' => '提交记录', 'submissions' => '提交记录',
'hacks' => 'Hack!', 'hacks' => 'Hack!',
'blogs' => '博客', 'blogs' => '博客',
'blogs overview' => '博客总览',
'announcements' => '公告', 'announcements' => '公告',
'all the announcements' => '所有公告……', 'all the announcements' => '所有公告……',
'solved' => 'AC 数', 'solved' => 'AC 数',