mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 13:38:41 +00:00
style(web): change link location of blog functions
When using sub-directory blog, the 'blogof' not looks so good. And, there are duplicate 'blog' characters, which making people uncomfortable. So, for sub-directory blog, use 'blog' instead of 'blogof'. 'blog' is not as a sub folder or type anymore, use 'post' instead. BREAKING CHANGE: Due to the conflict of 'blog' sub-directory, when go to blog post, now should use 'blogs/{id}'; but when subdomain mode is on, you can still use 'blog' to access these blog posts. 'blogof' is no longer used, and you need to inform users that blog link is changed, to avoid the inaccessbility.
This commit is contained in:
parent
46c8644a6e
commit
0854940fe0
@ -3,5 +3,5 @@
|
||||
become404Page();
|
||||
}
|
||||
|
||||
redirectTo(HTML::blog_url($blog['poster'], $_SERVER["REQUEST_URI"]));
|
||||
redirectTo(HTML::blog_url($blog['poster'], '/post/'.$_GET['id']));
|
||||
?>
|
||||
|
@ -23,7 +23,7 @@ EOD;
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<a href="<?= HTML::blog_url(Auth::id(), '/') ?>" class="btn btn-default btn-sm">我的博客首页</a>
|
||||
<a href="<?= HTML::blog_url(Auth::id(), '/blog/new/write')?>" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-edit"></span> 写新博客</a>
|
||||
<a href="<?= HTML::blog_url(Auth::id(), '/post/new/write')?>" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-edit"></span> 写新博客</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
@ -543,7 +543,7 @@ EOD;
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php foreach ($contest['extra_config']['links'] as $link) { ?>
|
||||
<a href="/blog/<?=$link[1]?>" class="list-group-item"><?=$link[0]?></a>
|
||||
<a href="/blogs/<?=$link[1]?>" class="list-group-item"><?=$link[0]?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -25,7 +25,7 @@
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="/blog/<?= $blog['id'] ?>"><?= $blog['title'] ?></a><?= $new_tag ?></td>
|
||||
<td><a href="/blogs/<?= $blog['id'] ?>"><?= $blog['title'] ?></a><?= $new_tag ?></td>
|
||||
<td>by <?= getUserLink($blog['poster']) ?></td>
|
||||
<td><small><?= $blog['post_time'] ?></small></td>
|
||||
</tr>
|
||||
|
@ -34,7 +34,7 @@
|
||||
<div class="col-md-3">
|
||||
<?php if (UOJContext::hasBlogPermission()): ?>
|
||||
<div class="btn-group btn-group-justified">
|
||||
<a href="<?=HTML::blog_url(UOJContext::userid(), '/blog/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"><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>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
@ -29,7 +29,7 @@
|
||||
global $myUser, $blog, $comment_form;
|
||||
$comment = HTML::escape($_POST['comment']);
|
||||
|
||||
list($comment, $referrers) = uojHandleAtSign($comment, "/blog/{$blog['id']}");
|
||||
list($comment, $referrers) = uojHandleAtSign($comment, "/post/{$blog['id']}");
|
||||
|
||||
$esc_comment = DB::escape($comment);
|
||||
DB::insert("insert into blogs_comments (poster, blog_id, content, reply_id, post_time, zan) values ('{$myUser['username']}', '{$blog['id']}', '$esc_comment', 0, now(), 0)");
|
||||
@ -92,7 +92,7 @@
|
||||
global $myUser, $blog, $reply_form;
|
||||
$comment = HTML::escape($_POST['reply_comment']);
|
||||
|
||||
list($comment, $referrers) = uojHandleAtSign($comment, "/blog/{$blog['id']}");
|
||||
list($comment, $referrers) = uojHandleAtSign($comment, "/post/{$blog['id']}");
|
||||
|
||||
$reply_id = $_POST['reply_id'];
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
);
|
||||
}
|
||||
if ($blog && !$blog['is_draft']) {
|
||||
$blog_editor->blog_url = "/blog/{$blog['id']}";
|
||||
$blog_editor->blog_url = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}");
|
||||
} else {
|
||||
$blog_editor->blog_url = null;
|
||||
}
|
||||
@ -55,8 +55,8 @@
|
||||
deleteBlog($blog['id']);
|
||||
insertBlog(array_merge($data, array('is_draft' => 0)));
|
||||
$blog = array('id' => DB::insert_id(), 'tags' => array());
|
||||
$ret['blog_write_url'] = HTML::blog_url(UOJContext::user()['username'], "/blog/{$blog['id']}/write");
|
||||
$ret['blog_url'] = HTML::blog_url(UOJContext::user()['username'], "/blog/{$blog['id']}");
|
||||
$ret['blog_write_url'] = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}/write");
|
||||
$ret['blog_url'] = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}");
|
||||
}
|
||||
} else {
|
||||
updateBlog($blog['id'], $data);
|
||||
@ -65,8 +65,8 @@
|
||||
insertBlog(array_merge($data, array('is_draft' => $data['is_hidden'] ? 1 : 0)));
|
||||
$blog = array('id' => DB::insert_id(), 'tags' => array());
|
||||
if (!$data['is_hidden']) {
|
||||
$ret['blog_write_url'] = HTML::blog_url(UOJContext::user()['username'], "/blog/{$blog['id']}/write");
|
||||
$ret['blog_url'] = HTML::blog_url(UOJContext::user()['username'], "/blog/{$blog['id']}");
|
||||
$ret['blog_write_url'] = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}/write");
|
||||
$ret['blog_url'] = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}");
|
||||
}
|
||||
}
|
||||
if ($data['tags'] !== $blog['tags']) {
|
||||
|
@ -9,7 +9,7 @@ call_user_func(function() { // to prevent variable scope leak
|
||||
$prefix = '';
|
||||
} else {
|
||||
$domain = UOJConfig::$data['web']['blog']['host'];
|
||||
$prefix = '/blogof/{blog_username}';
|
||||
$prefix = '/blog/{blog_username}';
|
||||
}
|
||||
|
||||
Route::group([
|
||||
@ -22,11 +22,11 @@ call_user_func(function() { // to prevent variable scope leak
|
||||
Route::any("$prefix/archive", '/subdomain/blog/archive.php');
|
||||
Route::any("$prefix/aboutme", '/subdomain/blog/aboutme.php');
|
||||
Route::any("$prefix/click-zan", '/click_zan.php');
|
||||
Route::any("$prefix/blog/{id}", '/subdomain/blog/blog.php');
|
||||
Route::any("$prefix/post/{id}", '/subdomain/blog/blog.php');
|
||||
Route::any("$prefix/slide/{id}", '/subdomain/blog/slide.php');
|
||||
Route::any("$prefix/blog/(?:{id}|new)/write", '/subdomain/blog/blog_write.php');
|
||||
Route::any("$prefix/post/(?:{id}|new)/write", '/subdomain/blog/blog_write.php');
|
||||
Route::any("$prefix/slide/(?:{id}|new)/write", '/subdomain/blog/slide_write.php');
|
||||
Route::any("$prefix/blog/{id}/delete", '/subdomain/blog/blog_delete.php');
|
||||
Route::any("$prefix/post/{id}/delete", '/subdomain/blog/blog_delete.php');
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
);
|
||||
}
|
||||
if ($blog && !$blog['is_draft']) {
|
||||
$blog_editor->blog_url = "/blog/{$blog['id']}";
|
||||
$blog_editor->blog_url = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}");
|
||||
} else {
|
||||
$blog_editor->blog_url = null;
|
||||
}
|
||||
@ -57,7 +57,7 @@
|
||||
insertSlide(array_merge($data, array('is_draft' => 0)));
|
||||
$blog = array('id' => DB::insert_id(), 'tags' => array());
|
||||
$ret['blog_write_url'] = HTML::blog_url(UOJContext::user()['username'], "/slide/{$blog['id']}/write");
|
||||
$ret['blog_url'] = HTML::blog_url(UOJContext::user()['username'], "/blog/{$blog['id']}");
|
||||
$ret['blog_url'] = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}");
|
||||
}
|
||||
} else {
|
||||
updateBlog($blog['id'], $data);
|
||||
|
@ -104,7 +104,7 @@ function getContestProblemLink($problem, $contest_id, $problem_title = '!title_o
|
||||
}
|
||||
function getBlogLink($id) {
|
||||
if (validateUInt($id) && $blog = queryBlog($id)) {
|
||||
return '<a href="/blog/'.$id.'">'.$blog['title'].'</a>';
|
||||
return '<a href="/blogs/'.$id.'">'.$blog['title'].'</a>';
|
||||
}
|
||||
}
|
||||
function getClickZanBlock($type, $id, $cnt, $val = null) {
|
||||
|
@ -47,7 +47,7 @@ class HTML {
|
||||
if (UOJConfig::$data['switch']['blog-use-subdomain'])
|
||||
$url = UOJConfig::$data['web']['blog']['protocol'].'://'.blog_name_encode($username).'.'.UOJConfig::$data['web']['blog']['host'].$port;
|
||||
else
|
||||
$url = UOJConfig::$data['web']['blog']['protocol'].'://'.UOJConfig::$data['web']['blog']['host'].$port.'/blogof/'.blog_name_encode($username);
|
||||
$url = UOJConfig::$data['web']['blog']['protocol'].'://'.UOJConfig::$data['web']['blog']['host'].$port.'/blog/'.blog_name_encode($username);
|
||||
$url .= $uri;
|
||||
$url = rtrim($url, '/');
|
||||
return HTML::escape($url);
|
||||
|
@ -39,7 +39,11 @@ Route::group([
|
||||
Route::any('/hack/{id}', '/hack.php');
|
||||
|
||||
Route::any('/blogs', '/blogs.php');
|
||||
Route::any('/blog/{id}', '/blog_show.php');
|
||||
if (UOJConfig::$data['switch']['blog-use-subdomain']) {
|
||||
Route::any('/blog/{id}', '/blog_show.php');
|
||||
}
|
||||
Route::any('/blogs/{id}', '/blog_show.php');
|
||||
Route::any('/post/{id}', '/blog_show.php');
|
||||
|
||||
Route::any('/announcements', '/announcements.php');
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
if ($is_preview) {
|
||||
$readmore_pos = strpos($blog['content'], '<!-- readmore -->');
|
||||
if ($readmore_pos !== false) {
|
||||
$content = substr($blog['content'], 0, $readmore_pos).'<p><a href="'.HTML::blog_url(UOJContext::userid(), '/blog/'.$blog['id']).'">阅读更多……</a></p>';
|
||||
$content = substr($blog['content'], 0, $readmore_pos).'<p><a href="'.HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id']).'">阅读更多……</a></p>';
|
||||
} else {
|
||||
$content = $blog['content'];
|
||||
}
|
||||
@ -12,14 +12,14 @@
|
||||
|
||||
$extra_text = $blog['is_hidden'] ? '<span class="text-muted">[已隐藏]</span> ' : '';
|
||||
|
||||
$blog_type = $blog['type'] == 'B' ? 'blog' : 'slide';
|
||||
$blog_type = $blog['type'] == 'B' ? 'post' : 'slide';
|
||||
?>
|
||||
<h2><?= $extra_text ?><a class="header-a" href="<?= HTML::blog_url(UOJContext::userid(), '/blog/'.$blog['id']) ?>"><?= $blog['title'] ?></a></h2>
|
||||
<h2><?= $extra_text ?><a class="header-a" href="<?= HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id']) ?>"><?= $blog['title'] ?></a></h2>
|
||||
<div><?= $blog['post_time'] ?> <strong>By</strong> <?= getUserLink($blog['poster']) ?></div>
|
||||
<?php if (!$show_title_only): ?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<?php if ($blog_type == 'blog'): ?>
|
||||
<?php if ($blog_type == 'post'): ?>
|
||||
<article><?= $content ?></article>
|
||||
<?php elseif ($blog_type == 'slide'): ?>
|
||||
<article>
|
||||
@ -40,11 +40,11 @@
|
||||
<?php endforeach ?>
|
||||
</li>
|
||||
<?php if ($is_preview): ?>
|
||||
<li><a href="<?= HTML::blog_url(UOJContext::userid(), '/blog/'.$blog['id']) ?>">阅读全文</a></li>
|
||||
<li><a href="<?= HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id']) ?>">阅读全文</a></li>
|
||||
<?php endif ?>
|
||||
<?php if (Auth::check() && (isSuperUser(Auth::user()) || Auth::id() == $blog['poster'])): ?>
|
||||
<li><a href="<?=HTML::blog_url(UOJContext::userid(), '/'.$blog_type.'/'.$blog['id'].'/write')?>">修改</a></li>
|
||||
<li><a href="<?=HTML::blog_url(UOJContext::userid(), '/blog/'.$blog['id'].'/delete')?>">删除</a></li>
|
||||
<li><a href="<?=HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id'].'/delete')?>">删除</a></li>
|
||||
<?php endif ?>
|
||||
<li><?= getClickZanBlock('B', $blog['id'], $blog['zan']) ?></li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user