Skip to content

Commit

Permalink
New Footer
Browse files Browse the repository at this point in the history
新的页脚,支持显示备案号、社交链接、一言和运行时间。还有更多细节等你发现
  • Loading branch information
Dreamer-Paul committed Dec 1, 2018
1 parent 02f9a7f commit 8ddf2a4
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 48 deletions.
45 changes: 45 additions & 0 deletions 404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

if (!defined('__TYPECHO_ROOT_DIR__')) exit;

$this->need('header.php');

?>
<main>
<div class="wrap min">
<section class="board error-page">
<div class="post-title">
<h2>404</h2>
<p>你正在寻找的文章已经不见了,不妨看看其他文章?</p>
</div>
<ul class="archives-list">
<?php

function theme_random_posts(){
$defaults = array(
'xformat' => '<li class="archive-post"><a class="archive-post-title" href="{permalink}">{title}</a><span class="date">{date}</span></li>'
);

$db = Typecho_Db::get();
$sql = $db -> select() -> from('table.contents')
-> where('status = ?','publish')
-> where('type = ?', 'post')
-> limit(6)
-> order('RAND()');
$result = $db->fetchAll($sql);

foreach($result as $value){
$value = Typecho_Widget::widget('Widget_Abstract_Contents') -> filter($value);
echo str_replace(array('{permalink}', '{title}', '{date}'), array($value['permalink'], $value['title'], date("Y-m-d", $value['created'])), $defaults['xformat']);
}
}

theme_random_posts();

?>
</ul>
</section>
</div>
</main>

<?php $this->need('footer.php'); ?>
8 changes: 3 additions & 5 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
<?php function threadedComments($comments, $options) {
$commentClass = '';
if ($comments->authorId) {
if ($comments->authorId == $comments->ownerId) {
$commentClass .= ' comment-by-author';
} else {
$commentClass .= ' comment-by-user';
if($comments->authorId == $comments->ownerId){
$commentClass .= ' by-author';
}
}

$commentLevelClass = $comments->levels > 0 ? ' comment-child' : ' comment-parent';
?>

<div class="comment-item" id="<?php $comments->theId(); ?>">
<div class="comment-item<?php echo $commentClass ?>" id="<?php $comments->theId(); ?>">
<?php $comments->gravatar('150', 'wavatar'); ?>
<div class="content">
<div class="comment-meta">
Expand Down
60 changes: 45 additions & 15 deletions footer.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
<footer>
<section class="foot-widget">
<div class="wrap min">
<div class="wrap mid">
<section class="foot-widget">
<div class="row">
<div class="col-m-4">
<div class="col-m-3">
<h3>最新文章:</h3>
<ul>
<ul class="clear">
<?php $this -> widget('Widget_Contents_Post_Recent', 'pageSize=6') -> parse('<li><a href="{permalink}" target="_blank">{title}</a></li>'); ?>
</ul>
</div>
<div class="col-m-4">
<div class="col-m-3">
<h3>时光机:</h3>
<ul>
<ul class="clear">
<?php $this -> widget('Widget_Contents_Post_Date', 'type=month&format=Y 年 m 月&limit=6') -> parse('<li><a href="{permalink}" rel="nofollow" target="_blank">{date}</a></li>'); ?>
</ul>
</div>
<div class="col-m-4">
<div class="col-m-3">
<h3>最近评论:</h3>
<ul>
<?php $this -> widget('Widget_Comments_Recent', 'pageSize=6') -> to($comments); ?>
<div class="foot-comments">
<?php $this -> widget('Widget_Comments_Recent', 'pageSize=5') -> to($comments); ?>
<?php while($comments -> next()): ?>
<li><?php $comments -> author(false); ?>: <a href="<?php $comments -> permalink(); ?>" rel="nofollow" target="_blank"><?php $comments -> excerpt(10, '...'); ?></a></li>
<a href="<?php $comments -> permalink(); ?>" rel="nofollow" target="_blank"><img src="<?php echo Typecho_Common::gravatarUrl($comments -> mail, 32, 'X', 'wavatar') ?>"/><?php $comments -> excerpt(10, '...'); ?></a>
<?php endwhile; ?>
</div>
</div>
<div class="col-m-3">
<h3>站点信息:</h3>
<ul class="clear">
<?php Typecho_Widget::widget('Widget_Stat')->to($stat); ?>
<li>文章:<?php $stat->publishedPostsNum() ?> 篇</li>
<li>分类:<?php $stat->categoriesNum() ?> 个</li>
<li>评论:<?php $stat->publishedCommentsNum() ?> 条</li>
<li>页面:<?php $stat->publishedPagesNum() ?> 个</li>
</ul>
</div>
</div>
</div>
</section>
<section class="foot-copyright">
<p>&copy; <?php echo date('Y') ?> <a href="<?php $this -> options -> siteUrl() ?>"><?php $this->options->title(); ?></a>. All Rights Reserved. Theme By <a href="https://github.com/Dreamer-Paul/Fantasy" target="_blank" rel="nofollow">Fantasy</a>.</p>
</section>
</section>
<section class="foot-copyright">
<div class="row">
<div class="col-m-6 left bottom to-center">
<?php if(in_array('verify', $this -> options -> footer_content) && $this -> options -> verify_num): ?>
<p><a href="http://www.miitbeian.gov.cn" rel="nofollow" target="_blank"><?php $this -> options -> verify_num() ?></a></p>
<?php endif; ?>
<?php if(in_array('link', $this -> options -> footer_content) && $this -> options -> home_social): ?>
<p class="foot-social"><?php $this -> options -> home_social() ?></p>
<?php endif; ?>
<?php if(in_array('time', $this -> options -> footer_content)): ?>
<p class="foot-date">站点已萌萌哒存活了 <a>?</a> 天 <a>?</a> 小时 <a>?</a> 分 <a>?</a> 秒</p>
<?php endif; ?>
<?php if(in_array('hitokoto', $this -> options -> footer_content)): ?>
<p class="foot-hitokoto">重要的是无论我们选择哪条路,都要担负起选择的责任。</p>
<?php endif; ?>
</div>
<div class="col-m-6 right bottom to-center">
<p>&copy; <?php echo date('Y') ?> <a href="<?php $this -> options -> siteUrl() ?>"><?php $this->options->title(); ?></a>. 版权所有.</p>
<p>Published With <a href="http://typecho.org" target="_blank" rel="nofollow">Typecho.</a> Theme By <a href="https://github.com/Dreamer-Paul/Fantasy" target="_blank" rel="nofollow">Fantasy</a>.</p>
</div>
</div>
</section>
</div>
</footer>

<script src="<?php $this->options->themeUrl('static/kico.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('static/fantasy.js'); ?>"></script>
<script>var fantasy = new Fantasy_Theme({created: <?php if($this -> options -> site_created): ?>"<?php echo $this -> options -> site_created; ?>"<?php else: ?>false<?php endif; ?>});</script>
<?php $this -> options -> custom_script() ?>
<?php $this -> footer() ?>

Expand Down
31 changes: 25 additions & 6 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,42 @@ function paul_update($name, $version){

echo "</div>";
}
paul_update("Fantasy", "1.1");
paul_update("Fantasy", "1.2");

// 自定义站点图标
$favicon = new Typecho_Widget_Helper_Form_Element_Text('favicon', NULL, NULL, _t('站点图标'), _t('在这里填入一张 png 图片地址(<a>192x192px</a>),不填则使用默认图标'));
$form->addInput($favicon);
$form -> addInput($favicon);

// 自定义社交链接
$home_social = new Typecho_Widget_Helper_Form_Element_Textarea('home_social', NULL, NULL, _t('自定义社交链接'), _t('在这里填入你的自定义社交链接,不填则不输出。(格式请看<a href="https://github.com/Dreamer-Paul/Single/releases/tag/1.1" target="_blank">帮助信息</a>)'));
$form->addInput($home_social);
$form -> addInput($home_social);

// 自定义样式表
$custom_css = new Typecho_Widget_Helper_Form_Element_Textarea('custom_css', NULL, NULL, _t('自定义样式表'), _t('在这里填入你的自定义样式表,不填则不输出'));
$form->addInput($custom_css);
$custom_css = new Typecho_Widget_Helper_Form_Element_Textarea('custom_css', NULL, NULL, _t('自定义样式表'), _t('在这里填入你的自定义样式表,不填则不输出'));
$form -> addInput($custom_css);

// 自定义统计代码
$custom_script = new Typecho_Widget_Helper_Form_Element_Textarea('custom_script', NULL, NULL, _t('统计代码'), _t('在这里填入你的统计代码,不填则不输出。需要 <a>&lt;script&gt;</a> 标签'));
$custom_script = new Typecho_Widget_Helper_Form_Element_Textarea('custom_script', NULL, NULL, _t('统计代码'), _t('在这里填入你的统计代码,不填则不输出。需要 <a>&lt;script&gt;</a> 标签'));
$form->addInput($custom_script);

// 建站时间
$site_created = new Typecho_Widget_Helper_Form_Element_Text('site_created', NULL, '2018/07/09', _t('建站日期'), _t('在这里填入一个建站日期(格式:<a>2018/07/09</a>),不填则无法正常输出运行时间'));
$form -> addInput($site_created);

// 备案号
$verify_num = new Typecho_Widget_Helper_Form_Element_Text('verify_num', NULL, '', _t('备案号'), _t('在这里填入一个备案号,不填则无法输出'));
$form -> addInput($verify_num);

// 页尾展示内容
$footer_content = new Typecho_Widget_Helper_Form_Element_Checkbox('footer_content',
array(
'verify' => _t('备案号'),
'link' => _t('社交链接'),
'time' => _t('运行时间'),
'hitokoto' => _t('随机一言')
),
array('time', 'hitokoto'), _t('页尾展示内容'));
$form -> addInput($footer_content -> multiMode());
}

function themeInit($archive){
Expand Down
5 changes: 4 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<link href="<?php $this->options->themeUrl('static/fantasy.css'); ?>" rel="stylesheet" type="text/css"/>
<link href="https://cdn.jsdelivr.net/gh/FortAwesome/Font-Awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1"/>
<?php $this->header('pingback=&xmlrpc=&wlw='); ?>
<?php $this->header('generator=&template=&pingback=&xmlrpc=&wlw='); ?>
<?php if ($this->options->custom_css): ?>
<style><?php $this->options->custom_css() ?></style>
<?php endif; ?>
Expand All @@ -27,6 +27,9 @@
<nav class="side-nav">
<a href="<?php $this->options->siteUrl() ?>">首页</a>
<?php $this->widget('Widget_Contents_Page_List')->parse('<a href="{permalink}">{title}</a>'); ?>
<?php if($this -> user -> hasLogin()): ?>
<a href="<?php $this -> options -> adminUrl() ?>" target="_blank">进入后台</a>
<?php endif; ?>
</nav>
<nav class="side-action">
<div class="search-btn"></div>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @package Fantasy Theme
* @author Dreamer-Paul
* @version 1.1
* @version 1.2
* @link https://paugram.com
*/

Expand Down
2 changes: 1 addition & 1 deletion post.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="post-meta">
<time class="date"><?php $this->date(); ?></time>
<span class="category"><?php $this->category(''); ?></span>
<span class="comments"><?php $this->commentsNum('%d 条评论'); ?></span>
<span class="comments"><?php $this->commentsNum('%d 评论'); ?></span>
<?php if($this->authorId == $this->user->uid): ?>
<span class="edit"><a href="<?php $this->options->adminUrl(); ?>write-post.php?cid=<?php echo $this->cid;?>" target="_blank">编辑</a></span>
<?php endif; ?>
Expand Down
42 changes: 32 additions & 10 deletions static/fantasy.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Fantasy Theme
# By: Dreamer-Paul
# Last Update: 2018.11.15
# Last Update: 2018.12.1
一个优美梦幻的动漫风 Typecho 博客主题。
Expand Down Expand Up @@ -341,7 +341,7 @@ header, main{ margin-left: 8em; margin-bottom: 3em }
font-size: .85em;
}

.post-meta .category:before, .post-meta .comments:before, .post-meta .edit:before{
.post-meta .category:before, .post-meta .comments:before, .post-meta .viewed:before, .post-meta .edit:before{
content: '·';
margin: 0 .5em;
}
Expand Down Expand Up @@ -488,24 +488,27 @@ header, main{ margin-left: 8em; margin-bottom: 3em }
.comment-list .comment-item:last-child{ margin-bottom: 0 }

.comment-list .comment-meta{ margin-bottom: .5em }

.comment-meta .comment-time{
color: #aaa;
font-size: .75em;
margin-left: .5em;
}
.comment-list .comment-author, .comment-list a{ font-weight: lighter }

.comment-list .content{
background: #fff4fb;
border-radius: .5em;
margin: 0 0 1em 1.5em;
padding: .75em .75em .75em 2.5em;
}
.comment-list a{ font-weight: lighter }

/* - 作者的评论 */
.comment-item.by-author > .content{ background: aliceblue }
.comment-item.by-author > .content a{ color: cornflowerblue }

/* - 子评论 */
.comment-list .comment-children{ margin-left: 1em }
.comment-list .comment-children a{ color: cornflowerblue }
.comment-list .comment-children .content{ background: aliceblue }

/* - 回复评论 */
.comment-list .comment-reply{
Expand All @@ -526,12 +529,13 @@ header, main{ margin-left: 8em; margin-bottom: 3em }
-------------------------------- */
footer{
color: #666;
padding: 2em 0;
background: #fff;
box-shadow: 0 0 8px rgba(0, 0, 0, .1);
}

.foot-widget{ padding: 3em 0 }
.foot-widget ul{ margin: 0 }
.foot-widget{ margin-bottom: 3em }

.foot-widget li{
overflow: hidden;
white-space: nowrap;
Expand All @@ -544,9 +548,27 @@ footer{
font-family: "FontAwesome";
}

.foot-widget .foot-comments a{
color: inherit;
display: block;
overflow: hidden;
white-space: nowrap;
margin-bottom: .5em;
text-overflow: ellipsis;
}
.foot-widget .foot-comments img{
margin-right: .5em;
border-radius: 66%;
}

.foot-copyright{
color: #999;
padding: 1.5em 0;
font-size: .875em;
text-align: center;
}
}
.foot-copyright p{ margin: .25em 0 }

.foot-social a{
color: #777790;
margin-right: .75em;
}
.foot-social a:last-child{ margin: 0 }
Loading

0 comments on commit 8ddf2a4

Please sign in to comment.