🤠添加随机文章刷新按钮,完善邮箱模板文字替换部分
This commit is contained in:
parent
d52f9557f5
commit
f2fe18f8ae
@ -32,12 +32,16 @@ email_push:
|
||||
# github_username: GitHub 用户名,用于构建issue api地址
|
||||
# github_repo: GitHub 仓库名,用于构建issue api地址
|
||||
# your_blog_url: 你的博客地址
|
||||
# website_info: 你的博客信息
|
||||
# title: 你的博客标题,如果启用了推送,用于生成邮件主题
|
||||
rss_subscribe:
|
||||
enable: true
|
||||
github_username: willow-god
|
||||
github_repo: Friend-Circle-Lite
|
||||
your_blog_url: https://blog.qyliu.top/
|
||||
your_blog_url: https://blog.liushen.fun/
|
||||
email_template: "./rss_subscribe/email_template.html"
|
||||
website_info:
|
||||
title: "清羽飞扬"
|
||||
|
||||
# SMTP 配置
|
||||
# 解释:使用其中的相关配置实现上面两种功能,若无推送要求可以不配置,请将以上两个配置置为false
|
||||
|
52
errors.json
Normal file
52
errors.json
Normal file
@ -0,0 +1,52 @@
|
||||
[
|
||||
[
|
||||
"满心记",
|
||||
"https://blog.lovelu.top/",
|
||||
"https://cdn.qyliu.top/i/2024/08/04/66af31bec75a0.webp"
|
||||
],
|
||||
[
|
||||
"dreamChaser",
|
||||
"https://blog.wenjing.xin/",
|
||||
"https://cdn.qyliu.top/i/2024/03/22/65fc59b439430.png"
|
||||
],
|
||||
[
|
||||
"听风小屋",
|
||||
"https://blog.ifeng.asia/",
|
||||
"https://cdn.qyliu.top/i/2024/03/31/6608e2697634c.png"
|
||||
],
|
||||
[
|
||||
"GuKaifeng",
|
||||
"https://gukaifeng.cn/",
|
||||
"https://cdn.qyliu.top/i/2024/04/09/6614ef03406cc.png"
|
||||
],
|
||||
[
|
||||
"乙未博客",
|
||||
"https://www.yvii.cn",
|
||||
"https://cdn.qyliu.top/i/2024/04/09/6614f05e2f75c.png"
|
||||
],
|
||||
[
|
||||
"理随",
|
||||
"https://lisui.top/",
|
||||
"https://cdn.qyliu.top/i/2024/04/07/66123e6aac11c.png"
|
||||
],
|
||||
[
|
||||
"Dreamaker",
|
||||
"https://dreamakerr.cn/",
|
||||
"https://cdn.qyliu.top/i/2024/06/05/66604a6f8dba9.webp"
|
||||
],
|
||||
[
|
||||
"SerMs",
|
||||
"https://blog.serms.top/",
|
||||
"https://cdn.qyliu.top/i/2024/06/23/6678094c8d38d.webp"
|
||||
],
|
||||
[
|
||||
"LinuxWin",
|
||||
"https://meoblog.pages.dev/",
|
||||
"https://cdn.qyliu.top/i/2024/09/18/66eabc22cf9e7.webp"
|
||||
],
|
||||
[
|
||||
"琅環书生",
|
||||
"https://www.zlog.us.kg/",
|
||||
"https://cdn.qyliu.top/i/2024/09/12/66e2a0ac35fb5.webp"
|
||||
]
|
||||
]
|
Binary file not shown.
@ -89,10 +89,24 @@
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.random-link-button {
|
||||
.random-button-container {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
border: none;
|
||||
border-radius: 20px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: background-color 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
#refresh-random-article {
|
||||
margin-right: 10px;
|
||||
color: #aaaaaa;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.random-link-button {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 20px;
|
||||
|
@ -65,16 +65,7 @@ function initialize_fc_lite() {
|
||||
<div>更新时间:${stats.last_updated_time}</div>
|
||||
`;
|
||||
|
||||
// 随机友链卡片
|
||||
const randomArticle = allArticles[Math.floor(Math.random() * allArticles.length)];
|
||||
randomArticleContainer.innerHTML = `
|
||||
<div class="random-container">
|
||||
<div class="random-container-title">随机钓鱼</div>
|
||||
<div class="random-title">${randomArticle.title}</div>
|
||||
<div class="random-author">作者: ${randomArticle.author}</div>
|
||||
</div>
|
||||
<button class="random-link-button" onclick="window.open('${randomArticle.link}', '_blank')">过去转转</button>
|
||||
`;
|
||||
displayRandomArticle(); // 显示随机友链卡片
|
||||
|
||||
const articles = allArticles.slice(start, start + UserConfig.page_turning_number);
|
||||
|
||||
@ -123,6 +114,29 @@ function initialize_fc_lite() {
|
||||
}
|
||||
}
|
||||
|
||||
// 显示随机文章的逻辑
|
||||
function displayRandomArticle() {
|
||||
const randomArticle = allArticles[Math.floor(Math.random() * allArticles.length)];
|
||||
randomArticleContainer.innerHTML = `
|
||||
<div class="random-container">
|
||||
<div class="random-container-title">随机钓鱼</div>
|
||||
<div class="random-title">${randomArticle.title}</div>
|
||||
<div class="random-author">作者: ${randomArticle.author}</div>
|
||||
</div>
|
||||
<div class="random-button-container">
|
||||
<a href="#" id="refresh-random-article">刷新</a>
|
||||
<button class="random-link-button" onclick="window.open('${randomArticle.link}', '_blank')">过去转转</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// 为刷新按钮添加事件监听器
|
||||
const refreshBtn = document.getElementById('refresh-random-article');
|
||||
refreshBtn.addEventListener('click', function (event) {
|
||||
event.preventDefault(); // 阻止默认的跳转行为
|
||||
displayRandomArticle(); // 调用显示随机文章的逻辑
|
||||
});
|
||||
}
|
||||
|
||||
function showAuthorArticles(author, avatar, link) {
|
||||
// 如果不存在,则创建模态框结构
|
||||
if (!document.getElementById('fclite-modal')) {
|
||||
@ -207,19 +221,9 @@ function initialize_fc_lite() {
|
||||
};
|
||||
};
|
||||
|
||||
//document.addEventListener("DOMContentLoaded", function() {
|
||||
// setTimeout(initialize_fc_lite, 0);
|
||||
//});
|
||||
|
||||
//document.addEventListener('pjax:complete', function() {
|
||||
// setTimeout(initialize_fc_lite, 0);
|
||||
//});
|
||||
|
||||
//setTimeout(initialize_fc_lite, 0);
|
||||
|
||||
function whenDOMReady() {
|
||||
initialize_fc_lite();
|
||||
}
|
||||
|
||||
whenDOMReady();
|
||||
document.addEventListener("pjax:complete", whenDOMReady);
|
||||
document.addEventListener("pjax:complete", initialize_fc_lite);
|
||||
|
13
readme.md
13
readme.md
@ -11,6 +11,11 @@
|
||||
|
||||
## 开发进度
|
||||
|
||||
### 2024-10-07
|
||||
|
||||
* 添加随机文章刷新按钮
|
||||
* 完善邮件通知模板自定义程度
|
||||
|
||||
### 2024-09-28
|
||||
|
||||
* 更新自部署的api地址,统一为all.json,提高js兼容性
|
||||
@ -21,14 +26,14 @@
|
||||
|
||||
* 修复 #18 提出的,由于rss倒序导致限制抓取错误的问题,改为先全部获取后,按照时间排序,再选择性获取
|
||||
|
||||
### 2024-09-05
|
||||
<details>
|
||||
<summary>查看更多</summary>
|
||||
|
||||
<h3>2024-09-05</h3>
|
||||
|
||||
* 更新部署方式,将静态文件放到page分支下,主分支不放数据文件
|
||||
* 前后端分离,部署方式不变但更加直观方便
|
||||
|
||||
<details>
|
||||
<summary>查看更多</summary>
|
||||
|
||||
<h3>2024-09-03</h3>
|
||||
|
||||
* 添加特定RSS选项,用于指定部分友链特殊RSS地址
|
||||
|
@ -116,7 +116,7 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>清羽飞扬の最新文章</h1>
|
||||
<h1>{{ website_title }}の最新文章</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p><strong>文章标题:</strong> <span class="title">{{ title }}</span></p>
|
||||
@ -128,7 +128,7 @@
|
||||
<p>感谢您的订阅!</p>
|
||||
</div>
|
||||
<div class="unsubscribe">
|
||||
<p><a href="https://github.com/willow-god/Friend-Circle-Lite/issues">取消订阅</a></p>
|
||||
<p><a href="{{ github_issue_url }}">取消订阅</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
8
run.py
8
run.py
@ -49,6 +49,8 @@ if config["rss_subscribe"]["enable"]:
|
||||
github_repo = str(config["rss_subscribe"]["github_repo"]).strip()
|
||||
your_blog_url = config["rss_subscribe"]["your_blog_url"]
|
||||
email_template = config["rss_subscribe"]["email_template"]
|
||||
# 获取网站信息
|
||||
website_title = config["rss_subscribe"]["website_info"]["title"]
|
||||
# 获取最近更新的文章
|
||||
latest_articles = get_latest_articles_from_link(
|
||||
url=your_blog_url,
|
||||
@ -73,7 +75,9 @@ if config["rss_subscribe"]["enable"]:
|
||||
"title": article["title"],
|
||||
"summary": article["summary"],
|
||||
"published": article["published"],
|
||||
"link": article["link"]
|
||||
"link": article["link"],
|
||||
"website_title": website_title,
|
||||
"github_issue_url": f"https://github.com/{github_username}/{github_repo}/issues/new",
|
||||
}
|
||||
|
||||
send_emails(
|
||||
@ -82,7 +86,7 @@ if config["rss_subscribe"]["enable"]:
|
||||
smtp_server=server,
|
||||
port=port,
|
||||
password=password,
|
||||
subject="清羽飞扬の最新文章:" + article["title"],
|
||||
subject= website_title + "の最新文章:" + article["title"],
|
||||
body="文章链接:" + article["link"] + "\n" + "文章内容:" + article["summary"] + "\n" + "发布时间:" + article["published"],
|
||||
template_path=email_template,
|
||||
template_data=template_data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user