mirror of
https://github.com/jkjoy/typecho-theme-farallon.git
synced 2026-06-28 04:04:28 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b595583c1 | |||
| 296ea94340 | |||
| 0c72f67d8e | |||
| ffe4db83de | |||
| 65d780c01a | |||
| 6165bacaa9 | |||
| 5fb2e66399 | |||
| 30fcb2885b | |||
| 8e0e73b594 | |||
| 57fd7fe485 | |||
| 95c172b529 | |||
| 34276f132b | |||
| f26bc907d4 | |||
| e37ef68e30 | |||
| 1deff9afbf | |||
| 8543bc6fe1 | |||
| a88130d5c5 |
+3
-4
@@ -54,7 +54,6 @@
|
||||
</g>
|
||||
</svg><?php $this->commentsNum(_t('0'), _t('1'), _t('%d')); ?>
|
||||
</h3>
|
||||
<ol class="commentlist sulliComment--list"></ol>
|
||||
<div id="<?php $this->respondId(); ?>" class="comment-respond">
|
||||
<div class="cancel-comment-reply cancel-comment-reply-link"><?php $comments->cancelReply(); ?></div>
|
||||
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form" class="comment-form">
|
||||
@@ -64,7 +63,6 @@
|
||||
<?php $this->user->screenName(); ?></a>.
|
||||
<a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> »</a></p>
|
||||
<?php else: ?>
|
||||
|
||||
<p class="comment-form-author">
|
||||
<input placeholder="称呼 *" type="text" name="author" id="author" class="text" value="" required />
|
||||
</p>
|
||||
@@ -87,8 +85,8 @@
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php _e(''); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
<ol class="commentlist sulliComment--list"></ol>
|
||||
<?php if ($comments->have()): ?>
|
||||
<?php $comments->listComments(); ?>
|
||||
<?php
|
||||
@@ -152,6 +150,7 @@ function threadedComments($comments, $options) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="comment-content">
|
||||
<?php if ($comments->parent) {echo getPermalinkFromCoid($comments->parent);}?>
|
||||
<?php $comments->content(); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@
|
||||
is_single = false;
|
||||
post_id = 0;
|
||||
is_archive = false;
|
||||
VERSION = "0.5.4";
|
||||
VERSION = "0.5.4.1";
|
||||
constructor() {
|
||||
super();
|
||||
this.initCopyright();
|
||||
|
||||
+8
-5
@@ -4,13 +4,16 @@
|
||||
<div class=site--footer__sns>
|
||||
<?php $this->need('sns.php'); ?>
|
||||
</div>
|
||||
<?php if($this->options->sitemapurl): ?>
|
||||
<?php //sitemap填入
|
||||
if($this->options->sitemapurl): ?>
|
||||
<a href="<?php $this->options->sitemapurl() ?>" target="_blank">💗</a>
|
||||
<?php endif; ?>
|
||||
<a href="https://www.typecho.org">Typecho驱动</a>
|
||||
<a href="https://www.imsun.org"> Made with Sun</a>
|
||||
页面加载耗时
|
||||
<?php echo timer_stop();?>
|
||||
<a href="https://www.typecho.org" target="_blank">Typecho驱动</a>
|
||||
<a href="https://www.imsun.org" target="_blank"> Made with Sun</a>
|
||||
<?php //添加加载时间控制
|
||||
if ($this->options->showtime): ?>
|
||||
页面加载耗时<?php echo timer_stop();?>
|
||||
<?php endif; ?>
|
||||
<div class="copyright">
|
||||
<a href="<?php $this->options->siteUrl(); ?>">
|
||||
<?php $this->options->title(); ?>
|
||||
|
||||
@@ -51,6 +51,14 @@ function themeConfig($form) {
|
||||
array('0'=> _t('否'), '1'=> _t('是')),
|
||||
'0', _t('是否显示文章目录'), _t('选择“是”将在文章页面显示文章目录(仅在宽度大于1400px的设备中显示)。'));
|
||||
$form->addInput($showtoc);
|
||||
$showtime = new Typecho_Widget_Helper_Form_Element_Radio('showtime',
|
||||
array('0'=> _t('否'), '1'=> _t('是')),
|
||||
'0', _t('是否显示页面加载时间'), _t('选择“是”将在页脚显示加载时间。'));
|
||||
$form->addInput($showtime);
|
||||
$qqboturl = new Typecho_Widget_Helper_Form_Element_Text('qqboturl', NULL, 'https://bot.asbid.cn', _t('QQ机器人API,保持默认则需添加 2280858259 为好友'), _t('基于cqhttp,有评论时QQ通知'));
|
||||
$form->addInput($qqboturl);
|
||||
$qqnum = new Typecho_Widget_Helper_Form_Element_Text('qqnum', NULL, '80116747', _t('QQ号码'), _t('用于接收QQ通知的号码'));
|
||||
$form->addInput($qqnum);
|
||||
}
|
||||
function get_post_view($archive) {
|
||||
$cid = $archive->cid;
|
||||
@@ -190,6 +198,70 @@ function img_postthumb($cid) {
|
||||
return ""; // 没有匹配到图片URL,返回空字符串
|
||||
}
|
||||
}
|
||||
//回复加上@
|
||||
function getPermalinkFromCoid($coid) {
|
||||
$db = Typecho_Db::get();
|
||||
$row = $db->fetchRow($db->select('author')->from('table.comments')->where('coid = ? AND status = ?', $coid, 'approved'));
|
||||
if (empty($row)) return '';
|
||||
return '<a href="#comment-'.$coid.'" style="text-decoration: none;">@'.$row['author'].'</a>';
|
||||
}
|
||||
// 评论提交通知函数
|
||||
function notifyQQBot($comment) {
|
||||
$options = Helper::options();
|
||||
// 检查评论是否已经审核通过
|
||||
if ($comment->status != "approved") {
|
||||
error_log('Comment is not approved.');
|
||||
return;
|
||||
}
|
||||
// 获取配置中的QQ机器人API地址
|
||||
$cq_url = $options->qqboturl;
|
||||
// 检查API地址是否为空
|
||||
if (empty($cq_url)) {
|
||||
error_log('QQ Bot URL is empty. Using default URL.');
|
||||
$cq_url = 'https://bot.asbid.cn';
|
||||
}
|
||||
// 获取QQ号码
|
||||
$qqnum = $options->qqnum;
|
||||
// 检查QQ号码是否为空
|
||||
if (empty($qqnum)) {
|
||||
error_log('QQ number is empty.');
|
||||
return;
|
||||
}
|
||||
// 如果是管理员自己发的评论则不发送通知
|
||||
if ($comment->authorId === $comment->ownerId) {
|
||||
error_log('This comment is by the post owner.');
|
||||
return;
|
||||
}
|
||||
// 构建消息内容
|
||||
$msg = '「' . $comment->author . '」在文章《' . $comment->title . '》中发表了评论!';
|
||||
$msg .= "\n评论内容:\n{$comment->text}\n永久链接地址:{$comment->permalink}";
|
||||
// 准备发送消息的数据
|
||||
$_message_data_ = [
|
||||
'user_id' => (int) trim($qqnum),
|
||||
'message' => str_replace(["\r\n", "\r", "\n"], "\r\n", htmlspecialchars_decode(strip_tags($msg)))
|
||||
];
|
||||
// 输出调试信息
|
||||
error_log('Sending message to QQ Bot: ' . print_r($_message_data_, true));
|
||||
// 初始化Curl请求
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => "{$cq_url}/send_msg?" . http_build_query($_message_data_, '', '&'),
|
||||
CURLOPT_CONNECTTIMEOUT => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSL_VERIFYHOST => 0
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
error_log('Curl error: ' . curl_error($ch));
|
||||
} else {
|
||||
error_log('Response: ' . $response);
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
Typecho_Plugin::factory('Widget_Feedback')->finishComment = 'notifyQQBot';
|
||||
//开始增加某些奇怪的东西
|
||||
// 获取月份
|
||||
function getMonth() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 移植自HUGO主题 farallon 原作者 bigfa
|
||||
* @package farallon
|
||||
* @author 老孙
|
||||
* @version 0.5.4
|
||||
* @version 0.5.5
|
||||
* @link https://imsun.org
|
||||
*/
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||
@@ -14,4 +14,4 @@ $this->need('header.php');
|
||||
<?php $this->need('postlist.php'); ?>
|
||||
</div>
|
||||
</main>
|
||||
<?php $this->need('footer.php'); ?>
|
||||
<?php $this->need('footer.php'); ?>
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<section class="site--main">
|
||||
<header class="archive--header">
|
||||
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
||||
<h2 class="post--single__subtitle">数据来源于豆瓣</h2>
|
||||
<h2 class="post--single__subtitle"><?php $this->content(); ?></h2>
|
||||
</header>
|
||||
<div class="site--main">
|
||||
<div class="db--container"></div>
|
||||
|
||||
+24
-14
@@ -100,27 +100,33 @@ 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 {
|
||||
width: 100%; /* 确保其宽度填满父容器 */
|
||||
height: 200px; /* 固定高度 */
|
||||
display: flex; /* 使用 flexbox 居中 */
|
||||
align-items: center; /* 垂直居中 */
|
||||
justify-content: center; /* 水平居中 */
|
||||
overflow: hidden; /* 确保容器内的多余内容不会显示出来 */
|
||||
border-radius: 4px; /* 圆角 */
|
||||
transition: transform .3s ease; /* 鼠标悬停时的过渡效果 */
|
||||
cursor: zoom-in; /* 鼠标指针变为放大镜 */
|
||||
}
|
||||
img {
|
||||
object-fit: cover; /* 保持图片的纵横比,但会将图片裁剪以填充容器 */
|
||||
object-position: center; /* 保证中央部分 */
|
||||
}
|
||||
/* 缩略图内的图片样式 */
|
||||
.thumbnail-image img {
|
||||
width:100%;
|
||||
height:170px;
|
||||
object-fit:cover;
|
||||
border-radius:4px;
|
||||
transition:transform .3s ease;
|
||||
cursor:zoom-in
|
||||
}
|
||||
width: 100%;
|
||||
min-height: 200px;
|
||||
}
|
||||
/* 当屏幕宽度小于732px时 */
|
||||
@media (max-width: 732px) {
|
||||
.resimg {
|
||||
@@ -132,6 +138,10 @@ div p a {
|
||||
.resimg {
|
||||
grid-template-columns: 1fr; /* 修改为一列 */
|
||||
}
|
||||
.thumbnail-image img {
|
||||
width: 100%;
|
||||
height: 480px;
|
||||
}
|
||||
}
|
||||
.load-more-btn {
|
||||
display: block;
|
||||
|
||||
+11
-9
@@ -31,7 +31,6 @@ if (99) {
|
||||
.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);
|
||||
@@ -43,8 +42,8 @@ if (99) {
|
||||
<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}
|
||||
<span class="tag--list"><a>${data.tag}</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@@ -56,7 +55,6 @@ if (99) {
|
||||
console.error('Error:', error);
|
||||
// 这里可以添加一些用户提示错误发生的 HTML 更新
|
||||
});
|
||||
// 页面内容格式化
|
||||
function Format(item) {
|
||||
let date = getTime(new Date(item.createdTs * 1000).toString()),
|
||||
content = item.content,
|
||||
@@ -112,7 +110,7 @@ div pre code {
|
||||
word-break: break-word;
|
||||
}
|
||||
div p a {
|
||||
word-break: break-all;
|
||||
word-break: break-all;
|
||||
word-break: break-word;
|
||||
}
|
||||
.thumbnail-image {
|
||||
@@ -121,6 +119,9 @@ div p a {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
border-radius:4px;
|
||||
transition:transform .3s ease;
|
||||
cursor:zoom-in;
|
||||
}
|
||||
.resimg {
|
||||
display: grid;
|
||||
@@ -130,12 +131,13 @@ div p a {
|
||||
}
|
||||
.thumbnail-image img {
|
||||
width:100%;
|
||||
height:170px;
|
||||
min-height: 200px;
|
||||
object-fit:cover;
|
||||
border-radius:4px;
|
||||
transition:transform .3s ease;
|
||||
cursor:zoom-in
|
||||
}
|
||||
}
|
||||
img {
|
||||
object-fit: cover; /* 保持图片的纵横比,但会将图片裁剪以填充容器 */
|
||||
object-position: center; /* 保证中央部分 */
|
||||
}
|
||||
/* 当屏幕宽度小于732px时 */
|
||||
@media (max-width: 732px) {
|
||||
.resimg {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<div class="author--card">
|
||||
<img src="<?php $this->options->logoUrl() ?>" class="avatar" height="64" width="64" decoding="async">
|
||||
<div class="author--name">
|
||||
<?php $this->options->author() ?>
|
||||
<?php $this->author(); ?>
|
||||
</div>
|
||||
<div class="author--description">
|
||||
<?php $this->options->description() ?>
|
||||
|
||||
Reference in New Issue
Block a user