Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a880c019d | |||
| ce1b8c4378 | |||
| aa30ed95f8 | |||
| bc3056bc4c | |||
| b9e3969134 | |||
| 65587efb0c | |||
| 0508d16c84 | |||
| 9f547244d3 | |||
| cf64160b75 | |||
| 7f69fd518d | |||
| f046a282c8 | |||
| 8f23486863 | |||
| bd3b384fde | |||
| e86e1afd66 | |||
| aec71a535b | |||
| f8fc4f293a | |||
| 21c75cdde2 | |||
| a99e370897 | |||
| 6456cb8521 | |||
| 041b559e97 | |||
| ab73d24361 | |||
| 5d3bd41e10 | |||
| cc3611d417 | |||
| 91743cbaad | |||
| 2aa42119dd | |||
| 2eff8ebd99 | |||
| 201bff5d11 | |||
| c91c5e54da | |||
| d6aaa9ac51 | |||
| 55724160cb | |||
| 4907670357 | |||
| bdd3eeb511 | |||
| 7b6154acad | |||
| fd639a1ffa | |||
| 496abfabb2 | |||
| d0d0a79064 |
@@ -1,30 +1,61 @@
|
|||||||
## 说明
|
## 说明
|
||||||
|
|
||||||
移植自`hugo-theme-farallon` 原汁原味,可以直接使用 原主题的CSS 和 JS.
|
移植自 `bigfa `大大的 `hugo-theme-farallon` 原汁原味,可以直接使用 原主题的CSS
|
||||||
|
精简部分 JS.
|
||||||
|
感谢
|
||||||
|
- 2024.6.4 v0.5.1
|
||||||
|
|
||||||
|
更改了设置memos的方式
|
||||||
|
新增了Mastodon 的 说说 页面
|
||||||
|
|
||||||
|
- 2024.6.3 v0.5.0
|
||||||
|
|
||||||
|
还是抄了原版的豆瓣获取方式
|
||||||
|
|
||||||
|
- 2024.5.26 v0.4.1
|
||||||
|
|
||||||
|
抄了个网站统计页面
|
||||||
|
|
||||||
|
- 2024.5.24
|
||||||
|
|
||||||
|
新增了说说页面,基于memos 0.19 以下的版本
|
||||||
|
在后台设置memos的地址和memoID即可
|
||||||
|
默认获取最近20条公开的memo
|
||||||
|
|
||||||
|
|
||||||
## 原项目地址
|
## 原项目地址
|
||||||
https://github.com/bigfa/hugo-theme-farallon
|
https://github.com/bigfa/hugo-theme-farallon
|
||||||
|
|
||||||
## 进度
|
## 移植进度
|
||||||
|
|
||||||
90%
|
96%
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
|
||||||
|
### 已知问题
|
||||||
|
|
||||||
由于typecho分类并无图片,所以默认使用
|
由于typecho分类并无图片,所以默认使用
|
||||||
`bigfa` 的 `https://static.fatesinger.com/2021/12/vhp6eou5x2wqh2zy.jpg`
|
`bigfa` 的 `https://static.fatesinger.com/2021/12/vhp6eou5x2wqh2zy.jpg`
|
||||||
可以自行替换或者删除
|
可以自行替换或者删除
|
||||||
|
|
||||||
|
|
||||||
## 功能
|
|
||||||
|
|
||||||
### 豆瓣观影
|
### 豆瓣观影
|
||||||
* 能力有限原项目功能无法实现 *
|
~~* 能力有限原项目功能无法实现~~
|
||||||
|
|
||||||
目前只能配合`DoubanBoard`插件使用
|
~~目前只能配合`DoubanBoard`插件使用~~
|
||||||
|
|
||||||
项目地址
|
~~项目地址~~
|
||||||
https://github.com/AlanDecode/Typecho-Plugin-DoubanBoard
|
~~https://github.com/AlanDecode/Typecho-Plugin-DoubanBoard~~
|
||||||
!!记得重命名文件夹为`DoubanBoard`
|
~~!!记得重命名文件夹为`DoubanBoard`~~
|
||||||
|
|
||||||
|
使用原版的获取方式
|
||||||
|
|
||||||
|
>豆瓣收藏使用方法
|
||||||
|
微信扫码登录https://node.wpista.com/
|
||||||
|
输入你的豆瓣数字 id,点击保存即可自动同步豆瓣记录。
|
||||||
|
点击 Get integration token 会生成一个 token。
|
||||||
|
|
||||||
|
获取`token`之后填入主题设置项中
|
||||||
|
|
||||||
### 友情链接
|
### 友情链接
|
||||||
|
|
||||||
@@ -36,6 +67,22 @@ https://github.com/AlanDecode/Typecho-Plugin-DoubanBoard
|
|||||||
|
|
||||||
若使用AI摘要插件则显示AI摘要,不使用则显示默认字数摘要
|
若使用AI摘要插件则显示AI摘要,不使用则显示默认字数摘要
|
||||||
|
|
||||||
|
### 说说 by Memos
|
||||||
|
|
||||||
|
使用自定义字段设置memos
|
||||||
|
在自定义字段中填入`memos`值为memos地址,不带`/`
|
||||||
|
在自定义字段中填入`memosID`默认值为`1`,不为`1`时才需要设置
|
||||||
|
在自定义字段中填入`memosnum`默认值为`20`,默认获取20条最近的memo
|
||||||
|
|
||||||
|
### 说说 by Mastodon
|
||||||
|
|
||||||
|
根据 https://www.imsun.org/archives/1643.html#toc3 获得API地址
|
||||||
|
在自定义字段中填入`tooot`值为Mastodon API 地址
|
||||||
|
|
||||||
## 预览地址
|
## 预览地址
|
||||||
|
|
||||||
https://www.imsun.org
|
https://www.imsun.org
|
||||||
|
|
||||||
|
## 感谢
|
||||||
|
|
||||||
|
[bigfa](https://github.com/bigfa/hugo-theme-farallon)
|
||||||
+41
-4
@@ -12,7 +12,6 @@
|
|||||||
<h3 class="post--single__subtitle"><?php $this->categorydescription(); ?></h3>
|
<h3 class="post--single__subtitle"><?php $this->categorydescription(); ?></h3>
|
||||||
<?php while($this->next()): ?>
|
<?php while($this->next()): ?>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<article class="post--item">
|
<article class="post--item">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h2 class="post--title">
|
<h2 class="post--title">
|
||||||
@@ -55,7 +54,7 @@
|
|||||||
'...',
|
'...',
|
||||||
array(
|
array(
|
||||||
'wrapTag' => 'div',
|
'wrapTag' => 'div',
|
||||||
'wrapClass' => 'cat_pagination_page',
|
'wrapClass' => 'pagination_page',
|
||||||
'itemTag' => '',
|
'itemTag' => '',
|
||||||
'textTag' => 'a',
|
'textTag' => 'a',
|
||||||
'currentClass' => 'active',
|
'currentClass' => 'active',
|
||||||
@@ -64,7 +63,6 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- 搜索结果 -->
|
<!-- 搜索结果 -->
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<main class="site--main">
|
<main class="site--main">
|
||||||
@@ -76,5 +74,44 @@
|
|||||||
</header>
|
</header>
|
||||||
</main>
|
</main>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<style>
|
||||||
|
/* 分页 */
|
||||||
|
.pagination_page{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: var(--margin);
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
.pagination_page li.active a {
|
||||||
|
background: var(--theme);
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.pagination_page a{
|
||||||
|
display: flex;
|
||||||
|
padding: 0.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
width: 1.75rem;
|
||||||
|
height: 1.75rem;
|
||||||
|
background: var(--background);
|
||||||
|
border-radius: 50%;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
transition: 0.2s;
|
||||||
|
-webkit-transition: 0.2s;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
letter-spacing: 0;
|
||||||
|
}
|
||||||
|
.pagination_page span.next{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.pagination_page li.active a:hover{
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
/* 分页 */
|
||||||
|
</style>
|
||||||
<?php $this->need('footer.php'); ?>
|
<?php $this->need('footer.php'); ?>
|
||||||
+47
-2
@@ -1,4 +1,44 @@
|
|||||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||||
|
<style>
|
||||||
|
/* 分页 */
|
||||||
|
.pagination_page{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: var(--margin);
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
.pagination_page li.active a {
|
||||||
|
background: var(--theme);
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.pagination_page a{
|
||||||
|
display: flex;
|
||||||
|
padding: 0.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
width: 1.75rem;
|
||||||
|
height: 1.75rem;
|
||||||
|
background: var(--background);
|
||||||
|
border-radius: 50%;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
transition: 0.2s;
|
||||||
|
-webkit-transition: 0.2s;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
letter-spacing: 0;
|
||||||
|
}
|
||||||
|
.pagination_page span.next{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.pagination_page li.active a:hover{
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
/* 分页 */
|
||||||
|
</style>
|
||||||
<div class="post--ingle__comments">
|
<div class="post--ingle__comments">
|
||||||
<?php $this->comments()->to($comments); ?>
|
<?php $this->comments()->to($comments); ?>
|
||||||
<?php if($this->allow('comment')): ?>
|
<?php if($this->allow('comment')): ?>
|
||||||
@@ -12,8 +52,9 @@
|
|||||||
d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z">
|
d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z">
|
||||||
</path>
|
</path>
|
||||||
</g>
|
</g>
|
||||||
</svg><?php $this->commentsNum(_t(''), _t('1'), _t('%d')); ?>
|
</svg><?php $this->commentsNum(_t('0'), _t('1'), _t('%d')); ?>
|
||||||
</h3>
|
</h3>
|
||||||
|
<ol class="commentlist sulliComment--list"></ol>
|
||||||
<?php if ($comments->have()): ?>
|
<?php if ($comments->have()): ?>
|
||||||
<?php $comments->listComments(); ?>
|
<?php $comments->listComments(); ?>
|
||||||
<?php
|
<?php
|
||||||
@@ -24,7 +65,7 @@
|
|||||||
'...',
|
'...',
|
||||||
array(
|
array(
|
||||||
'wrapTag' => 'div',
|
'wrapTag' => 'div',
|
||||||
'wrapClass' => 'cat_pagination_page',
|
'wrapClass' => 'pagination_page',
|
||||||
'itemTag' => '',
|
'itemTag' => '',
|
||||||
'textTag' => 'a',
|
'textTag' => 'a',
|
||||||
'currentClass' => 'active',
|
'currentClass' => 'active',
|
||||||
@@ -33,6 +74,10 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
<?php else: ?>
|
||||||
|
|
||||||
|
<center><h3><?php _e('暂无评论'); ?></h3></center>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div id="<?php $this->respondId(); ?>" class="comment-respond">
|
<div id="<?php $this->respondId(); ?>" class="comment-respond">
|
||||||
<div class="cancel-comment-reply cancel-comment-reply-link"><?php $comments->cancelReply(); ?></div>
|
<div class="cancel-comment-reply cancel-comment-reply-link"><?php $comments->cancelReply(); ?></div>
|
||||||
|
|||||||
Vendored
-298
@@ -3804,301 +3804,3 @@ div.cancel-comment-reply.cancel-comment-reply-link {
|
|||||||
width: 80%
|
width: 80%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-ai {
|
|
||||||
background: #f5f5f5;
|
|
||||||
border-radius: .5rem;
|
|
||||||
padding: .5rem;
|
|
||||||
line-height: 1.3;
|
|
||||||
border: 1px solid #cfe6f3;
|
|
||||||
margin: 1rem 0
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-title {
|
|
||||||
display: flex;
|
|
||||||
color: #2d96bd;
|
|
||||||
border-radius: .5rem;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 .25rem;
|
|
||||||
cursor: default;
|
|
||||||
user-select: none
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-title-icon {
|
|
||||||
width: 20px;
|
|
||||||
height: auto;
|
|
||||||
margin-right: .25rem
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-title-text {
|
|
||||||
font-weight: 700;
|
|
||||||
margin-left: .25rem;
|
|
||||||
line-height: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-explanation {
|
|
||||||
margin-top: 1rem;
|
|
||||||
padding: .5rem 1rem;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: .5rem;
|
|
||||||
border: 1px solid #cfe6f3;
|
|
||||||
font-size: .95rem;
|
|
||||||
line-height: 1.4;
|
|
||||||
display: inline-block;
|
|
||||||
width: 95%
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-explanation span {
|
|
||||||
margin-left: .5rem
|
|
||||||
}
|
|
||||||
|
|
||||||
:root {
|
|
||||||
--ht-main: #334155;
|
|
||||||
--ht-day-bg: #ebedf0;
|
|
||||||
--ht-tooltip: #24292f;
|
|
||||||
--ht-tooltip-bg: #fff;
|
|
||||||
--ht-lv-0: #ebedf0;
|
|
||||||
--ht-lv-1: #9be9a8;
|
|
||||||
--ht-lv-2: #40c463;
|
|
||||||
--ht-lv-3: #30a14e;
|
|
||||||
--ht-lv-4: #216e39
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme=dark] {
|
|
||||||
--ht-main: #94a3b8;
|
|
||||||
--ht-day-bg: #161b22;
|
|
||||||
--ht-tooltip: #24292f;
|
|
||||||
--ht-tooltip-bg: #fff;
|
|
||||||
--ht-lv-0: #161b22;
|
|
||||||
--ht-lv-1: #0e4429;
|
|
||||||
--ht-lv-2: #006d32;
|
|
||||||
--ht-lv-3: #26a641;
|
|
||||||
--ht-lv-4: #39d353
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-end;
|
|
||||||
font-size: 10px;
|
|
||||||
line-height: 12px;
|
|
||||||
color: var(--ht-main)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: flex-end
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_week {
|
|
||||||
display: flex;
|
|
||||||
margin-top: .25rem;
|
|
||||||
margin-right: .25rem;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: flex-end;
|
|
||||||
align-items: flex-end;
|
|
||||||
text-align: right
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_main {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_month {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-around;
|
|
||||||
margin-bottom: .25rem
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
height: 84px
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_footer {
|
|
||||||
display: flex;
|
|
||||||
margin-top: .5rem;
|
|
||||||
align-items: center
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_level {
|
|
||||||
display: flex;
|
|
||||||
gap: 2px;
|
|
||||||
margin: 0 .25rem;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
width: max-content;
|
|
||||||
height: 10px
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_level_item {
|
|
||||||
display: block;
|
|
||||||
border-radius: .125rem;
|
|
||||||
width: 10px;
|
|
||||||
height: 10px
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_level_0 {
|
|
||||||
background: var(--ht-lv-0)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_level_1 {
|
|
||||||
background: var(--ht-lv-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_level_2 {
|
|
||||||
background: var(--ht-lv-2)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_level_3 {
|
|
||||||
background: var(--ht-lv-3)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_level_4 {
|
|
||||||
background: var(--ht-lv-4)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_day {
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
background-color: var(--ht-day-bg);
|
|
||||||
margin: 1px;
|
|
||||||
border-radius: 2px;
|
|
||||||
display: inline-block;
|
|
||||||
position: relative
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_tooltip {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 12px;
|
|
||||||
left: 50%;
|
|
||||||
width: max-content;
|
|
||||||
color: var(--ht-tooltip);
|
|
||||||
background-color: var(--ht-tooltip-bg);
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 16px;
|
|
||||||
padding: 8px;
|
|
||||||
border-radius: 3px;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
opacity: 1;
|
|
||||||
transition: .3s;
|
|
||||||
z-index: 1000;
|
|
||||||
text-align: right;
|
|
||||||
transform: translateX(-50%)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_tooltip_count,
|
|
||||||
.heatmap_tooltip_post {
|
|
||||||
display: inline-block
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_tooltip_title,
|
|
||||||
.heatmap_tooltip_date {
|
|
||||||
display: block
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_tooltip_date {
|
|
||||||
margin: 0 .25rem
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_day_level_0 {
|
|
||||||
background-color: var(--ht-lv-0)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_day_level_1 {
|
|
||||||
background-color: var(--ht-lv-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_day_level_2 {
|
|
||||||
background-color: var(--ht-lv-2)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_day_level_3 {
|
|
||||||
background-color: var(--ht-lv-3)
|
|
||||||
}
|
|
||||||
|
|
||||||
.heatmap_day_level_4 {
|
|
||||||
background-color: var(--ht-lv-4)
|
|
||||||
}
|
|
||||||
/* 分页 */
|
|
||||||
.cat_pagination_page{
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin-top: var(--margin);
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
.cat_pagination_page li.active a {
|
|
||||||
background: var(--theme);
|
|
||||||
color: #fff;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.cat_pagination_page a{
|
|
||||||
display: flex;
|
|
||||||
padding: 0.5rem;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
width: 1.75rem;
|
|
||||||
height: 1.75rem;
|
|
||||||
background: var(--background);
|
|
||||||
border-radius: 50%;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
transition: 0.2s;
|
|
||||||
-webkit-transition: 0.2s;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
letter-spacing: 0;
|
|
||||||
}
|
|
||||||
.cat_pagination_page span.next{
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.cat_pagination_page li.active a:hover{
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
/* 分页 */
|
|
||||||
.cat_archive_next {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin-top: var(--margin);
|
|
||||||
}
|
|
||||||
.cat_archive_next .next{
|
|
||||||
color: var(--C);
|
|
||||||
padding: 0.5rem 0.75rem;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
background: var(--background);
|
|
||||||
border-radius: 1rem;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
transition: 0.2s;
|
|
||||||
-webkit-transition: 0.2s;
|
|
||||||
letter-spacing: 2px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.cat_archive_next .over{
|
|
||||||
font-size: small;
|
|
||||||
color: var(--A);
|
|
||||||
padding: 0.5rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.cat_categorymenu{
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
.cat_categorymenu a:last-child {
|
|
||||||
margin-right: auto;
|
|
||||||
}
|
|
||||||
.cat_categorymenu a {
|
|
||||||
display: inline-block;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Vendored
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
is_single = false;
|
is_single = false;
|
||||||
post_id = 0;
|
post_id = 0;
|
||||||
is_archive = false;
|
is_archive = false;
|
||||||
VERSION = "0.4.1";
|
VERSION = "0.5.0";
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.initCopyright();
|
this.initCopyright();
|
||||||
|
|||||||
Vendored
+7
File diff suppressed because one or more lines are too long
Vendored
+6
File diff suppressed because one or more lines are too long
+4
-9
@@ -1,16 +1,16 @@
|
|||||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||||
|
|
||||||
<footer class="site--footer">
|
<footer class="site--footer">
|
||||||
<div class="site--footer__content">
|
<div class="site--footer__content">
|
||||||
<div class=site--footer__sns>
|
<div class=site--footer__sns>
|
||||||
<?php $this->need('sns.php'); ?>
|
<?php $this->need('sns.php'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if($this->options->sitemapurl): ?>
|
<?php if($this->options->sitemapurl): ?>
|
||||||
<a href="<?php $this->options->sitemapurl() ?>" target="_blank">💗</a>
|
<a href="<?php $this->options->sitemapurl() ?>" target="_blank">💗</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a href="https://www.typecho.org">Typecho</a>驱动 <a href="https://www.imsun.org">Made with 老孙</a>💗 加载耗时
|
<a href="https://www.typecho.org">Typecho驱动</a>
|
||||||
<?php echo timer_stop();?> 💗
|
<a href="https://www.imsun.org"> Made with Sun</a>
|
||||||
|
页面加载耗时
|
||||||
|
<?php echo timer_stop();?>
|
||||||
<div class="copyright">
|
<div class="copyright">
|
||||||
<a href="<?php $this->options->siteUrl(); ?>">
|
<a href="<?php $this->options->siteUrl(); ?>">
|
||||||
<?php $this->options->title(); ?>
|
<?php $this->options->title(); ?>
|
||||||
@@ -22,13 +22,9 @@
|
|||||||
p-id="4007"></path>
|
p-id="4007"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php $this->options->tongji(); ?>
|
<?php $this->options->tongji(); ?>
|
||||||
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<div class="backToTop">
|
<div class="backToTop">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="svgIcon" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true">
|
<svg xmlns="http://www.w3.org/2000/svg" class="svgIcon" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true">
|
||||||
<path
|
<path
|
||||||
@@ -36,7 +32,6 @@
|
|||||||
</path>
|
</path>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="<?php $this->options->themeUrl('/dist/js/bundle.js'); ?>"></script>
|
<script src="<?php $this->options->themeUrl('/dist/js/bundle.js'); ?>"></script>
|
||||||
<?php $this->footer(); ?>
|
<?php $this->footer(); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+296
-26
@@ -5,37 +5,36 @@ function themeConfig($form) {
|
|||||||
$form->addInput($logoUrl);
|
$form->addInput($logoUrl);
|
||||||
$icoUrl = new Typecho_Widget_Helper_Form_Element_Text('icoUrl', NULL, NULL, _t('站点 Favicon 地址'));
|
$icoUrl = new Typecho_Widget_Helper_Form_Element_Text('icoUrl', NULL, NULL, _t('站点 Favicon 地址'));
|
||||||
$form->addInput($icoUrl);
|
$form->addInput($icoUrl);
|
||||||
$jzyear = new Typecho_Widget_Helper_Form_Element_Text('jzyear', NULL, NULL, _t('建站年份 eg. 2006'));
|
$jzyear = new Typecho_Widget_Helper_Form_Element_Text('jzyear', NULL, NULL, _t('建站年份'), _t('eg. 2006'));
|
||||||
$form->addInput($jzyear);
|
$form->addInput($jzyear);
|
||||||
$instagramurl = new Typecho_Widget_Helper_Form_Element_Text('instagramurl', NULL, NULL, _t('ins'));
|
|
||||||
$form->addInput($instagramurl);
|
|
||||||
$telegramurl = new Typecho_Widget_Helper_Form_Element_Text('telegramurl', NULL, NULL, _t('电报'));
|
|
||||||
$form->addInput($telegramurl);
|
|
||||||
$githuburl = new Typecho_Widget_Helper_Form_Element_Text('githuburl', NULL, NULL, _t('github'));
|
|
||||||
$form->addInput($githuburl);
|
|
||||||
$twitterurl = new Typecho_Widget_Helper_Form_Element_Text('twitterurl', NULL, NULL, _t('twitter'));
|
|
||||||
$form->addInput($twitterurl);
|
|
||||||
$mastodonurl = new Typecho_Widget_Helper_Form_Element_Text('mastodonurl', NULL, NULL, _t('mastodon'));
|
|
||||||
$form->addInput($mastodonurl);
|
|
||||||
$sitemapurl = new Typecho_Widget_Helper_Form_Element_Text('sitemapurl', NULL, NULL, _t('sitemap'));
|
|
||||||
$form->addInput($sitemapurl);
|
|
||||||
$cnavatar = new Typecho_Widget_Helper_Form_Element_Text('cnavatar', NULL, 'https://cravatar.cn/avatar/', _t('自定义Gravatar镜像服务器,默认https://cravatar.cn/avatar/'));
|
|
||||||
$form->addInput($cnavatar);
|
|
||||||
$donate = new Typecho_Widget_Helper_Form_Element_Text('donate', NULL, 'https://blogcdn.loliko.cn/donate/wx.png', _t('赞赏二维码'));
|
|
||||||
$form->addInput($donate);
|
|
||||||
|
|
||||||
|
|
||||||
$twikoo = new Typecho_Widget_Helper_Form_Element_Textarea('twikoo', NULL, NULL, _t('引用第三方评论'));
|
|
||||||
$form->addInput($twikoo);
|
|
||||||
|
|
||||||
$addhead = new Typecho_Widget_Helper_Form_Element_Textarea('addhead', NULL, NULL, _t('添加head'));
|
|
||||||
$form->addInput($addhead);
|
|
||||||
$tongji = new Typecho_Widget_Helper_Form_Element_Textarea('tongji', NULL, NULL, _t('统计代码'));
|
|
||||||
$form->addInput($tongji);
|
|
||||||
$showProfile = new Typecho_Widget_Helper_Form_Element_Radio('showProfile',
|
$showProfile = new Typecho_Widget_Helper_Form_Element_Radio('showProfile',
|
||||||
array('0'=> _t('否'), '1'=> _t('是')),
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
'0', _t('是否在文章页面显示显示作者信息'), _t('选择“是”将在文章页面包含显示作者信息。'));
|
'0', _t('是否在文章页面显示显示作者信息'), _t('选择“是”将在文章页面包含显示作者信息。'));
|
||||||
$form->addInput($showProfile);
|
$form->addInput($showProfile);
|
||||||
|
$instagramurl = new Typecho_Widget_Helper_Form_Element_Text('instagramurl', NULL, NULL, _t('Instagram'), _t('会在个人信息显示'));
|
||||||
|
$form->addInput($instagramurl);
|
||||||
|
$telegramurl = new Typecho_Widget_Helper_Form_Element_Text('telegramurl', NULL, NULL, _t('电报'), _t('会在个人信息显示'));
|
||||||
|
$form->addInput($telegramurl);
|
||||||
|
$githuburl = new Typecho_Widget_Helper_Form_Element_Text('githuburl', NULL, NULL, _t('github'), _t('会在个人信息显示'));
|
||||||
|
$form->addInput($githuburl);
|
||||||
|
$twitterurl = new Typecho_Widget_Helper_Form_Element_Text('twitterurl', NULL, NULL, _t('twitter'), _t('会在个人信息显示'));
|
||||||
|
$form->addInput($twitterurl);
|
||||||
|
$mastodonurl = new Typecho_Widget_Helper_Form_Element_Text('mastodonurl', NULL, NULL, _t('mastodon'), _t('会在个人信息显示'));
|
||||||
|
$form->addInput($mastodonurl);
|
||||||
|
$sitemapurl = new Typecho_Widget_Helper_Form_Element_Text('sitemapurl', NULL, NULL, _t('sitemap'), _t('会在页脚显示'));
|
||||||
|
$form->addInput($sitemapurl);
|
||||||
|
$cnavatar = new Typecho_Widget_Helper_Form_Element_Text('cnavatar', NULL, 'https://cravatar.cn/avatar/', _t('Gravatar镜像'), _t('默认https://cravatar.cn/avatar/,建议保持默认'));
|
||||||
|
$form->addInput($cnavatar);
|
||||||
|
$donate = new Typecho_Widget_Helper_Form_Element_Text('donate', NULL, 'https://blogcdn.loliko.cn/donate/wx.png', _t('赞赏二维码'), _t('不填写则不显示'));
|
||||||
|
$form->addInput($donate);
|
||||||
|
$doubanID = new Typecho_Widget_Helper_Form_Element_Text('doubanID', NULL, '322dba2a3a27524b97c06d941d9631d153fc', _t('豆瓣页面必需Token'), _t('从<a href="https://node.wpista.com/" target="_blank">https://node.wpista.com/</a>获得token'));
|
||||||
|
$form->addInput($doubanID);
|
||||||
|
$twikoo = new Typecho_Widget_Helper_Form_Element_Textarea('twikoo', NULL, NULL, _t('引用第三方评论'), _t('不填写则不显示'));
|
||||||
|
$form->addInput($twikoo);
|
||||||
|
$addhead = new Typecho_Widget_Helper_Form_Element_Textarea('addhead', NULL, NULL, _t('添加head'), _t('支持HTML'));
|
||||||
|
$form->addInput($addhead);
|
||||||
|
$tongji = new Typecho_Widget_Helper_Form_Element_Textarea('tongji', NULL, NULL, _t('统计代码'), _t('支持HTML'));
|
||||||
|
$form->addInput($tongji);
|
||||||
$showallwords = new Typecho_Widget_Helper_Form_Element_Radio('showallwords',
|
$showallwords = new Typecho_Widget_Helper_Form_Element_Radio('showallwords',
|
||||||
array('0'=> _t('否'), '1'=> _t('是')),
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
'0', _t('是否显示归档字数统计'), _t('选择“是”将在归档页面显示全站总字数。'));
|
'0', _t('是否显示归档字数统计'), _t('选择“是”将在归档页面显示全站总字数。'));
|
||||||
@@ -44,6 +43,14 @@ function themeConfig($form) {
|
|||||||
array('0'=> _t('否'), '1'=> _t('是')),
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
'0', _t('是否显示相关文章'), _t('选择“是”将在文章页面显示相关文章。'));
|
'0', _t('是否显示相关文章'), _t('选择“是”将在文章页面显示相关文章。'));
|
||||||
$form->addInput($showrelated);
|
$form->addInput($showrelated);
|
||||||
|
$showshare = new Typecho_Widget_Helper_Form_Element_Radio('showshare',
|
||||||
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
|
'0', _t('是否显示复制链接'), _t('选择“是”将在文章页面显示复制链接。'));
|
||||||
|
$form->addInput($showshare);
|
||||||
|
$showtoc = new Typecho_Widget_Helper_Form_Element_Radio('showtoc',
|
||||||
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
|
'0', _t('是否显示文章目录'), _t('选择“是”将在文章页面显示文章目录(仅在宽度大于1400px的设备中显示)。'));
|
||||||
|
$form->addInput($showtoc);
|
||||||
}
|
}
|
||||||
function get_post_view($archive) {
|
function get_post_view($archive) {
|
||||||
$cid = $archive->cid;
|
$cid = $archive->cid;
|
||||||
@@ -172,3 +179,266 @@ function show_first_image($content) {
|
|||||||
}
|
}
|
||||||
return false; // 没有找到图片,返回 false
|
return false; // 没有找到图片,返回 false
|
||||||
}
|
}
|
||||||
|
//开始增加某些奇怪的东西
|
||||||
|
// 获取月份
|
||||||
|
function getMonth() {
|
||||||
|
$path = $_SERVER['PHP_SELF']; // 获取路劲
|
||||||
|
preg_match('/\d{4}\/\d{2}\/\d{2}|\d{4}\/\d{2}/', $path, $date); // 匹配路劲中的日期
|
||||||
|
if (is_array($date) && count($date)) {
|
||||||
|
$date = explode('/', $date[0]); // 如果匹配到就分割日期
|
||||||
|
}else {
|
||||||
|
$date = date('Y/m/d', time()); // 如果没有匹配到就获取当前月
|
||||||
|
$date = explode('/', $date); // 分割日期
|
||||||
|
}
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
// 获取指定月份的文章
|
||||||
|
function getMonthPost() {
|
||||||
|
$date = getMonth(); // 获取要查询文章的月份
|
||||||
|
|
||||||
|
$start = $date[0] . '-' . $date[1] . '-01 00:00:00'; // 月的第一天
|
||||||
|
$end = date('Y-m-t', strtotime($date[0] . '-' . $date[1] . '-' . '1 23:59:59')); // 月最后一天
|
||||||
|
$start = strtotime($start); // 把月的第一天转换为时间戳
|
||||||
|
$end = strtotime($end . ' 23:59:59'); // 把月的最后一天转换为时间戳
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
// 按照提供的月份查询出文件的时间
|
||||||
|
$post = $db->fetchAll($db->select('table.contents.created')->from('table.contents')->where('created >= ?', $start)->where('created <= ?', $end)->where('type = ?', 'post')->where('status = ?', 'publish'));
|
||||||
|
// 按照提供的月份查询前一个月的文章
|
||||||
|
$previous = $db->fetchAll($db->select('table.contents.created')->from('table.contents')->where('created < ?', $start)->where('type = ?', 'post')->where('status = ?', 'publish')->offset(0)->limit(1)->order('created', Typecho_Db::SORT_DESC));
|
||||||
|
// 按照提供的月份查询后一个月的文章
|
||||||
|
$next = $db->fetchAll($db->select('table.contents.created')->from('table.contents')->where('created > ?', $end)->where('type = ?', 'post')->where('status = ?', 'publish')->offset(0)->limit(1)->order('created', Typecho_Db::SORT_ASC));
|
||||||
|
|
||||||
|
if (count($next)) {
|
||||||
|
$next = date('Y/m/', $next[0]['created']); // 格式化前一个月的文章时间
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($previous)) {
|
||||||
|
$previous = date('Y/m/', $previous[0]['created']); // 格式化后一个月的文章时间
|
||||||
|
}
|
||||||
|
|
||||||
|
$day = array();
|
||||||
|
foreach ($post as $val) {
|
||||||
|
array_push($day, date('j', $val['created'])); // 把查询出的文章日加入数组
|
||||||
|
}
|
||||||
|
return array(
|
||||||
|
'post'=> $day,
|
||||||
|
'previous' => $previous,
|
||||||
|
'next' => $next
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// 生成日历
|
||||||
|
function calendar($month, $url, $rewrite) {
|
||||||
|
$monthArr = getMonth(); // 获取月份
|
||||||
|
$post = getMonthPost(); // 获取文章日期
|
||||||
|
|
||||||
|
// 判断是否启用了地址重写功能
|
||||||
|
if ($rewrite) {
|
||||||
|
$monthUrl = $url . $monthArr[0] . '/' . $monthArr[1] . '/'; // 生成日期链接前缀
|
||||||
|
$previousUrl = is_array($post['previous'])?'':$url . $post['previous']; // 生成前一个月的跳转链接地址
|
||||||
|
$nextUrl = is_array($post['next'])?'':$url . $post['next']; // 生成后一个月的跳转链接地址
|
||||||
|
}else {
|
||||||
|
$monthUrl = $url . 'index.php/' . $monthArr[0] . '/' . $monthArr[1] . '/'; // 生成日期链接前缀
|
||||||
|
$previousUrl = is_array($post['previous'])?'':$url . 'index.php/' . $post['previous']; // 生成前一个月的跳转链接地址
|
||||||
|
$nextUrl = is_array($post['next'])?'':$url . 'index.php/' . $post['next']; // 生成后一个月的跳转链接地址
|
||||||
|
}
|
||||||
|
|
||||||
|
$postCount = array_count_values($post['post']); // 统计每天的文章数量
|
||||||
|
|
||||||
|
$calendar = ''; // 初始化
|
||||||
|
$week_arr = ['日', '一', '二', '三', '四', '五', '六']; // 表头
|
||||||
|
$this_month_days = (int)date('t', strtotime($month)); // 本月共多少天
|
||||||
|
$this_month_one_n = (int)date('w', strtotime($month)); // 本月1号星期几
|
||||||
|
$calendar .= '<table aria-label="' . $monthArr[0] . '年' . $monthArr[1] . '月日历" class="table table-bordered table-sm m-0"><thead><tr>'; // 表头
|
||||||
|
|
||||||
|
foreach ($week_arr as $k => $v){
|
||||||
|
if($k == 0){
|
||||||
|
$class = ' class="sunday"';
|
||||||
|
}elseif ($k == 6){
|
||||||
|
$class = ' class="saturday"';
|
||||||
|
}else{
|
||||||
|
$class = '';
|
||||||
|
}
|
||||||
|
$calendar .= '<th class="text-center py-2">' . $v . '</th>';
|
||||||
|
}
|
||||||
|
$calendar .= '</tr></thead><tbody>';
|
||||||
|
// 表身
|
||||||
|
// 计算本月共几行数据
|
||||||
|
$total_rows = ceil(($this_month_days - (7 - $this_month_one_n)) / 7) + 1;
|
||||||
|
$number = 1;
|
||||||
|
$flag = 0;
|
||||||
|
for ($row = 1;$row <= $total_rows;$row++){
|
||||||
|
$calendar .= '<tr>';
|
||||||
|
for ($week = 0;$week <= 6;$week ++){
|
||||||
|
if($number < 10){
|
||||||
|
$numbera = '0' . $number;
|
||||||
|
}else{
|
||||||
|
$numbera = $number;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($number <= $this_month_days){
|
||||||
|
if ($number < 10) {
|
||||||
|
$zero = '0';
|
||||||
|
}else {
|
||||||
|
$zero = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($row == 1){
|
||||||
|
if($week >= $this_month_one_n){
|
||||||
|
if (in_array($number, $post['post'])) {
|
||||||
|
$calendar .= '<td class="active text-center py-2">' . '<a rel="archives" href="' . $monthUrl . $zero . $number . '/' . '" class="p-0" title="' . $postCount[$number] . '篇文章" data-toggle="tooltip" data-placement="top"><b>' . $number . '</b></a>' . '</td>';
|
||||||
|
}else {
|
||||||
|
$calendar .= '<td class="text-center py-2">' . $number . '</td>';
|
||||||
|
}
|
||||||
|
$flag = 1;
|
||||||
|
}else{
|
||||||
|
$calendar .= '<td></td>';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (in_array($number, $post['post'])) {
|
||||||
|
$calendar .= '<td class="active text-center py-2">' . '<a rel="archives" href="' . $monthUrl . $zero . $number . '/' . '" class="p-0" title="' . $postCount[$number] . '篇文章" data-toggle="tooltip" data-placement="top"><b>' . $number . '</b></a>' . '</td>';
|
||||||
|
}else {
|
||||||
|
$calendar .= '<td class="text-center py-2">' . $number . '</td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($flag){
|
||||||
|
$number ++;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$calendar .= '<td></td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$calendar .= '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$calendar .= '</tbody></table>';
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'calendar' => $calendar,
|
||||||
|
'previous' => is_array($post['previous'])?false:$post['previous'],
|
||||||
|
'next' => is_array($post['next'])?false:$post['next'],
|
||||||
|
'previousUrl' => $previousUrl,
|
||||||
|
'nextUrl' => $nextUrl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// 获取分类数量
|
||||||
|
function categoryCount() {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$count = $db->fetchRow($db->select('COUNT(*)')->from('table.metas')->where('type = ?', 'category'));
|
||||||
|
return $count['COUNT(*)'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取标签数量
|
||||||
|
function tagCount() {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$count = $db->fetchRow($db->select('COUNT(*)')->from('table.metas')->where('type = ?', 'tag'));
|
||||||
|
return $count['COUNT(*)'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取总阅读量
|
||||||
|
function viewsCount() {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$count = $db->fetchRow($db->select('SUM(views) AS viewsCount')->from('table.contents'));
|
||||||
|
return $count['viewsCount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取阅读量排名前 5 的 5 篇文章的信息
|
||||||
|
function top5post() {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$top5Post = $db->fetchAll($db->select()->from('table.contents')->where('type = ?', 'post')->where('status = ?', 'publish')->order('views', Typecho_Db::SORT_DESC)->offset(0)->limit(5));
|
||||||
|
$postList =array();
|
||||||
|
foreach ($top5Post as $post) {
|
||||||
|
$post = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($post);
|
||||||
|
array_push($postList, array(
|
||||||
|
'title' => $post['title'],
|
||||||
|
'link' => $post['permalink'],
|
||||||
|
'views' => $post['views']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return $postList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取评论数排名前 5 的 5 篇文章的信息
|
||||||
|
function top5CommentPost() {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$top5Post = $db->fetchAll($db->select()->from('table.contents')->where('type = ?', 'post')->where('status = ?', 'publish')->order('commentsNum', Typecho_Db::SORT_DESC)->offset(0)->limit(5));
|
||||||
|
$postList = array();
|
||||||
|
foreach ($top5Post as $post) {
|
||||||
|
$post = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($post);
|
||||||
|
array_push($postList, array(
|
||||||
|
'title' => $post['title'],
|
||||||
|
'link' => $post['permalink'],
|
||||||
|
'commentsNum' => $post['commentsNum']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return $postList;
|
||||||
|
}
|
||||||
|
// 获取 ECharts 格式要求的文章更新日历
|
||||||
|
function postCalendar($start, $end) {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$dateList = $db->fetchAll($db->select('created')->from('table.contents')->where('created > ?', $start)->where('created < ?', $end));
|
||||||
|
if (count($dateList) < 1) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$dateList2 = array();
|
||||||
|
foreach ($dateList as $val) {
|
||||||
|
array_push($dateList2, date('Y-m-d', $val['created']));
|
||||||
|
}
|
||||||
|
$dateList2 = array_count_values($dateList2);
|
||||||
|
$key = array_keys($dateList2);
|
||||||
|
$dateList = array();
|
||||||
|
|
||||||
|
for ($i = 0;$i < count($dateList2);$i ++) {
|
||||||
|
array_push($dateList, array(
|
||||||
|
$key[$i],
|
||||||
|
$dateList2[$key[$i]]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dateList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取 ECharts 格式要求的评论更新日历
|
||||||
|
function commentCalendar($start, $end) {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$dateList = $db->fetchAll($db->select('created')->from('table.comments')->where('created > ?', $start)->where('created < ?', $end));
|
||||||
|
if (count($dateList) < 1) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$dateList2 = array();
|
||||||
|
foreach ($dateList as $val) {
|
||||||
|
array_push($dateList2, date('Y-m-d', $val['created']));
|
||||||
|
}
|
||||||
|
$dateList2 = array_count_values($dateList2);
|
||||||
|
$key = array_keys($dateList2);
|
||||||
|
$dateList = array();
|
||||||
|
|
||||||
|
for ($i = 0;$i < count($dateList2);$i ++) {
|
||||||
|
array_push($dateList, array(
|
||||||
|
$key[$i],
|
||||||
|
$dateList2[$key[$i]]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dateList;
|
||||||
|
}
|
||||||
|
// 获取个分类的文章数量
|
||||||
|
function categoryPostCount() {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$count = $db->fetchAll($db->select('name', 'count AS value')->from('table.metas')->where('type = ?', 'category'));
|
||||||
|
if (count($count) < 1) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取父分类的名称
|
||||||
|
function getParentCategory($categoryId) {
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$category = $db->fetchRow($db->select()->from('table.metas')->where('mid = ?', $categoryId));
|
||||||
|
return $category['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算两个时间之间相差的天数
|
||||||
|
function getDays($time1, $time2) {
|
||||||
|
return floor(($time2 - $time1) / 86400);
|
||||||
|
}
|
||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
<?php ini_set('display_errors', 1);
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
error_reporting(E_ALL);if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
error_reporting(E_ALL);
|
||||||
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* 移植自HUGO主题`farallon`原作者`bigfa`
|
* 移植自HUGO主题`farallon`原作者`bigfa`
|
||||||
* @package farallon
|
* @package farallon
|
||||||
* @author 老孙
|
* @author 老孙
|
||||||
* @version 0.4.1
|
* @version 0.5.1
|
||||||
* @link https://imsun.org
|
* @link https://imsun.org
|
||||||
*/
|
*/
|
||||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* 无评论页面
|
|
||||||
*
|
|
||||||
* @package custom
|
|
||||||
*/
|
|
||||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|
||||||
<?php $this->need('header.php'); ?>
|
|
||||||
<main class="site--main">
|
|
||||||
<header class="archive--header">
|
|
||||||
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
|
||||||
</header>
|
|
||||||
<article class="post--single">
|
|
||||||
<div class="graph u-marginBottom30">
|
|
||||||
<?php $this->content(); ?>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</main>
|
|
||||||
<?php $this->need('footer.php'); ?>
|
|
||||||
|
|
||||||
+31
-18
@@ -10,7 +10,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||||||
<header class="archive--header">
|
<header class="archive--header">
|
||||||
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
||||||
<?php Typecho_Widget::widget('Widget_Stat')->to($quantity); ?>
|
<?php Typecho_Widget::widget('Widget_Stat')->to($quantity); ?>
|
||||||
<h2 class="archive--title__year">共包含 <?php $quantity->publishedPostsNum(); ?> 篇文章</h2>
|
<h2 class="post--single__subtitle">共包含 <?php $quantity->publishedPostsNum(); ?> 篇文章</h2>
|
||||||
<?php if ($this->options->showallwords): ?>
|
<?php if ($this->options->showallwords): ?>
|
||||||
<h3><?php echo allwords(); ?></h3>
|
<h3><?php echo allwords(); ?></h3>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -19,31 +19,44 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||||||
<?php
|
<?php
|
||||||
$stat = Typecho_Widget::widget('Widget_Stat');
|
$stat = Typecho_Widget::widget('Widget_Stat');
|
||||||
Typecho_Widget::widget('Widget_Contents_Post_Recent', 'pageSize=' . $stat->publishedPostsNum)->to($archives);
|
Typecho_Widget::widget('Widget_Contents_Post_Recent', 'pageSize=' . $stat->publishedPostsNum)->to($archives);
|
||||||
$year = 0;
|
$year = 0; $mon = 0;
|
||||||
$mon = 0;
|
$output = '<div class="archives">'; // Start archives container
|
||||||
$i = 0;
|
|
||||||
$j = 0;
|
|
||||||
$output = '<div class="archives">';
|
|
||||||
while ($archives->next()) {
|
while ($archives->next()) {
|
||||||
$year_tmp = date('Y', $archives->created);
|
$year_tmp = date('Y', $archives->created);
|
||||||
$mon_tmp = date('m', $archives->created);
|
$mon_tmp = date('m', $archives->created);
|
||||||
$y = $year;
|
// 检查是否需要新的年份标题
|
||||||
$m = $mon;
|
if ($year != $year_tmp) {
|
||||||
if ($year > $year_tmp || $mon > $mon_tmp) {
|
if ($year > 0) {
|
||||||
$output .= '</ul>';
|
$output .= '</ul></div>'; // 结束上一个年份的月份列表和包裹的div
|
||||||
}
|
}
|
||||||
if ($year != $year_tmp || $mon != $mon_tmp) {
|
|
||||||
$year = $year_tmp;
|
$year = $year_tmp;
|
||||||
|
$mon = 0; // 重置月份
|
||||||
|
$output .= '<div class="archive-year"><h2 class="archive--title__year">' . $year . '</h2>'; // 开始新的年份div
|
||||||
|
}
|
||||||
|
// 检查是否需要新的月份标题
|
||||||
|
if ($mon != $mon_tmp) {
|
||||||
|
if ($mon > 0) {
|
||||||
|
$output .= '</ul>'; // 结束上一个月份的列表
|
||||||
|
}
|
||||||
$mon = $mon_tmp;
|
$mon = $mon_tmp;
|
||||||
$output .= '<h2 class="archive--title__year">' . date('Y年', $archives->created) . '</h2>
|
$output .= '<h3 class="archive--title__month"></h3>';// '. $mon . '
|
||||||
<h3 class="archive--title__month">'. date('m月', $archives->created) .'</h3><ul class="archive--list" aria-label="' . date('Y年m月', $archives->created) . '">
|
$output .= '<ul class="archive--list">'; // 开始新的月份列表
|
||||||
'; //输出年份
|
|
||||||
}
|
}
|
||||||
$output .= '<li class="archive--item"><div class="archive--title"><a href="' . $archives->permalink . '">' . $archives->title . '</a></div>
|
// 输出文章项
|
||||||
<div class="archive--meta">' . date('m月d日', $archives->created) . '</div> </li>'; //输出文章
|
$output .= '<li class="archive--item">';
|
||||||
|
$output .= '<div class="archive--title"><a href="' . $archives->permalink . '">' . $archives->title . '</a></div>';
|
||||||
|
$output .= '<div class="archive--meta">' . date('m月d日', $archives->created) . '</div></li>';
|
||||||
}
|
}
|
||||||
$output .= ' </ul></div>';
|
// 循环后,确保所有标签都已经关闭
|
||||||
echo $output;?>
|
if ($mon > 0) {
|
||||||
|
$output .= '</ul>'; // 结束最后一个月份的列表
|
||||||
|
}
|
||||||
|
if ($year > 0) {
|
||||||
|
$output .= '</div>'; // 结束最后一个年份的div
|
||||||
|
}
|
||||||
|
$output .= '</div>'; // End archives container
|
||||||
|
echo $output;
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<?php $this->need('footer.php'); ?>
|
<?php $this->need('footer.php'); ?>
|
||||||
|
|||||||
+154
@@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 网站数据
|
||||||
|
* @package custom
|
||||||
|
*/
|
||||||
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||||
|
$this->need('header.php');
|
||||||
|
?>
|
||||||
|
<section class="site--main">
|
||||||
|
<header class="archive--header">
|
||||||
|
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
||||||
|
<h2 class="archive--title__year"> </h2>
|
||||||
|
</header>
|
||||||
|
<article class="post--single">
|
||||||
|
<div class="graph u-marginBottom30">
|
||||||
|
<div data-target="<?php $this->options->postLinkOpen(); ?>" class="post-content">
|
||||||
|
<h2>分类占比</h2>
|
||||||
|
<p>下面是个分类的文章占比:</p>
|
||||||
|
<div id="category-chart" style="height: 390px;"></div>
|
||||||
|
<h2>文章更新</h2>
|
||||||
|
<p>下面是 <?php echo date('Y年m月d日', time() - 20736000); ?> 到 <?php echo date('Y年m月d日', time()); ?> 的文章更新情况</p>
|
||||||
|
<div id="post-chart" style="height: 250px;"></div>
|
||||||
|
<h2>评论动态</h2>
|
||||||
|
<p>下面是 <?php echo date('Y年m月d日', time() - 20736000); ?> 到 <?php echo date('Y年m月d日', time()); ?> 的评论动态</p>
|
||||||
|
<div id="comment-chart" style="height: 250px;"></div>
|
||||||
|
<h2>最多阅读的文章</h2>
|
||||||
|
<?php $top5Post = top5post(); ?>
|
||||||
|
<p>下面是阅读量排名前 <?php echo count($top5Post); ?> 的文章</p>
|
||||||
|
<table class="pure-table pure-table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>排名</th>
|
||||||
|
<th>文章</th>
|
||||||
|
<th>阅读量</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php $top = 1; ?>
|
||||||
|
<?php foreach ($top5Post as $post): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $top; ?></td>
|
||||||
|
<td><a href="<?php echo $post['link']; ?>"><?php echo $post['title']; ?></a></td>
|
||||||
|
<td><?php echo $post['views']; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php $top ++; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2>最多评论的文章</h2>
|
||||||
|
<?php $top5CommentPost = top5CommentPost(); ?>
|
||||||
|
<p>下面是评论数排名前 <?php echo count($top5CommentPost); ?> 的文章:</p>
|
||||||
|
<table class="pure-table pure-table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>排名</th>
|
||||||
|
<th>文章</th>
|
||||||
|
<th>评论数</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php $top = 1; ?>
|
||||||
|
<?php foreach ($top5CommentPost as $post): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $top; ?></td>
|
||||||
|
<td><a href="<?php echo $post['link']; ?>"><?php echo $post['title']; ?></a></td>
|
||||||
|
<td><?php echo $post['commentsNum']; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php $top ++; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var data = {
|
||||||
|
post: <?php echo json_encode(postCalendar(time() - 20736000, time())); ?>,
|
||||||
|
comment: <?php echo json_encode(commentCalendar(time() - 20736000, time())); ?>,
|
||||||
|
category: <?php echo json_encode(categoryPostCount()); ?>
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/jkjoy/typecho-theme-farallon@0.5.0/dist/js/chart.js"></script>
|
||||||
|
<script id="MathJax-script" async src="https://jsd.onmicrosoft.cn/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||||
|
<script>
|
||||||
|
// 配置 MathJax
|
||||||
|
MathJax = {
|
||||||
|
tex: {
|
||||||
|
inlineMath: [['$', '$']],
|
||||||
|
displayMath: [['$$', '$$']],
|
||||||
|
processEscapes: true,
|
||||||
|
processEnvironments: true,
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
// 刷新预时重新渲染
|
||||||
|
document.addEventListener('pjax:complete', () => {
|
||||||
|
MathJax.typesetPromise();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
td,th {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
empty-cells: show;
|
||||||
|
border: 1px solid #cbcbcb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table caption {
|
||||||
|
color: #000;
|
||||||
|
font: italic 85%/1 arial,sans-serif;
|
||||||
|
padding: 1em 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table td,.pure-table th {
|
||||||
|
border-left: 1px solid #cbcbcb;
|
||||||
|
border-width: 0 0 0 1px;
|
||||||
|
font-size: inherit;
|
||||||
|
margin: 0;
|
||||||
|
overflow: visible;
|
||||||
|
padding: .5em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table thead {
|
||||||
|
background-color: #e0e0e0;
|
||||||
|
color: #000;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table td {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table-bordered td {
|
||||||
|
border-bottom: 1px solid #cbcbcb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-table-bordered tbody>tr:last-child>td {
|
||||||
|
border-bottom-width: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<?php $this->need('footer.php'); ?>
|
||||||
+334
-2
@@ -9,10 +9,342 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||||||
<section class="site--main">
|
<section class="site--main">
|
||||||
<header class="archive--header">
|
<header class="archive--header">
|
||||||
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
||||||
<h2 class="post--single__subtitle">观影数据来源于豆瓣</h2>
|
<h2 class="post--single__subtitle">数据来源于豆瓣</h2>
|
||||||
</header>
|
</header>
|
||||||
|
<div class="site--main">
|
||||||
|
<div class="db--container" data-token="<?php $this->options->doubanID() ?>">
|
||||||
|
<nav class="db--nav">
|
||||||
|
<div class="db--navItem JiEun current" data-type="movie">Movie</div>
|
||||||
|
<div class="db--navItem JiEun" data-type="book">Book</div>
|
||||||
|
<div class="db--navItem JiEun" data-type="music">Music</div>
|
||||||
|
</nav>
|
||||||
|
<div class="db--genres">
|
||||||
|
</div>
|
||||||
|
<div class="db--list db--list__card">
|
||||||
|
</div>
|
||||||
|
<div class="block-more block-more__centered">
|
||||||
|
<div class="lds-ripple">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
class APIHandler {
|
||||||
|
constructor(token) {
|
||||||
|
this.ver = "1.0.1";
|
||||||
|
this.type = "movie";
|
||||||
|
this.finished = false;
|
||||||
|
this.paged = 1;
|
||||||
|
this.genre_list = [];
|
||||||
|
this.genre = [];
|
||||||
|
this.subjects = [];
|
||||||
|
this.baseAPI = "https://node.wpista.com/v1/outer/";
|
||||||
|
this.token = token;
|
||||||
|
this._create();
|
||||||
|
}
|
||||||
|
|
||||||
<div data-status="watched" class="douban-movie-list doubanboard-list"></div>
|
on(event, selector, handler) {
|
||||||
|
const elements = document.querySelectorAll(selector);
|
||||||
|
elements.forEach(element => {
|
||||||
|
element.addEventListener(event, handler);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_fetchGenres() {
|
||||||
|
document.querySelector(".db--genres").innerHTML = "";
|
||||||
|
fetch(`${this.baseAPI}genres?token=${this.token}&type=${this.type}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.data.length) {
|
||||||
|
this.genre_list = data.data;
|
||||||
|
this._renderGenre();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleGenreClick() {
|
||||||
|
this.on("click", ".db--genreItem", event => {
|
||||||
|
const target = event.currentTarget;
|
||||||
|
if (target.classList.contains("is-active")) {
|
||||||
|
const index = this.genre.indexOf(target.innerText);
|
||||||
|
target.classList.remove("is-active");
|
||||||
|
this.genre.splice(index, 1);
|
||||||
|
this.paged = 1;
|
||||||
|
this.finished = false;
|
||||||
|
this.subjects = [];
|
||||||
|
this._fetchData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.querySelector(".db--list").innerHTML = "";
|
||||||
|
document.querySelector(".lds-ripple").classList.remove("u-hide");
|
||||||
|
target.classList.add("is-active");
|
||||||
|
this.genre.push(target.innerText);
|
||||||
|
this.paged = 1;
|
||||||
|
this.finished = false;
|
||||||
|
this.subjects = [];
|
||||||
|
this._fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_renderGenre() {
|
||||||
|
document.querySelector(".db--genres").innerHTML = this.genre_list.map(genre =>
|
||||||
|
`<span class="db--genreItem${this.genre.includes(genre.name) ? " is-active" : ""}">${genre.name}</span>`
|
||||||
|
).join("");
|
||||||
|
this._handleGenreClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
_fetchData() {
|
||||||
|
fetch(`${this.baseAPI}faves?token=${this.token}&type=${this.type}&paged=${this.paged}&genre=${JSON.stringify(this.genre)}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.data.length) {
|
||||||
|
if (document.querySelector(".db--list").classList.contains("db--list__card"))
|
||||||
|
{
|
||||||
|
this.subjects = [...this.subjects, ...data.data];
|
||||||
|
this._randerDateTemplate();
|
||||||
|
} else {
|
||||||
|
this.subjects = [...this.subjects, ...data.data];
|
||||||
|
this._randerListTemplate();
|
||||||
|
}
|
||||||
|
document
|
||||||
|
.querySelector(".lds-ripple").classList.add("u-hide");
|
||||||
|
} else {
|
||||||
|
this.finished = true;
|
||||||
|
document.querySelector(".lds-ripple").classList.add("u-hide");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_randerDateTemplate() {
|
||||||
|
const result = this.subjects.reduce((result, item) => {
|
||||||
|
const date = new Date(item.create_time);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = date.getMonth() + 1;
|
||||||
|
const key = `${year}-${month.toString().padStart(2, "0")}`;
|
||||||
|
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
||||||
|
result[key].push(item);
|
||||||
|
} else {
|
||||||
|
result[key] = [item];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
let html = ``;
|
||||||
|
for (let key in result) {
|
||||||
|
const date = key.split("-");
|
||||||
|
html += `<div class="db--listBydate"><div class="db--titleDate "><div class="db--titleDate__day">${date[1]}</div><div class="db--titleDate__month">${date[0]}</div></div><div class="db--dateList__card">`;
|
||||||
|
html += result[key]
|
||||||
|
.map(subject => {
|
||||||
|
return `<div class="db--item">${
|
||||||
|
subject.is_top250
|
||||||
|
? '<span class="top250">Top 250</span>'
|
||||||
|
: ""
|
||||||
|
}<img src="${
|
||||||
|
subject.poster
|
||||||
|
}" referrerpolicy="no-referrer" class="db--image"><div class="db--score ">${
|
||||||
|
subject.douban_score > 0
|
||||||
|
? '<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" ><path d="M12 20.1l5.82 3.682c1.066.675 2.37-.322 2.09-1.584l-1.543-6.926 5.146-4.667c.94-.85.435-2.465-.799-2.567l-6.773-.602L13.29.89a1.38 1.38 0 0 0-2.581 0l-2.65 6.53-6.774.602C.052 8.126-.453 9.74.486 10.59l5.147 4.666-1.542 6.926c-.28 1.262 1.023 2.26 2.09 1.585L12 20.099z"></path></svg>' +
|
||||||
|
subject.douban_score
|
||||||
|
: ""
|
||||||
|
}${
|
||||||
|
subject.year > 0 ? " · " + subject.year : ""
|
||||||
|
}</div><div class="db--title"><a href="${
|
||||||
|
subject.link
|
||||||
|
}" target="_blank">${subject.name}</a></div></div>`;
|
||||||
|
})
|
||||||
|
.join("");
|
||||||
|
html += `</div></div>`;
|
||||||
|
}
|
||||||
|
document.querySelector(".db--list").innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
_renderListTemplate() {
|
||||||
|
document.querySelector(".db--list").innerHTML = this.subjects.map(subject =>
|
||||||
|
`<div class="db--item">
|
||||||
|
${subject.is_top250 ? '<span class="top250">Top 250</span>' : ""}
|
||||||
|
<img src="${subject.poster}" referrerpolicy="no-referrer" class="db--image">
|
||||||
|
<div class="ipc-signpost">${subject.create_time}</div>
|
||||||
|
<div class="db--score">${subject.douban_score > 0 ?
|
||||||
|
`<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor">
|
||||||
|
<path d="M12 20.1l5.82 3.682c1.066.675 2.37-.322 2.09-1.584l-1.543-6.926 5.146-4.667c.94-.85.435-2.465-.799-2.567l-6.773-.602L13.29.89a1.38 1.38 0 0 0-2.581 0l-2.65 6.53-6.774.602C.052 8.126-.453 9.74.486 10.59l5.147 4.666-1.542 6.926c-.28 1.262 1.023 2.26 2.09 1.585L12 20.099z"></path>
|
||||||
|
</svg>` + subject.douban_score : ""}
|
||||||
|
${subject.year > 0 ? " · " + subject.year : ""}
|
||||||
|
</div>
|
||||||
|
<div class="db--title"><a href="${subject.link}" target="_blank">${subject.name}</a></div>
|
||||||
|
</div>`
|
||||||
|
).join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleScroll() {
|
||||||
|
window.addEventListener("scroll", () => {
|
||||||
|
const scrollY = window.scrollY || window.pageYOffset;
|
||||||
|
const blockMoreOffsetTop = document.querySelector(".block-more").offsetTop;
|
||||||
|
if (blockMoreOffsetTop - window.innerHeight < scrollY && document.querySelector(".lds-ripple").classList.contains("u-hide") && !this.finished) {
|
||||||
|
document.querySelector(".lds-ripple").classList.remove("u-hide");
|
||||||
|
this.paged++;
|
||||||
|
this._fetchData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleNavClick() {
|
||||||
|
this.on("click", ".db--navItem", event => {
|
||||||
|
if (event.currentTarget.classList.contains("current")) return;
|
||||||
|
this.genre = [];
|
||||||
|
this.type = event.currentTarget.dataset.type;
|
||||||
|
if (this.type != "book") {
|
||||||
|
this._fetchGenres();
|
||||||
|
document.querySelector(".db--genres").classList.remove("u-hide");
|
||||||
|
} else {
|
||||||
|
document.querySelector(".db--genres").classList.add("u-hide");
|
||||||
|
}
|
||||||
|
document.querySelector(".db--list").innerHTML = "";
|
||||||
|
document.querySelector(".lds-ripple").classList.remove("u-hide");
|
||||||
|
document.querySelector(".db--navItem.current").classList.remove("current");
|
||||||
|
event.target.classList.add("current");
|
||||||
|
this.paged = 1;
|
||||||
|
this.finished = false;
|
||||||
|
this.subjects = [];
|
||||||
|
this._fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_create() {
|
||||||
|
if (document.querySelector(".db--container")) {
|
||||||
|
const container = document.querySelector(".db--container");
|
||||||
|
if (container.dataset.token) {
|
||||||
|
this.token = container.dataset.token;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const currentNavItem = document.querySelector(".db--navItem.current");
|
||||||
|
if (currentNavItem instanceof HTMLElement) {
|
||||||
|
this.type = currentNavItem.dataset.type;
|
||||||
|
}
|
||||||
|
const list = document.querySelector(".db--list");
|
||||||
|
if (list.dataset.type) {
|
||||||
|
this.type = list.dataset.type;
|
||||||
|
}
|
||||||
|
if (this.type == "movie") {
|
||||||
|
document.querySelector(".db--genres").classList.remove("u-hide");
|
||||||
|
}
|
||||||
|
this._fetchGenres();
|
||||||
|
this._fetchData();
|
||||||
|
this._handleScroll();
|
||||||
|
this._handleNavClick();
|
||||||
|
}
|
||||||
|
if (document.querySelector(".js-db")) {
|
||||||
|
document.querySelectorAll(".js-db").forEach(element => {
|
||||||
|
const id = element.dataset.id;
|
||||||
|
const type = element.dataset.type;
|
||||||
|
const parentNode = element.parentNode;
|
||||||
|
fetch(`${this.baseAPI}${type}/${id}?token=${this.token}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.data) {
|
||||||
|
const itemData = data.data;
|
||||||
|
const div = document.createElement("div");
|
||||||
|
div.classList.add("doulist-item");
|
||||||
|
div.innerHTML = `
|
||||||
|
<div class="doulist-subject">
|
||||||
|
<div class="doulist-post">
|
||||||
|
<img decoding="async" referrerpolicy="no-referrer" src="${itemData.poster}">
|
||||||
|
</div>
|
||||||
|
<div class="doulist-content">
|
||||||
|
<div class="doulist-title">
|
||||||
|
<a href="${itemData.link}" class="cute" target="_blank" rel="external nofollow">${itemData.name}</a>
|
||||||
|
</div>
|
||||||
|
<div class="rating">
|
||||||
|
<span class="allstardark">
|
||||||
|
<span class="allstarlight" style="width:55%"></span>
|
||||||
|
</span>
|
||||||
|
<span class="rating_nums"> ${itemData.douban_score} </span>
|
||||||
|
</div>
|
||||||
|
<div class="abstract">${itemData.card_subtitle}</div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
parentNode.replaceWith(div);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (document.querySelector(".db--collection")) {
|
||||||
|
document.querySelectorAll(".db--collection").forEach(collection => {
|
||||||
|
this._fetchCollection(collection);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_fetchCollection(collection) {
|
||||||
|
const style = collection.dataset.style ? collection.dataset.style : "card";
|
||||||
|
fetch(`${this.baseAPI}v1/movies?type=${collection.dataset.type}&paged=1&genre=&start_time=${collection.dataset.start}&end_time=${collection.dataset.end}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.length) {
|
||||||
|
if (style === "card") {
|
||||||
|
collection.innerHTML += data.map(item => `
|
||||||
|
<div class="doulist-item">
|
||||||
|
<div class="doulist-subject">
|
||||||
|
<div class="db--viewTime">Marked ${item.create_time}</div>
|
||||||
|
<div class="doulist-post">
|
||||||
|
<img referrerpolicy="no-referrer" src="${item.poster}">
|
||||||
|
</div>
|
||||||
|
<div class="doulist-content">
|
||||||
|
<div class="doulist-title">
|
||||||
|
<a href="${item.link}" class="cute" target="_blank" rel="external nofollow">${item.name}</a>
|
||||||
|
</div>
|
||||||
|
<div class="rating">
|
||||||
|
<span class="allstardark">
|
||||||
|
<span class="allstarlight" style="width:75%"></span>
|
||||||
|
</span>
|
||||||
|
<span class="rating_nums">${item.douban_score}</span>
|
||||||
|
</div>
|
||||||
|
<div class="abstract">${item.remark || item.card_subtitle}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`).join("");
|
||||||
|
} else {
|
||||||
|
const groupedData = data.reduce((acc, item) => {
|
||||||
|
if (acc[item.create_time]) {
|
||||||
|
acc[item.create_time].push(item);
|
||||||
|
} else {
|
||||||
|
acc[item.create_time] = [item];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
let html = "";
|
||||||
|
for (const date in groupedData) {
|
||||||
|
html += `<div class="db--date">${date}</div><div class="db--dateList">`;
|
||||||
|
html += groupedData[date].map(item => `
|
||||||
|
<div class="db--card__list">
|
||||||
|
<img referrerpolicy="no-referrer" src="${item.poster}">
|
||||||
|
<div>
|
||||||
|
<div class="title">
|
||||||
|
<a href="${item.link}" class="cute" target="_blank" rel="external nofollow">${item.name}</a>
|
||||||
|
</div>
|
||||||
|
<div class="rating">
|
||||||
|
<span class="allstardark">
|
||||||
|
<span class="allstarlight" style="width:75%"></span>
|
||||||
|
</span>
|
||||||
|
<span class="rating_nums">${item.douban_score}</span>
|
||||||
|
</div>
|
||||||
|
${item.remark || item.card_subtitle}
|
||||||
|
</div>
|
||||||
|
</div>`).join("");
|
||||||
|
html += "</div>";
|
||||||
|
}
|
||||||
|
collection.innerHTML = html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在页面加载完成后实例化APIHandler类
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const token = "<?php $this->options->doubanID() ?>"; // 替换为你的API令牌
|
||||||
|
new APIHandler(token);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</section>
|
</section>
|
||||||
<?php $this->need('footer.php'); ?>
|
<?php $this->need('footer.php'); ?>
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 说说页面 - Mastodon
|
||||||
|
*
|
||||||
|
* @package custom
|
||||||
|
*/
|
||||||
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||||
|
<?php $this->need('header.php'); ?>
|
||||||
|
<div class="site--main">
|
||||||
|
<header class="archive--header">
|
||||||
|
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
||||||
|
<h2 class="post--single__subtitle"><?php $this->content(); ?> </h2>
|
||||||
|
</header>
|
||||||
|
<article class="post--single">
|
||||||
|
<?php $tooot = $this->fields->tooot ? $this->fields->tooot : 'https://bbapi.ima.cm'; ?>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css" />
|
||||||
|
<div id="memos-container"></div>
|
||||||
|
<div class="nav-links" id="loadmore">
|
||||||
|
<span class="loadmore">加载更多</span>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
let offset = 0; // 初始偏移量
|
||||||
|
const limit = 20; // 每次加载的数量
|
||||||
|
function formatHTML(toots) {
|
||||||
|
let htmlString = '';
|
||||||
|
toots.forEach(toot => {
|
||||||
|
const { content, account, created_at, media_attachments} = toot;
|
||||||
|
let mediaHTML = ''; // 初始化资源相关HTML为空字符串
|
||||||
|
// 处理媒体附件
|
||||||
|
if (media_attachments.length > 0) {
|
||||||
|
media_attachments.forEach(attachment => {
|
||||||
|
if (attachment.type === 'image') {
|
||||||
|
mediaHTML += `<a href="${attachment.url}" target="_blank"><img src="${attachment.preview_url}" data-fancybox="img" class="thumbnail-image img"></a>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 使用 marked 转换 markdown 内容为 HTML
|
||||||
|
const htmlContent = marked.parse(content);
|
||||||
|
// 创建 HTML 字符串
|
||||||
|
htmlString += `
|
||||||
|
<article class='post--item post--item__status'>
|
||||||
|
<div class='content'>
|
||||||
|
<header>
|
||||||
|
<img src="${account.avatar}" class="avatar" width="48" height="48" />
|
||||||
|
<a class="humane--time" href="${account.url}" target="_blank">${new Date(created_at).toLocaleString()}</a>
|
||||||
|
</header>
|
||||||
|
<div class="description" itemprop="about">
|
||||||
|
${htmlContent}
|
||||||
|
<div class="resimg">${mediaHTML}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>`;
|
||||||
|
});
|
||||||
|
return htmlString;
|
||||||
|
}
|
||||||
|
function fetchToots() {
|
||||||
|
return fetch('<?php echo $tooot; ?>')
|
||||||
|
.then(response => response.json())
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching toots:', error);
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function fetchAndDisplayToots() {
|
||||||
|
fetchToots().then(data => {
|
||||||
|
const memosContainer = document.getElementById('memos-container');
|
||||||
|
const tootsToShow = data.slice(offset, offset + limit); // 选择要显示的toots
|
||||||
|
memosContainer.innerHTML += formatHTML(tootsToShow);
|
||||||
|
offset += limit; // 更新偏移量
|
||||||
|
// 如果没有更多的toots,隐藏“加载更多”按钮
|
||||||
|
if (offset >= data.length) {
|
||||||
|
document.getElementById('loadmore').style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 在页面加载完成后获取并展示 toots
|
||||||
|
fetchAndDisplayToots();
|
||||||
|
// 绑定“加载更多”按钮的点击事件
|
||||||
|
document.getElementById('loadmore').addEventListener('click', fetchAndDisplayToots);
|
||||||
|
};
|
||||||
|
Fancybox.bind("[data-fancybox]", {
|
||||||
|
// Your custom options
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
div pre code {
|
||||||
|
/* 迫使文字断行 */
|
||||||
|
white-space: pre-wrap; /* CSS3 */
|
||||||
|
word-wrap: break-word; /* 老版本的浏览器 */
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
/* 指定如何断行 */
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
div p a {
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
.thumbnail-image {
|
||||||
|
width:100%;
|
||||||
|
height: 200px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.resimg {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
column-gap: 10px;
|
||||||
|
row-gap: 10px;
|
||||||
|
}
|
||||||
|
.thumbnail-image img {
|
||||||
|
width:100%;
|
||||||
|
height:170px;
|
||||||
|
object-fit:cover;
|
||||||
|
border-radius:4px;
|
||||||
|
transition:transform .3s ease;
|
||||||
|
cursor:zoom-in
|
||||||
|
}
|
||||||
|
/* 当屏幕宽度小于732px时 */
|
||||||
|
@media (max-width: 732px) {
|
||||||
|
.resimg {
|
||||||
|
grid-template-columns: repeat(2, 1fr); /* 修改为两列 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* 当屏幕宽度小于400px时 */
|
||||||
|
@media (max-width: 400px) {
|
||||||
|
.resimg {
|
||||||
|
grid-template-columns: 1fr; /* 修改为一列 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.load-more-btn {
|
||||||
|
display: block;
|
||||||
|
margin: 20px auto;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #007bff;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.load-more-btn:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
.nav-links .loadmore {
|
||||||
|
border: 1px solid var(--farallon-border-color);
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
padding: 5px 30px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--farallon-text-gray)
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links .loadmore:hover {
|
||||||
|
border-color: var(--farallon-hover-color);
|
||||||
|
color: var(--farallon-hover-color)
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</div>
|
||||||
|
<?php $this->need('footer.php'); ?>
|
||||||
+156
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 说说页面 - memos
|
||||||
|
*
|
||||||
|
* @package custom
|
||||||
|
*/
|
||||||
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||||
|
<?php $this->need('header.php'); ?>
|
||||||
|
<div class="site--main">
|
||||||
|
<header class="archive--header">
|
||||||
|
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
||||||
|
<h2 class="archive--title__year"><?php $this->content(); ?> </h2>
|
||||||
|
</header>
|
||||||
|
<?php
|
||||||
|
// 检查是否存在自定义字段 'memos' 和 'memosID'
|
||||||
|
$memos = $this->fields->memos ? $this->fields->memos : 'https://memos.loliko.cn';
|
||||||
|
$memosID = $this->fields->memosID ? $this->fields->memosID : '1';
|
||||||
|
$memosnum = $this->fields->memosnum ? $this->fields->memosnum : '20';
|
||||||
|
?>
|
||||||
|
<article class="post--single">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css" />
|
||||||
|
<div id="talk"></div>
|
||||||
|
</article>
|
||||||
|
<script>
|
||||||
|
if (99) {
|
||||||
|
let url = '<?php echo $memos; ?>';
|
||||||
|
fetch(url + '/api/v1/memo?creatorId=<?php echo $memosID; ?>&rowStatus=NORMAL&limit=<?php echo $memosnum; ?>')
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
let html = '';
|
||||||
|
data.forEach(item => {
|
||||||
|
// 假设这里的 Format 函数能正确地格式化每个 item,并确保它返回有 `date` 和 `tag` 的对象
|
||||||
|
let data = Format(item);
|
||||||
|
let memoURL = url + '/m/' + item.id;
|
||||||
|
let mdContent = marked.parse(data.content);
|
||||||
|
html += `
|
||||||
|
<article class='post--item post--item__status'>
|
||||||
|
<div class='content'>
|
||||||
|
<header>
|
||||||
|
<img src="<?php $this->options->logoUrl() ?>" class="avatar" width="48" height="48" />
|
||||||
|
<a class="humane--time" href="${memoURL}" target="_blank">${data.date}</a>
|
||||||
|
</header>
|
||||||
|
<div class="description" itemprop="about">
|
||||||
|
<span class="talk_tag"># ${data.tag}</span><br>
|
||||||
|
${mdContent}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('talk').innerHTML = html;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
// 这里可以添加一些用户提示错误发生的 HTML 更新
|
||||||
|
});
|
||||||
|
|
||||||
|
// 页面内容格式化
|
||||||
|
function Format(item) {
|
||||||
|
let date = getTime(new Date(item.createdTs * 1000).toString()),
|
||||||
|
content = item.content,
|
||||||
|
tag = item.content.match(/#([^\s#]+?) /g),
|
||||||
|
imgs = content.match(/!\[.*\]\(.*?\)/g),
|
||||||
|
text = ''
|
||||||
|
if (imgs) imgs = imgs.map(item => { return item.replace(/!\[.*\]\((.*?)\)/, '$1') })
|
||||||
|
if (item.resourceList.length) {
|
||||||
|
if (!imgs) imgs = []
|
||||||
|
item.resourceList.forEach(t => {
|
||||||
|
if (t.externalLink) imgs.push(t.externalLink)
|
||||||
|
else imgs.push(`${url}/o/r/${t.id}/${t.publicId}/${t.filename}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
text = content.replace(/#(.*?)\s/g, '').replace(/\!?\[(.*?)\]\((.*?)\)/g, '').replace(/\{(.*?)\}/g, '')
|
||||||
|
content = text.replace(/\[(.*?)\]\((.*?)\)/g, `<a href="$2" target="_blank">$1</a>`);
|
||||||
|
if (imgs) {
|
||||||
|
content += `<div class="resimg">`
|
||||||
|
imgs.forEach(e => content += `<a href="${e}" data-fancybox="gallery" class="fancybox img" data-thumb="${e}"><img class="no-lazyload thumbnail-image" src="${e}"></a>`
|
||||||
|
)
|
||||||
|
content += '</div>'
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
content: content,
|
||||||
|
tag: tag ? tag[0].replace(/#([^\s#]+?) /,'$1') : '日常',
|
||||||
|
date: date,
|
||||||
|
text: text.replace(/\[(.*?)\]\((.*?)\)/g, '[链接]' + `${imgs?'[图片]':''}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 页面时间格式化
|
||||||
|
function getTime(time) {
|
||||||
|
let d = new Date(time),
|
||||||
|
ls = [d.getFullYear(), d.getMonth() + 1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()];
|
||||||
|
for (let i = 0; i < ls.length; i++) {
|
||||||
|
ls[i] = ls[i] <= 9 ? '0' + ls[i] : ls[i] + ''
|
||||||
|
}
|
||||||
|
if (new Date().getFullYear() == ls[0]) return ls[1] + '月' + ls[2] + '日 ' + ls[3] +':'+ ls[4]
|
||||||
|
else return ls[0] + '年' + ls[1] + '月' + ls[2] + '日 ' + ls[3] +':'+ ls[4]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Fancybox.bind("[data-fancybox]", {
|
||||||
|
// Your custom options
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
div pre code {
|
||||||
|
/* 迫使文字断行 */
|
||||||
|
white-space: pre-wrap; /* CSS3 */
|
||||||
|
word-wrap: break-word; /* 老版本的浏览器 */
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
/* 指定如何断行 */
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
div p a {
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
.thumbnail-image {
|
||||||
|
width:100%;
|
||||||
|
height: 200px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.resimg {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
column-gap: 10px;
|
||||||
|
row-gap: 10px;
|
||||||
|
}
|
||||||
|
.thumbnail-image img {
|
||||||
|
width:100%;
|
||||||
|
height:170px;
|
||||||
|
object-fit:cover;
|
||||||
|
border-radius:4px;
|
||||||
|
transition:transform .3s ease;
|
||||||
|
cursor:zoom-in
|
||||||
|
}
|
||||||
|
/* 当屏幕宽度小于732px时 */
|
||||||
|
@media (max-width: 732px) {
|
||||||
|
.resimg {
|
||||||
|
grid-template-columns: repeat(2, 1fr); /* 修改为两列 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 当屏幕宽度小于400px时 */
|
||||||
|
@media (max-width: 400px) {
|
||||||
|
.resimg {
|
||||||
|
grid-template-columns: 1fr; /* 修改为一列 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</div>
|
||||||
|
<?php $this->need('footer.php'); ?>
|
||||||
@@ -27,13 +27,20 @@
|
|||||||
</path>
|
</path>
|
||||||
</g>
|
</g>
|
||||||
</svg> <a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 评论', '%d 评论'); ?></a>
|
</svg> <a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 评论', '%d 评论'); ?></a>
|
||||||
|
<?php if($this->user->hasLogin() && $this->user->pass('editor', true)): ?>
|
||||||
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16">
|
||||||
|
<!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
|
||||||
|
<path
|
||||||
|
d="M362.7 19.3L314.3 67.7 444.3 197.7l48.4-48.4c25-25 25-65.5 0-90.5L453.3 19.3c-25-25-65.5-25-90.5 0zm-71 71L58.6 323.5c-10.4 10.4-18 23.3-22.2 37.4L1 481.2C-1.5 489.7 .8 498.8 7 505s15.3 8.5 23.7 6.1l120.3-35.4c14.1-4.2 27-11.8 37.4-22.2L421.7 220.3 291.7 90.3z"/>
|
||||||
|
</svg>
|
||||||
|
<a href="<?php $this->options->adminUrl('write-post.php?cid=' . $this->cid); ?>" target="_blank" title="编辑文章">编辑文章</a>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="post--single__title"><?php $this->title() ?></h2>
|
<h2 class="post--single__title"><?php $this->title() ?></h2>
|
||||||
<div class="post--single__content graph" ><?php $this->content(); ?></div>
|
<div class="post--single__content graph" ><?php $this->content(); ?></div>
|
||||||
|
|
||||||
<div class="post--single">
|
|
||||||
<?php if($this->options->donate): ?>
|
|
||||||
<!--打赏 -->
|
<!--打赏 -->
|
||||||
|
<?php if($this->options->donate): ?>
|
||||||
|
<div class="post--single__action">
|
||||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/donate.css'); ?>">
|
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/donate.css'); ?>">
|
||||||
<script type="text/javascript" src="<?php $this->options->themeUrl('/dist/js/donate.js'); ?>"></script>
|
<script type="text/javascript" src="<?php $this->options->themeUrl('/dist/js/donate.js'); ?>"></script>
|
||||||
<div class="donate-panel">
|
<div class="donate-panel">
|
||||||
@@ -57,9 +64,63 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
<!--打赏结束 -->
|
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<!-- 复制链接 -->
|
||||||
|
<?php if($this->options->showshare): ?>
|
||||||
|
<div class="post--share">
|
||||||
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||||
|
<g>
|
||||||
|
<path d="M18.36 5.64c-1.95-1.96-5.11-1.96-7.07 0L9.88 7.05 8.46 5.64l1.42-1.42c2.73-2.73 7.16-2.73 9.9 0 2.73 2.74 2.73 7.17 0 9.9l-1.42 1.42-1.41-1.42 1.41-1.41c1.96-1.96 1.96-5.12 0-7.07zm-2.12 3.53l-7.07 7.07-1.41-1.41 7.07-7.07 1.41 1.41zm-12.02.71l1.42-1.42 1.41 1.42-1.41 1.41c-1.96 1.96-1.96 5.12 0 7.07 1.95 1.96 5.11 1.96 7.07 0l1.41-1.41 1.42 1.41-1.42 1.42c-2.73 2.73-7.16 2.73-9.9 0-2.73-2.74-2.73-7.17 0-9.9z"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<span class="text">复制链接</span>
|
||||||
|
<span class="link" @click="copy" data-link="<?php $this->permalink(); ?>"><?php $this->permalink(); ?></span>
|
||||||
|
<script src="<?php $this->options->themeUrl('/dist/js/vue.min.js'); ?>"></script>
|
||||||
|
<script src="<?php $this->options->themeUrl('/dist/js/clipboard.min.js'); ?>"></script>
|
||||||
|
<script>
|
||||||
|
var app = new Vue({
|
||||||
|
el: '.post--share',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
msg: "<?php $this->permalink(); ?>",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
//复制方法
|
||||||
|
copy: function () {
|
||||||
|
var that = this;
|
||||||
|
//注意vue umd版本ClipboardJS,而ES包请使用Clipboard
|
||||||
|
var clipboard = new ClipboardJS(".link",{
|
||||||
|
text: function (trigger) {
|
||||||
|
//返回字符串
|
||||||
|
return that.msg;
|
||||||
|
}});
|
||||||
|
clipboard.on("success", (e) => {
|
||||||
|
//复制成功,显示提示
|
||||||
|
this.showCopySuccessToast();
|
||||||
|
clipboard.destroy();
|
||||||
|
});
|
||||||
|
clipboard.on("error", (e) => {
|
||||||
|
//复制失败
|
||||||
|
clipboard.destroy();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showCopySuccessToast: function() {
|
||||||
|
const toast = document.createElement("div");
|
||||||
|
toast.textContent = "复制成功!";
|
||||||
|
toast.className = "notice--wrapper";
|
||||||
|
document.body.appendChild(toast);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(toast);
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
<!-- TAG -->
|
<!-- TAG -->
|
||||||
<div class="tag--list artile--tag">
|
<div class="tag--list artile--tag">
|
||||||
<?php $this->tags(' ', true, ' '); ?>
|
<?php $this->tags(' ', true, ' '); ?>
|
||||||
@@ -72,7 +133,6 @@
|
|||||||
<?php if ($this->options->showrelated): ?>
|
<?php if ($this->options->showrelated): ?>
|
||||||
<?php $this->need('related.php'); ?>
|
<?php $this->need('related.php'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<!-- 判断如果禁止评论则不显示评论的div -->
|
<!-- 判断如果禁止评论则不显示评论的div -->
|
||||||
<?php if ($this->allow('comment')): ?>
|
<?php if ($this->allow('comment')): ?>
|
||||||
<?php $this->need('comments.php'); ?>
|
<?php $this->need('comments.php'); ?>
|
||||||
@@ -82,11 +142,9 @@
|
|||||||
<!--翻页-->
|
<!--翻页-->
|
||||||
<nav class="navigation post-navigation is-active">
|
<nav class="navigation post-navigation is-active">
|
||||||
<div class="nav-links">
|
<div class="nav-links">
|
||||||
|
|
||||||
<div class="nav-previous">
|
<div class="nav-previous">
|
||||||
<span class="meta-nav"> 上一篇: <?php $this->thePrev('%s','没有了'); ?></span>
|
<span class="meta-nav"> 上一篇: <?php $this->thePrev('%s','没有了'); ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav-next">
|
<div class="nav-next">
|
||||||
<span class="meta-nav"> 下一篇: <?php $this->theNext('%s','没有了'); ?></span>
|
<span class="meta-nav"> 下一篇: <?php $this->theNext('%s','没有了'); ?></span>
|
||||||
</div>
|
</div>
|
||||||
@@ -94,66 +152,71 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
|
<?php if($this->options->showtoc): ?>
|
||||||
<!--TOC 在宽度大于1400px时才会显示-->
|
<!--TOC 在宽度大于1400px时才会显示-->
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
|
|
||||||
const postContent = document.querySelector('.post--single__content');
|
const postContent = document.querySelector('.post--single__content');
|
||||||
if (!postContent) return;
|
if (!postContent) return;
|
||||||
|
|
||||||
// 依次查找从h1到h6,直到找到存在的标题级别
|
|
||||||
let found = false;
|
let found = false;
|
||||||
for (let i = 1; i <= 6 && !found; i++) {
|
for (let i = 1; i <= 6 && !found; i++) {
|
||||||
if (postContent.querySelector(`h${i}`)) {
|
if (postContent.querySelector(`h${i}`)) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!found) return;
|
||||||
if (!found) return; // 如果没有标题,则不继续执行
|
|
||||||
|
|
||||||
const heads = postContent.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
const heads = postContent.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||||
const toc = document.createElement('div');
|
const toc = document.createElement('div');
|
||||||
toc.id = 'toc';
|
toc.id = 'toc';
|
||||||
toc.innerHTML = '<strong>目录</strong><ul></ul>';
|
toc.innerHTML = '<strong>目录</strong><ul></ul>';
|
||||||
document.body.appendChild(toc);
|
document.body.appendChild(toc);
|
||||||
|
|
||||||
let currentLevel = 0;
|
let currentLevel = 0;
|
||||||
let currentList = toc.querySelector('ul');
|
let currentList = toc.querySelector('ul');
|
||||||
|
let levelCounts = [0]; // 初始化层级计数器
|
||||||
|
|
||||||
heads.forEach((head, index) => {
|
heads.forEach((head, index) => {
|
||||||
const level = parseInt(head.tagName.substring(1)); // 提取标题级别
|
const level = parseInt(head.tagName.substring(1));
|
||||||
|
if (levelCounts[level] === undefined) {
|
||||||
if (currentLevel === 0) { // 设置初次的级别
|
levelCounts[level] = 1; // 初始化该层级计数
|
||||||
currentLevel = level;
|
} else {
|
||||||
|
levelCounts[level]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (level > currentLevel) { // 如果标题级别增加,则创建新的子列表
|
// 重置下级标题的计数器
|
||||||
|
levelCounts = levelCounts.slice(0, level + 1);
|
||||||
|
|
||||||
|
if (currentLevel === 0) {
|
||||||
|
currentLevel = level;
|
||||||
|
}
|
||||||
|
while (level > currentLevel) {
|
||||||
let newList = document.createElement('ul');
|
let newList = document.createElement('ul');
|
||||||
if(!currentList.lastElementChild) { // 如果当前列表为空,则直接在其中添加元素
|
if(!currentList.lastElementChild) {
|
||||||
currentList.appendChild(newList);
|
currentList.appendChild(newList);
|
||||||
} else {
|
} else {
|
||||||
currentList.lastElementChild.appendChild(newList); // 否则,添加到最后一个列表项中
|
currentList.lastElementChild.appendChild(newList);
|
||||||
}
|
}
|
||||||
currentList = newList;
|
currentList = newList;
|
||||||
currentLevel++;
|
currentLevel++;
|
||||||
|
levelCounts[currentLevel] = 1; // 初始化下一层级的计数器
|
||||||
}
|
}
|
||||||
|
while (level < currentLevel) {
|
||||||
while (level < currentLevel) { // 如果标题级别降低,则向上回溯列表层级
|
|
||||||
currentList = currentList.parentElement;
|
currentList = currentList.parentElement;
|
||||||
if(currentList.tagName.toLowerCase() === 'li') { // 确保回到上一层列表
|
if(currentList.tagName.toLowerCase() === 'li') {
|
||||||
currentList = currentList.parentElement;
|
currentList = currentList.parentElement;
|
||||||
}
|
}
|
||||||
currentLevel--;
|
currentLevel--;
|
||||||
}
|
}
|
||||||
|
const numbers = levelCounts.slice(1, level + 1).join(' ') ;
|
||||||
const item = document.createElement('li');
|
const item = document.createElement('li');
|
||||||
|
item.classList.add('toc-item'); // 添加基本类
|
||||||
|
item.classList.add(`level-${level}`); // 根据级别添加类
|
||||||
const anchor = `toc${index}`;
|
const anchor = `toc${index}`;
|
||||||
head.id = anchor;
|
head.id = anchor;
|
||||||
|
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = `#${anchor}`;
|
link.href = `#${anchor}`;
|
||||||
link.textContent = head.textContent;
|
link.textContent = `${numbers}. ${head.textContent}`; // 序号+标题文本
|
||||||
|
|
||||||
item.appendChild(link);
|
item.appendChild(link);
|
||||||
currentList.appendChild(item);
|
currentList.appendChild(item);
|
||||||
});
|
});
|
||||||
@@ -170,12 +233,12 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
/* 其他样式... */
|
/* 其他样式... */
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 1400px) {
|
@media screen and (max-width: 1400px) {
|
||||||
#toc {
|
#toc {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<?php endif; ?>
|
||||||
</main>
|
</main>
|
||||||
<?php $this->need('footer.php'); ?>
|
<?php $this->need('footer.php'); ?>
|
||||||
+41
-3
@@ -71,7 +71,7 @@
|
|||||||
'...',
|
'...',
|
||||||
array(
|
array(
|
||||||
'wrapTag' => 'div',
|
'wrapTag' => 'div',
|
||||||
'wrapClass' => 'cat_pagination_page',
|
'wrapClass' => 'pagination_page',
|
||||||
'itemTag' => '',
|
'itemTag' => '',
|
||||||
'textTag' => 'a',
|
'textTag' => 'a',
|
||||||
'currentClass' => 'active',
|
'currentClass' => 'active',
|
||||||
@@ -80,5 +80,43 @@
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
<style>
|
||||||
|
/* 分页 */
|
||||||
|
.pagination_page{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: var(--margin);
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
.pagination_page li.active a {
|
||||||
|
background: var(--theme);
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.pagination_page a{
|
||||||
|
display: flex;
|
||||||
|
padding: 0.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
width: 1.75rem;
|
||||||
|
height: 1.75rem;
|
||||||
|
background: var(--background);
|
||||||
|
border-radius: 50%;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
transition: 0.2s;
|
||||||
|
-webkit-transition: 0.2s;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
letter-spacing: 0;
|
||||||
|
}
|
||||||
|
.pagination_page span.next{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.pagination_page li.active a:hover{
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
/* 分页 */
|
||||||
|
</style>
|
||||||
@@ -11,4 +11,3 @@
|
|||||||
<?php $this->need('sns.php'); ?>
|
<?php $this->need('sns.php'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Reference in New Issue
Block a user