mirror of
https://github.com/Kakune55/ComiPy.git
synced 2025-05-06 18:29:26 +08:00
commit
9553016af7
13
db/file.py
13
db/file.py
@ -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()
|
||||
c = conn.cursor()
|
||||
cursor = c.execute(
|
||||
"SELECT * FROM Metadata ORDER BY num desc LIMIT ?, ?", (form, num)
|
||||
)
|
||||
if search is None:
|
||||
cursor = c.execute(
|
||||
"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 = []
|
||||
for row in cursor:
|
||||
out.append(list(row))
|
||||
|
@ -66,6 +66,11 @@
|
||||
</head>
|
||||
|
||||
<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">
|
||||
{% for item in list %}
|
||||
<div class="image-container">
|
||||
|
16
web/page.py
16
web/page.py
@ -10,9 +10,9 @@ conf = app_conf.conf()
|
||||
@page_bp.route("/overview/<page>")
|
||||
def overview(page): # 概览
|
||||
page = int(page)
|
||||
if request.cookies.get("islogin") is None:
|
||||
return redirect("/")
|
||||
metaDataList = db.file.getMetadata((page - 1) * 20, page * 20)
|
||||
if request.cookies.get("islogin") is None: #验证登录状态
|
||||
return redirect("/")
|
||||
metaDataList = db.file.getMetadata((page - 1) * 20, page * 20, request.args.get("search"))
|
||||
for item in metaDataList:
|
||||
item[2] = item[2][:-4] #去除文件扩展名
|
||||
if page <= 3:
|
||||
@ -31,8 +31,8 @@ def overview(page): # 概览
|
||||
|
||||
@page_bp.route("/book/<bookid>")
|
||||
def book(bookid): # 接口
|
||||
if request.cookies.get("islogin") is None:
|
||||
return abort(403)
|
||||
if request.cookies.get("islogin") is None: #验证登录状态
|
||||
return redirect("/")
|
||||
data = db.file.searchByid(bookid)
|
||||
if len(data) == 0:
|
||||
return abort(404)
|
||||
@ -50,8 +50,8 @@ def book(bookid): # 接口
|
||||
|
||||
@page_bp.route("/view/<bookid>")
|
||||
def view(bookid): # 接口
|
||||
if request.cookies.get("islogin") is None:
|
||||
return abort(403)
|
||||
if request.cookies.get("islogin") is None: #验证登录状态
|
||||
return redirect("/")
|
||||
data = db.file.searchByid(bookid)
|
||||
if len(data) == 0:
|
||||
return abort(404)
|
||||
@ -60,6 +60,8 @@ def view(bookid): # 接口
|
||||
|
||||
@page_bp.route("/upload", methods=["GET", "POST"]) # 文件上传
|
||||
def upload_file():
|
||||
if request.cookies.get("islogin") is None: #验证登录状态
|
||||
return redirect("/")
|
||||
if request.method == "GET":
|
||||
return render_template("upload.html")
|
||||
uploaded_file = request.files.getlist("files[]") # 获取上传的文件列表
|
||||
|
Loading…
x
Reference in New Issue
Block a user