Files
open-ww3-project-ww3-tw/templates/blog/posts.html
2026-02-08 10:54:32 +08:00

76 lines
2.5 KiB
HTML
Executable File

<!DOCTYPE html>
<html>
<head>
<title>{{ posts['title'] }}</title>
<link rel="icon" type="image/x-icon" href="/static/icon/original.ico">
<meta property="og:title" content="{{ posts['title'] }}">
<meta property="og:description" content="{{ posts['content']}}">
<meta property="og:image" content="https://ww3.tw/static/img/open-ww3-project.png">
<meta property="og:url" content="https://ww3.tw/blog/posts/{{ posts['id']}}/">
<meta property="og:type" content="website">
</head>
</head>
<body>
<a href="/blog">返回主页</a>
<br>
<h1>{{ posts['title'] }}</h1>
<br>
<br>
{{ posts['content'].replace('&a&a','<style>a{text-decoration: none;}</style>') | safe}}
<br>
<br>
<br>
<hr>
<h2>留言区: </h2>
<form method="post" action="./chat/">
昵称: (20字)
<input type="text" name="name" maxlength="20" required>
<br>
留言内容: (100字)
<br>
<textarea name="data" maxlength="100" style="height: 60px;" required></textarea>
<button type="submit">发送</button>
</form>
<br>
{% for message_ss in message_ss %}
<span class="msg-date">{{message_ss.date}}</span>
<br>
[{{message_ss.name}}@arch-cat ArchLinux]
<br>
$ {{message_ss.data}}
<br>
<br>
{% endfor %}
</body>
</html>
<style>
body {
background-color: rgb(175, 223, 255);
}
a {
text-decoration: none;
}
</style>
<script>
document.querySelectorAll('.msg-date').forEach(el => {
let dateStr = el.innerText.trim();
if (dateStr) {
// 兼容 ISO 格式,将空格替换为 T 方便解析
let date = new Date(dateStr.replace(' ', 'T'));
// 增加 8 小时
date.setHours(date.getHours() + 8);
// 格式化回 YYYY-MM-DD HH:mm:ss
let formatted = date.getFullYear() + '-' +
String(date.getMonth() + 1).padStart(2, '0') + '-' +
String(date.getDate()).padStart(2, '0') + ' ' +
String(date.getHours()).padStart(2, '0') + ':' +
String(date.getMinutes()).padStart(2, '0') + ':' +
String(date.getSeconds()).padStart(2, '0');
el.innerText = formatted;
}
});
</script>