def manageLittlePanda(): global lpfs_dll global adding_to_sys_status if request.method == 'GET': sqlM = sql.sqlDataManager() book_removed = book.bookInfo(sqlM) book_removed.getRemovedBooks() sqlM.sqldb.commit() sqlM.sqldb.close() return render_template("managePage.html", removed_books=book_removed.bookAllInfo, archpath=uploadedArchPath) if request.method == 'POST': jso = request.get_data() data = json.loads(jso) actionType = data.get('type') actionData = data.get('data') sqlManager2 = sql.sqlDataManager() archPath = actionData print("actionYpe: " + actionType) print("actionData: " + actionData) adding_to_sys_status = {} file.importArchFileFromTmp(sqlManager2, archPath, status=adding_to_sys_status, lpfs_dll=lpfs_dll) return actionType
def randomGallery(): sqlM = sql.sqlDataManager() if request.method == 'GET': bookInfo = book.bookInfo(sqlM) bookInfo.getRandom20Book() return render_template("searchpage.html", books=bookInfo.bookAllInfo, nowPage=1)
def search(): sqlM = sql.sqlDataManager() if request.method == 'POST': search_keyword = request.form['keyword'] # type: str search_keywords = search_keyword.split(" ") search_books = book.bookInfo(sqlM) search_books.SearchBooksInfoFromDatabaseOrderByCreateTime( search_keywords) sqlM.sqldb.close() return render_template("searchpage.html", books=search_books.bookAllInfo, nowPage=1) if request.method == 'GET': search_tag = request.args.get("tag") bookInfo = book.bookInfo(sqlM) bookInfo.SearchBooksInfoFromDatabaseOrderByCreateTimeWithTag( search_tag) sqlM.sqldb.close() return render_template("searchpage.html", books=bookInfo.bookAllInfo, nowPage=1)
def editGalery(): if request.method == 'GET': book_id = request.args.get("id") book_id = int(book_id) sqlM = sql.sqlDataManager() bookInfo = book.bookInfo(sqlM) bookInfo.getBookInfoFromDatabaseWithoutCover(book_id) sqlM.sqldb.commit() sqlM.sqldb.close() return render_template("editGallery.html", pages=bookInfo.bookAllInfo) elif request.method == 'POST': jso = request.get_data() new_book_order = json.loads(jso) sqlM = sql.sqlDataManager() bookInfo = book.bookInfo(sqlM) book_id = new_book_order['book_id'] new_book_order = new_book_order['pageOrder'] bookInfo.getBookInfoFromDatabaseWithoutCover(book_id) print(new_book_order) pageList = list(bookInfo.bookAllInfo) pageList = copy.deepcopy(pageList) print(pageList) for index in range(0, len(pageList), 2): page = int(pageList[index]['page']) newPage = new_book_order[page - 1] newPageIndex = (newPage - 1) * 2 pageList[index]['image_id'] = bookInfo.bookAllInfo[newPageIndex][ 'image_id'] pageList[index + 1]['image_id'] = bookInfo.bookAllInfo[newPageIndex + 1]['image_id'] sqlM.changeBookInfo(book_id, pageList) sqlM.sqldb.commit() return redirect("/gallery/" + str(book_id), code=280)
def download_gallery(gallery_id: str): if not gallery_id.isdigit(): return "gallery id error" gallery_id = int(gallery_id) tag_group = { "aritsi": ["jinjia", "nishi"], "para": [ "clannad", "is", "is", "is", "is", "is", "is", "is", "is", "is", "is", "is" ] } bookInfo = book.bookInfo(sqlManager) book_info_res = bookInfo.getBookInfoFromDatabase(gallery_id) if book_info_res == None: return "No this Gallery" book_contentImages = bookInfo.filteOutAllContentImage() zipClass.createZipArch(bookInfo.bookAllInfo[0]["title"], book_contentImages) return ""
def editGalleryCover(): if request.method == 'POST': jso = request.get_data() newCoverJson = json.loads(jso) book_id = newCoverJson['book_id'] cover_page_number = newCoverJson['page'] recX, recY, recW, recH = newCoverJson['rectInfo'] elif request.method == 'GET': book_id = request.args.get("book_id") page = request.args.get("page") sqlM = sql.sqlDataManager() bookInfo = book.bookInfo(sqlM) if (bookInfo.getPageWithBookId(book_id, page)) == None: return "No this Page In gallery" sqlM.sqldb.commit() sqlM.sqldb.close() return render_template("cropCover.html", pageInfo=bookInfo.bookAllInfo[0], book_id=book_id, page=page)
def homepage(): page = int(request.args.get("page", 1)) items = int(request.args.get("items", 20)) gid_mode = int(request.args.get("gid", 1)) mode = request.args.get("mode", "normal") if page < 1: page = 1 sqlM = sql.sqlDataManager() home_page_books = book.bookInfo(sqlM) if gid_mode == 1: items = 40 if mode == "findnoehpath": # I really crated this so long function name before one year?????????????? home_page_books.getBooksCoverThumbInfoNotHaveCatalogInfoFromDatabaseOrderByCreateTimeWithPage( page, items) return render_template("homepage_gid_findnoehpath.html", books=home_page_books.bookAllInfo, nowPage=page) else: if (home_page_books. getBooksCoverThumbInfoFromDatabaseOrderByCreateTimeWithPage( page, items)) == None: return "Gallery no book" return render_template("homepage_gid.html", books=home_page_books.bookAllInfo, nowPage=page) else: items = 40 if home_page_books.getBooksCoverThumbInfoFromDatabaseOrderByCreateTimeWithPage( page, items) == None: return "Gallery no book" return render_template("homepage_gid.html", books=home_page_books.bookAllInfo, nowPage=page)
def get_gallery(gallery_id: str): sqlM = sql.sqlDataManager() if not gallery_id.isdigit(): return "gallery id error" gallery_id = int(gallery_id) tag_group = { "aritsi": ["jinjia", "nishi"], "para": [ "clannad", "is", "is", "is", "is", "is", "is", "is", "is", "is", "is", "is" ] } bookInfo = book.bookInfo(sqlM) book_info_res = bookInfo.getBookInfoFromDatabaseWithoutCover(gallery_id) if book_info_res == None: return "No this Gallery" book_contentImages = bookInfo.filteOutAllContentImage() book_size = 0 for bk in book_contentImages: book_size += int(bk["size"]) book_size /= 1000000 tags_groups = sqlM.getTagsFromDatabase(gallery_id) if tags_groups == None: tags_groups = {} sqlM.sqldb.close() return render_template( "gallery.html", search_title=file.dealWithFileName(bookInfo.bookAllInfo[0]['title']), title=bookInfo.bookAllInfo[0]['title'], tagGroup=tags_groups, books=book_contentImages, book_size=book_size, content_images=json.dumps(bookInfo.getAllContentImageHash()), gallery_id=gallery_id)