17 Commits

Author SHA1 Message Date
浪子 2b595583c1 Update index.php 2024-07-01 18:34:20 +08:00
浪子 296ea94340 正确获取昵称 2024-06-27 15:37:29 +08:00
浪子 0c72f67d8e 调整图片显示 2024-06-20 09:38:13 +08:00
浪子 ffe4db83de 调整图片 2024-06-20 08:22:58 +08:00
浪子 65d780c01a Update page-memos.php 2024-06-16 11:09:22 +08:00
浪子 6165bacaa9 Update page-memos.php 2024-06-16 10:24:28 +08:00
浪子 5fb2e66399 Update page-memos.php 2024-06-16 10:19:50 +08:00
浪子 30fcb2885b Update page-memos.php 2024-06-16 09:44:05 +08:00
浪子 8e0e73b594 Update page-memos.php 2024-06-15 16:44:34 +08:00
浪子 57fd7fe485 Update page-mastodon.php 2024-06-15 10:47:10 +08:00
浪子 95c172b529 Update page-mastodon.php 2024-06-15 10:38:53 +08:00
浪子 34276f132b Update page-mastodon.php 2024-06-15 10:32:29 +08:00
浪子 f26bc907d4 add有新评论通知QQ 2024-06-14 16:33:47 +08:00
浪子 e37ef68e30 Update comments.php 2024-06-13 22:05:34 +08:00
浪子 1deff9afbf 刷新版本号 2024-06-13 18:30:48 +08:00
浪子 8543bc6fe1 增加显示页面加载时间的开关 2024-06-13 17:51:54 +08:00
浪子 a88130d5c5 优化一下评论列表加上@ 2024-06-13 15:30:11 +08:00
9 changed files with 123 additions and 37 deletions
+3 -4
View File
@@ -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('退出'); ?> &raquo;</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>
+1 -1
View File
@@ -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
View File
@@ -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">&nbsp;Made with Sun</a>
&nbsp;页面加载耗时
<?php echo timer_stop();?>
<a href="https://www.typecho.org" target="_blank">Typecho驱动</a>
<a href="https://www.imsun.org" target="_blank">&nbsp;Made with Sun</a>
<?php //添加加载时间控制
if ($this->options->showtime): ?>
&nbsp;页面加载耗时<?php echo timer_stop();?>
<?php endif; ?>
<div class="copyright">
<a href="<?php $this->options->siteUrl(); ?>">
<?php $this->options->title(); ?>
+72
View File
@@ -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() {
+2 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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() ?>