mirror of
https://github.com/Kakune55/ComiPy.git
synced 2025-05-07 02:39:26 +08:00
commit
9553016af7
@ -46,12 +46,17 @@ def new(filename: str, pagenumber:int):
|
|||||||
|
|
||||||
|
|
||||||
# 获取文件元数据
|
# 获取文件元数据
|
||||||
def getMetadata(form: int, num: int):
|
def getMetadata(form: int, num: int, search:str = None):
|
||||||
conn = util.getConn()
|
conn = util.getConn()
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
if search is None:
|
||||||
cursor = c.execute(
|
cursor = c.execute(
|
||||||
"SELECT * FROM Metadata ORDER BY num desc LIMIT ?, ?", (form, num)
|
"SELECT * FROM Metadata ORDER BY num desc LIMIT ?, ?", (form, num)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
cursor = c.execute(
|
||||||
|
"SELECT * FROM Metadata WHERE filename LIKE ? ORDER BY num desc LIMIT ?, ?", (f"%{search}%", form, num)
|
||||||
|
)
|
||||||
out = []
|
out = []
|
||||||
for row in cursor:
|
for row in cursor:
|
||||||
out.append(list(row))
|
out.append(list(row))
|
||||||
|
@ -66,6 +66,11 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" class="form-control" id="search_text" placeholder="键入以搜索">
|
||||||
|
<button class="btn btn-secondary" type="button" onclick="window.location.href='/overview/1?search='+document.getElementById('search_text').value">Search</button>
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
<div id="gallery">
|
<div id="gallery">
|
||||||
{% for item in list %}
|
{% for item in list %}
|
||||||
<div class="image-container">
|
<div class="image-container">
|
||||||
|
14
web/page.py
14
web/page.py
@ -10,9 +10,9 @@ conf = app_conf.conf()
|
|||||||
@page_bp.route("/overview/<page>")
|
@page_bp.route("/overview/<page>")
|
||||||
def overview(page): # 概览
|
def overview(page): # 概览
|
||||||
page = int(page)
|
page = int(page)
|
||||||
if request.cookies.get("islogin") is None:
|
if request.cookies.get("islogin") is None: #验证登录状态
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
metaDataList = db.file.getMetadata((page - 1) * 20, page * 20)
|
metaDataList = db.file.getMetadata((page - 1) * 20, page * 20, request.args.get("search"))
|
||||||
for item in metaDataList:
|
for item in metaDataList:
|
||||||
item[2] = item[2][:-4] #去除文件扩展名
|
item[2] = item[2][:-4] #去除文件扩展名
|
||||||
if page <= 3:
|
if page <= 3:
|
||||||
@ -31,8 +31,8 @@ def overview(page): # 概览
|
|||||||
|
|
||||||
@page_bp.route("/book/<bookid>")
|
@page_bp.route("/book/<bookid>")
|
||||||
def book(bookid): # 接口
|
def book(bookid): # 接口
|
||||||
if request.cookies.get("islogin") is None:
|
if request.cookies.get("islogin") is None: #验证登录状态
|
||||||
return abort(403)
|
return redirect("/")
|
||||||
data = db.file.searchByid(bookid)
|
data = db.file.searchByid(bookid)
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
return abort(404)
|
return abort(404)
|
||||||
@ -50,8 +50,8 @@ def book(bookid): # 接口
|
|||||||
|
|
||||||
@page_bp.route("/view/<bookid>")
|
@page_bp.route("/view/<bookid>")
|
||||||
def view(bookid): # 接口
|
def view(bookid): # 接口
|
||||||
if request.cookies.get("islogin") is None:
|
if request.cookies.get("islogin") is None: #验证登录状态
|
||||||
return abort(403)
|
return redirect("/")
|
||||||
data = db.file.searchByid(bookid)
|
data = db.file.searchByid(bookid)
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
return abort(404)
|
return abort(404)
|
||||||
@ -60,6 +60,8 @@ def view(bookid): # 接口
|
|||||||
|
|
||||||
@page_bp.route("/upload", methods=["GET", "POST"]) # 文件上传
|
@page_bp.route("/upload", methods=["GET", "POST"]) # 文件上传
|
||||||
def upload_file():
|
def upload_file():
|
||||||
|
if request.cookies.get("islogin") is None: #验证登录状态
|
||||||
|
return redirect("/")
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
return render_template("upload.html")
|
return render_template("upload.html")
|
||||||
uploaded_file = request.files.getlist("files[]") # 获取上传的文件列表
|
uploaded_file = request.files.getlist("files[]") # 获取上传的文件列表
|
||||||
|
Loading…
x
Reference in New Issue
Block a user