mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 09:38:42 +00:00
refactor: blog_index and blog_archive with bs5
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
40921a5701
commit
0704b85065
@ -5,6 +5,8 @@
|
||||
become403Page(UOJLocale::get('need login'));
|
||||
}
|
||||
|
||||
$REQUIRE_LIB['bootstrap5'] = '';
|
||||
|
||||
$blogs_cond = "poster = '".UOJContext::userid()."'";
|
||||
if (!UOJContext::hasBlogPermission()) {
|
||||
$blogs_cond .= " and is_hidden = false";
|
||||
@ -24,7 +26,7 @@
|
||||
'table_name' => 'blogs',
|
||||
'cond' => $display_blogs_cond,
|
||||
'tail' => 'order by post_time desc',
|
||||
'page_len' => 10
|
||||
'page_len' => 15
|
||||
));
|
||||
|
||||
$all_tags = DB::selectAll("select distinct tag from blogs_tags where blog_id in (select id from blogs where $blogs_cond)");
|
||||
@ -35,14 +37,101 @@
|
||||
<?php echoUOJPageHeader('日志') ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<?php if (!$blog_tag_required): ?>
|
||||
<?php if ($blogs_pag->isEmpty()): ?>
|
||||
<div class="text-muted">此人很懒,什么博客也没留下。</div>
|
||||
<?php else: ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table uoj-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>标题</th>
|
||||
<th style="width: 20%">发表时间</th>
|
||||
<th class="text-center" style="width: 180px">评价</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $cnt = 0 ?>
|
||||
<?php foreach ($blogs_pag->get() as $blog): ?>
|
||||
<?php $cnt++ ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?= getBlogLink($blog['id']) ?>
|
||||
<?php foreach (queryBlogTags($blog['id']) as $tag): ?>
|
||||
<?php echoBlogTag($tag) ?>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<td><?= $blog['post_time'] ?></td>
|
||||
<td><?= getClickZanBlock('B', $blog['id'], $blog['zan']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer bg-transparent text-end text-muted">
|
||||
第 <?= $blogs_pag->cur_start + 1 ?> - <?= $blogs_pag->cur_start + $cnt ?> 篇,共 <?= $blogs_pag->n_rows ?> 篇博客
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<?php if ($blogs_pag->isEmpty()): ?>
|
||||
<div class="alert alert-danger">
|
||||
没有找到包含 “<?= HTML::escape($blog_tag_required) ?>” 标签的博客:
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="alert alert-success">
|
||||
共找到 <?= $blogs_pag->n_rows ?> 篇包含 “<?= HTML::escape($blog_tag_required) ?>” 标签的博客:
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table uoj-table mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>标题</th>
|
||||
<th style="width: 20%">发表时间</th>
|
||||
<th class="text-center" style="width: 180px">评价</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($blogs_pag->get() as $blog): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?= getBlogLink($blog['id']) ?>
|
||||
<?php foreach (queryBlogTags($blog['id']) as $tag): ?>
|
||||
<?php echoBlogTag($tag) ?>
|
||||
<?php endforeach ?>
|
||||
</td>
|
||||
<td><?= $blog['post_time'] ?></td>
|
||||
<td><?= getClickZanBlock('B', $blog['id'], $blog['zan']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="text-center mt-3">
|
||||
<?= $blogs_pag->pagination() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<?php if (UOJContext::hasBlogPermission()): ?>
|
||||
<div class="btn-group d-flex">
|
||||
<a href="<?=HTML::blog_url(UOJContext::userid(), '/post/new/write')?>" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span> 写新博客</a>
|
||||
<a href="<?=HTML::blog_url(UOJContext::userid(), '/slide/new/write')?>" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span> 写新幻灯片</a>
|
||||
<a href="<?= HTML::blog_url(UOJContext::userid(), '/post/new/write') ?>" class="btn btn-primary">
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
写新博客
|
||||
</a>
|
||||
<a href="<?= HTML::blog_url(UOJContext::userid(), '/slide/new/write') ?>" class="btn btn-primary">
|
||||
<i class="bi bi-file-earmark-slides"></i>
|
||||
写新幻灯片
|
||||
</a>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="card border-info top-buffer-sm">
|
||||
<div class="card border-info mt-3">
|
||||
<div class="card-header bg-info">标签</div>
|
||||
<div class="card-body">
|
||||
<?php if ($all_tags): ?>
|
||||
@ -55,32 +144,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<?php if (!$blog_tag_required): ?>
|
||||
<?php if ($blogs_pag->isEmpty()): ?>
|
||||
<div class="text-muted">此人很懒,什么博客也没留下。</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($blogs_pag->get() as $blog): ?>
|
||||
<?php echoBlog($blog, array('is_preview' => true)) ?>
|
||||
<?php endforeach ?>
|
||||
<div class="text-right text-muted">共 <?= $blogs_pag->n_rows ?> 篇博客</div>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<?php if ($blogs_pag->isEmpty()): ?>
|
||||
<div class="alert alert-danger">
|
||||
没有找到包含 “<?= HTML::escape($blog_tag_required) ?>” 标签的博客:
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="alert alert-success">
|
||||
共找到 <?= $blogs_pag->n_rows ?> 篇包含 “<?= HTML::escape($blog_tag_required) ?>” 标签的博客:
|
||||
</div>
|
||||
<?php foreach ($blogs_pag->get() as $blog): ?>
|
||||
<?php echoBlog($blog, array('is_preview' => true)) ?>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $blogs_pag->pagination() ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echoUOJPageFooter() ?>
|
||||
|
@ -3,17 +3,19 @@
|
||||
become403Page(UOJLocale::get('need login'));
|
||||
}
|
||||
|
||||
if (!isset($_COOKIE['bootstrap4'])) {
|
||||
$REQUIRE_LIB['bootstrap5'] = '';
|
||||
}
|
||||
|
||||
$blogs_pag = new Paginator(array(
|
||||
'col_names' => array('*'),
|
||||
'table_name' => 'blogs',
|
||||
'cond' => "poster = '".UOJContext::userid()."' and is_hidden = 0",
|
||||
'tail' => 'order by post_time desc limit 5',
|
||||
'echo_full' => true
|
||||
'tail' => 'order by post_time desc',
|
||||
'page_len' => 5
|
||||
));
|
||||
|
||||
if (!isset($_COOKIE['bootstrap4'])) {
|
||||
$REQUIRE_LIB['bootstrap5'] = '';
|
||||
}
|
||||
$all_tags = DB::selectAll("select distinct tag from blogs_tags where blog_id in (select id from blogs where $blogs_cond)");
|
||||
|
||||
$REQUIRE_LIB['mathjax'] = '';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
@ -25,7 +27,13 @@
|
||||
<?php echoUOJPageHeader(UOJContext::user()['username'] . '的博客') ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div class="
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
col-lg-9
|
||||
<?php else: ?>
|
||||
col-md-9
|
||||
<?php endif ?>
|
||||
">
|
||||
<?php if ($blogs_pag->isEmpty()): ?>
|
||||
<div class="text-muted">此人很懒,什么博客也没留下。</div>
|
||||
<?php else: ?>
|
||||
@ -33,9 +41,54 @@
|
||||
<?php echoBlog($blog, array('is_preview' => true)) ?>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
<div class="text-center">
|
||||
<?= $blogs_pag->pagination(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
col-lg-3
|
||||
<?php else: ?>
|
||||
col-md-3
|
||||
<?php endif ?>">
|
||||
<img class="media-object img-thumbnail center-block" alt="<?= UOJContext::user()['username'] ?> Avatar" src="<?= HTML::avatar_addr(UOJContext::user(), 512) ?>" />
|
||||
<?php if (UOJContext::hasBlogPermission()): ?>
|
||||
<div class="btn-group d-flex mt-3">
|
||||
<a href="<?= HTML::blog_url(UOJContext::userid(), '/post/new/write') ?>" class="btn btn-primary">
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<i class="bi bi-pencil-square"></i>
|
||||
<?php else: ?>
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
<?php endif ?>
|
||||
写新博客
|
||||
</a>
|
||||
<a href="<?= HTML::blog_url(UOJContext::userid(), '/slide/new/write') ?>" class="btn btn-primary">
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<i class="bi bi-file-earmark-slides"></i>
|
||||
<?php else: ?>
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
<?php endif ?>
|
||||
写新幻灯片
|
||||
</a>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="card border-info
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
mt-3
|
||||
<?php else: ?>
|
||||
top-buffer-sm
|
||||
<?php endif ?>">
|
||||
<div class="card-header bg-info">标签</div>
|
||||
<div class="card-body">
|
||||
<?php if ($all_tags): ?>
|
||||
<?php foreach ($all_tags as $tag): ?>
|
||||
<?php echoBlogTag($tag['tag']) ?>
|
||||
<?php endforeach ?>
|
||||
<?php else: ?>
|
||||
<div class="text-muted">暂无</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<img class="media-object img-thumbnail center-block" alt="<?= UOJContext::user()['username'] ?> Avatar" src="<?= HTML::avatar_addr(UOJContext::user(), 256) ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php echoUOJPageFooter() ?>
|
||||
|
@ -156,7 +156,7 @@
|
||||
</div>
|
||||
<div class="card card-default mb-2">
|
||||
<div class="card-body">
|
||||
<?php $ac_problems = DB::selectAll("select a.problem_id as problem_id, b.title as title from best_ac_submissions a inner join problems b on a.problem_id = b.id where submitter = '{$user['username']}';") ?>
|
||||
<?php $ac_problems = DB::selectAll("select a.problem_id as problem_id, b.title as title from best_ac_submissions a inner join problems b on a.problem_id = b.id where submitter = '{$user['username']}' order by id") ?>
|
||||
<h4 class="card-title h5">
|
||||
<?= UOJLocale::get('accepted problems').': '.UOJLocale::get('n problems in total', count($ac_problems))?>
|
||||
</h4>
|
||||
|
@ -1315,10 +1315,10 @@ function echoBlogTag($tag) {
|
||||
global $REQUIRE_LIB;
|
||||
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo '<a class="uoj-problem-tag my-1">';
|
||||
echo '<a class="uoj-blog-tag my-1">';
|
||||
echo '<span class="badge bg-secondary">';
|
||||
} else {
|
||||
echo '<a class="uoj-problem-tag">';
|
||||
echo '<a class="uoj-blog-tag">';
|
||||
echo '<span class="badge badge-pill badge-secondary">';
|
||||
}
|
||||
echo HTML::escape($tag), '</span></a>';
|
||||
|
@ -203,6 +203,8 @@ EOD
|
||||
}
|
||||
|
||||
public function handleSave() {
|
||||
global $REQUIRE_LIB;
|
||||
|
||||
$save = $this->save;
|
||||
$this->receivePostData();
|
||||
$ret = $save($this->post_data);
|
||||
@ -213,8 +215,19 @@ EOD
|
||||
if (isset($_POST['need_preview'])) {
|
||||
ob_start();
|
||||
if ($this->type == 'blog') {
|
||||
echoUOJPageHeader('博客预览', array('ShowPageHeader' => false, 'REQUIRE_LIB' => array('mathjax' => '', 'shjs' => '')));
|
||||
$req_lib = array('mathjax' => '');
|
||||
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
$req_lib['bootstrap5'] = '';
|
||||
$req_lib['hljs'] = '';
|
||||
} else {
|
||||
$req_lib['shjs'] = '';
|
||||
}
|
||||
|
||||
echoUOJPageHeader('博客预览', array('ShowPageHeader' => false, 'REQUIRE_LIB' => $req_lib));
|
||||
if (!isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo '<link rel="stylesheet" type="text/css" href="' . HTML::url('/css/markdown.css') . '">';
|
||||
}
|
||||
echo '<article class="markdown-body">';
|
||||
echo $this->post_data['content'];
|
||||
echo '</article>';
|
||||
|
@ -34,7 +34,7 @@ mb-4" role="navigation">
|
||||
<?php else: ?>
|
||||
<span class="glyphicon glyphicon-inbox"></span>
|
||||
<?php endif ?>
|
||||
日志
|
||||
归档
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
|
Loading…
Reference in New Issue
Block a user