主题: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.
@ -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>
|
||||
@ -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">
|
||||
@ -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