主题:painting 更新完善
- 新增弹出框 - 新增背景音乐 - 完善最后一页 - 完善停词表
This commit is contained in:
parent
47918d49a1
commit
75ee065752
2
.github/workflows/docker-publish.yml
vendored
2
.github/workflows/docker-publish.yml
vendored
@ -3,7 +3,7 @@ name: Publish Docker image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
3117
data/stop_words.txt
3117
data/stop_words.txt
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@ from loguru import logger
|
||||
from .analyzer import analyze_sentiment, calculate_weight, classify_and_extract_keywords
|
||||
from .config import Config
|
||||
from .scraper import Blog
|
||||
from .tools import get_yiyan
|
||||
|
||||
|
||||
def build_data():
|
||||
@ -30,6 +31,7 @@ def build_data():
|
||||
"blog_link": my_blog.link,
|
||||
"blog_article_count": my_blog.article_count,
|
||||
"blog_article_word_count": my_blog.article_word_count,
|
||||
"blog_end_yiyan": get_yiyan()
|
||||
}
|
||||
|
||||
if my_blog.life is None:
|
||||
|
26
src/tools.py
26
src/tools.py
@ -97,3 +97,29 @@ def remove_html_tags(text):
|
||||
:return:文本
|
||||
"""
|
||||
return BeautifulSoup(text, "html.parser").get_text()
|
||||
|
||||
|
||||
def get_yiyan():
|
||||
"""
|
||||
获取一言文学语句
|
||||
:return:一言
|
||||
"""
|
||||
try:
|
||||
response = requests.get("https://v1.hitokoto.cn/?c=d&min_length=12&encode=text", timeout=30) # Set timeout to 5 seconds
|
||||
if response.status_code == 200:
|
||||
return response.text
|
||||
else:
|
||||
logger.error(f"一言网站无法访问,状态码:{response.status_code}")
|
||||
return False
|
||||
except requests.Timeout as e:
|
||||
logger.error(f"一言请求超时 30 秒,错误:{e}")
|
||||
return False
|
||||
except requests.ConnectionError as e:
|
||||
logger.error(f"一言连接错误,错误:{e}")
|
||||
return False
|
||||
except requests.RequestException as e:
|
||||
logger.error(f"一言网站无法访问,错误:{e}")
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.error(f"一言未知错误,错误:{e}")
|
||||
return False
|
@ -3,6 +3,11 @@
|
||||
src: url('../font/LXGWWenKaiMonoGB-Bold.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'dongzhu';
|
||||
src: url('../font/dongzhu-Extralight.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@media screen and (max-width: 320px) {
|
||||
html {
|
||||
font-size: 15px;
|
||||
@ -81,6 +86,7 @@ html {
|
||||
|
||||
.popup {
|
||||
position: absolute;
|
||||
margin: 0 2px;
|
||||
bottom: 0.5rem;
|
||||
background: #fff;
|
||||
padding: 1.5rem;
|
||||
@ -266,3 +272,18 @@ html {
|
||||
background-image: url('../img/page7.jpg');
|
||||
}
|
||||
|
||||
#tab7 > .tab7-box{
|
||||
padding: 2rem 2rem;
|
||||
}
|
||||
|
||||
.tab7-box > p {
|
||||
font-family: 'dongzhu', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
||||
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
||||
'Noto Color Emoji';
|
||||
font-size: 2.75rem;
|
||||
line-height: 3.5rem;
|
||||
writing-mode: vertical-rl;
|
||||
color: #FFFFFFD9;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
|
BIN
static/painting/font/dongzhu-Extralight.ttf
Normal file
BIN
static/painting/font/dongzhu-Extralight.ttf
Normal file
Binary file not shown.
BIN
static/painting/music/bgm.mp3
Normal file
BIN
static/painting/music/bgm.mp3
Normal file
Binary file not shown.
@ -5,13 +5,13 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>EndOfYear</title>
|
||||
{% if web_status == 1 %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='painting/css/normalize.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='painting/css/animate.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='painting/css/painting.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='painting/css/normalize.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='painting/css/animate.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='painting/css/painting.css') }}">
|
||||
{% else %}
|
||||
<link rel="stylesheet" href="painting/css/normalize.css">
|
||||
<link rel="stylesheet" href="painting/css/animate.min.css">
|
||||
<link rel="stylesheet" href="painting/css/painting.css">
|
||||
<link rel="stylesheet" href="painting/css/normalize.css">
|
||||
<link rel="stylesheet" href="painting/css/animate.min.css">
|
||||
<link rel="stylesheet" href="painting/css/painting.css">
|
||||
{% endif %}
|
||||
<script async src="https://umami.7wate.org/script.js"
|
||||
data-website-id="635fec50-bc6c-4ac2-909a-e2a7403438be"></script>
|
||||
@ -20,9 +20,10 @@
|
||||
<div class="container active animate__animated animate__fadeIn animate__slow" id="tab1">
|
||||
<audio id="bgm" loop>
|
||||
{% if web_status == 1 %}
|
||||
<source src="{{ url_for('static', filename='painting/music/bgm.mp3') }}" type="audio/mpeg">Your browser does not support the audio element.
|
||||
<source src="{{ url_for('static', filename='painting/music/bgm.mp3') }}" type="audio/mpeg">Your browser does
|
||||
not support the audio element.
|
||||
{% else %}
|
||||
<source src="painting/Time.ogg" type="audio/music/bgm.mp3">Your browser does not support the audio element.
|
||||
<source src="painting/music/bgm.mp3" type="audio/mpeg">Your browser does not support the audio element.
|
||||
{% endif %}
|
||||
|
||||
</audio>
|
||||
@ -48,12 +49,12 @@
|
||||
<div class="tab2-box">
|
||||
<p class="animate__animated animate__fadeIn animate__delay-1s">亲爱的{{ data.blog_name }}</p>
|
||||
{% if data.blog_life == 0 %}
|
||||
<p class="animate__animated animate__fadeIn animate__delay-2s">旧事如梦,一年已过</p>
|
||||
<p class="animate__animated animate__fadeIn animate__delay-2s">贰三年、感谢有你!</p>
|
||||
<p class="animate__animated animate__fadeIn animate__delay-2s">旧事如梦,一年已过</p>
|
||||
<p class="animate__animated animate__fadeIn animate__delay-2s">贰三年、感谢有你!</p>
|
||||
{% else %}
|
||||
<p class="animate__animated animate__fadeIn animate__delay-2s">今天是我们相识的</p>
|
||||
<p class="animate__animated animate__fadeIn animate__delay-3s">第 <small>{{ data.blog_life_year }}</small> 年
|
||||
<small>{{ data.blog_life_day }}</small> 天</p>
|
||||
<p class="animate__animated animate__fadeIn animate__delay-2s">今天是我们相识的</p>
|
||||
<p class="animate__animated animate__fadeIn animate__delay-3s">第 <small>{{ data.blog_life_year }}</small> 年
|
||||
<small>{{ data.blog_life_day }}</small> 天</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@ -63,8 +64,8 @@
|
||||
<p class="animate__animated animate__fadeInUp animate__delay-1s">这一年你写下了</p>
|
||||
<p class="animate__animated animate__fadeInUp animate__delay-2s"><small>{{ data.blog_article_count }}</small>
|
||||
篇博文</p>
|
||||
<p class="animate__animated animate__fadeInUp animate__delay-3s"><small>{{ data.blog_article_word_count
|
||||
}}</small> 个文字</p>
|
||||
<p class="animate__animated animate__fadeInUp animate__delay-3s">
|
||||
<small>{{ data.blog_article_word_count }}</small> 个文字</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container animate__animated animate__fadeIn animate__slow" id="tab4">
|
||||
@ -78,7 +79,7 @@
|
||||
<div class="container animate__animated animate__fadeIn animate__slow" id="tab5">
|
||||
<div class="tab5-box">
|
||||
{% for keyword in data.blog_top_keywords %}
|
||||
<p>{{ keyword[0] }}</p>
|
||||
<p>{{ keyword[0] }}</p>
|
||||
{% endfor %}
|
||||
<p class="animate__animated animate__fadeInDown animate__delay-1s">这些都是<small>你</small>的</p>
|
||||
<p class="animate__animated animate__fadeInDown animate__delay-2s">专属<small>关键词</small></p>
|
||||
@ -92,7 +93,7 @@
|
||||
</div>
|
||||
<div class="container animate__animated animate__fadeIn animate__slow" id="tab7">
|
||||
<div class="tab7-box">
|
||||
|
||||
<p id="yiyan"> {{ data.blog_end_yiyan }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -143,9 +144,15 @@
|
||||
|
||||
denyButton.addEventListener('click', function (event) {
|
||||
event.stopPropagation();
|
||||
audioElement.pause();
|
||||
popup.style.display = 'none'; // 隐藏弹出窗口
|
||||
});
|
||||
|
||||
// 博客最后的一言
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
let textElement = document.getElementById("yiyan");
|
||||
let text = textElement.innerHTML;
|
||||
textElement.innerHTML = text.replace(/[\u3000-\u303F\uFF01-\uFF0F\uFF1A-\uFF1E\uFF3B-\uFF3F\uFF5B-\uFF60\uFFE0-\uFFE6\u00D2]/g, "<br>");
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user