Skip to content

Commit

Permalink
更新至1.3.0版本
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigZagK committed Jan 10, 2020
1 parent 092bc0c commit e6e24f8
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 59 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

基于[MDUI](https://mdui.org)的一款typecho主题,私用为主QAQ……若喜欢可以Star,谢谢QwQ。

作者:ZigZagK | 版本:1.2.9
作者:ZigZagK | 版本:1.3.0

## 主题特性

Expand Down Expand Up @@ -41,6 +41,10 @@

## 版本更新

### 1.3.0

增加日记页面按月归档。修改了Meting插件的教程链接。

### 1.2.9

增加友链页面按照随机顺序显示的功能(好吧实际上是魔改了一下插件)。
Expand Down
14 changes: 6 additions & 8 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('Version','1.2.9');
define('Version','1.3.0');

function themeFields($layout) {
$picUrl = new Typecho_Widget_Helper_Form_Element_Text('picUrl', NULL, NULL, _t('图片地址'), _t('在这里填入一个图片 URL 地址, 作为文章的头图,如果不填则显示随机图片'));
Expand Down Expand Up @@ -35,7 +35,7 @@ function themeConfig($form) {
$form->addInput($filing);
$gafiling = new Typecho_Widget_Helper_Form_Element_Text('gafiling', NULL, NULL, _t('公安备案信息'), _t('用于显示网站公安备案信息,不填则不显示公安备案信息'));
$form->addInput($gafiling);
$AplayerCode = new Typecho_Widget_Helper_Form_Element_Text('AplayerCode', NULL, NULL, _t('全站音乐播放器APlayer代码'), _t('ps:需要下载METO大佬的 <a target="_blank" href="https://github.com/MoePlayer/APlayer-Typecho">Meting</a> 插件。格式参考 <a target="_blank" href="https://github.com/metowolf/MetingJS">Meting</a> 文档填写,若不加<code>data-fixed="true"</code>参数则显示在最下方,若不想在切换页面时停止播放请参考 <a target="_blank" href="https://github.com/MoePlayer/APlayer-Typecho/pull/60">这里</a> 。如果不填则不启用APlayer'));
$AplayerCode = new Typecho_Widget_Helper_Form_Element_Text('AplayerCode', NULL, NULL, _t('全站音乐播放器APlayer代码'), _t('ps:需要下载METO大佬的 <a target="_blank" href="https://github.com/MoePlayer/APlayer-Typecho">Meting</a> 插件。格式参考 <a target="_blank" href="https://github.com/metowolf/MetingJS/tree/3ded12563fe1fd0744d762da3103abac585e5ec7">Meting</a> 文档填写,若不加<code>data-fixed="true"</code>参数则显示在最下方,若不想在切换页面时停止播放请参考 <a target="_blank" href="https://github.com/MoePlayer/APlayer-Typecho/pull/60">这里</a> 。如果不填则不启用APlayer'));
$form->addInput($AplayerCode);
$highlightstyle = new Typecho_Widget_Helper_Form_Element_Text('highlightstyle', NULL, NULL, _t('代码片渲染样式'), _t('参考 <a target="_blank" href="https://highlightjs.org/static/demo/">highlightjs</a> 样式,如果不填则使用<code>default</code>'));
$form->addInput($highlightstyle);
Expand Down Expand Up @@ -117,10 +117,8 @@ function CountCateOrTag($id){
$pom=$db->fetchAll($po);$num=count($pom);$shu=0;for ($x=0;$x<$num;$x++) $shu=$pom[$x]['count']+$shu;return $shu;
}
function convertSmilies($widget){
if (get_headers(Typecho_Widget::widget('Widget_Options')->themeUrl."/img/QAQ/QAQ.json",1)[0]=='HTTP/1.1 200 OK')
$getJson=file_get_contents(Typecho_Widget::widget('Widget_Options')->themeUrl."/img/QAQ/QAQ.json");
else $getJson=file_get_contents(Helper::options()->themeFile(ThemeName(),"img/QAQ/QAQ.json"));
$QAQTAB = json_decode($getJson,true);$TABName = array_keys($QAQTAB);$length = count($TABName);
$getJson=file_get_contents(Helper::options()->themeFile(ThemeName(),"img/QAQ/QAQ.json"));
$QAQTAB=json_decode($getJson,true);$TABName=array_keys($QAQTAB);$length=count($TABName);
for ($i=0;$i<$length;$i++){
$key=$TABName[$i];$tot=count($QAQTAB[$key]['content']);
if ($QAQTAB[$key]['type']=='picture'){
Expand Down Expand Up @@ -300,8 +298,8 @@ function ajaxComment($archive){
if ($data['parent']) $data['content'] = GetCommentAt($data['parent']) . $data['content'];
$data['text'] = $comment['text'];
// 身份标识
if ($data['authorId']==$comment['ownerId']) $data['ifauthor'] = '<span class="mdui-chip-icon mdui-color-theme-accent"><i class="mdui-icon material-icons">account_circle</i></span><div class="mdui-chip-title">博主</div>';
else $data['ifauthor'] = '<span class="mdui-chip-icon"><i class="mdui-icon material-icons">remove_red_eye</i></span><div class="mdui-chip-title">访客</div>';
if ($data['authorId']==$comment['ownerId']) {$data['ifowner'] = true;$data['identity'] = '<span class="mdui-chip-icon mdui-color-theme-accent"><i class="mdui-icon material-icons">account_circle</i></span><div class="mdui-chip-title">博主</div>';}
else {$data['ifowner'] = false;$data['identity'] = '<span class="mdui-chip-icon"><i class="mdui-icon material-icons">remove_red_eye</i></span><div class="mdui-chip-title">访客</div>';}
// 网址链接
if ($data['url']) $data['authorurl']='<a target="_blank" href="'.$data['url'].'">'.$data['author'].'</a>';
else $data['authorurl']=$data['author'];
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @package MDUI2333
* @author ZigZagK
* @version 1.2.9
* @version 1.3.0
* @link https://zigzagk.top
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down
10 changes: 6 additions & 4 deletions js/commentjs.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
var form=$(this),params=form.serialize();
params+='&themeAction=comment';
var appendComment=function(comment){
var html='<div id="comment-{coid}" class="mdui-panel" mdui-panel><div class="mdui-panel-item mdui-panel-item-open"><div class="mdui-panel-item-header"><div class="mdui-panel-item-title"><div class="comment-author mdui-chip mdui-hidden-xs-down"><img class="avatar mdui-chip-icon mdui-color-grey-200" src="{avatar}" alt="{author}" width="100" height="100" />\n<span class="fn mdui-chip-title">{authorurl}</span></div><div class="mdui-hidden-sm-up"><img class="avatar mdui-chip-icon mdui-color-grey-200" src="{avatar}" alt="{author}" width="100" height="100" /></div></div><div class="mdui-panel-item-summary"><span class="mdui-hidden-xs-down">{datetime}</span><span class="fn mdui-chip-title mdui-hidden-sm-up">{authorurl}</span></div><i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i></div><div class="comment-meta mdui-panel-item-body"><span class="mdui-typo-caption mdui-text-color-theme-accent mdui-hidden-sm-up">{datetime}<br></span>{content}<div class="mdui-chip">{ifauthor}</div><span class="comment-reply mdui-float-right"><a href="?replyTo={coid}#<?php $this->respondId(); ?>" onclick="return TypechoComment.reply(\'comment-{coid}\',{coid});" class="mdui-btn mdui-color-theme-accent mdui-ripple">回复</a></span>';
var html='<div id="comment-{coid}" class="mdui-panel" mdui-panel><div class="mdui-panel-item mdui-panel-item-open"><div class="mdui-panel-item-header"><div class="mdui-panel-item-title"><div class="comment-author mdui-chip mdui-hidden-xs-down"><img class="avatar mdui-chip-icon mdui-color-grey-200" src="{avatar}" alt="{author}" width="100" height="100" />\n<span class="fn mdui-chip-title">{authorurl}</span></div><div class="mdui-hidden-sm-up"><img class="avatar mdui-chip-icon mdui-color-grey-200" src="{avatar}" alt="{author}" width="100" height="100" /></div></div><div class="mdui-panel-item-summary"><span class="mdui-hidden-xs-down">{datetime}</span><span class="fn mdui-chip-title mdui-hidden-sm-up">{authorurl}</span></div><i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i></div><div class="comment-meta mdui-panel-item-body"><span class="mdui-typo-caption mdui-text-color-theme-accent mdui-hidden-sm-up">{datetime}<br></span>{content}<div class="mdui-chip">{identity}</div><span class="comment-reply mdui-float-right"><a href="?replyTo={coid}#<?php $this->respondId(); ?>" onclick="return TypechoComment.reply(\'comment-{coid}\',{coid});" class="mdui-btn mdui-color-theme-accent mdui-ripple">回复</a></span>';
var sidebarhtml='<a href="{permalink}" class="mdui-list-item mdui-ripple" mdui-tooltip="{content: \'{datetime}\', position: \'right\'}"><div class="mdui-list-item-content mdui-text-truncate">{text}</div><div class="mdui-text-color-blue-900">{author}</div></a>';
$.each(comment,function(k,v){
regExp=new RegExp('{'+k+'}','g');
Expand Down Expand Up @@ -119,9 +119,11 @@
}
}
$(html).prependTo(el);
$(sidebarhtml).prependTo('#recentcomments');
if ($('#recentcomments').find('.mdui-list-item').length>5)
$('#recentcomments .mdui-list-item:last').remove();
if (comment.ifowner==false){
$(sidebarhtml).prependTo('#recentcomments');
if ($('#recentcomments').find('.mdui-list-item').length>5)
$('#recentcomments .mdui-list-item:last').remove();
}
}
$.ajax({
url: '<?php $this->permalink();?>',
Expand Down
108 changes: 67 additions & 41 deletions page-diary.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,85 @@
* @package custom
*/
$this->need('header.php'); ?>
<?php function threadedComments($comments, $options) { ?>
<?php global $total;global $diary;$total=0; ?>
<?php function threadedComments($comments, $options){
$GLOBALS['diary'][$GLOBALS['total']][0]=$comments->date;
$GLOBALS['diary'][$GLOBALS['total']][1]='
<div class="mdui-col">
<div id="<?php $comments->theId(); ?>" class="mdui-card mdui-m-t-2">
<div id="'.$comments->theId.'" class="mdui-card mdui-m-t-2">
<div class="mdui-card-header">
<img class="mdui-card-header-avatar" src="https://cdn.v2ex.com/gravatar/<?php echo HashTheMail($comments->mail) ?>?s=100&r=&d=mystery" />
<div class="mdui-card-header-title"><?php echo $comments->author; ?></div>
<div class="mdui-card-header-subtitle"><?php $comments->date(); ?></div>
<img class="mdui-card-header-avatar" src="https://cdn.v2ex.com/gravatar/'.HashTheMail($comments->mail).'?s=100&r=&d=mystery" />
<div class="mdui-card-header-title">'.$comments->author.'</div>
<div class="mdui-card-header-subtitle">'.$comments->date->format(Helper::options()->commentDateFormat).'</div>
</div>
<div class="mdui-card-content" style="min-height:200px"><?php echo RewriteComment($comments); ?></div>
<div class="mdui-card-content" style="min-height:200px">'.RewriteComment($comments).'</div>
</div>
</div>
<?php } ?>
</div>';
$GLOBALS['total']++;
} ?>

<div class="mdui-container mdui-m-b-2">
<?php $this->comments()->to($comments); ?>
<div class="mdui-typo" id="comments">
<?php $this->comments()->to($comments); ?>
<div class="mdui-row-xs-1 mdui-row-sm-2 mdui-row-md-3 mdui-row-lg-4">
<?php if ($this->user->hasLogin()){ ?>
<div class="mdui-col">
<div class="mdui-card mdui-m-t-2">
<div class="mdui-card-header">
<i class="mdui-card-header-avatar mdui-text-color-theme-accent mdui-icon material-icons" style="font-size:35px">edit</i>
<div class="mdui-card-header-title">发表日记</div>
<div class="mdui-card-header-subtitle">在下方输入日记内容</div>
<a href="<?php $this->options->adminUrl(); ?>manage-comments.php?cid=<?php echo $this->cid; ?>" target="_blank" class="mdui-btn mdui-btn-icon mdui-color-theme-accent mdui-color-theme-accent mdui-float-right mdui-ripple" style="position:absolute;right:16px;top:16px" mdui-tooltip="{content: '管理日记', position: 'top'}"><i class="mdui-icon material-icons">archive</i></a>
<?php $comments->listComments(array('before'=>'','after'=>'')); ?>
<div class="mdui-tab mdui-color-theme" mdui-tab>
<?php
$last='2333333';
for ($i=0;$i<$total;$i++){
if ($diary[$i][0]->format('Y-n')!=$last) echo '<a href="#'.$diary[$i][0]->format('Y-n').'" class="mdui-ripple">'.$diary[$i][0]->format('Y.n').'</a>';
$last=$diary[$i][0]->format('Y-n');
}
?>
</div>
<?php if ($this->user->hasLogin()){ ?>
<div class="mdui-typo mdui-card mdui-m-t-2">
<div class="mdui-card-header">
<i class="mdui-card-header-avatar mdui-text-color-theme-accent mdui-icon material-icons" style="font-size:35px">edit</i>
<div class="mdui-card-header-title">发表日记</div>
<div class="mdui-card-header-subtitle">在下方输入日记内容</div>
<a href="<?php $this->options->adminUrl(); ?>manage-comments.php?cid=<?php echo $this->cid; ?>" target="_blank" class="mdui-btn mdui-btn-icon mdui-color-theme-accent mdui-color-theme-accent mdui-float-right mdui-ripple" style="position:absolute;right:16px;top:16px" mdui-tooltip="{content: '管理日记', position: 'top'}"><i class="mdui-icon material-icons">archive</i></a>
</div>
<div class="mdui-card-content">
<?php if($this->allow('comment')): ?>
<div id="<?php $this->respondId(); ?>" class="respond">
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
<div class="mdui-textfield" style="padding-top:0">
<i class="mdui-icon material-icons">message</i>
<textarea name="text" id="commenttextarea" class="textarea mdui-textfield-input" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('commentsumbit').click();return false};" placeholder="在这里写下你想说的QwQ" required><?php $this->remember('text'); ?></textarea>
<div class="mdui-textfield-error">内容不能为空</div>
<div class="mdui-textfield-helper">资瓷Markdown和LaTeX数学公式</div>
</div>
<div class="mdui-card-content" style="min-height:200px">
<?php if($this->allow('comment')): ?>
<div id="<?php $this->respondId(); ?>" class="respond">
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
<div class="mdui-textfield" style="padding-top:0">
<i class="mdui-icon material-icons">message</i>
<textarea name="text" id="commenttextarea" class="textarea mdui-textfield-input" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('commentsumbit').click();return false};" placeholder="在这里写下你想说的QwQ" required><?php $this->remember('text'); ?></textarea>
<div class="mdui-textfield-error">内容不能为空</div>
<div class="mdui-textfield-helper">资瓷Markdown和LaTeX数学公式</div>
</div>
<div class="actions mdui-p-b-2">
<?php if ($this->options->commentpicture == 'true'){ ?><?php $this->need('php/QAQTAB.php'); ?><?php } ?>
<button id="commentsumbit" type="submit" class="submit mdui-btn mdui-btn-icon mdui-color-theme-accent mdui-ripple mdui-float-right" mdui-tooltip="{content: '发布(Ctrl+Enter)', position: 'top'}"><i class="mdui-icon material-icons">check</i></button>
</div>
</form>
</div>
<?php else: ?>
<p>未开启评论QAQ!请在控制台中开启此页面的评论。</p>
<?php endif; ?>
<div class="actions mdui-p-b-2">
<?php if ($this->options->commentpicture == 'true'){ ?><?php $this->need('php/QAQTAB.php'); ?><?php } ?>
<button id="commentsumbit" type="submit" class="submit mdui-btn mdui-btn-icon mdui-color-theme-accent mdui-ripple mdui-float-right" mdui-tooltip="{content: '发布(Ctrl+Enter)', position: 'top'}"><i class="mdui-icon material-icons">check</i></button>
</div>
</div>
</form>
</div>
<?php } ?>
<?php $comments->listComments(array('before'=>'')); ?>
<?php else: ?>
<p>未开启评论QAQ!请在控制台中开启此页面的评论。</p>
<?php endif; ?>
</div>
</div>
<?php } ?>
<?php
$last='2333333';
for ($i=0;$i<$total;$i++){
if ($diary[$i][0]->format('Y-n')!=$last){
if ($last!='2333333') echo '
</div>
</div>
';
echo '
<div class="mdui-typo" id="'.$diary[$i][0]->format('Y-n').'">
<div class="mdui-row-xs-1 mdui-row-sm-2 mdui-row-md-3 mdui-row-lg-4">
';
}
echo $diary[$i][1];
$last=$diary[$i][0]->format('Y-n');
}
if ($last!='2333333') echo '
</div>
</div>';
?>
</div>
<script>
var QAQTab=new mdui.Tab('#QAQTab');
Expand Down
4 changes: 1 addition & 3 deletions php/QAQTAB.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
if (get_headers(Typecho_Widget::widget('Widget_Options')->themeUrl."/img/QAQ/QAQ.json",1)[0]=='HTTP/1.1 200 OK')
$getJson=file_get_contents(Typecho_Widget::widget('Widget_Options')->themeUrl."/img/QAQ/QAQ.json");
else $getJson=file_get_contents(Helper::options()->themeFile(ThemeName(),"img/QAQ/QAQ.json"));
$getJson=file_get_contents(Helper::options()->themeFile(ThemeName(),"img/QAQ/QAQ.json"));
$QAQTAB=json_decode($getJson,true);$TABName=array_keys($QAQTAB);$length=count($TABName);
?>
<div class="mdui-text-color-theme-accent mdui-btn mdui-btn-icon mdui-float-left" mdui-tooltip="{content: '使用表情',position: 'top'}" mdui-dialog="{target: '#QAQ'}"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></div>
Expand Down
2 changes: 1 addition & 1 deletion sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<?php $this->widget('Widget_Comments_Recent','pageSize=5&ignoreAuthor=true')->to($comment); ?>
<?php while($comment->next()): ?>
<a href="<?php $comment->permalink(); ?>" class="mdui-list-item mdui-ripple" mdui-tooltip="{content: '<?php $comment->date(); ?>', position: 'right'}">
<div class="mdui-list-item-content mdui-text-truncate"><?php $comment->text(); ?></div>
<div class="mdui-list-item-content mdui-text-truncate"><?php echo htmlspecialchars(substr($comment->text,0,50)); ?></div>
<div class="mdui-text-color-blue-900"><?php echo $comment->author; ?></div>
</a>
<?php endwhile; ?>
Expand Down

0 comments on commit e6e24f8

Please sign in to comment.