1.0版本
24
404.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<?php $this->need('header.php'); ?>
|
||||
|
||||
<div class="section-inner">
|
||||
|
||||
<header class="page-header section-inner">
|
||||
<!--
|
||||
<h4 class="page-subtitle"><?php _e('404错误'); ?></h4>
|
||||
<h1 class="page-title"><?php _e('恭喜你迷路了'); ?></h1>
|
||||
-->
|
||||
</header><!-- .page-header -->
|
||||
|
||||
<div class="section-inner">
|
||||
|
||||
<?php ?>
|
||||
<p class="excerpt">笑不活了,您要查看的页面不见了……</p>
|
||||
<!--
|
||||
|
||||
|
||||
</div><!-- .section-inner -->
|
||||
|
||||
</div><!-- .post -->
|
||||
|
||||
<?php $this->need('footer.php'); ?>
|
125
README.md
@@ -1,3 +1,124 @@
|
||||
# typecho-theme-simpleblog
|
||||
# simpleblog - 简约而不简陋的 Typecho 主题
|
||||
|
||||
简约而不简陋的Typecho博客主题
|
||||
simpleblog 是一个简约、优雅且功能丰富的 Typecho 主题,专注于内容展示和阅读体验。
|
||||
|
||||
## 主题特点
|
||||
|
||||
- **简约设计**:极简主义设计风格,让内容成为焦点
|
||||
- **响应式布局**:完美适配桌面端和移动端设备
|
||||
- **自定义侧边栏**:可自定义侧边栏背景颜色
|
||||
- **社交媒体集成**:支持 Twitter、Facebook、GitHub 等社交媒体链接
|
||||
- **特色图片支持**:通过自定义字段实现特色图片功能
|
||||
- **文章摘要**:支持自定义文章摘要
|
||||
- **按年份归档**:首页文章按年份分组显示
|
||||
- **搜索功能**:内置搜索功能,方便查找内容
|
||||
- **评论系统**:美观的评论布局和样式
|
||||
|
||||
## 安装方法
|
||||
|
||||
1. 下载主题压缩包
|
||||
2. 解压后将文件夹重命名为 `simpleblog`
|
||||
3. 上传到 Typecho 的 `/usr/themes/` 目录下
|
||||
4. 登录 Typecho 后台,进入「外观」,启用 simpleblog 主题
|
||||
|
||||
## 主题配置
|
||||
|
||||
在 Typecho 后台 → 外观 → 设置外观 中,可以进行以下配置:
|
||||
|
||||
### 基本设置
|
||||
|
||||
- **侧边栏背景颜色**:设置桌面端侧边栏和移动端顶部的背景颜色,使用十六进制颜色代码
|
||||
|
||||
### 社交媒体设置
|
||||
|
||||
- **Twitter 链接**:填入您的 Twitter 个人资料链接
|
||||
- **Facebook 链接**:填入您的 Facebook 个人资料链接
|
||||
- **GitHub 链接**:填入您的 GitHub 个人资料链接
|
||||
|
||||
## 特殊功能使用说明
|
||||
|
||||
### 特色图片
|
||||
|
||||
Typecho 默认没有特色图片功能,本主题使用自定义字段来实现。在编辑文章时,添加自定义字段:
|
||||
|
||||
- 字段名:`thumbnail`
|
||||
- 字段值:图片的 URL 地址
|
||||
|
||||
### 文章摘要
|
||||
|
||||
在编辑文章时,添加自定义字段:
|
||||
|
||||
- 字段名:`excerpt`
|
||||
- 字段值:文章摘要内容
|
||||
|
||||
### 文章置顶
|
||||
|
||||
需配合我修改的文章置顶插件使用。
|
||||
|
||||
**注意:**插件设置中“置顶标记的 HTML”**切勿**修改,否则将无法显示主题内置的置顶文章样式。
|
||||
|
||||
## 文件结构
|
||||
|
||||
```
|
||||
simpleblog/
|
||||
├── 404.php # 404 错误页面
|
||||
├── archive.php # 归档页面
|
||||
├── comments.css # 评论样式
|
||||
├── comments.php # 评论模板
|
||||
├── footer.php # 页脚模板
|
||||
├── functions.php # 主题函数
|
||||
├── header.php # 页头模板
|
||||
├── index.php # 首页模板
|
||||
├── page.php # 独立页面模板
|
||||
├── pagination.php # 分页模板
|
||||
├── post.php # 文章页面模板
|
||||
├── README.md # 主题说明文档
|
||||
├── screenshot.png # 主题预览图
|
||||
├── search.php # 搜索结果页面
|
||||
├── style.css # 主题样式表
|
||||
├── assets/ # 资源文件夹
|
||||
├── css/ # CSS 文件夹
|
||||
├── fonts/ # 字体文件夹
|
||||
├── images/ # 图片文件夹
|
||||
└── js/ # JavaScript 文件夹
|
||||
```
|
||||
|
||||
## 浏览器兼容性
|
||||
|
||||
simpleblog 主题兼容所有现代浏览器,包括:
|
||||
|
||||
- Chrome
|
||||
- Firefox
|
||||
- Safari
|
||||
- Edge
|
||||
- Opera
|
||||
|
||||
## 许可证
|
||||
|
||||
本主题基于 GNU General Public License v2.0 许可证发布。
|
||||
|
||||
## 作者信息
|
||||
|
||||
- 原主题作者:Anders Norén
|
||||
- 移植作者:林海草原
|
||||
- 作者网站:[https://lhcy.org](https://lhcy.org)
|
||||
|
||||
## 更新日志
|
||||
|
||||
### 1.0 (初始版本)
|
||||
- 初始版本发布
|
||||
|
||||
## 常见问题
|
||||
|
||||
**Q: 如何设置特色图片?**
|
||||
A: 在编辑文章时,添加自定义字段 `thumbnail`,值为图片 URL。
|
||||
|
||||
**Q: 如何添加文章摘要?**
|
||||
A: 在编辑文章时,添加自定义字段 `excerpt`,值为摘要内容。
|
||||
|
||||
**Q: 如何修改侧边栏颜色?**
|
||||
A: 在主题设置中修改「侧边栏背景颜色」选项。
|
||||
|
||||
## 支持与反馈
|
||||
|
||||
如有问题或建议,请访问作者网站 [https://lhcy.org](https://lhcy.org) 获取支持。
|
98
archive.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<?php $this->need('header.php'); ?>
|
||||
|
||||
<div class="section-inner">
|
||||
|
||||
<header class="page-header">
|
||||
<h1 class="page-title"><?php $this->archiveTitle(array(
|
||||
'category' => _t('分类: %s'),
|
||||
'search' => _t('搜索结果: %s'),
|
||||
'tag' => _t('标签: %s'),
|
||||
'author' => _t('作者: %s'),
|
||||
'date' => _t('归档: %s')
|
||||
), '', ''); ?></h1>
|
||||
|
||||
<?php if ($this->is('category') && $this->getDescription()): ?>
|
||||
<div class="archive-description">
|
||||
<?php echo $this->getDescription(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</header>
|
||||
|
||||
<?php if ($this->have()): ?>
|
||||
<div class="posts" id="posts">
|
||||
<?php
|
||||
$old_year = '1';
|
||||
|
||||
while($this->next()):
|
||||
// 获取当前文章的年份
|
||||
$current_year = date('Y', $this->created);
|
||||
|
||||
// 如果年份与之前不同,需要新的包装器
|
||||
if ($current_year != $old_year) :
|
||||
|
||||
// 如果是有效年份,而不是我们在循环前添加的默认值,我们有一个需要关闭的开放包装器
|
||||
if (1 != $old_year) {
|
||||
echo '</ul><!-- /' . $old_year . '-->';
|
||||
}
|
||||
|
||||
// 包装新的年份
|
||||
echo '<ul>';
|
||||
|
||||
if (!$this->is('date')) :
|
||||
?>
|
||||
<li>
|
||||
<h3 class="list-title"><a href="<?php echo $this->options->siteUrl . date('Y', $this->created); ?>"><?php echo $current_year; ?></a></h3>
|
||||
</li>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
// 更新 old_year 变量
|
||||
$old_year = $current_year;
|
||||
|
||||
endif;
|
||||
?>
|
||||
<li class="post-preview" id="post-<?php $this->cid(); ?>">
|
||||
<a href="<?php $this->permalink(); ?>">
|
||||
<?php
|
||||
$sticky = $this->is('sticky') ? '<div class="sticky-arrow"></div>' : '';
|
||||
?>
|
||||
<h2 class="title"><?php echo $sticky; ?><span><?php $this->title(); ?></span></h2>
|
||||
|
||||
<?php
|
||||
// 获取日期格式设置(这里假设使用 Typecho 的选项或默认为 'j M')
|
||||
$date_format = $this->options->dateFormat ? $this->options->dateFormat : 'n月j日';
|
||||
|
||||
// 格式化日期
|
||||
$date = date($date_format, $this->created);
|
||||
|
||||
// 输出日期
|
||||
echo '<time>' . $date . '</time>';
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<?php if (1 != $old_year) : ?>
|
||||
</ul><!-- /最后一年 -->
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- 使用统一的分页模板 -->
|
||||
<?php $this->need('pagination.php'); ?>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="post no-results not-found">
|
||||
<div class="post-header">
|
||||
<h2 class="title"><?php _e('没有找到任何内容'); ?></h2>
|
||||
</div>
|
||||
|
||||
<div class="post-content">
|
||||
<p><?php _e('抱歉,没有找到符合条件的内容。'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- .section-inner -->
|
||||
|
||||
<?php $this->need('footer.php'); ?>
|
BIN
assets/images/404.png
Normal file
After Width: | Height: | Size: 26 KiB |
1
assets/images/arrow-black-down.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 13 16" width="13" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="matrix(0 1 -1 0 16.242641 -131.242641)"/></svg>
|
After Width: | Height: | Size: 299 B |
1
assets/images/arrow-black-left.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="12" viewBox="0 0 15 12" width="15" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="matrix(-1 0 0 -1 146.485282 16)"/></svg>
|
After Width: | Height: | Size: 292 B |
1
assets/images/arrow-black-right.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="12" viewBox="0 0 15 12" width="15" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="translate(-132 -4)"/></svg>
|
After Width: | Height: | Size: 279 B |
1
assets/images/arrow-black-up.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 13 16" width="13" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="matrix(0 -1 1 0 -3.757359 147.242641)"/></svg>
|
After Width: | Height: | Size: 298 B |
1
assets/images/arrow-white-right.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="12" viewBox="0 0 15 12" width="15" xmlns="http://www.w3.org/2000/svg"><path d="m10.424621 7.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 223 B |
1
assets/images/chevron-up-white.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="7" viewBox="0 0 21 7" width="21" xmlns="http://www.w3.org/2000/svg"><path d="m187.388847 75.0019966-10.388847 5.9980034.5.8660254 9.891152-5.7106593 9.891152 5.7106593.5-.8660254-10.388846-5.9980034-.001153-.0019966-.001153.0006655-.001153-.0006655z" fill="#fff" fill-rule="evenodd" transform="translate(-177 -75)"/></svg>
|
After Width: | Height: | Size: 335 B |
1
assets/images/loading-white.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="74" viewBox="0 0 84 74" width="84" xmlns="http://www.w3.org/2000/svg"><path d="m74.48 26.437-8.387 11.077 5.625-.198c-.125 12.46-8.205 23.752-20.32 27.72-13.373 4.377-28.058-1.346-34.914-13.609l-6.109 3.416c6.572 11.754 18.947 18.653 31.883 18.653 3.768 0 7.586-.587 11.318-1.809 15.094-4.941 25.117-19.073 25.139-34.618l4.934-.174zm-61.763 10.375c.072-12.51 8.164-23.866 20.322-27.848 13.371-4.378 28.053 1.346 34.912 13.61l6.109-3.416c-8.486-15.179-26.658-22.262-43.199-16.846-15.137 4.956-25.172 19.152-25.141 34.746l-5.369.189 9.17 10.459 8.385-11.077z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 590 B |
1
assets/images/spyglass-black.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="25" viewBox="0 0 26 25" width="26" xmlns="http://www.w3.org/2000/svg"><path d="m18.1749738 15.7607602 7.7747737 7.7747737-1.4142136 1.4142136-7.6745876-7.6745877c-1.7906686 1.6893314-4.2048794 2.7248402-6.8609463 2.7248402-5.5228475 0-10-4.4771525-10-10s4.4771525-10 10-10 10 4.4771525 10 10c0 2.1450026-.6753539 4.1322679-1.8250262 5.7607602zm-8.1749738 2.2392398c4.418278 0 8-3.581722 8-8s-3.581722-8-8-8-8 3.581722-8 8 3.581722 8 8 8z" fill="#121212" fill-rule="evenodd"/></svg>
|
After Width: | Height: | Size: 494 B |
1
assets/images/spyglass-semiopaque.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="25" viewBox="0 0 26 25" width="26" xmlns="http://www.w3.org/2000/svg"><path d="m18.1749738 15.7607602 7.7747737 7.7747737-1.4142136 1.4142136-7.6745876-7.6745877c-1.7906686 1.6893314-4.2048794 2.7248402-6.8609463 2.7248402-5.5228475 0-10-4.4771525-10-10s4.4771525-10 10-10 10 4.4771525 10 10c0 2.1450026-.6753539 4.1322679-1.8250262 5.7607602zm-8.1749738 2.2392398c4.418278 0 8-3.581722 8-8s-3.581722-8-8-8-8 3.581722-8 8 3.581722 8 8 8z" fill-opacity=".9"/></svg>
|
After Width: | Height: | Size: 477 B |
1
assets/images/spyglass-white.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="25" viewBox="0 0 26 25" width="26" xmlns="http://www.w3.org/2000/svg"><path d="m18.1749738 15.7607602 7.7747737 7.7747737-1.4142136 1.4142136-7.6745876-7.6745877c-1.7906686 1.6893314-4.2048794 2.7248402-6.8609463 2.7248402-5.5228475 0-10-4.4771525-10-10s4.4771525-10 10-10 10 4.4771525 10 10c0 2.1450026-.6753539 4.1322679-1.8250262 5.7607602zm-8.1749738 2.2392398c4.418278 0 8-3.581722 8-8s-3.581722-8-8-8-8 3.581722-8 8 3.581722 8 8 8z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 471 B |
57
comments.css
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
|
||||
.comment-respond {
|
||||
margin-top: 40px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
/* 评论分页样式 */
|
||||
.page-navigator {
|
||||
display: flex;
|
||||
flex-wrap: wrap; /* 允许在小屏幕上换行 */
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 20px 0;
|
||||
justify-content: center;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.page-navigator li {
|
||||
margin: 0 5px 5px 0;
|
||||
}
|
||||
|
||||
.page-navigator a {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #ddd;
|
||||
text-decoration: none;
|
||||
border-radius: 3px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.page-navigator .current a {
|
||||
background: #333;
|
||||
color: #fff;
|
||||
border-color: #333;
|
||||
}
|
||||
|
||||
/* 响应式设计 - 平板设备 (768px 及以下) */
|
||||
@media screen and (max-width: 768px) {
|
||||
|
||||
.page-navigator {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式设计 - 手机设备 (480px 及以下) */
|
||||
@media screen and (max-width: 480px) {
|
||||
|
||||
.page-navigator li {
|
||||
margin: 0 3px 3px 0;
|
||||
}
|
||||
|
||||
.page-navigator a {
|
||||
padding: 4px 8px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
}
|
64
comments.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
|
||||
<div id="comments" class="comments">
|
||||
<?php $this->comments()->to($comments); ?>
|
||||
|
||||
<?php if ($comments->have()): ?>
|
||||
|
||||
<?php $comments->listComments(array(
|
||||
'before' => '<div class="comment-list">',
|
||||
'after' => '</div>',
|
||||
'beforeAuthor' => '',
|
||||
'afterAuthor' => '',
|
||||
'beforeDate' => '',
|
||||
'afterDate' => '',
|
||||
'dateFormat' => 'Y-m-d H:i',
|
||||
'replyWord' => _t('回复'),
|
||||
'commentStatus' => _t('您的评论正等待审核!'),
|
||||
'avatarSize' => 40,
|
||||
'callback' => 'themeCommentList'
|
||||
)); ?>
|
||||
|
||||
|
||||
<?php if($comments->pageNav()): ?>
|
||||
<div class="comments-pagination pagination">
|
||||
<?php $comments->pageNav('«', '»', 1, '...', array('wrapTag' => 'div', 'wrapClass' => 'page-navigator', 'itemTag' => '', 'textTag' => 'span', 'currentClass' => 'current', 'prevClass' => 'prev', 'nextClass' => 'next')); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($this->allow('comment')): ?>
|
||||
<div id="<?php $this->respondId(); ?>" class="respond">
|
||||
<h3 id="response" class="comment-reply-title"><?php _e('发表评论'); ?></h3>
|
||||
|
||||
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
|
||||
<?php if($this->user->hasLogin()): ?>
|
||||
<p><?php _e('登录身份: '); ?><a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> »</a></p>
|
||||
<?php $comments->cancelReply(); ?>
|
||||
<p>
|
||||
<textarea name="text" id="textarea" class="textarea" placeholder="<?php _e('评论内容...'); ?>" required ><?php $this->remember('text'); ?></textarea>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
<?php $comments->cancelReply(); ?>
|
||||
<p>
|
||||
<textarea name="text" id="textarea" class="textarea" placeholder="<?php _e('评论内容...'); ?>" required ><?php $this->remember('text'); ?></textarea>
|
||||
</p>
|
||||
<p>
|
||||
<input type="text" name="author" id="author" class="text" placeholder="<?php _e('称呼'); ?>" value="<?php $this->remember('author'); ?>" required />
|
||||
<input type="email" name="mail" id="mail" class="text" placeholder="<?php _e('邮箱'); ?>" value="<?php $this->remember('mail'); ?>"<?php if ($this->options->commentsRequireMail): ?> required<?php endif; ?> />
|
||||
<input type="url" name="url" id="url" class="text" placeholder="<?php _e('网站'); ?>" value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> required<?php endif; ?> />
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
<button type="submit" class="submit"><?php _e('提交评论'); ?></button>
|
||||
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<h3><?php _e('评论已关闭'); ?></h3>
|
||||
<?php endif; ?>
|
||||
</div><!-- #comments -->
|
15
css/font-awesome.css
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
@font-face {
|
||||
font-family: 'Font Awesome 5';
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
src: url( ../fonts/font-awesome/fa-solid-900.woff2 ) format( 'woff2' ),
|
||||
url( ../fonts/font-awesome/fa-solid-900.woff ) format( 'woff' );
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Font Awesome 5 Brands';
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
src: url( ../fonts/font-awesome/fa-brands-400.woff2 ) format( 'woff2' ),
|
||||
url( ../fonts/font-awesome/fa-brands-400.woff ) format( 'woff' );
|
||||
}
|
BIN
fonts/font-awesome/fa-brands-400.woff
Normal file
BIN
fonts/font-awesome/fa-brands-400.woff2
Normal file
BIN
fonts/font-awesome/fa-solid-900.woff
Normal file
BIN
fonts/font-awesome/fa-solid-900.woff2
Normal file
14
footer.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<footer class="site-footer section-inner">
|
||||
|
||||
<p class="copyright">© <?php echo date('Y'); ?> <a href="<?php $this->options->siteUrl(); ?>" class="site-name"><?php $this->options->title(); ?></a></p>
|
||||
<!-- 请不要删除作者信息,谢谢!-->
|
||||
<p class="theme-by"><?php _e('主题来源:'); ?> <a href="https://lhcy.org" target="_blank">林海草原</a></p>
|
||||
<!-- 请不要删除作者信息,谢谢!-->
|
||||
</footer> <!-- footer -->
|
||||
|
||||
</main>
|
||||
|
||||
<?php $this->footer(); ?>
|
||||
|
||||
</body>
|
||||
</html>
|
297
functions.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||
|
||||
/**
|
||||
* simpleblog- theme 主题函数
|
||||
*/
|
||||
|
||||
/**
|
||||
* 主题设置
|
||||
*/
|
||||
function themeConfig($form) {
|
||||
// 侧边栏背景颜色
|
||||
$accentColor = new Typecho\Widget\Helper\Form\Element\Text(
|
||||
'accentColor',
|
||||
null,
|
||||
'#121212',
|
||||
_t('侧边栏背景颜色'),
|
||||
_t('设置桌面端侧边栏和移动端顶部的背景颜色,请使用十六进制颜色代码')
|
||||
);
|
||||
$form->addInput($accentColor);
|
||||
|
||||
// 社交链接设置
|
||||
$socialTwitter = new Typecho\Widget\Helper\Form\Element\Text(
|
||||
'socialTwitter',
|
||||
null,
|
||||
'',
|
||||
_t('Twitter 链接'),
|
||||
_t('您的 Twitter 个人资料链接')
|
||||
);
|
||||
$form->addInput($socialTwitter);
|
||||
|
||||
$socialFacebook = new Typecho\Widget\Helper\Form\Element\Text(
|
||||
'socialFacebook',
|
||||
null,
|
||||
'',
|
||||
_t('Facebook 链接'),
|
||||
_t('您的 Facebook 个人资料链接')
|
||||
);
|
||||
$form->addInput($socialFacebook);
|
||||
|
||||
$socialGitHub = new Typecho\Widget\Helper\Form\Element\Text(
|
||||
'socialGitHub',
|
||||
null,
|
||||
'',
|
||||
_t('Github 链接'),
|
||||
_t('您的 Github 个人资料链接')
|
||||
);
|
||||
$form->addInput($socialGitHub);
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出自定义CSS
|
||||
*/
|
||||
function outputCustomCSS() {
|
||||
$options = Helper::options();
|
||||
$accentColor = $options->accentColor ? $options->accentColor : '#121212';
|
||||
|
||||
echo '<style type="text/css">';
|
||||
echo 'body .site-header { background-color: ' . $accentColor . '; }';
|
||||
echo '.social-menu.desktop { background-color: ' . $accentColor . '; }';
|
||||
echo '.social-menu a:hover { color: ' . $accentColor . '; }';
|
||||
echo '.social-menu a.active { color: ' . $accentColor . '; }';
|
||||
echo '.mobile-menu-wrapper { background-color: ' . $accentColor . '; }';
|
||||
echo '.social-menu.mobile { background-color: ' . $accentColor . '; }';
|
||||
echo '.mobile-search.active { background-color: ' . $accentColor . '; }';
|
||||
echo ':root { --accent-color: ' . $accentColor . '; }';
|
||||
echo '</style>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加自定义CSS到头部
|
||||
*/
|
||||
function themeInit($archive) {
|
||||
// 输出自定义CSS
|
||||
if ($archive->is('index') || $archive->is('archive') || $archive->is('single')) {
|
||||
outputCustomCSS();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章类
|
||||
*/
|
||||
function getPostClass($post) {
|
||||
$classes = array();
|
||||
|
||||
// 检查是否有缩略图
|
||||
if ($post->attachment && $post->attachment->isImage) {
|
||||
$classes[] = 'has-thumbnail';
|
||||
} else {
|
||||
$classes[] = 'missing-thumbnail';
|
||||
}
|
||||
|
||||
// 检查是否有标题
|
||||
if (empty($post->title)) {
|
||||
$classes[] = 'no-title';
|
||||
}
|
||||
|
||||
return implode(' ', $classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 body 类
|
||||
*/
|
||||
function getBodyClass($archive) {
|
||||
$options = Helper::options();
|
||||
$classes = array();
|
||||
|
||||
// 白色背景
|
||||
if ($options->accentColor == '#ffffff') {
|
||||
$classes[] = 'white-bg';
|
||||
}
|
||||
|
||||
|
||||
return implode(' ', $classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取归档类型
|
||||
*/
|
||||
function getArchiveType($archive) {
|
||||
if ($archive->is('category')) {
|
||||
return _t('分类');
|
||||
} elseif ($archive->is('tag')) {
|
||||
return _t('标签');
|
||||
} elseif ($archive->is('author')) {
|
||||
return _t('作者');
|
||||
} elseif ($archive->is('date') && $archive->is('year')) {
|
||||
return _t('年');
|
||||
} elseif ($archive->is('date') && $archive->is('month')) {
|
||||
return _t('月');
|
||||
} elseif ($archive->is('date') && $archive->is('day')) {
|
||||
return _t('日');
|
||||
} elseif ($archive->is('search')) {
|
||||
return _t('搜索结果');
|
||||
} elseif ($archive->is('index') && $options->homeTitle) {
|
||||
return _t('简介');
|
||||
} else {
|
||||
return _t('归档');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取归档标题
|
||||
*/
|
||||
function getArchiveTitle($archive) {
|
||||
$options = Helper::options();
|
||||
|
||||
if ($archive->is('category')) {
|
||||
return $archive->category;
|
||||
} elseif ($archive->is('tag')) {
|
||||
return '#' . $archive->tag;
|
||||
} elseif ($archive->is('author')) {
|
||||
return $archive->author->screenName;
|
||||
} elseif ($archive->is('date') && $archive->is('year')) {
|
||||
return $archive->year;
|
||||
} elseif ($archive->is('date') && $archive->is('month')) {
|
||||
return $archive->year . ' ' . $archive->month;
|
||||
} elseif ($archive->is('date') && $archive->is('day')) {
|
||||
return $archive->year . '-' . $archive->month . '-' . $archive->day;
|
||||
} elseif ($archive->is('search')) {
|
||||
return '"' . $archive->getKeywords() . '"';
|
||||
} elseif ($archive->is('index') && $options->homeTitle) {
|
||||
return $options->homeTitle;
|
||||
} else {
|
||||
return _t('归档');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取归档描述
|
||||
*/
|
||||
function getArchiveDescription($archive) {
|
||||
if ($archive->is('search')) {
|
||||
$count = $archive->have();
|
||||
if ($count) {
|
||||
return sprintf(_t('我们找到 %s 符合您的搜索请求。'), $count . ' ' . _t('个结果'));
|
||||
} else {
|
||||
return sprintf(_t('我们没有找到关于 "%s" 的搜索结果。'), $archive->getKeywords());
|
||||
}
|
||||
}
|
||||
|
||||
return $archive->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义评论列表
|
||||
*/
|
||||
function threadedComments($comments, $options) {
|
||||
$commentClass = '';
|
||||
$commentLevelClass = $comments->_levels > 0 ? ' comment-child' : ' comment-parent';
|
||||
|
||||
if ($comments->url) {
|
||||
$author = '<a href="' . $comments->url . '" target="_blank" rel="external nofollow">' . $comments->author . '</a>';
|
||||
} else {
|
||||
$author = $comments->author;
|
||||
}
|
||||
|
||||
// 评论作者为文章作者
|
||||
$byPostAuthor = '';
|
||||
if ($comments->authorId == $comments->ownerId) {
|
||||
$byPostAuthor = ' <span class="comment-by-post-author">(' . _t('本文作者') . ')</span>';
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="li-<?php $comments->theId(); ?>" class="comment<?php echo $commentLevelClass; ?>">
|
||||
<div id="<?php $comments->theId(); ?>">
|
||||
<header class="comment-meta">
|
||||
<span class="comment-author">
|
||||
<cite><?php echo $author; ?></cite>
|
||||
<?php echo $byPostAuthor; ?>
|
||||
</span>
|
||||
<span class="comment-date">
|
||||
<a class="comment-date-link" href="<?php $comments->permalink(); ?>" title="<?php $comments->date('c'); ?>">
|
||||
<?php $comments->date(); ?>
|
||||
</a>
|
||||
</span>
|
||||
<span class="comment-reply">
|
||||
<?php $comments->reply(_t('回复')); ?>
|
||||
</span>
|
||||
</header>
|
||||
<div class="comment-content entry-content">
|
||||
<?php $comments->content(); ?>
|
||||
</div>
|
||||
<div class="comment-actions">
|
||||
<?php if ('waiting' == $comments->status): ?>
|
||||
<p class="comment-awaiting-moderation"><?php _t('您的评论正等待审核'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($comments->children) { ?>
|
||||
<div class="comment-children">
|
||||
<?php $comments->threadedComments($options); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加 JavaScript 功能
|
||||
*/
|
||||
function addJsFeatures() {
|
||||
?>
|
||||
<script>jQuery('html').removeClass('no-js').addClass('js');</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
// 添加钩子
|
||||
Typecho\Plugin::factory('header')->header = 'addJsFeatures';
|
||||
Typecho\Plugin::factory('Widget_Archive')->header = 'outputCustomCSS';
|
||||
|
||||
/**
|
||||
* 自定义评论回调函数
|
||||
*/
|
||||
function themeCommentList($comment, $options) {
|
||||
$commentClass = '';
|
||||
if ($comment->authorId) {
|
||||
if ($comment->authorId == $comment->ownerId) {
|
||||
$commentClass .= ' comment-by-author';
|
||||
} else {
|
||||
$commentClass .= ' comment-by-user';
|
||||
}
|
||||
}
|
||||
|
||||
$commentLevelClass = $comment->levels > 0 ? ' comment-child' : ' comment-parent';
|
||||
|
||||
$depth = $comment->levels + 1;
|
||||
if ($depth > 4) {
|
||||
$depth = 4;
|
||||
}
|
||||
$commentLevelClass .= ' comment-level-' . $depth;
|
||||
?>
|
||||
|
||||
<div id="<?php $comment->theId(); ?>" class="comment-body<?php echo $commentClass . $commentLevelClass; ?>">
|
||||
<div class="comment-author">
|
||||
<?php $comment->gravatar('40', ''); ?>
|
||||
<cite class="fn"><?php $comment->author(); ?></cite>
|
||||
</div>
|
||||
<div class="comment-meta">
|
||||
<time datetime="<?php $comment->date('c'); ?>"><?php $comment->date('Y-m-d H:i'); ?></time>
|
||||
</div>
|
||||
<div class="comment-content">
|
||||
<?php $comment->content(); ?>
|
||||
</div>
|
||||
<div class="comment-reply">
|
||||
<?php $comment->reply(_t('回复')); ?>
|
||||
</div>
|
||||
|
||||
<?php if ($comment->children) { ?>
|
||||
<div class="comment-children">
|
||||
<?php $comment->threadedComments($options); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
170
header.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html class="no-js" lang="<?php $this->options->lang(); ?>">
|
||||
|
||||
<head>
|
||||
<style>:root { --accent-color: <?php echo $this->options->accent_color ?: '#121212'; ?>; }</style>
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=<?php $this->options->charset(); ?>" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
|
||||
|
||||
<link rel="profile" href="http://gmpg.org/xfn/11">
|
||||
|
||||
<title><?php $this->archiveTitle([
|
||||
'category' => _t('分类 %s 下的文章'),
|
||||
'search' => _t('包含关键字 %s 的文章'),
|
||||
'tag' => _t('标签 %s 下的文章'),
|
||||
'author' => _t('%s 发布的文章')
|
||||
], '', ' - '); ?><?php $this->options->title(); ?></title>
|
||||
|
||||
<?php $this->header(); ?>
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('style.css'); ?>">
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('comments.css'); ?>">
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/font-awesome.css'); ?>">
|
||||
<script src="<?php $this->options->themeUrl('js/jquery.min.js'); ?>"></script>
|
||||
<script src="<?php $this->options->themeUrl('js/global.js'); ?>"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="<?php $this->options->bodyClass(); ?>">
|
||||
|
||||
<a class="skip-link button" href="#site-content"><?php _e('跳转到文章'); ?></a>
|
||||
|
||||
<header class="site-header group">
|
||||
|
||||
<?php $site_title_elem = $this->is('index') ? 'h1' : 'p'; ?>
|
||||
|
||||
<<?php echo $site_title_elem; ?> class="site-title"><a href="<?php $this->options->siteUrl(); ?>" class="site-name"><?php $this->options->title(); ?></a></<?php echo $site_title_elem; ?>>
|
||||
|
||||
<?php if ($this->options->description): ?>
|
||||
|
||||
<div class="site-description"><?php $this->options->description(); ?></div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="nav-toggle">
|
||||
<div class="bar"></div>
|
||||
<div class="bar"></div>
|
||||
</div>
|
||||
|
||||
<div class="menu-wrapper">
|
||||
|
||||
<ul class="main-menu desktop">
|
||||
|
||||
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
|
||||
<?php while($pages->next()): ?>
|
||||
<li<?php if($this->is('page', $pages->slug)): ?> class="current-menu-item"<?php endif; ?>>
|
||||
<a href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<?php
|
||||
// 这里可以添加自定义菜单项
|
||||
?>
|
||||
<!-- 例如:<li><a href="<?php $this->options->siteUrl(); ?>">首页</a></li> -->
|
||||
|
||||
</ul>
|
||||
|
||||
</div><!-- .menu-wrapper -->
|
||||
|
||||
|
||||
<div class="social-menu desktop">
|
||||
|
||||
<ul class="social-menu-inner">
|
||||
|
||||
<li class="social-search-wrapper"><a href="<?php $this->options->siteUrl(); ?>?s=" class="search-toggle"><span class="screen-reader-text"><?php _e('搜索'); ?></span></a></li>
|
||||
|
||||
|
||||
<?php if ($options->socialTwitter): ?>
|
||||
<li><a href="<?php echo $options->socialTwitter; ?>" target="_blank"><span class="screen-reader-text">Twitter</span></a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($options->socialFacebook): ?>
|
||||
<li><a href="<?php echo $options->socialFacebook; ?>" target="_blank"><span class="screen-reader-text">Facebook</span></a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($options->socialGitHub): ?>
|
||||
<li><a href="<?php echo $options->socialGitHub; ?>" target="_blank"><span class="screen-reader-text">GitHub</span></a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</ul><!-- .social-menu-inner -->
|
||||
|
||||
</div><!-- .social-menu -->
|
||||
|
||||
</header><!-- header -->
|
||||
|
||||
<div class="mobile-menu-wrapper">
|
||||
|
||||
<ul class="main-menu mobile">
|
||||
<?php while($pages->next()): ?>
|
||||
<li<?php if($this->is('page', $pages->slug)): ?> class="current-menu-item"<?php endif; ?>>
|
||||
<a href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<?php
|
||||
// 这里可以添加自定义菜单项
|
||||
?>
|
||||
<!-- 例如:<li><a href="<?php $this->options->siteUrl(); ?>">首页</a></li> -->
|
||||
|
||||
|
||||
|
||||
<li class="toggle-mobile-search-wrapper"><a href="#" class="toggle-mobile-search"><?php _e('搜索'); ?></a></li>
|
||||
|
||||
</ul><!-- .main-menu.mobile -->
|
||||
|
||||
|
||||
|
||||
<div class="social-menu mobile">
|
||||
|
||||
<ul class="social-menu-inner">
|
||||
<?php if ($options->socialTwitter): ?>
|
||||
<li><a href="<?php echo $options->socialTwitter; ?>" target="_blank"><span class="screen-reader-text">Twitter</span></a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($options->socialFacebook): ?>
|
||||
<li><a href="<?php echo $options->socialFacebook; ?>" target="_blank"><span class="screen-reader-text">Facebook</span></a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($options->socialGitHub): ?>
|
||||
<li><a href="<?php echo $options->socialGitHub; ?>" target="_blank"><span class="screen-reader-text">GitHub</span></a></li>
|
||||
<?php endif; ?>
|
||||
</ul><!-- .social-menu-inner -->
|
||||
|
||||
</div><!-- .social-menu -->
|
||||
|
||||
|
||||
|
||||
</div><!-- .mobile-menu-wrapper -->
|
||||
|
||||
|
||||
|
||||
<div class="mobile-search">
|
||||
|
||||
|
||||
<form method="post" class="search-for action="<?php $this->options->siteUrl(); ?>" role="search">
|
||||
<input type="text" name="s" class="search-field" placeholder="<?php _e('输入关键字并按下回车键'); ?>" />
|
||||
|
||||
</form>
|
||||
|
||||
<div class="mobile-results">
|
||||
|
||||
<div class="results-wrapper"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div><!-- .mobile-search -->
|
||||
|
||||
<div class="search-overlay">
|
||||
|
||||
<form method="post" class="search-for action="<?php $this->options->siteUrl(); ?>" role="search">
|
||||
<input type="text" name="s" class="search-field" placeholder="<?php _e('输入关键字并按下回车键'); ?>" />
|
||||
|
||||
</form>
|
||||
|
||||
</div><!-- .search-overlay -->
|
||||
|
||||
|
||||
|
||||
<main class="site-content" id="site-content">
|
BIN
images/404.png
Normal file
After Width: | Height: | Size: 26 KiB |
1
images/arrow-black-down.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 13 16" width="13" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="matrix(0 1 -1 0 16.242641 -131.242641)"/></svg>
|
After Width: | Height: | Size: 299 B |
1
images/arrow-black-left.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="12" viewBox="0 0 15 12" width="15" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="matrix(-1 0 0 -1 146.485282 16)"/></svg>
|
After Width: | Height: | Size: 292 B |
1
images/arrow-black-right.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="12" viewBox="0 0 15 12" width="15" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="translate(-132 -4)"/></svg>
|
After Width: | Height: | Size: 279 B |
1
images/arrow-black-up.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 13 16" width="13" xmlns="http://www.w3.org/2000/svg"><path d="m142.424621 11.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#121212" fill-rule="evenodd" transform="matrix(0 -1 1 0 -3.757359 147.242641)"/></svg>
|
After Width: | Height: | Size: 298 B |
1
images/arrow-white-right.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="12" viewBox="0 0 15 12" width="15" xmlns="http://www.w3.org/2000/svg"><path d="m10.424621 7.0606602h-10.424621v-2.12132037h10.424621l-3.43934-3.43933983 1.5-1.5 5.25 5.25.75.75-6 6-1.5-1.5z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 223 B |
1
images/chevron-up-white.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="7" viewBox="0 0 21 7" width="21" xmlns="http://www.w3.org/2000/svg"><path d="m187.388847 75.0019966-10.388847 5.9980034.5.8660254 9.891152-5.7106593 9.891152 5.7106593.5-.8660254-10.388846-5.9980034-.001153-.0019966-.001153.0006655-.001153-.0006655z" fill="#fff" fill-rule="evenodd" transform="translate(-177 -75)"/></svg>
|
After Width: | Height: | Size: 335 B |
1
images/loading-white.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="74" viewBox="0 0 84 74" width="84" xmlns="http://www.w3.org/2000/svg"><path d="m74.48 26.437-8.387 11.077 5.625-.198c-.125 12.46-8.205 23.752-20.32 27.72-13.373 4.377-28.058-1.346-34.914-13.609l-6.109 3.416c6.572 11.754 18.947 18.653 31.883 18.653 3.768 0 7.586-.587 11.318-1.809 15.094-4.941 25.117-19.073 25.139-34.618l4.934-.174zm-61.763 10.375c.072-12.51 8.164-23.866 20.322-27.848 13.371-4.378 28.053 1.346 34.912 13.61l6.109-3.416c-8.486-15.179-26.658-22.262-43.199-16.846-15.137 4.956-25.172 19.152-25.141 34.746l-5.369.189 9.17 10.459 8.385-11.077z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 590 B |
1
images/spyglass-black.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="25" viewBox="0 0 26 25" width="26" xmlns="http://www.w3.org/2000/svg"><path d="m18.1749738 15.7607602 7.7747737 7.7747737-1.4142136 1.4142136-7.6745876-7.6745877c-1.7906686 1.6893314-4.2048794 2.7248402-6.8609463 2.7248402-5.5228475 0-10-4.4771525-10-10s4.4771525-10 10-10 10 4.4771525 10 10c0 2.1450026-.6753539 4.1322679-1.8250262 5.7607602zm-8.1749738 2.2392398c4.418278 0 8-3.581722 8-8s-3.581722-8-8-8-8 3.581722-8 8 3.581722 8 8 8z" fill="#121212" fill-rule="evenodd"/></svg>
|
After Width: | Height: | Size: 494 B |
1
images/spyglass-semiopaque.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="25" viewBox="0 0 26 25" width="26" xmlns="http://www.w3.org/2000/svg"><path d="m18.1749738 15.7607602 7.7747737 7.7747737-1.4142136 1.4142136-7.6745876-7.6745877c-1.7906686 1.6893314-4.2048794 2.7248402-6.8609463 2.7248402-5.5228475 0-10-4.4771525-10-10s4.4771525-10 10-10 10 4.4771525 10 10c0 2.1450026-.6753539 4.1322679-1.8250262 5.7607602zm-8.1749738 2.2392398c4.418278 0 8-3.581722 8-8s-3.581722-8-8-8-8 3.581722-8 8 3.581722 8 8 8z" fill-opacity=".9"/></svg>
|
After Width: | Height: | Size: 477 B |
1
images/spyglass-white.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg height="25" viewBox="0 0 26 25" width="26" xmlns="http://www.w3.org/2000/svg"><path d="m18.1749738 15.7607602 7.7747737 7.7747737-1.4142136 1.4142136-7.6745876-7.6745877c-1.7906686 1.6893314-4.2048794 2.7248402-6.8609463 2.7248402-5.5228475 0-10-4.4771525-10-10s4.4771525-10 10-10 10 4.4771525 10 10c0 2.1450026-.6753539 4.1322679-1.8250262 5.7607602zm-8.1749738 2.2392398c4.418278 0 8-3.581722 8-8s-3.581722-8-8-8-8 3.581722-8 8 3.581722 8 8 8z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 471 B |
154
index.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* 简约又不简陋的Typecho模板。
|
||||
*
|
||||
* @package simpleblog-theme
|
||||
* @author 林海草原
|
||||
* @version 1.0
|
||||
* @link https://lhcy.org
|
||||
*/
|
||||
$this->need('header.php'); ?>
|
||||
|
||||
<div class="section-inner">
|
||||
|
||||
<?php
|
||||
// 确定标题元素类型
|
||||
$archive_title_elem = $this->is('index') ? 'h2' : 'h1';
|
||||
|
||||
// 归档类型和标题
|
||||
$archive_type = '';
|
||||
$archive_title = '';
|
||||
$archive_description = '';
|
||||
|
||||
// 设置归档标题和描述
|
||||
if ($this->is('category')) {
|
||||
$archive_type = '分类';
|
||||
$archive_title = $this->category;
|
||||
$archive_description = $this->getDescription();
|
||||
} elseif ($this->is('tag')) {
|
||||
$archive_type = '标签';
|
||||
$archive_title = $this->archiveTitle(array('tag' => _t('标签 %s 下的文章')), '', '');
|
||||
} elseif ($this->is('author')) {
|
||||
$archive_type = '作者';
|
||||
$archive_title = $this->archiveTitle(array('author' => _t('%s 发布的文章')), '', '');
|
||||
} elseif ($this->is('search')) {
|
||||
$archive_type = '搜索';
|
||||
$archive_title = $this->archiveTitle(array('search' => _t('包含关键字 %s 的文章')), '', '');
|
||||
} elseif ($this->is('archive')) {
|
||||
$archive_title = $this->archiveTitle(array(
|
||||
'category' => _t('分类 %s 下的文章'),
|
||||
'search' => _t('包含关键字 %s 的文章'),
|
||||
'tag' => _t('标签 %s 下的文章'),
|
||||
'author' => _t('%s 发布的文章')
|
||||
), '', '');
|
||||
}
|
||||
|
||||
if ($archive_title || $archive_description) :
|
||||
?>
|
||||
<header class="page-header">
|
||||
<?php if ($archive_type) : ?>
|
||||
<h4 class="page-subtitle"><?php echo $archive_type; ?></h4>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($archive_title) : ?>
|
||||
<<?php echo $archive_title_elem; ?> class="page-title"><?php echo $archive_title; ?></<?php echo $archive_title_elem; ?>>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($archive_description) : ?>
|
||||
<div class="page-description">
|
||||
<?php echo $archive_description; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->is('search') && !$this->have()) : ?>
|
||||
<form method="post" action="<?php $this->options->siteUrl(); ?>" class="search-form">
|
||||
<input type="search" class="search-field" placeholder="搜索..." name="s" />
|
||||
<button type="submit" class="search-button">搜索</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
</header><!-- .page-header -->
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->have()): ?>
|
||||
<div class="posts" id="posts">
|
||||
<?php
|
||||
$old_year = '1';
|
||||
|
||||
while($this->next()):
|
||||
// 获取当前文章的年份
|
||||
$current_year = date('Y', $this->created);
|
||||
|
||||
// 如果年份与之前不同,需要新的包装器
|
||||
if ($current_year != $old_year) :
|
||||
|
||||
// 如果是有效年份,而不是我们在循环前添加的默认值,我们有一个需要关闭的开放包装器
|
||||
if (1 != $old_year) {
|
||||
echo '</ul><!-- /' . $old_year . '-->';
|
||||
}
|
||||
|
||||
// 包装新的年份
|
||||
echo '<ul>';
|
||||
|
||||
if (!$this->is('date')) :
|
||||
?>
|
||||
<li>
|
||||
<h3 class="list-title"><a href="<?php echo $this->options->siteUrl . date('Y', $this->created); ?>"><?php echo $current_year; ?></a></h3>
|
||||
</li>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
// 更新 old_year 变量
|
||||
$old_year = $current_year;
|
||||
|
||||
endif;
|
||||
?>
|
||||
<li class="post-preview" id="post-<?php $this->cid(); ?>">
|
||||
<a href="<?php $this->permalink(); ?>">
|
||||
<?php
|
||||
$sticky = $this->is('sticky') ? '<div class="sticky-arrow"></div>' : '';
|
||||
?>
|
||||
<h2 class="title"><?php echo $sticky; ?><span><?php $this->title(); ?></span></h2>
|
||||
|
||||
<?php
|
||||
// 日期格式设置
|
||||
// 日期格式设置
|
||||
$date_format = $this->options->themeConfig('DateFormat') ? $this->options->themeConfig('DateFormat') : 'n月j日';
|
||||
|
||||
|
||||
|
||||
// 格式化日期
|
||||
$date = date($date_format, $this->created);
|
||||
|
||||
// 输出日期
|
||||
echo '<time>' . $date . '</time>';
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<?php if (1 != $old_year) : ?>
|
||||
</ul><!-- /最后一年 -->
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php else: ?>
|
||||
<div class="post no-results not-found">
|
||||
<div class="post-header">
|
||||
<h2 class="title"><?php _e('没有找到任何内容'); ?></h2>
|
||||
</div>
|
||||
|
||||
<div class="post-content">
|
||||
<p><?php _e('抱歉,没有找到符合条件的内容。'); ?></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- .section-inner -->
|
||||
|
||||
<?php $this->need('pagination.php'); ?>
|
||||
|
||||
<?php $this->need('footer.php'); ?>
|
249
js/global.js
Normal file
@@ -0,0 +1,249 @@
|
||||
// ======================================================================= Namespace
|
||||
var TEST = TEST || {},
|
||||
$ = jQuery;
|
||||
|
||||
|
||||
// ======================================================================= Global variables
|
||||
var doc = $( document ),
|
||||
win = $( window ),
|
||||
winHeight = win.height(),
|
||||
winWidth = win.width();
|
||||
|
||||
var viewport = {};
|
||||
viewport.top = $( window ).scrollTop();
|
||||
viewport.bottom = viewport.top + $( window ).height();
|
||||
|
||||
|
||||
// ======================================================================= Mobile Menu
|
||||
TEST.mobileMenu = {
|
||||
|
||||
init: function(){
|
||||
|
||||
// Toggle navigation
|
||||
$( '.nav-toggle' ).on( 'click', function(){
|
||||
$( this ).toggleClass( 'active' );
|
||||
$( '.mobile-menu-wrapper' ).slideToggle().toggleClass( 'visible' );
|
||||
$( 'body' ).toggleClass( 'mobile-menu-visible lock-scroll' );
|
||||
$( '.mobile-search, .toggle-mobile-search' ).removeClass( 'active' );
|
||||
} );
|
||||
|
||||
// Hide navigation on resize
|
||||
$( window ).on( 'resize', function(){
|
||||
var winWidth = $( window ).width();
|
||||
if ( winWidth > 1000 ) {
|
||||
$( 'body' ).removeClass( 'mobile-menu-visible lock-scroll' );
|
||||
$( '.mobile-menu-wrapper' ).hide().removeClass( 'visible' );
|
||||
$( '.nav-toggle' ).removeClass( 'active' );
|
||||
$( '.mobile-search' ).removeClass( 'active hide' );
|
||||
|
||||
// Empty the mobile search results
|
||||
TEST.ajaxSearch.emptyResults();
|
||||
}
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
} // TEST.mobileMenu
|
||||
|
||||
console.log("%c主题移植者:", "color: #4CAF50; font-weight: bold; font-size: 18px;");
|
||||
console.log("%c林海草原 https://lhcy.org", "color: #2196F3; font-size: 16px;");
|
||||
console.log("%c林海爱折腾 https://blog.lhcy.org", "color: #2196F3; font-size: 16px;");
|
||||
|
||||
// ======================================================================= Search Toggle
|
||||
TEST.searchToggle = {
|
||||
|
||||
init: function(){
|
||||
|
||||
// Toggle desktop search
|
||||
$( 'a[href$="?s="]' ).on( 'click', function(){
|
||||
$( this ).toggleClass( 'active' );
|
||||
$( '.search-overlay' ).toggleClass( 'active' );
|
||||
if ( $( this ).hasClass( 'active' ) ) {
|
||||
$( '.search-overlay .search-field' ).focus();
|
||||
} else {
|
||||
$( '.search-overlay .search-field' ).blur();
|
||||
}
|
||||
return false;
|
||||
} );
|
||||
|
||||
// Untoggle on click outside of form
|
||||
$( '.search-overlay' ).click( function( e ){
|
||||
console.log( 'log' );
|
||||
if ( e.target != this ) return; // only continue if the target itself has been clicked
|
||||
$( '.search-overlay .search-field' ).blur();
|
||||
$( '.search-overlay' ).removeClass( 'active' );
|
||||
$( '.social-menu.desktop a[href$="?s="]' ).removeClass( 'active' );
|
||||
} );
|
||||
|
||||
// Toggle mobile search
|
||||
$( '.toggle-mobile-search' ).on( 'click', function(){
|
||||
$( '.mobile-search' ).removeClass( 'hide' );
|
||||
$( '.toggle-mobile-search, .mobile-search' ).toggleClass( 'active' );
|
||||
$( '.mobile-search .search-field' ).focus();
|
||||
return false;
|
||||
} );
|
||||
|
||||
// Untoggle mobile search
|
||||
$( '.untoggle-mobile-search' ).on( 'click', function(){
|
||||
$( '.mobile-search' ).addClass( 'hide' );
|
||||
$( '.mobile-search, .toggle-mobile-search' ).removeClass( 'active' )
|
||||
$( '.mobile-search .search-field' ).blur();
|
||||
|
||||
// Empty the results
|
||||
TEST.ajaxSearch.emptyResults();
|
||||
return false;
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
} // TEST.searchToggle
|
||||
|
||||
|
||||
|
||||
// ======================================================================= Resize videos
|
||||
TEST.intrinsicRatioEmbeds = {
|
||||
|
||||
init: function(){
|
||||
|
||||
// Resize videos after their container
|
||||
var vidSelector = ".post iframe, .post object, .post video, .widget-content iframe, .widget-content object, .widget-content iframe";
|
||||
var resizeVideo = function( sSel ) {
|
||||
$( sSel ).each( function() {
|
||||
var $video = $( this ),
|
||||
$container = $video.parent(),
|
||||
iTargetWidth = $container.width();
|
||||
|
||||
if ( ! $video.attr( "data-origwidth" ) ) {
|
||||
$video.attr( "data-origwidth", $video.attr( "width" ) );
|
||||
$video.attr( "data-origheight", $video.attr( "height" ) );
|
||||
}
|
||||
|
||||
var ratio = iTargetWidth / $video.attr( "data-origwidth" );
|
||||
|
||||
$video.css( "width", iTargetWidth + "px" );
|
||||
$video.css( "height", ( $video.attr( "data-origheight" ) * ratio ) + "px" );
|
||||
} );
|
||||
}
|
||||
|
||||
resizeVideo( vidSelector );
|
||||
|
||||
$( window ).resize( function() {
|
||||
resizeVideo( vidSelector );
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
} // TEST.intrinsicRatioEmbeds
|
||||
|
||||
|
||||
|
||||
|
||||
// ======================================================================= Smooth Scroll
|
||||
TEST.smoothScroll = {
|
||||
|
||||
init: function(){
|
||||
|
||||
// Smooth scroll to anchor links
|
||||
$( 'a[href*="#"]' )
|
||||
// Remove links that don't actually link to anything
|
||||
.not( '[href="#"]' )
|
||||
.not( '[href="#0"]' )
|
||||
.not( '.skip-link' )
|
||||
.click( function( event ) {
|
||||
// On-page links
|
||||
if ( location.pathname.replace( /^\//, '' ) == this.pathname.replace( /^\//, '' ) && location.hostname == this.hostname ) {
|
||||
// Figure out element to scroll to
|
||||
var target = $( this.hash );
|
||||
target = target.length ? target : $( '[name=' + this.hash.slice( 1 ) + ']' );
|
||||
// Does a scroll target exist?
|
||||
if ( target.length ) {
|
||||
// Only prevent default if animation is actually gonna happen
|
||||
event.preventDefault();
|
||||
$( 'html, body' ).animate({
|
||||
scrollTop: target.offset().top
|
||||
}, 1000 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
} // TEST.smoothScroll
|
||||
|
||||
|
||||
|
||||
// ======================================================================= AJAX Search
|
||||
TEST.ajaxSearch = {
|
||||
|
||||
init: function(){
|
||||
|
||||
// Delay function
|
||||
var delay = ( function(){
|
||||
var timer = 0;
|
||||
return function( callback, ms ) {
|
||||
clearTimeout( timer );
|
||||
timer = setTimeout( callback, ms );
|
||||
}
|
||||
} )();
|
||||
|
||||
// Update results on keyup, after delay
|
||||
$( '.mobile-search .search-field' ).keyup( function() {
|
||||
if ( $( this ).val().length != 0 ) {
|
||||
delay( function(){
|
||||
TEST.ajaxSearch.loadPosts();
|
||||
}, 200 );
|
||||
} else {
|
||||
delay( function(){
|
||||
TEST.ajaxSearch.emptyResults();
|
||||
}, 50 );
|
||||
}
|
||||
} );
|
||||
|
||||
delay( function(){
|
||||
TEST.ajaxSearch.emptyResults();
|
||||
}, 50 );
|
||||
|
||||
// Check for empty on blur
|
||||
$( '.mobile-search .search-field' ).blur( function() {
|
||||
if ( $( this ).val().length == 0 ) {
|
||||
TEST.ajaxSearch.emptyResults();
|
||||
}
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
loadPosts: function(){
|
||||
|
||||
var $container = $( '.mobile-results .results-wrapper' ),
|
||||
data = $( '.mobile-search .search-field' ).val();
|
||||
|
||||
search_string = JSON.stringify( data );
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
emptyResults: function(){
|
||||
$( '.mobile-results .results-wrapper' ).empty();
|
||||
$( '.mobile-results' ).removeClass( 'no-results searching' );
|
||||
$( '.mobile-search .search-field' ).val( '' );
|
||||
}
|
||||
|
||||
} // TEST.ajaxSearch
|
||||
|
||||
|
||||
|
||||
// ======================================================================= Function calls
|
||||
$( document ).ready( function() {
|
||||
|
||||
TEST.mobileMenu.init(); // Mobile Menu
|
||||
|
||||
TEST.searchToggle.init(); // Search Toggles
|
||||
|
||||
TEST.intrinsicRatioEmbeds.init(); // Resize videos
|
||||
|
||||
TEST.smoothScroll.init(); // Resize videos
|
||||
|
||||
TEST.ajaxSearch.init(); // AJAX search on mobile
|
||||
|
||||
} );
|
2
js/jquery.min.js
vendored
Normal file
51
page.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* 页面模板
|
||||
*/
|
||||
$this->need('header.php');
|
||||
?>
|
||||
|
||||
<article class="post page">
|
||||
|
||||
<?php if ($this->fields->thumbnail && !$this->password): ?>
|
||||
<div class="featured-image">
|
||||
<img src="<?php echo $this->fields->thumbnail; ?>" alt="<?php $this->title() ?>" />
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<header class="entry-header section-inner">
|
||||
<h1 class="entry-title"><?php $this->title() ?></h1>
|
||||
|
||||
<?php if ($this->fields->excerpt): ?>
|
||||
<p class="excerpt"><?php echo $this->fields->excerpt; ?></p>
|
||||
<?php endif; ?>
|
||||
</header><!-- .entry-header -->
|
||||
|
||||
<div class="entry-content section-inner">
|
||||
<?php $this->content(); ?>
|
||||
</div> <!-- .content -->
|
||||
|
||||
<?php
|
||||
// 页面分页
|
||||
if ($this->is('page') && $this->fields->pagePage && $this->fields->pagePage != 1) {
|
||||
echo '<p class="section-inner linked-pages">' . _t('页面:');
|
||||
for ($i = 1; $i <= $this->fields->pagePage; $i++) {
|
||||
if ($i == 1) {
|
||||
echo '<a href="' . $this->permalink . '">' . $i . '</a>';
|
||||
} else {
|
||||
echo '<a href="' . $this->permalink . '?page=' . $i . '">' . $i . '</a>';
|
||||
}
|
||||
}
|
||||
echo '</p>';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($this->allow('comment')): ?>
|
||||
<div class="comments-section-inner section-inner wide">
|
||||
<?php $this->need('comments.php'); ?>
|
||||
</div><!-- .comments-section-inner -->
|
||||
<?php endif; ?>
|
||||
|
||||
</article> <!-- .post -->
|
||||
|
||||
<?php $this->need('footer.php'); ?>
|
19
pagination.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php if ($this->have() && $this->getTotalPage() > 1): ?>
|
||||
|
||||
<div class="archive-pagination section-inner group">
|
||||
|
||||
<?php if ($this->_currentPage > 1): ?>
|
||||
<div class="previous-posts-link">
|
||||
<h4 class="title"><?php $this->pageLink('上一页', 'prev'); ?></h4>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->_currentPage < $this->getTotalPage()): ?>
|
||||
<div class="next-posts-link">
|
||||
<h4 class="title"><?php $this->pageLink('下一页', 'next'); ?></h4>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div> <!-- .pagination -->
|
||||
|
||||
<?php endif; ?>
|
91
post.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* 文章页面模板
|
||||
*/
|
||||
$this->need('header.php');
|
||||
?>
|
||||
|
||||
<article class="post">
|
||||
|
||||
<?php if ($this->fields->thumbnail && !$this->password): ?>
|
||||
<div class="featured-image">
|
||||
<img src="<?php echo $this->fields->thumbnail; ?>" alt="<?php $this->title() ?>" />
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<header class="entry-header section-inner">
|
||||
|
||||
<h1 class="entry-title"><?php $this->title() ?></h1>
|
||||
|
||||
<?php if ($this->fields->excerpt): ?>
|
||||
<p class="excerpt"><?php echo $this->fields->excerpt; ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="meta">
|
||||
<time><a href="<?php $this->permalink() ?>"><?php $this->date(); ?></a></time>
|
||||
|
||||
<span>
|
||||
<?php _e('分类:', 'simpleblog'); ?> <?php $this->category(','); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</header><!-- .entry-header -->
|
||||
|
||||
<div class="entry-content section-inner">
|
||||
<?php $this->content(); ?>
|
||||
</div> <!-- .content -->
|
||||
|
||||
<?php
|
||||
// 文章分页
|
||||
if ($this->is('single') && $this->fields->postPage && $this->fields->postPage != 1) {
|
||||
echo '<p class="section-inner linked-pages">' . _t('页面:');
|
||||
for ($i = 1; $i <= $this->fields->postPage; $i++) {
|
||||
if ($i == 1) {
|
||||
echo '<a href="' . $this->permalink . '">' . $i . '</a>';
|
||||
} else {
|
||||
echo '<a href="' . $this->permalink . '?page=' . $i . '">' . $i . '</a>';
|
||||
}
|
||||
}
|
||||
echo '</p>';
|
||||
}
|
||||
|
||||
// 显示标签
|
||||
if ($this->tags): ?>
|
||||
<div class="meta bottom section-inner">
|
||||
<p class="tags">
|
||||
<?php
|
||||
$i = 0;
|
||||
$result = array();
|
||||
foreach ($this->tags as $tag) {
|
||||
$result[] = '<a href="' . $tag['permalink'] . '">#' . $tag['name'] . '</a>';
|
||||
}
|
||||
echo implode(' ', $result);
|
||||
?>
|
||||
</p>
|
||||
</div> <!-- .meta -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<div class="post-pagination section-inner">
|
||||
<div class="previous-post">
|
||||
<?php $this->thePrev('%s', '<span></span>'); ?>
|
||||
</div>
|
||||
|
||||
<div class="next-post">
|
||||
<?php $this->theNext('%s', '<span></span>'); ?>
|
||||
</div>
|
||||
</div><!-- .post-pagination -->
|
||||
|
||||
<?php if ($this->allow('comment')): ?>
|
||||
<div class="comments-section-inner section-inner wide">
|
||||
<?php $this->need('comments.php'); ?>
|
||||
</div><!-- .comments-section-inner -->
|
||||
<?php endif; ?>
|
||||
|
||||
</article> <!-- .post -->
|
||||
|
||||
<?php
|
||||
|
||||
$this->need('footer.php');
|
||||
?>
|
BIN
screenshot.png
Normal file
After Width: | Height: | Size: 189 KiB |
88
search.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<?php $this->need('header.php'); ?>
|
||||
|
||||
<div class="section-inner">
|
||||
|
||||
<header class="page-header">
|
||||
<h1 class="page-title"><?php _e('搜索结果: %s', $this->archiveTitle(array(
|
||||
'search' => _t('"%s"'),
|
||||
), '', false)); ?></h1>
|
||||
</header>
|
||||
|
||||
<?php if ($this->have()): ?>
|
||||
<div class="posts" id="posts">
|
||||
<?php
|
||||
$old_year = '1';
|
||||
|
||||
while($this->next()):
|
||||
// 获取当前文章的年份
|
||||
$current_year = date('Y', $this->created);
|
||||
|
||||
// 如果年份与之前不同,需要新的包装器
|
||||
if ($current_year != $old_year) :
|
||||
|
||||
// 如果是有效年份,而不是我们在循环前添加的默认值,我们有一个需要关闭的开放包装器
|
||||
if (1 != $old_year) {
|
||||
echo '</ul><!-- /' . $old_year . '-->';
|
||||
}
|
||||
|
||||
// 包装新的年份
|
||||
echo '<ul>';
|
||||
|
||||
if (!$this->is('date')) :
|
||||
?>
|
||||
<li>
|
||||
<h3 class="list-title"><a href="<?php echo $this->options->siteUrl . date('Y', $this->created); ?>"><?php echo $current_year; ?></a></h3>
|
||||
</li>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
// 更新 old_year 变量
|
||||
$old_year = $current_year;
|
||||
|
||||
endif;
|
||||
?>
|
||||
<li class="post-preview" id="post-<?php $this->cid(); ?>">
|
||||
<a href="<?php $this->permalink(); ?>">
|
||||
<?php
|
||||
$sticky = $this->is('sticky') ? '<div class="sticky-arrow"></div>' : '';
|
||||
?>
|
||||
<h2 class="title"><?php echo $sticky; ?><span><?php $this->title(); ?></span></h2>
|
||||
|
||||
<?php
|
||||
// 获取日期格式设置
|
||||
$date_format = $this->options->dateFormat ? $this->options->dateFormat : 'n月j日';
|
||||
|
||||
// 格式化日期
|
||||
$date = date($date_format, $this->created);
|
||||
|
||||
// 输出日期
|
||||
echo '<time>' . $date . '</time>';
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<?php if (1 != $old_year) : ?>
|
||||
</ul><!-- /最后一年 -->
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- 使用统一的分页模板 -->
|
||||
<?php $this->need('pagination.php'); ?>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="post no-results not-found">
|
||||
<div class="post-header">
|
||||
<h2 class="title"><?php _e('没有找到任何结果'); ?></h2>
|
||||
</div>
|
||||
|
||||
<div class="post-content">
|
||||
<p><?php _e('抱歉,没有符合您搜索条件的结果。请换其它关键词再试。'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- .section-inner -->
|
||||
|
||||
<?php $this->need('footer.php'); ?>
|