修改主页,感觉还可以
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ databases/*
|
|||||||
mirrors/*
|
mirrors/*
|
||||||
blueprint/kami_views.py
|
blueprint/kami_views.py
|
||||||
templates/kami/*
|
templates/kami/*
|
||||||
|
static/upload/*
|
||||||
0
__init__.py
Normal file
0
__init__.py
Normal file
@@ -1,46 +1,54 @@
|
|||||||
from flask import Blueprint, render_template, request, url_for, flash, redirect, send_from_directory, make_response, current_app
|
from flask import Blueprint, render_template, request, url_for, flash, redirect, send_from_directory, make_response, current_app
|
||||||
from database import get_owp_db
|
from database import get_owp_db
|
||||||
|
from flask_autoindex import AutoIndex
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import time
|
||||||
|
|
||||||
def get_owp_db_conn():
|
def get_owp_db_conn():
|
||||||
conn = sqlite3.connect('/var/open-ww3-project-ww3-tw/databases/sqlite/owp.db')
|
conn = sqlite3.connect('/var/open-ww3-project-ww3-tw/databases/sqlite/owp.db')
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
||||||
blog_bp = Blueprint('blog', __name__)
|
blog_bp = Blueprint('blog', __name__)
|
||||||
|
|
||||||
|
index_path = '/var/open-ww3-project-ww3-tw/mirrors/'
|
||||||
|
index = AutoIndex(blog_bp, browse_root=index_path, add_url_rules=False)
|
||||||
|
|
||||||
@blog_bp.route('/')
|
@blog_bp.route('/')
|
||||||
def home():
|
def home():
|
||||||
db = get_owp_db()
|
db = get_owp_db()
|
||||||
conn = get_owp_db_conn()
|
conn = get_owp_db_conn()
|
||||||
sql_logs = "SELECT * from logs;"
|
sql_logs = "SELECT * from logs;"
|
||||||
sql_posts = "SELECT * from posts;"
|
sql_posts = "SELECT * from posts where status= 1;"
|
||||||
logs = conn.execute(sql_logs).fetchall()
|
logs = conn.execute(sql_logs).fetchall()
|
||||||
posts = conn.execute(sql_posts).fetchall()
|
posts = conn.execute(sql_posts).fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return render_template('home.html', logs=logs[::-1], posts=posts[::-1])
|
return render_template('blog/home.html', logs=logs[::-1], posts=posts[::-1])
|
||||||
|
|
||||||
@blog_bp.route('/about/')
|
@blog_bp.route('/about/')
|
||||||
def about():
|
def about():
|
||||||
return render_template('about.html')
|
return render_template('blog/about.html')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@blog_bp.route('/posts/')
|
@blog_bp.route('/posts/')
|
||||||
def posts_list():
|
def posts_list():
|
||||||
conn = get_owp_db_conn()
|
conn = get_owp_db_conn()
|
||||||
sql_posts = "SELECT * from posts;"
|
sql_posts = "SELECT * from posts where status= 1;"
|
||||||
posts = conn.execute(sql_posts).fetchall()
|
posts = conn.execute(sql_posts).fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return render_template('list.html', posts=posts[::-1])
|
return render_template('blog/list.html', posts=posts[::-1])
|
||||||
|
|
||||||
@blog_bp.route('/posts/<int:posts_id>/')
|
@blog_bp.route('/posts/<int:posts_id>/')
|
||||||
def show_posts_id(posts_id):
|
def show_posts_id(posts_id):
|
||||||
conn = get_owp_db_conn()
|
conn = get_owp_db_conn()
|
||||||
sql_posts = "SELECT * FROM posts WHERE id = ?"
|
sql_posts = "SELECT * FROM posts WHERE status = 1 AND id = ?"
|
||||||
posts = conn.execute(sql_posts, (posts_id,)).fetchone()
|
posts = conn.execute(sql_posts, (posts_id,)).fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
return render_template('posts.html', posts=posts)
|
if posts is None:
|
||||||
|
return f'未找到该文章{posts_id}<title>未找到该文章{posts_id}</title>', 404
|
||||||
|
return render_template('blog/posts.html', posts=posts)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -72,14 +80,32 @@ def google02f6a3f6004a32c6():
|
|||||||
@blog_bp.route('/sitemap.xml/')
|
@blog_bp.route('/sitemap.xml/')
|
||||||
def sitemap():
|
def sitemap():
|
||||||
conn = get_owp_db_conn()
|
conn = get_owp_db_conn()
|
||||||
sql_posts = "SELECT * from posts;"
|
sql_posts = "SELECT * from posts where status = 1;"
|
||||||
posts = conn.execute(sql_posts).fetchall()
|
posts = conn.execute(sql_posts).fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
template = render_template('sitemap.xml', posts=posts[::-1], base_url="https://open-ww3-project.ww3.tw/blog/")
|
template = render_template('blog/sitemap.xml', posts=posts[::-1], base_url="https://open-ww3-project.ww3.tw/blog/")
|
||||||
response = make_response(template)
|
response = make_response(template)
|
||||||
response.headers['Content-Type'] = 'application/xml'
|
response.headers['Content-Type'] = 'application/xml'
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@blog_bp.errorhandler(404)
|
@blog_bp.route('/kami/')
|
||||||
def not_found_error(error):
|
def kami():
|
||||||
return '404 not found', 404
|
return redirect(url_for('kami.home'))
|
||||||
|
|
||||||
|
@blog_bp.route('/mirrors/')
|
||||||
|
@blog_bp.route('/mirrors/<path:path>')
|
||||||
|
def autoindex(path='.'):
|
||||||
|
return index.render_autoindex(path, template='blog/mirrors.html')
|
||||||
|
|
||||||
|
|
||||||
|
@blog_bp.route('/upload/', methods=['POST' , 'GET'])
|
||||||
|
def upload():
|
||||||
|
if request.method == "POST":
|
||||||
|
f = request.files.get('img')
|
||||||
|
filename = f.filename
|
||||||
|
with open(f'/var/open-ww3-project-ww3-tw/static/upload/img/{filename}', 'wb') as tf:
|
||||||
|
tf.write(f.read())
|
||||||
|
return '上传成功<meta http-equiv="refresh" content="1.2;url=https://ww3.tw/blog/upload/">'
|
||||||
|
img_files = '/var/open-ww3-project-ww3-tw/static/upload/img/'
|
||||||
|
images = [img for img in os.listdir(img_files) if img.endswith(('.png', '.jpg', '.jpeg', '.gif'))]
|
||||||
|
return render_template('blog/upload.html', images=images)
|
||||||
17
blueprint/index_views.py
Normal file
17
blueprint/index_views.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
from flask import Blueprint, render_template, url_for, redirect
|
||||||
|
import sqlite3
|
||||||
|
import os
|
||||||
|
|
||||||
|
index_bp = Blueprint('/', __name__)
|
||||||
|
|
||||||
|
@index_bp.route('/')
|
||||||
|
def repage():
|
||||||
|
return redirect(url_for('blog.home'))
|
||||||
|
|
||||||
|
@index_bp.route('/mirrors/')
|
||||||
|
def mirrors():
|
||||||
|
return redirect(url_for('blog.autoindex'))
|
||||||
|
|
||||||
|
@index_bp.route('/greet/<name>/')
|
||||||
|
def greet(name):
|
||||||
|
return f'Hello, {name}!'
|
||||||
16
main.py
16
main.py
@@ -3,6 +3,7 @@ from blueprint.blog_views import blog_bp
|
|||||||
from blueprint.study_views import study_bp
|
from blueprint.study_views import study_bp
|
||||||
from flask_autoindex import AutoIndex
|
from flask_autoindex import AutoIndex
|
||||||
from blueprint.kami_views import kami_bp
|
from blueprint.kami_views import kami_bp
|
||||||
|
from blueprint.index_views import index_bp
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
@@ -13,8 +14,6 @@ def get_owp_db_conn():
|
|||||||
|
|
||||||
app = Flask(__name__, static_url_path='/static/')
|
app = Flask(__name__, static_url_path='/static/')
|
||||||
|
|
||||||
index_path = '/var/open-ww3-project-ww3-tw/mirrors/'
|
|
||||||
index = AutoIndex(app, browse_root=index_path, add_url_rules=False)
|
|
||||||
|
|
||||||
# session
|
# session
|
||||||
#app.secret_key = "508948973a8651f160baf3b26f18c47d"
|
#app.secret_key = "508948973a8651f160baf3b26f18c47d"
|
||||||
@@ -26,18 +25,11 @@ app.secret_key = '玩鵬畝遜溉痕叛課還擇鼇粹拜溜泉聰倡效蘭鱅
|
|||||||
app.register_blueprint(blog_bp, url_prefix='/blog')
|
app.register_blueprint(blog_bp, url_prefix='/blog')
|
||||||
app.register_blueprint(study_bp, url_prefix='/study')
|
app.register_blueprint(study_bp, url_prefix='/study')
|
||||||
app.register_blueprint(kami_bp, url_prefix='/kami')
|
app.register_blueprint(kami_bp, url_prefix='/kami')
|
||||||
|
app.register_blueprint(index_bp, url_prefix='/')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def repage():
|
|
||||||
# return '<meta http-equiv="refresh" content="0.1;url=/blog/">'
|
|
||||||
return redirect(url_for('blog.home'))
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/greet/<name>/')
|
|
||||||
def greet(name):
|
|
||||||
return f'Hello, {name}!'
|
|
||||||
|
|
||||||
# 全局清理关闭数据库连接
|
# 全局清理关闭数据库连接
|
||||||
@app.teardown_appcontext
|
@app.teardown_appcontext
|
||||||
def close_connection(exception):
|
def close_connection(exception):
|
||||||
@@ -46,10 +38,6 @@ def close_connection(exception):
|
|||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
@app.route('/mirrors/')
|
|
||||||
@app.route('/mirrors/<path:path>')
|
|
||||||
def autoindex(path='.'):
|
|
||||||
return index.render_autoindex(path, template='mirrors.html')
|
|
||||||
|
|
||||||
@app.errorhandler(400)
|
@app.errorhandler(400)
|
||||||
def bad_request(error):
|
def bad_request(error):
|
||||||
|
|||||||
0
static/google02f6a3f6004a32c6.html
Normal file → Executable file
0
static/google02f6a3f6004a32c6.html
Normal file → Executable file
@@ -2,6 +2,6 @@ User-agent: *
|
|||||||
|
|
||||||
Allow: /
|
Allow: /
|
||||||
|
|
||||||
Disallow: /admin/
|
Disallow: /kami/
|
||||||
|
|
||||||
Sitemap: https://open-ww3-project.ww3.tw/blog/sitemap.xml
|
Sitemap: https://open-ww3-project.ww3.tw/blog/sitemap.xml
|
||||||
0
static/tui_jian/index.html
Normal file → Executable file
0
static/tui_jian/index.html
Normal file → Executable file
0
static/video.html
Normal file → Executable file
0
static/video.html
Normal file → Executable file
83
templates/blog/home.html
Normal file
83
templates/blog/home.html
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
{# 引入base #}
|
||||||
|
{% extends 'blog/home_base.html' %}
|
||||||
|
|
||||||
|
{# 引入标题 #}
|
||||||
|
{% block title %}首页{% endblock %}
|
||||||
|
|
||||||
|
{% block logs_and_page %}
|
||||||
|
<h1>欢迎访问open-ww3-project</h1>
|
||||||
|
<!-- 屑站日志 -->
|
||||||
|
<h3 style="margin: 10px 0 30px 50px;">屑站日志:<br></h3>
|
||||||
|
<div id="logs">
|
||||||
|
<font size="3.2">
|
||||||
|
<table border="0">
|
||||||
|
<tbody>
|
||||||
|
{# 调用数据库 #}
|
||||||
|
{% for logs in logs %}
|
||||||
|
<tr>
|
||||||
|
<td id="td_logs">
|
||||||
|
<a style='font-size: 18px;'>
|
||||||
|
{{ logs['date'].replace('.', '-') }}
|
||||||
|
</a>
|
||||||
|
<br>
|
||||||
|
</td>
|
||||||
|
<td id="td_logs_content">
|
||||||
|
{{ logs['content'].replace('&&', '<br>') | safe }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</font>
|
||||||
|
</div>
|
||||||
|
<!-- 屑站日志 -->
|
||||||
|
<div id="posts">
|
||||||
|
<h1>全部文章</h1>
|
||||||
|
文章如下↓
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{% for posts in posts %}
|
||||||
|
文章id:{{ posts['id'] }}
|
||||||
|
<br>
|
||||||
|
标题: {{ posts['title'] }}
|
||||||
|
<br>
|
||||||
|
日期: {{ posts['date'].replace('.', '-')}}
|
||||||
|
<a href="{{ url_for('blog.posts_list') }}{{ posts['id'] }}">页面跳转</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- css 部分 -->
|
||||||
|
<style>
|
||||||
|
#posts {
|
||||||
|
margin: -20% 0 0 60%;
|
||||||
|
}
|
||||||
|
/* 日志 */
|
||||||
|
#logs
|
||||||
|
{
|
||||||
|
height: 220px;
|
||||||
|
width: 460px;
|
||||||
|
overflow: auto;
|
||||||
|
background: #ffffffbc;
|
||||||
|
/* up、right、down、left */
|
||||||
|
margin: -10px 0px 0px 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#td_logs
|
||||||
|
{
|
||||||
|
width: 93px;
|
||||||
|
padding-top: 1.8px;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
#td_logs_content
|
||||||
|
{
|
||||||
|
color: rgb(132, 132, 132);
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
/* 日志 */
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
142
templates/blog/home_base.html
Normal file
142
templates/blog/home_base.html
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
{# base模板 #}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" lang="zh_CN">
|
||||||
|
<link rel="icon" type="image/x-icon" href="/static/icon/original.ico">
|
||||||
|
<link rel="preload" href="{{ wallpaper }}" as="image">
|
||||||
|
<title>{% block title %}{% endblock %} | ww3</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% set navbar_list = [
|
||||||
|
{"id":1, "name": "首页", "url": url_for('blog.home')},
|
||||||
|
{"id":2, "name": "关于", "url": url_for('blog.about')},
|
||||||
|
{"id":3, "name": "文章", "url": url_for('blog.posts_list')},
|
||||||
|
{"id":4, "name": "mirrors", "url": url_for('blog.autoindex')},
|
||||||
|
{"id":5, "name": "study", "url": url_for('study.home')},
|
||||||
|
]%}
|
||||||
|
|
||||||
|
{% set wallpaper_apis =[
|
||||||
|
'https://www.loliapi.com/acg/pc/',
|
||||||
|
'https://api.sretna.cn/api/pc.php',
|
||||||
|
'https://www.api.plus/API/dongman/',
|
||||||
|
'https://moe.jitsu.top/img/?sort=pc',
|
||||||
|
'https://www.dmoe.cc/random.php',
|
||||||
|
'https://api.r10086.com/樱道随机图片api接口.php?图片系列=猫娘1',
|
||||||
|
'https://api.mtyqx.cn/tapi/random.php'] %}
|
||||||
|
{% set wallpaper = wallpaper_apis | random %}
|
||||||
|
<div style="display: none;">
|
||||||
|
<p>一个致力于分享个人学习到的知识的记录形式的屑站</p>
|
||||||
|
<p>在这里,我会分享我学到的计算机知识或者记录一些自己经常碰到的问题</p>
|
||||||
|
</div>
|
||||||
|
<div id="wallpaper">
|
||||||
|
<div id="navbar1">
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div id="navbar">
|
||||||
|
{% for navbar in navbar_list %}
|
||||||
|
<a href="{{ navbar.url }}" id="url_">{{ navbar.name }}</a></td>
|
||||||
|
{% endfor %}
|
||||||
|
<a id="url_" href="https://api.ww3.tw">api</a>
|
||||||
|
<a id="url_" href="https://gitea.ww3.tw">gitea</a>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div style="text-align: center;
|
||||||
|
font-weight: bolder;
|
||||||
|
text-shadow:
|
||||||
|
3px 3px 0 rgba(0,0,0,0.2),
|
||||||
|
6px 6px 0 rgba(0,0,0,0.1);
|
||||||
|
font-size: 300%;
|
||||||
|
color: rgb(240, 248, 255);
|
||||||
|
">
|
||||||
|
<p>open-ww3-poject</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p style="text-align: right; margin: 420px 0 0 0;">图片来源: <a href="{{ wallpaper }}" style="color: rgb(247, 74, 74);">{{ wallpaper }}<a></p>
|
||||||
|
</div>
|
||||||
|
<div style="text-align: center; color: rgba(255, 255, 255, 0.664); margin: -400px 0 0 0; text-shadow: 3px 3px 5px rgba(47, 79, 79, 0.7);">
|
||||||
|
<p>一个致力于分享个人学习到的知识的记录形式的屑站</p>
|
||||||
|
<p>在这里,我会分享我学到的计算机知识或者记录一些自己经常碰到的问题</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="logs_and_page">
|
||||||
|
{% block logs_and_page %}
|
||||||
|
{# 这里存放写入模板的数据 #}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer style="
|
||||||
|
text-align: center;
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
color: rgb(255, 255, 255);
|
||||||
|
padding: 10px;
|
||||||
|
margin-top: 0;
|
||||||
|
">
|
||||||
|
© 2025 | open-ww3-poject for ww3.tw
|
||||||
|
<br>
|
||||||
|
<a href="https://wiki.ww3.tw/doku.php?id=zh_cn:skimrme" style="color: rgb(188, 188, 255);">关于站长</a>
|
||||||
|
<a href="{{ url_for('blog.sitemap') }}" style="color: rgb(188, 188, 255);">网页地图</a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
联系:
|
||||||
|
<br>
|
||||||
|
电子邮件: <a style="color: rgb(188, 188, 255);">master@ww3.tw<a>
|
||||||
|
<br>
|
||||||
|
社交:
|
||||||
|
<br>
|
||||||
|
暂不提供
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
{# css部分 #}
|
||||||
|
<style>
|
||||||
|
#navbar {
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
#url_ {
|
||||||
|
margin: 0 5px 0 0;
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
#logs_and_page {
|
||||||
|
margin: 0 0 0 0;
|
||||||
|
margin-left: 5%;
|
||||||
|
width: 90%;
|
||||||
|
height: 640px;
|
||||||
|
background-color: #93B9FFA4;
|
||||||
|
}
|
||||||
|
#wallpaper {
|
||||||
|
margin-left: 5%;
|
||||||
|
width: 90%;
|
||||||
|
height: 640px;
|
||||||
|
background-color: #93B9FFA4;
|
||||||
|
background-image: url('{{ wallpaper }}');
|
||||||
|
background-size: 100% 100%;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
#navbar1 {
|
||||||
|
font-size: 125%;
|
||||||
|
width: 35%;
|
||||||
|
height: 13px;
|
||||||
|
background-color: rgba(169, 198, 252, 0);
|
||||||
|
}
|
||||||
|
#navbar {
|
||||||
|
font-size: 125%;
|
||||||
|
width: 500px;
|
||||||
|
height: auto;
|
||||||
|
background-color: rgb(169, 198, 252);
|
||||||
|
}
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background-color: rgb(92, 92, 92);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
{% block footer %}
|
{% block footer %}
|
||||||
<hr>
|
<hr>
|
||||||
<div style="text-align: right; color: #fb8888; background-color: rgba(229, 229, 255, 0); width: 300px; margin: -13.82% 0 0 70.45%;">
|
<div style="color: #fb8888; text-align: center;">
|
||||||
© 2025 open-ww3-project
|
© 2025 open-ww3-project
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
19
templates/blog/posts.html
Executable file
19
templates/blog/posts.html
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ posts['title'] }}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="../">返回上级</a>
|
||||||
|
<br>
|
||||||
|
<h1>{{ posts['title'] }}</h1>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{{ posts['content'].replace('&a&a','<style>a{text-decoration: none;}</style>') | safe}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: rgb(175, 223, 255);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
29
templates/blog/sitemap.xml
Executable file
29
templates/blog/sitemap.xml
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
<url>
|
||||||
|
<loc>{{ base_url }}</loc>
|
||||||
|
<lastmod>2025-12-22</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
{% for post in posts %}
|
||||||
|
<url>
|
||||||
|
<loc>{{ base_url }}posts/{{ post['id'] }}/</loc>
|
||||||
|
<lastmod>{{ post['date'].replace('.', '-') }}</lastmod>
|
||||||
|
<changefreq>monthly</changefreq>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>
|
||||||
|
{% endfor %}
|
||||||
|
<url>
|
||||||
|
<loc>{{ base_url }}posts/</loc>
|
||||||
|
<lastmod>2025-12-23</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>{{ base_url }}mirrors/</loc>
|
||||||
|
<lastmod>2025-12-23</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>
|
||||||
|
</urlset>
|
||||||
19
templates/blog/upload.html
Normal file
19
templates/blog/upload.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<title>上传文件</title>
|
||||||
|
上传文件
|
||||||
|
<br>
|
||||||
|
目前只支持jpg, jpeg, png, gif
|
||||||
|
<form id="upload-form" enctype="multipart/form-data" method="post" action="./">
|
||||||
|
<input type="file" name="img" required>
|
||||||
|
<button type="submit">上传文件</button>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
已上传图片
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{% for image in images %}
|
||||||
|
<a href="{{ url_for('static', filename='upload/img/' + image) }}">
|
||||||
|
<img src="{{ url_for('static', filename='upload/img/' + image) }}" style="width: 10%;" alt="{{ image }}">
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
@@ -1,277 +0,0 @@
|
|||||||
<!-- 主页 -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>首页 | ww3</title>
|
|
||||||
<meta charset="utf-8" lang="zh-CN">
|
|
||||||
<link rel="icon" type="image/x-icon" href="/static/icon/original.ico">
|
|
||||||
<!-- 引入页面蓝图css -->
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/main.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app-canvas">
|
|
||||||
<header>
|
|
||||||
<h1 style="margin: 80px 0 0 0; color:aqua;">open-ww3-project</h1>
|
|
||||||
</header>
|
|
||||||
<!-- 导航栏 -->
|
|
||||||
<div id="navbar1">
|
|
||||||
<table border="0" style="background-color: rgba(147, 185, 255, 0.644);">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td id="td_navbar_40px"><b><a href="{{ url_for('blog.home') }}" id="url_">首页</a></b></td>
|
|
||||||
<td id="td_navbar_40px"><b><a href="{{ url_for('blog.about') }}" id="url_">关于</a></b></td>
|
|
||||||
<td id="td_navbar_40px"><b><a href="{{ url_for('blog.posts_list') }}" id="url_">文章</a></b></td>
|
|
||||||
<td id="td_navbar_75px"><b><a href="#" id="url_">弹幕留言</a></b></td>
|
|
||||||
<td id="td_navbar_78px"><b><a href="#" id="url_">短链生成</a></b></td>
|
|
||||||
<td id="td_navbar_52px"><b><a href="https://gitea.ww3.tw/skimrme/" id="url_">gitea</a></b></td>
|
|
||||||
<td id="td_navbar_150px"><b><a href="https://ww3.tw/docker-registry/" id="url_">docker-registry</a></b></td>
|
|
||||||
<td id="td_navbar_40px"><b><a href="https://api.ww3.tw/" id="url_">api</a></b></td>
|
|
||||||
<td id="td_navbar_40px"><b><a href="https://wiki.ww3.tw/" id="url_">wiki</a></b></td>
|
|
||||||
<td id="td_navbar_52px"><b><a href="/mirrors" id="url_">mirrors</a></b></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<!-- 倒过来的箱子 真不明白,为什么我会称呼箱子为open-ww3-project-->
|
|
||||||
<div style="margin: 80px -30px -100px 180px;">
|
|
||||||
<img id="open-ww3-project-img" width="10%" src="/static/img/open-ww3-project.png" alt="open-ww3-project-img">
|
|
||||||
</div>
|
|
||||||
<!-- gitea 图标 -->
|
|
||||||
<a style="background-color: blueviolet; position: absolute;" href="https://gitea.ww3.tw/skimrme/open-ww3-project-ww3-tw">
|
|
||||||
<img id="gitea-img" src="https://gitea.ww3.tw/assets/img/logo.svg" width="150px" alt="gitea" >
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<!-- 导航栏 -->
|
|
||||||
<div id="content-area">
|
|
||||||
<!-- 屑站日志 -->
|
|
||||||
<h3 style="margin: 70px 0 30px -50px;">屑站日志:<br></h3>
|
|
||||||
<div id="logs">
|
|
||||||
<font size="3.2">
|
|
||||||
<table border="0">
|
|
||||||
<tbody>
|
|
||||||
{# 调用数据库 #}
|
|
||||||
{% for logs in logs %}
|
|
||||||
<tr>
|
|
||||||
<td id="td_logs">
|
|
||||||
<a style='font-size: 18px;'>
|
|
||||||
{{ logs['date'] }}
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
</td>
|
|
||||||
<td id="td_logs_content">
|
|
||||||
{{ logs['content'].replace('&&', '<br>') | safe }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</font>
|
|
||||||
</div>
|
|
||||||
<!-- 屑站日志 -->
|
|
||||||
|
|
||||||
<div id="post_content">
|
|
||||||
{#
|
|
||||||
<?php
|
|
||||||
//include "post/index.php";
|
|
||||||
// 设定数据库路径
|
|
||||||
$db_path = '/var/www/owp/open-ww3-project-ww3-tw/databases/sqlite/owp.db';
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 连接数据库
|
|
||||||
$db = new SQLite3($db_path);
|
|
||||||
// 连接成功输出连接成功
|
|
||||||
echo "<!--数据库连接成功-->";
|
|
||||||
// 如果连接成功,但是内部状态有问题
|
|
||||||
if ($db->lastErrorCode() !==0) {
|
|
||||||
// 依旧显示为连接失败
|
|
||||||
die("数据库连接失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 内容区
|
|
||||||
// 执行sql命令 查询表单
|
|
||||||
$select_id_date_title_from_posts_btos /*查询posts表单中的id date title id从大到小排列*/ = $db->query('SELECT id, date, title FROM posts ORDER BY id DESC'); // 执行查询posts表单中的id date title id从大到小排列的命令
|
|
||||||
// 循环 写入
|
|
||||||
|
|
||||||
echo "<center><b><h2>全部文章</h2></b></center>";
|
|
||||||
echo "<br>";
|
|
||||||
echo "文章如下↓";
|
|
||||||
echo "<br>";
|
|
||||||
echo "<br>";
|
|
||||||
|
|
||||||
while ($row = $select_id_date_title_from_posts_btos->fetchArray(SQLITE3_ASSOC)) {
|
|
||||||
|
|
||||||
echo "文章id: " . $row['id'] . "<br>";
|
|
||||||
echo $row['date'] . " " . "文章标题: " . $row['title'] . "<br>";
|
|
||||||
echo "<a href='https://ww3.tw/blog/post/s/?id=" . $row['id'] . "'>页面跳转</a><br><br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 关闭数据库连接
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
// 捕获php报错
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// 依旧显示为连接失败
|
|
||||||
die("数据库连接失败");
|
|
||||||
// 关闭数据库连接
|
|
||||||
$db->close();
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
#}
|
|
||||||
<center><b><h2>全部文章</h2></b></center>
|
|
||||||
<br>
|
|
||||||
文章如下↓
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
{% for posts in posts %}
|
|
||||||
文章id:{{ posts['id'] }}
|
|
||||||
<br>
|
|
||||||
{{ posts['date'] }}
|
|
||||||
{{ posts['title'] }}
|
|
||||||
<br>
|
|
||||||
<a href="{{ url_for('blog.posts_list') }}{{ posts['id'] }}">页面跳转</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- 私の娘 -->
|
|
||||||
<div style="margin: 40px 0 0 0;">
|
|
||||||
<div id="my_girl" style="margin: -40px 0 0 1100px;"></div>
|
|
||||||
</div>
|
|
||||||
<!-- 私の娘 -->
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- css 部分 -->
|
|
||||||
<style>
|
|
||||||
#navbar1 {
|
|
||||||
margin: -160px 0 100px -30px;
|
|
||||||
}
|
|
||||||
#url_
|
|
||||||
{
|
|
||||||
text-decoration: none;
|
|
||||||
color: rgb(0, 0, 0);
|
|
||||||
font-size: 18.8px;
|
|
||||||
}
|
|
||||||
#td_navbar_40px
|
|
||||||
{
|
|
||||||
width: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#td_navbar_52px
|
|
||||||
{
|
|
||||||
width: 52px;;
|
|
||||||
}
|
|
||||||
|
|
||||||
#td_navbar_78px
|
|
||||||
{
|
|
||||||
width: 78px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#td_navbar_150px
|
|
||||||
{
|
|
||||||
width: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 日志 */
|
|
||||||
#logs
|
|
||||||
{
|
|
||||||
height: 220px;
|
|
||||||
width: 450px;
|
|
||||||
overflow: auto;
|
|
||||||
background: #ffffffbc;
|
|
||||||
/* up、right、down、left */
|
|
||||||
margin: 115px 0px 0px -280px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#td_logs
|
|
||||||
{
|
|
||||||
width: 75px;
|
|
||||||
padding-top: 1.8px;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
#td_logs_content
|
|
||||||
{
|
|
||||||
color: rgb(132, 132, 132);
|
|
||||||
padding-left: 10px;
|
|
||||||
padding-bottom: 5px;
|
|
||||||
}
|
|
||||||
/* 日志 */
|
|
||||||
|
|
||||||
/* 文章 */
|
|
||||||
#post_content
|
|
||||||
{
|
|
||||||
/*text-align: center;*/
|
|
||||||
height: 450px;
|
|
||||||
width: 490px;
|
|
||||||
color: rgb(202, 202, 202);
|
|
||||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
|
||||||
background-color: rgba(27, 27, 27, 0.010);
|
|
||||||
overflow: auto;
|
|
||||||
font-size: 19px;
|
|
||||||
/* up、right、down、left */
|
|
||||||
margin: 40px 0 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 图标 */
|
|
||||||
#open-ww3-pro1ject-img
|
|
||||||
{
|
|
||||||
overflow: auto;
|
|
||||||
/* up、right、down、left */
|
|
||||||
margin: 0 0 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#gitea-img
|
|
||||||
{
|
|
||||||
margin: -150px 0 0 1150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- js 部分-->
|
|
||||||
<script src="/static/js/main.js"> 引入js页面蓝图 </script>
|
|
||||||
|
|
||||||
<!-- 私の娘 -->
|
|
||||||
<!-- https://cdn.jsdelivr.net/npm/sakana-widget@2.7.1/lib/sakana.min.css -->
|
|
||||||
<!-- https://cdn.jsdelivr.net/npm/sakana-widget@2.7.1/lib/sakana.min.js -->
|
|
||||||
<!-- https://cdnjs.cloudflare.com/ajax/libs/sakana-widget/2.7.1/sakana.min.css -->
|
|
||||||
<!-- https://cdnjs.cloudflare.com/ajax/libs/sakana-widget/2.7.1/sakana.min.js -->
|
|
||||||
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
href="https://cdn.jsdelivr.net/npm/sakana-widget@2.7.1/lib/sakana.min.css"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function initSakanaWidget(){
|
|
||||||
const customImageUrl = "{{ url_for('static', filename='img/my_girl.png') }}";
|
|
||||||
const baseCharacter = SakanaWidget.getCharacter('chisato');
|
|
||||||
const myCharacter = {
|
|
||||||
image: customImageUrl,
|
|
||||||
initialState: baseCharacter.initialState,
|
|
||||||
};
|
|
||||||
|
|
||||||
SakanaWidget.registerCharacter('my_girl', myCharacter);
|
|
||||||
new SakanaWidget({
|
|
||||||
character: 'my_girl',
|
|
||||||
size: 200,
|
|
||||||
autoFit: true,
|
|
||||||
controls: true
|
|
||||||
})
|
|
||||||
.setState({ y: 0, t: 0, w: 0, r: 0 })
|
|
||||||
.mount('#my_girl');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script
|
|
||||||
async
|
|
||||||
onload="initSakanaWidget()"
|
|
||||||
src="https://cdn.jsdelivr.net/npm/sakana-widget@2.7.1/lib/sakana.min.js">
|
|
||||||
</script>
|
|
||||||
<!-- 私の娘 -->
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>{{ posts['title'] }}</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<a href="../">返回上级</a>
|
|
||||||
<br>
|
|
||||||
{{ posts['title'] }}
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
{{ posts['content'] | safe}}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<urlset xmlns="www.sitemaps.org">
|
|
||||||
<url>
|
|
||||||
<loc>{{ base_url }}</loc>
|
|
||||||
<lastmod>2025.12.22</lastmod>
|
|
||||||
<changefreq>daily</changefreq>
|
|
||||||
<priority>1.0</priority>
|
|
||||||
</url>
|
|
||||||
{% for posts in posts %}
|
|
||||||
<url>
|
|
||||||
<loc>{{ base_url }}posts/{{ posts['id'] }}/</loc>
|
|
||||||
<lastmod>{{ posts['date'] }}</lastmod>
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
<priority>0.8</priority>
|
|
||||||
</url>
|
|
||||||
{% endfor %}
|
|
||||||
</urlset>
|
|
||||||
Reference in New Issue
Block a user