Skip to content

Commit

Permalink
优化评论模块和其他一些bug修改资源更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Xingr committed Aug 12, 2020
1 parent 8ce806b commit b188640
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 39 deletions.
46 changes: 20 additions & 26 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function threadedComments($comments, $options) {
$avatar = $host . $url . $hash . '?s=50' . '&r=' . $rating . '&d=mm';
}
?>
<div class="vlist">

<div class="vcard" id="<?php $comments->theId(); ?>">
<img class="vimg" src="<?php echo $avatar ?>">
<div class="vh">
Expand All @@ -37,49 +37,35 @@ function threadedComments($comments, $options) {
</div>
<div class="vmeta" >
<span class="vtime"><?php $comments->dateWord(); ?></span>
<span class="vat"><?php $comments->reply('回复'); ?></span>
<span class="vat comment-reply cp-<?php $comments->theId(); ?> text-muted comment-reply-link"><?php $comments->reply('回复'); ?></span><span id="vat cancel-comment-reply" class="cancel-comment-reply cl-<?php $comments->theId(); ?> text-muted comment-reply-link" style="display:none" ><?php $comments->cancelReply('取消'); ?></span>
</div>
<div class="vcontent">
<?php showCommentContent($comments->coid); ?>
</div>


</div>
</div>
<?php if ($comments->children) { ?>
<?php $comments->threadedComments($options); ?>
<?php } ?>
</div>

<?php } ?>
<?php $this->comments()->to($comments); ?>
<?php if($this->allow('comment')): ?>
<div class="blog-post-comments v" id="comments">
<div class="blog-post-comments v" id="<?php $this->respondId(); ?>">
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form">
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form">
<?php if($this->user->hasLogin()): ?>
<?php _e('登录身份: '); ?><h5><a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> &raquo;</a></h5>
<div class="vwrap">
<div class="vheader item3">
</div>
<div class="vedit">
<textarea name="text" id="veditor" class="OwO-textarea veditor vinput" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('misubmit').click();return false};" placeholder="说点什么?"><?php $this->remember('text',false); ?></textarea>
<div class="vrow"><div class="vcol vcol-60 status-bar"></div><div class="vcol vcol-40 vctrl text-right"><div title="表情" class="OwO"></div></div></div>
</div>
<div class="vcontrol">
<div class="col col-20" title="Markdown is supported">
<a href="https://segmentfault.com/markdown" target="_blank"><svg class="markdown" viewbox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z"></path></svg></a>
</div>
<div class="col col-80 text-right">
<button type="submit" title="Cmd|Ctrl+Enter" class="vsubmit vbtn" id="misubmit">回复</button>
<?php $security = $this->widget('Widget_Security'); ?>
</div>
</div>
<div style="display:none;" class="vmark">
</div>
</div>

<div class="vwrap">
<?php else: ?>
<div class="vwrap">
<div class="vheader item3">
<input name="author" placeholder="昵称" class="vnick vinput" type="text" value="<?php $this->remember('author'); ?>" required><input name="mail" placeholder="邮箱" class="vmail vinput" type="email" value="<?php $this->remember('mail'); ?>"<?php if ($this->options->commentsRequireMail): ?> required<?php endif; ?>><input name="url" placeholder="网址(http://)" class="vlink vinput" type="url" value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> required<?php endif; ?>>
</div>

<?php endif; ?>
<div class="vedit">
<textarea name="text" id="veditor" class="OwO-textarea veditor vinput" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('misubmit').click();return false};" placeholder="说点什么?"><?php $this->remember('text'); ?></textarea>
<div class="vrow"><div class="vcol vcol-60 status-bar"></div><div class="vcol vcol-40 vctrl text-right"><div title="表情" class="OwO"></div></div></div>
Expand All @@ -99,8 +85,9 @@ function threadedComments($comments, $options) {
<div style="display:none;" class="vmark">
</div>
</div>
<?php endif; ?>

</form>
</div>
<?php if($this->commentsNum!=0): ?>
<div class="vinfo" style="display:block;">
<div class="vcount col">
Expand All @@ -110,11 +97,18 @@ function threadedComments($comments, $options) {
<?php else: ?>
<div class="vempty" style="display:block;">快来做第一个评论的人吧~</div>
<?php endif; ?>
<div class="vlist">
<?php if ($comments->have()): ?>
<?php $comments->listComments(); ?>
<?php endif; ?>

</div>
<?php $comments->pageNav('<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>',10,'',array('wrapTag' => 'div', 'wrapClass' => 'pagination','itemTag' => '','currentClass' => 'page-number',)); ?>

</div>
<script type="text/javascript">
function showhidediv(id){var sbtitle=document.getElementById(id);if(sbtitle){if(sbtitle.style.display=='flex'){sbtitle.style.display='none';}else{sbtitle.style.display='flex';}}}
(function(){window.TypechoComment={dom:function(id){return document.getElementById(id)},pom:function(id){return document.getElementsByClassName(id)[0]},iom:function(id,dis){var alist=document.getElementsByClassName(id);if(alist){for(var idx=0;idx<alist.length;idx++){var mya=alist[idx];mya.style.display=dis}}},create:function(tag,attr){var el=document.createElement(tag);for(var key in attr){el.setAttribute(key,attr[key])}return el},reply:function(cid,coid){var comment=this.dom(cid),parent=comment.parentNode,response=this.dom("<?php echo $this->respondId(); ?>"),input=this.dom("comment-parent"),form="form"==response.tagName?response:response.getElementsByTagName("form")[0],textarea=response.getElementsByTagName("textarea")[0];if(null==input){input=this.create("input",{"type":"hidden","name":"parent","id":"comment-parent"});form.appendChild(input)}input.setAttribute("value",coid);if(null==this.dom("comment-form-place-holder")){var holder=this.create("div",{"id":"comment-form-place-holder"});response.parentNode.insertBefore(holder,response)}comment.appendChild(response);this.iom("comment-reply","");this.pom("cp-"+cid).style.display="none";this.iom("cancel-comment-reply","none");this.pom("cl-"+cid).style.display="";if(null!=textarea&&"text"==textarea.name){textarea.focus()}return false},cancelReply:function(){var response=this.dom("<?php echo $this->respondId(); ?>"),holder=this.dom("comment-form-place-holder"),input=this.dom("comment-parent");if(null!=input){input.parentNode.removeChild(input)}if(null==holder){return true}this.iom("comment-reply","");this.iom("cancel-comment-reply","none");holder.parentNode.insertBefore(response,holder);return false}}})();
</script>
<script src="<?php $this->options->themeUrl('lib/OwO/OwO.min.js'); ?>"></script>
<script type="text/javascript">
//OwO
Expand Down
2 changes: 1 addition & 1 deletion css/comments.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
})
});</script>
<?php endif; ?>
<?php if ($this->is('post')) : ?>
<?php if ($this->is('post') || $this->is('page')) : ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('js/lightbox.min.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('lib/highlight.min.js'); ?>"></script>
Expand Down
8 changes: 7 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ function themeConfig($form) {
$form->addInput($twitter->addRule('xssCheck', _t('请不要在图片链接中使用特殊字符')));
$weibo = new Typecho_Widget_Helper_Form_Element_Text('weibo', NULL, NULL, _t('Weibo地址'), _t('一般为http://www.weibo.com/xxx ,留空则不设置Weibo地址'));
$form->addInput($weibo->addRule('xssCheck', _t('请不要在图片链接中使用特殊字符')));
$writing = new Typecho_Widget_Helper_Form_Element_Text('writing', NULL, NULL, _t('首页writing地址'), _t('一般设置为你的归档地址 ,留空则默认为/archives.html'));
$form->addInput($writing->addRule('xssCheck', _t('请不要在图片链接中使用特殊字符')));

$Projectsurl = new Typecho_Widget_Helper_Form_Element_Text('Projectsurl', NULL, NULL, _t('首页Projects地址'), _t('一般为http://www.url.com/ ,留空则默认为#地址'));
$form->addInput($Projectsurl->addRule('xssCheck', _t('请不要在图片链接中使用特殊字符')));

$urldiy = new Typecho_Widget_Helper_Form_Element_Text('urldiy', NULL, NULL, _t('主页自定义地址'), _t('注意该设置会直接输出设置内容,建议格式为《a class="icon" href="https://twitter.com/skyurl" target="_blank" title="twitter"》《i class="fa fa-twitter"》《/i》《/a》 支持 FontAwesome 图标 ,留空则不显示'));
$form->addInput($urldiy->addRule('xssCheck', _t('请不要在链接中使用特殊字符')));
$beian = new Typecho_Widget_Helper_Form_Element_Text('beian', NULL, NULL, _t('备案号设置'), _t('直接填写备案号即可如:京ICP备888888号'));
$form->addInput($beian->addRule('xssCheck', _t('请不要在图片链接中使用特殊字符')));
$sticky = new Typecho_Widget_Helper_Form_Element_Text('sticky', NULL,NULL, _t('文章置顶'), _t('置顶的文章cid,按照排序输入, 请以半角逗号或空格分隔'));
$form->addInput($sticky);
$Projects = new Typecho_Widget_Helper_Form_Element_Textarea('Projects', NULL, NULL, _t('首页 Projects 设置(注意:切换主题会被清空,注意备份!)'), _t('按照格式输入链接信息,格式:<br><strong>链接名称(必须)|链接地址(必须)|链接描述</strong><br>不同信息之间用英文竖线“|”分隔,例如:<br><strong>XDE|http://www.xde.io/|仙岛驿站</strong><br>若中间有暂时不想填的信息,请留空,例如暂时不想填写链接描述:<br><strong>XDE|http://www.xde.io||</strong><br>多个链接换行即可,一行一个'));
$Projects = new Typecho_Widget_Helper_Form_Element_Textarea('Projects', NULL, NULL, _t('首页 Projects 作品链接 设置(注意:切换主题会被清空,注意备份!)'), _t('按照格式输入链接信息,格式:<br><strong>链接名称(必须)|链接地址(必须)|链接描述</strong><br>不同信息之间用英文竖线“|”分隔,例如:<br><strong>XDE|http://www.xde.io/|仙岛驿站</strong><br>若中间有暂时不想填的信息,请留空,例如暂时不想填写链接描述:<br><strong>XDE|http://www.xde.io||</strong><br>多个链接换行即可,一行一个'));
$form->addInput($Projects);

$catalog = new Typecho_Widget_Helper_Form_Element_Radio('catalog',
Expand Down
4 changes: 2 additions & 2 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta http-equiv="Cache-Control" content="no-transform"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<meta name="description" itemprop="description" content="<?php $this->options->description() ?>">
<meta name="keywords" content="<?php $this->options->keywords() ?>">

<meta property="og:type" content="blog"/>
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="<?php if($this->options->logoimg): ?><?php $this->options->logoimg();?><?php else : ?><?php $this->options->themeUrl('images/logo.png'); ?><?php endif; ?>">
Expand All @@ -29,7 +29,7 @@
<meta property="og:description" content="<?php $this->description();?>"/>
<meta property="og:release_date" content="<?php $this->date(); ?>"/>
<?php endif;?>
<?php $this->header('keywords=&generator=&template=&pingback=&xmlrpc=&wlw=&commentReply=&rss1=&rss2=&atom='); ?>
<?php $this->header('generator=&template=&pingback=&xmlrpc=&wlw=&commentReply='); ?>
<title><?php $this->archiveTitle(array(
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键字 %s 的文章'),
Expand Down
6 changes: 3 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 仙人掌(Cactus)是优雅简洁的暗色主题
* @package Cactus Theme
* @author Intern
* @version 1.3.1
* @version 1.3.2
* @link https://www.xde.io/
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down Expand Up @@ -89,7 +89,7 @@
</section>
<section id="writing">
<span class="h1">
<a href="archives.html">Writing</a>
<a href="<?php if($this->options->writing): ?><?php $this->options->writing();?><?php else : ?>archives.html<?php endif; ?>">Writing</a>
</span>
<ul class="post-list" id="post-list">
<?php while($this->next()): ?>
Expand All @@ -106,7 +106,7 @@
</section>
<section id="projects">
<span class="h1">
<a href="#" rel="external nofollow noopener noreferrer" target="_blank">Projects</a>
<a href="<?php if($this->options->Projects): ?><?php $this->options->Projects();?><?php else : ?>#<?php endif; ?>" rel="external nofollow noopener noreferrer" target="_blank">Projects</a>
</span>
<ul class="project-list">
<?php Projects(); ?>
Expand Down
47 changes: 44 additions & 3 deletions lib/highlight.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ self.__precacheManifest = [
},
{
"url": "css/comments.css",
"revision": "ac52ba3ceaa29d337d9aa44538e7f4f7"
"revision": "1999d64221003e829e10e1a21e36b399"
},
{
"url": "js/lazyload.js",
Expand Down Expand Up @@ -72,7 +72,7 @@ self.__precacheManifest = [
},
{
"url": "lib/highlight.min.js",
"revision": "4e0da54bb1cb0511de5f7bbf12298aa9"
"revision": "885244632b9e623c0cc40061ee5745f4"
},
{
"url": "lib/OwO/OwO.min.js",
Expand Down

0 comments on commit b188640

Please sign in to comment.