Skip to content

Commit

Permalink
增加搜索修复评论审核
Browse files Browse the repository at this point in the history
#19 #18 #14
avatar 头像cdn修改
远程文件本地化
增加搜索功能
修复评论审核
回复加@功能修复
增强1.2.0 php8 兼容性 和其他优化
  • Loading branch information
Seevil committed Apr 8, 2022
1 parent 5724c4a commit caa60c5
Show file tree
Hide file tree
Showing 8 changed files with 1,270 additions and 51 deletions.
19 changes: 17 additions & 2 deletions css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/vcomments.css

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,26 @@
</footer>
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/fonts.css'); ?>">
<?php if ($this->is('post') || $this->is('page') && $this->options->useHighline == 'able'): ?>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
<script src="<?php $this->options->themeUrl('lib/highlight.min.js'); ?>"></script>
<script>hljs.highlightAll();</script>
<?php endif; ?>
<div class="searchbox">
<div class="searchbox-container">
<div class="searchbox-input-wrapper">
<form class="search-form" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
<input name="s" type="search" class="searchbox-input" placeholder="输入关键字回车搜索" />
<span class="searchbox-close searchbox-selectable"><svg t="1649406485387" class="icon" viewBox="0 0 1025 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3502" width="20" height="20"><path d="M716.241478 658.468298c14.825761 14.314528 14.825761 38.342486 0 52.657014l-1.022467 1.022466c-14.825761 14.825761-38.853719 14.825761-53.67948 0l-150.302546-147.235147L360.934438 712.147778c-14.825761 14.314528-38.853719 14.314528-53.67948 0l-1.022467-1.022466c-14.825761-14.825761-14.825761-38.342486 0-52.657014l150.302546-147.235148-150.813779-147.235147c-14.825761-14.314528-14.825761-38.342486 0-52.657014l1.022466-1.022467c14.825761-14.825761 38.853719-14.825761 53.679481 0l150.302546 147.235147 150.302547-147.235147c14.825761-14.314528 38.853719-14.314528 53.67948 0l1.022467 1.022467c14.825761 14.825761 14.825761 38.342486 0 52.657014l-150.302547 147.235147 150.81378 147.235148z" p-id="3503" fill="#515151"></path><path d="M511.236985 0C229.036286 0 0.003834 229.032451 0.003834 511.23315s229.032451 511.23315 511.233151 511.233151 511.23315-229.032451 511.23315-511.233151-229.032451-511.23315-511.23315-511.23315z m0 940.668997c-237.212182 0-429.435846-192.223665-429.435847-429.435847s192.223665-429.435846 429.435847-429.435846 429.435846 192.223665 429.435846 429.435846-192.734898 429.435846-429.435846 429.435847z" p-id="3504" fill="#515151"></path></svg></span>
</form>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded',function(){(function($){$('#search').click(function(){$('.searchbox').toggleClass('show')});$('.searchbox .searchbox-mask').click(function(){$('.searchbox').removeClass('show')});$('.searchbox-close').click(function(){$('.searchbox').removeClass('show')})})(jQuery)});
</script>
<style type="text/css">
a.back_to_top{text-decoration:none;position:fixed;bottom:40px;right:30px;background:#f0f0f0;height:40px;width:40px;border-radius:50%;line-height:36px;font-size:18px;text-align:center;transition-duration:.5s;transition-propety:background-color;display:none}a.back_to_top span{color:#888}a.back_to_top:hover{cursor:pointer;background:#dfdfdf}a.back_to_top:hover span{color:#555}@media print,screen and (max-width:580px){.back_to_top{display:none!important}}
</style>
<a id="search" class="search icon" href="javascript:;"><svg t="1649405627786" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2703" width="16" height="16"><path d="M1012.224 953.856l-180.224-180.224c68.608-81.92 110.08-187.392 110.08-302.592 0-260.096-210.944-471.04-471.04-471.04S0 210.944 0 471.04s210.944 471.04 471.04 471.04c115.2 0 221.184-41.472 303.104-110.08l180.224 180.224c8.192 8.192 18.432 11.776 29.184 11.776s20.992-4.096 29.184-11.776c15.36-16.384 15.36-41.984-0.512-58.368zM75.264 471.04c0-218.624 177.152-395.776 395.776-395.776s395.776 177.152 395.776 395.776-177.152 395.776-395.776 395.776S75.264 689.664 75.264 471.04z" p-id="2704" fill="#707070"></path></svg></a>
<a id="back_to_top" href="#top" class="back_to_top"><span>△</span></a>
<script>
$(document).ready((function(_this){return function(){var bt;bt=$('#back_to_top');if($(document).width()>480){$(window).scroll(function(){var st;st=$(window).scrollTop();if(st>30){return bt.css('display','block')}else{return bt.css('display','none')}});return bt.click(function(){$('body,html').animate({scrollTop:0},800);return false})}}})(this));
Expand Down
70 changes: 26 additions & 44 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,14 @@ function theme_random_posts(){
echo $defaults['after'];
}

function getCommentAt($coid){
$db = Typecho_Db::get();
$prow = $db->fetchRow($db->select('parent')
->from('table.comments')
->where('coid = ? AND status = ?', $coid, 'approved'));
$parent = $prow['parent'];
if ($parent != "0") {
$arow = $db->fetchRow($db->select('author')
->from('table.comments')
->where('coid = ? AND status = ?', $parent, 'approved'));
$author = $arow['author'];
$href = '<a href="#comment-'.$parent.'">@'.$author.'</a>';
echo $href;
} else {
echo '';
}
}

/**
* 输出评论回复内容,配合 commentAtContent($coid)一起使用
* <?php showCommentContent($comments->coid); ?>
*/
function showCommentContent($coid)
{
$db = Typecho_Db::get();
$result = $db->fetchRow($db->select('text')->from('table.comments')->where('coid = ? AND status = ?', $coid, 'approved'));
$result = $db->fetchRow($db->select('text')->from('table.comments')->where('coid = ? AND (status = ? OR status = ?)', $coid, 'approved','waiting'));
$text = $result['text'];
$atStr = commentAtContent($coid);
$_content = Markdown::convert($text);
Expand All @@ -119,11 +101,11 @@ function showCommentContent($coid)
function commentAtContent($coid)
{
$db = Typecho_Db::get();
$prow = $db->fetchRow($db->select('parent')->from('table.comments')->where('coid = ? AND status = ?', $coid, 'approved'));
$prow = $db->fetchRow($db->select('parent')->from('table.comments')->where('coid = ? AND (status = ? OR status = ?)', $coid, 'approved','waiting'));
$parent = $prow['parent'];
if ($parent != "0") {
$arow = $db->fetchRow($db->select('author')->from('table.comments')
->where('coid = ? AND status = ?', $parent, 'approved'));
->where('coid = ? AND (status = ? OR status = ?)', $parent, 'approved','waiting'));
$author = $arow['author'];
$href = '<p><a href="#comment-' . $parent . '">@' . $author . '</a> ';
return $href;
Expand Down Expand Up @@ -295,8 +277,8 @@ function getOs($agent)
$os = false;

if (preg_match('/win/i', $agent)) {
if (preg_match('/nt 6.0/i', $agent)) {
$os = 'Windows Vista';
if (preg_match('/nt 10.0/i', $agent)) {
$os = 'Windows 10';
} else if (preg_match('/nt 6.1/i', $agent)) {
$os = 'Windows 7';
} else if (preg_match('/nt 6.2/i', $agent)) {
Expand All @@ -305,33 +287,33 @@ function getOs($agent)
$os = 'Windows 8.1';
} else if(preg_match('/nt 5.1/i', $agent)) {
$os = 'Windows XP';
} else if (preg_match('/nt 10.0/i', $agent)) {
$os = 'Windows 10';
} else if (preg_match('/nt 6.0/i', $agent)) {
$os = 'Windows Vista';
} else{
$os = 'Windows';
$os = 'Windows 11';
}
} else if (preg_match('/android/i', $agent)) {
if (preg_match('/android 9/i', $agent)) {
$os = 'Android P';
}
else if (preg_match('/android 8/i', $agent)) {
$os = 'Android O';
}
else if (preg_match('/android 7/i', $agent)) {
$os = 'Android N';
}
else if (preg_match('/android 6/i', $agent)) {
$os = 'Android M';
}
else if (preg_match('/android 5/i', $agent)) {
$os = 'Android L';
if (preg_match('/android 11/i', $agent)) {
$os = 'Android R';
}
else if (preg_match('/android 12/i', $agent)) {
$os = 'Android 12';
}
else if (preg_match('/android 10/i', $agent)) {
$os = 'Android Q';
}
else if (preg_match('/android 9/i', $agent)) {
$os = 'Android P';
}
else if (preg_match('/android 8/i', $agent)) {
$os = 'Android O';
}
else{
$os = 'Android';
}
else{
$os = 'Android';
}
}
else if (preg_match('/ubuntu/i', $agent)) {
$os = 'Linux';
$os = 'ubuntu';
} else if (preg_match('/linux/i', $agent)) {
$os = 'Linux';
} else if (preg_match('/iPhone/i', $agent)) {
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 又改名为Fantasy取义“清梦”源自“ 醉后不知天在水,满船清梦压星河。” 意图用来描绘现状。
* @package Fantasy Theme
* @author Xingr
* @version 1.4.1
* @version 1.4.2
* @link https://www.krsay.com/
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down Expand Up @@ -52,7 +52,7 @@
<p><?php $this->excerpt();?></p>
</div>
<div class="meta">
<span class="item"><i class="iconfont icon-calendar"></i><time datetime="<?php $this->date(); ?>"><?php $this->date('Y.m.d '); ?></time></span>
<span class="item"><i class="iconfont icon-calendar"></i><time datetime="<?php $this->date(); ?>"> <?php $this->date('Y.m.d '); ?></time></span>
<span class="item"><i class="iconfont icon-tag"></i><?php $this->category(''); ?></span>
<span class="item"><i class="iconfont icon-message"></i><a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('0 评', '1 评', '%d 评'); ?></a></span>
</div>
Expand Down
Loading

0 comments on commit caa60c5

Please sign in to comment.