From 67e37215305e5546441c99b2f582b5cf5d1af030 Mon Sep 17 00:00:00 2001 From: xlivevil Date: Wed, 1 Dec 2021 11:28:03 +0800 Subject: [PATCH 01/40] fix(tinymce Simplified Chinese locale):rename zh_CN to zh_Hans_CN --- cps/static/js/libs/tinymce/langs/zh_Hans_CN.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/static/js/libs/tinymce/langs/zh_Hans_CN.js b/cps/static/js/libs/tinymce/langs/zh_Hans_CN.js index 2a784f57..981c9090 100644 --- a/cps/static/js/libs/tinymce/langs/zh_Hans_CN.js +++ b/cps/static/js/libs/tinymce/langs/zh_Hans_CN.js @@ -1,4 +1,4 @@ -tinymce.addI18n('zh_CN',{ +tinymce.addI18n('zh_Hans_CN',{ "Redo": "\u91cd\u505a", "Undo": "\u64a4\u9500", "Cut": "\u526a\u5207", From 8438b2a07b309ab0d2ce22ea2a8cbe1ad0336a1b Mon Sep 17 00:00:00 2001 From: xlivevil Date: Wed, 1 Dec 2021 12:14:57 +0800 Subject: [PATCH 02/40] Update Simplified Chinese translation --- .../zh_Hans_CN/LC_MESSAGES/messages.po | 197 ++++++++------- messages.pot | 232 ++++++++++-------- 2 files changed, 233 insertions(+), 196 deletions(-) diff --git a/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po b/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po index da32d2cb..6625279e 100644 --- a/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po +++ b/cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Calibre-Web\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-11-23 19:29+0100\n" +"POT-Creation-Date: 2021-12-01 11:37+0800\n" "PO-Revision-Date: 2020-09-27 22:18+0800\n" "Last-Translator: xlivevil \n" "Language: zh_CN\n" @@ -16,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.9.0\n" +"Generated-By: Babel 2.9.1\n" #: cps/about.py:34 cps/about.py:49 cps/about.py:65 cps/converter.py:31 msgid "not installed" @@ -46,9 +46,9 @@ msgstr "重新连接成功" msgid "Unknown command" msgstr "未知命令" -#: cps/admin.py:167 cps/editbooks.py:704 cps/editbooks.py:718 -#: cps/editbooks.py:859 cps/editbooks.py:861 cps/editbooks.py:888 -#: cps/editbooks.py:904 cps/updater.py:584 cps/uploader.py:93 +#: cps/admin.py:167 cps/editbooks.py:703 cps/editbooks.py:717 +#: cps/editbooks.py:862 cps/editbooks.py:864 cps/editbooks.py:891 +#: cps/editbooks.py:907 cps/updater.py:584 cps/uploader.py:93 #: cps/uploader.py:103 msgid "Unknown" msgstr "未知" @@ -290,7 +290,6 @@ msgid "Certfile Location is not Valid, Please Enter Correct Path" msgstr "证书文件路径无效,请输入正确的路径" #: cps/admin.py:1316 -#, fuzzy msgid "Database Settings updated" msgstr "邮件服务器设置已更新" @@ -435,13 +434,12 @@ msgid "General error" msgstr "一般错误" #: cps/admin.py:1701 -#, fuzzy msgid "Update file could not be saved in temp dir" msgstr "更新文件无法保存在临时目录中" #: cps/admin.py:1702 msgid "Files could not be replaced during update" -msgstr "" +msgstr "更新期间无法替换文件" #: cps/admin.py:1726 msgid "Failed to extract at least One LDAP User" @@ -481,103 +479,103 @@ msgstr "缺少执行权限" msgid "Custom Column No.%(column)d is not existing in calibre database" msgstr "自定义列号:%(column)d在Calibre数据库中不存在" -#: cps/editbooks.py:306 cps/editbooks.py:308 +#: cps/editbooks.py:305 cps/editbooks.py:307 msgid "Book Format Successfully Deleted" msgstr "书籍格式已成功删除" -#: cps/editbooks.py:315 cps/editbooks.py:317 +#: cps/editbooks.py:314 cps/editbooks.py:316 msgid "Book Successfully Deleted" msgstr "书籍已成功删除" -#: cps/editbooks.py:373 cps/editbooks.py:760 cps/web.py:528 cps/web.py:1719 +#: cps/editbooks.py:372 cps/editbooks.py:759 cps/web.py:528 cps/web.py:1719 #: cps/web.py:1760 cps/web.py:1827 msgid "Oops! Selected book title is unavailable. File does not exist or is not accessible" msgstr "糟糕!选择书名无法打开。文件不存在或者文件不可访问" -#: cps/editbooks.py:407 +#: cps/editbooks.py:406 msgid "edit metadata" msgstr "编辑元数据" -#: cps/editbooks.py:455 +#: cps/editbooks.py:454 #, python-format msgid "%(seriesindex)s is not a valid number, skipping" msgstr "%(seriesindex)s 不是一个有效的数值,忽略" -#: cps/editbooks.py:491 +#: cps/editbooks.py:490 cps/editbooks.py:954 #, python-format -msgid "%(langname)s is not a valid language" -msgstr "%(langname)s 不是一种有效语言" +msgid "'%(langname)s' is not a valid language" +msgstr "'%(langname)s' 不是一种有效语言" -#: cps/editbooks.py:631 cps/editbooks.py:974 +#: cps/editbooks.py:630 cps/editbooks.py:981 #, python-format msgid "File extension '%(ext)s' is not allowed to be uploaded to this server" msgstr "不能上传文件扩展名为“%(ext)s”的文件到此服务器" -#: cps/editbooks.py:635 cps/editbooks.py:978 +#: cps/editbooks.py:634 cps/editbooks.py:985 msgid "File to be uploaded must have an extension" msgstr "要上传的文件必须具有扩展名" -#: cps/editbooks.py:647 +#: cps/editbooks.py:646 #, python-format msgid "Failed to create path %(path)s (Permission denied)." msgstr "创建路径 %(path)s 失败(权限拒绝)。" -#: cps/editbooks.py:652 +#: cps/editbooks.py:651 #, python-format msgid "Failed to store file %(file)s." msgstr "保存文件 %(file)s 失败。" -#: cps/editbooks.py:670 cps/editbooks.py:1065 cps/web.py:1680 +#: cps/editbooks.py:669 cps/editbooks.py:1072 cps/web.py:1680 #, python-format msgid "Database error: %(error)s." msgstr "数据库错误:%(error)s。" -#: cps/editbooks.py:675 +#: cps/editbooks.py:674 #, python-format msgid "File format %(ext)s added to %(book)s" msgstr "已添加 %(ext)s 格式到 %(book)s" -#: cps/editbooks.py:811 +#: cps/editbooks.py:810 msgid "Identifiers are not Case Sensitive, Overwriting Old Identifier" msgstr "标识符不区分大小写,覆盖旧标识符" -#: cps/editbooks.py:845 +#: cps/editbooks.py:844 msgid "Metadata successfully updated" msgstr "已成功更新元数据" -#: cps/editbooks.py:854 +#: cps/editbooks.py:857 msgid "Error editing book, please check logfile for details" msgstr "编辑书籍出错,请检查日志文件以获取详细信息" -#: cps/editbooks.py:892 +#: cps/editbooks.py:895 msgid "Uploaded book probably exists in the library, consider to change before upload new: " msgstr "上传的书籍可能已经存在,建议修改后重新上传: " -#: cps/editbooks.py:986 +#: cps/editbooks.py:993 #, python-format msgid "File %(filename)s could not saved to temp dir" msgstr "文件 %(filename)s 无法保存到临时目录" -#: cps/editbooks.py:1005 +#: cps/editbooks.py:1012 #, python-format msgid "Failed to Move Cover File %(file)s: %(error)s" msgstr "移动封面文件失败 %(file)s:%(error)s" -#: cps/editbooks.py:1052 +#: cps/editbooks.py:1059 #, python-format msgid "File %(file)s uploaded" msgstr "文件 %(file)s 已上传" -#: cps/editbooks.py:1077 +#: cps/editbooks.py:1084 msgid "Source or destination format for conversion missing" msgstr "转换的源或目的格式缺失" -#: cps/editbooks.py:1085 +#: cps/editbooks.py:1092 #, python-format msgid "Book successfully queued for converting to %(book_format)s" msgstr "书籍已经被成功加入到 %(book_format)s 格式转换队列" -#: cps/editbooks.py:1089 +#: cps/editbooks.py:1096 #, python-format msgid "There was an error converting this book: %(res)s" msgstr "转换此书籍时出现错误: %(res)s" @@ -719,7 +717,7 @@ msgstr "封面文件只支持jpg/jpeg/png/webp/bmp文件" #: cps/helper.py:651 msgid "Invalid cover file content" -msgstr "" +msgstr "封面文件内容无效" #: cps/helper.py:655 msgid "Only jpg/jpeg files are supported as coverfile" @@ -831,7 +829,7 @@ msgstr "Google Oauth 错误: {}" msgid "{} Stars" msgstr "{} 星" -#: cps/remotelogin.py:65 cps/templates/layout.html:86 +#: cps/remotelogin.py:65 cps/templates/layout.html:84 #: cps/templates/login.html:4 cps/templates/login.html:21 cps/web.py:1600 msgid "Login" msgstr "登录" @@ -1007,7 +1005,7 @@ msgstr "此书籍已被添加到书架:%(sname)s" #: cps/shelf.py:126 msgid "You are not allowed to add a book to the shelf" -msgstr "" +msgstr "你没有向书架添加书籍的权限" #: cps/shelf.py:144 #, python-format @@ -1031,9 +1029,9 @@ msgstr "此书已从书架 %(sname)s 中删除" #: cps/shelf.py:218 msgid "Sorry you are not allowed to remove a book from this shelf" -msgstr "" +msgstr "抱歉,你没有从这个书架删除书籍的权限" -#: cps/shelf.py:228 cps/templates/layout.html:142 +#: cps/shelf.py:228 cps/templates/layout.html:140 msgid "Create a Shelf" msgstr "创建书架" @@ -1047,7 +1045,7 @@ msgstr "编辑书架" #: cps/shelf.py:249 msgid "Sorry you are not allowed to create a public shelf" -msgstr "" +msgstr "抱歉,你没有创建公开书架的权限" #: cps/shelf.py:261 #, python-format @@ -1168,7 +1166,7 @@ msgstr "语言:%(name)s" msgid "Advanced Search" msgstr "高级搜索" -#: cps/templates/book_edit.html:239 cps/templates/feed.xml:33 +#: cps/templates/book_edit.html:235 cps/templates/feed.xml:33 #: cps/templates/index.xml:11 cps/templates/layout.html:45 #: cps/templates/layout.html:48 cps/templates/search_form.html:226 #: cps/web.py:755 cps/web.py:1090 @@ -1187,7 +1185,7 @@ msgstr "评分列表" msgid "File formats list" msgstr "文件格式列表" -#: cps/templates/layout.html:75 cps/templates/tasks.html:7 cps/web.py:1069 +#: cps/templates/layout.html:73 cps/templates/tasks.html:7 cps/web.py:1069 msgid "Tasks" msgstr "任务列表" @@ -1236,7 +1234,7 @@ msgstr "请先配置您的kindle邮箱。" msgid "E-Mail server is not configured, please contact your administrator!" msgstr "邮件服务未配置,请联系网站管理员!" -#: cps/templates/layout.html:87 cps/templates/register.html:17 cps/web.py:1486 +#: cps/templates/layout.html:85 cps/templates/register.html:17 cps/web.py:1486 #: cps/web.py:1493 cps/web.py:1499 cps/web.py:1518 cps/web.py:1522 #: cps/web.py:1528 msgid "Register" @@ -1347,7 +1345,7 @@ msgstr "邮箱地址" msgid "Send to Kindle E-mail Address" msgstr "接收书籍的Kindle邮箱地址" -#: cps/templates/admin.html:17 cps/templates/layout.html:78 +#: cps/templates/admin.html:17 cps/templates/layout.html:76 #: cps/templates/user_table.html:143 msgid "Admin" msgstr "管理权限" @@ -1357,7 +1355,7 @@ msgstr "管理权限" msgid "Password" msgstr "密码" -#: cps/templates/admin.html:20 cps/templates/layout.html:67 +#: cps/templates/admin.html:20 cps/templates/layout.html:66 #: cps/templates/user_table.html:145 msgid "Upload" msgstr "上传书籍" @@ -1548,7 +1546,7 @@ msgid "OK" msgstr "确定" #: cps/templates/admin.html:215 cps/templates/admin.html:229 -#: cps/templates/book_edit.html:217 cps/templates/book_table.html:124 +#: cps/templates/book_edit.html:213 cps/templates/book_table.html:124 #: cps/templates/config_db.html:54 cps/templates/config_edit.html:359 #: cps/templates/config_view_edit.html:173 cps/templates/modal_dialogs.html:64 #: cps/templates/modal_dialogs.html:99 cps/templates/modal_dialogs.html:117 @@ -1646,13 +1644,13 @@ msgstr "转换书籍" msgid "Book Title" msgstr "书名" -#: cps/templates/book_edit.html:62 cps/templates/book_edit.html:274 -#: cps/templates/book_edit.html:292 cps/templates/search_form.html:12 +#: cps/templates/book_edit.html:62 cps/templates/book_edit.html:270 +#: cps/templates/book_edit.html:288 cps/templates/search_form.html:12 msgid "Author" msgstr "作者" -#: cps/templates/book_edit.html:67 cps/templates/book_edit.html:279 -#: cps/templates/book_edit.html:294 cps/templates/search_form.html:153 +#: cps/templates/book_edit.html:67 cps/templates/book_edit.html:275 +#: cps/templates/book_edit.html:290 cps/templates/search_form.html:153 msgid "Description" msgstr "简介" @@ -1660,15 +1658,15 @@ msgstr "简介" msgid "Identifiers" msgstr "书号" -#: cps/templates/book_edit.html:76 cps/templates/book_edit.html:303 +#: cps/templates/book_edit.html:76 cps/templates/book_edit.html:299 msgid "Identifier Type" msgstr "书号类型" -#: cps/templates/book_edit.html:77 cps/templates/book_edit.html:304 +#: cps/templates/book_edit.html:77 cps/templates/book_edit.html:300 msgid "Identifier Value" msgstr "书号编号" -#: cps/templates/book_edit.html:78 cps/templates/book_edit.html:305 +#: cps/templates/book_edit.html:78 cps/templates/book_edit.html:301 #: cps/templates/user_table.html:24 msgid "Remove" msgstr "移除" @@ -1689,90 +1687,89 @@ msgstr "丛书编号" msgid "Rating" msgstr "评分" -#: cps/templates/book_edit.html:104 +#: cps/templates/book_edit.html:103 msgid "Fetch Cover from URL (JPEG - Image will be downloaded and stored in database)" msgstr "从URL获取封面(JPEG - 图片将下载并存储在数据库中)" -#: cps/templates/book_edit.html:108 +#: cps/templates/book_edit.html:107 msgid "Upload Cover from Local Disk" msgstr "从本地磁盘上传封面" -#: cps/templates/book_edit.html:114 +#: cps/templates/book_edit.html:112 msgid "Published Date" msgstr "出版日期" -#: cps/templates/book_edit.html:123 cps/templates/book_edit.html:276 -#: cps/templates/book_edit.html:293 cps/templates/detail.html:164 +#: cps/templates/book_edit.html:121 cps/templates/book_edit.html:272 +#: cps/templates/book_edit.html:289 cps/templates/detail.html:164 #: cps/templates/search_form.html:16 msgid "Publisher" msgstr "出版社" -#: cps/templates/book_edit.html:127 cps/templates/detail.html:131 +#: cps/templates/book_edit.html:125 cps/templates/detail.html:131 #: cps/templates/user_edit.html:33 msgid "Language" msgstr "语言" -#: cps/templates/book_edit.html:137 cps/templates/search_form.html:45 +#: cps/templates/book_edit.html:135 cps/templates/search_form.html:45 #: cps/templates/search_form.html:164 msgid "Yes" msgstr "确认" -#: cps/templates/book_edit.html:138 cps/templates/search_form.html:46 +#: cps/templates/book_edit.html:136 cps/templates/search_form.html:46 #: cps/templates/search_form.html:165 msgid "No" msgstr "没有" -#: cps/templates/book_edit.html:203 +#: cps/templates/book_edit.html:200 msgid "Upload Format" msgstr "上传格式" -#: cps/templates/book_edit.html:212 +#: cps/templates/book_edit.html:208 msgid "View Book on Save" msgstr "查看保存书籍" -#: cps/templates/book_edit.html:215 cps/templates/book_edit.html:233 +#: cps/templates/book_edit.html:211 cps/templates/book_edit.html:229 msgid "Fetch Metadata" msgstr "获取元数据" -#: cps/templates/book_edit.html:216 cps/templates/config_db.html:53 +#: cps/templates/book_edit.html:212 cps/templates/config_db.html:53 #: cps/templates/config_edit.html:358 cps/templates/config_view_edit.html:172 #: cps/templates/email_edit.html:65 cps/templates/shelf_edit.html:25 #: cps/templates/shelf_order.html:41 cps/templates/user_edit.html:139 msgid "Save" msgstr "保存" -#: cps/templates/book_edit.html:236 +#: cps/templates/book_edit.html:232 msgid "Keyword" msgstr "关键字" -#: cps/templates/book_edit.html:237 -#, fuzzy +#: cps/templates/book_edit.html:233 msgid "Search keyword" msgstr " 搜索关键字 " -#: cps/templates/book_edit.html:243 +#: cps/templates/book_edit.html:239 msgid "Click the cover to load metadata to the form" msgstr "单击封面将元数据加载到表单" -#: cps/templates/book_edit.html:250 cps/templates/book_edit.html:289 +#: cps/templates/book_edit.html:246 cps/templates/book_edit.html:285 msgid "Loading..." msgstr "加载中..." -#: cps/templates/book_edit.html:254 cps/templates/layout.html:64 -#: cps/templates/layout.html:188 cps/templates/modal_dialogs.html:34 +#: cps/templates/book_edit.html:250 cps/templates/layout.html:63 +#: cps/templates/layout.html:186 cps/templates/modal_dialogs.html:34 #: cps/templates/user_edit.html:160 msgid "Close" msgstr "关闭" -#: cps/templates/book_edit.html:281 cps/templates/book_edit.html:295 +#: cps/templates/book_edit.html:277 cps/templates/book_edit.html:291 msgid "Source" msgstr "源" -#: cps/templates/book_edit.html:290 +#: cps/templates/book_edit.html:286 msgid "Search error!" msgstr "搜索错误!" -#: cps/templates/book_edit.html:291 +#: cps/templates/book_edit.html:287 msgid "No Result(s) found! Please try another keyword." msgstr "无搜索结果!请尝试另一个关键字。" @@ -1856,21 +1853,19 @@ msgid "Enter Publishers" msgstr "输入出版社" #: cps/templates/book_table.html:73 -#, fuzzy msgid "Enter comments" -msgstr "输入域名" +msgstr "输入简介" #: cps/templates/book_table.html:73 msgid "Comments" -msgstr "" +msgstr "简介" #: cps/templates/book_table.html:77 cps/templates/book_table.html:79 #: cps/templates/book_table.html:81 cps/templates/book_table.html:83 #: cps/templates/book_table.html:87 cps/templates/book_table.html:89 #: cps/templates/book_table.html:91 cps/templates/book_table.html:93 -#, fuzzy msgid "Enter " -msgstr "书号" +msgstr "输入" #: cps/templates/book_table.html:110 cps/templates/modal_dialogs.html:46 msgid "Are you really sure?" @@ -1946,7 +1941,7 @@ msgstr "夜间版" #: cps/templates/config_edit.html:50 msgid "Trusted Hosts (Comma Separated)" -msgstr "" +msgstr "可信主机(用逗号分隔)" #: cps/templates/config_edit.html:61 msgid "Logfile Configuration" @@ -1970,12 +1965,16 @@ msgstr "功能配置" #: cps/templates/config_edit.html:104 msgid "Convert non-English characters in title and author while saving to disk" -msgstr "" +msgstr "保存到磁盘事转换标题和作者中的非英文字符" #: cps/templates/config_edit.html:108 msgid "Enable Uploads" msgstr "启用上传" +#: cps/templates/config_edit.html:108 +msgid "(Please ensure users having also upload rights)" +msgstr "(请确保用户也有上传权限)" + #: cps/templates/config_edit.html:112 msgid "Allowed Upload Fileformats" msgstr "允许上传的文件格式" @@ -2261,14 +2260,12 @@ msgid "Allow Editing Public Shelves" msgstr "允许编辑公共书架" #: cps/templates/config_view_edit.html:123 -#, fuzzy msgid "Default Language" -msgstr "排除语言" +msgstr "默认语言" #: cps/templates/config_view_edit.html:131 -#, fuzzy msgid "Default Visible Language of Books" -msgstr "按语言显示书籍" +msgstr "默认显示书籍语言" #: cps/templates/config_view_edit.html:147 msgid "Default Visibilities for New Users" @@ -2337,7 +2334,7 @@ msgid "Add to shelf" msgstr "添加到书架" #: cps/templates/detail.html:267 cps/templates/detail.html:284 -#: cps/templates/feed.xml:79 cps/templates/layout.html:139 +#: cps/templates/feed.xml:79 cps/templates/layout.html:137 #: cps/templates/search.html:20 msgid "(Public)" msgstr "(公共)" @@ -2412,7 +2409,7 @@ msgstr "输入域名" msgid "Denied Domains (Blacklist)" msgstr "禁止注册的域名(黑名单)" -#: cps/templates/feed.xml:21 cps/templates/layout.html:172 +#: cps/templates/feed.xml:21 cps/templates/layout.html:170 msgid "Next" msgstr "下一个" @@ -2438,11 +2435,11 @@ msgstr "登出账号" #: cps/templates/index.html:69 msgid "Sort ascending according to download count" -msgstr "" +msgstr "按下载数排序" #: cps/templates/index.html:70 msgid "Sort descending according to download count" -msgstr "" +msgstr "按下载数逆序排序" #: cps/templates/index.html:76 cps/templates/search.html:33 #: cps/templates/shelf.html:21 @@ -2522,7 +2519,7 @@ msgstr "书籍按评分排序" msgid "Books ordered by file formats" msgstr "书籍按文件格式排序" -#: cps/templates/index.xml:119 cps/templates/layout.html:137 +#: cps/templates/index.xml:119 cps/templates/layout.html:135 #: cps/templates/search_form.html:87 msgid "Shelves" msgstr "书架列表" @@ -2543,48 +2540,48 @@ msgstr "切换导航" msgid "Search Library" msgstr "搜索书库" -#: cps/templates/layout.html:64 cps/templates/layout.html:119 +#: cps/templates/layout.html:63 cps/templates/layout.html:117 msgid "Uploading..." msgstr "正在上传..." -#: cps/templates/layout.html:64 +#: cps/templates/layout.html:63 msgid "Error" msgstr "错误" -#: cps/templates/layout.html:64 +#: cps/templates/layout.html:63 msgid "Upload done, processing, please wait..." msgstr "上传完成,正在处理,请稍候..." -#: cps/templates/layout.html:78 cps/templates/read.html:71 +#: cps/templates/layout.html:76 cps/templates/read.html:71 #: cps/templates/readcbr.html:84 cps/templates/readcbr.html:108 msgid "Settings" msgstr "设置" -#: cps/templates/layout.html:80 +#: cps/templates/layout.html:78 msgid "Account" msgstr "账号" -#: cps/templates/layout.html:82 +#: cps/templates/layout.html:80 msgid "Logout" msgstr "注销" -#: cps/templates/layout.html:120 +#: cps/templates/layout.html:118 msgid "Please do not refresh the page" msgstr "请不要刷新页面" -#: cps/templates/layout.html:130 +#: cps/templates/layout.html:128 msgid "Browse" msgstr "按条件浏览" -#: cps/templates/layout.html:143 cps/templates/stats.html:3 +#: cps/templates/layout.html:141 cps/templates/stats.html:3 msgid "About" msgstr "关于" -#: cps/templates/layout.html:157 +#: cps/templates/layout.html:155 msgid "Previous" msgstr "上一个" -#: cps/templates/layout.html:184 +#: cps/templates/layout.html:182 msgid "Book Details" msgstr "书籍详情" diff --git a/messages.pot b/messages.pot index 48925886..a6267b2c 100644 --- a/messages.pot +++ b/messages.pot @@ -8,14 +8,14 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-11-23 19:29+0100\n" +"POT-Creation-Date: 2021-12-01 11:37+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.9.0\n" +"Generated-By: Babel 2.9.1\n" #: cps/about.py:34 cps/about.py:49 cps/about.py:65 cps/converter.py:31 msgid "not installed" @@ -45,9 +45,9 @@ msgstr "" msgid "Unknown command" msgstr "" -#: cps/admin.py:167 cps/editbooks.py:704 cps/editbooks.py:718 -#: cps/editbooks.py:859 cps/editbooks.py:861 cps/editbooks.py:888 -#: cps/editbooks.py:904 cps/updater.py:584 cps/uploader.py:93 +#: cps/admin.py:167 cps/editbooks.py:703 cps/editbooks.py:717 +#: cps/editbooks.py:862 cps/editbooks.py:864 cps/editbooks.py:891 +#: cps/editbooks.py:907 cps/updater.py:584 cps/uploader.py:93 #: cps/uploader.py:103 msgid "Unknown" msgstr "" @@ -168,23 +168,33 @@ msgid "Are you sure you want to change locales of selected user(s)?" msgstr "" #: cps/admin.py:582 -msgid "Are you sure you want to change visible book languages for selected user(s)?" +msgid "" +"Are you sure you want to change visible book languages for selected " +"user(s)?" msgstr "" #: cps/admin.py:584 -msgid "Are you sure you want to change the selected role for the selected user(s)?" +msgid "" +"Are you sure you want to change the selected role for the selected " +"user(s)?" msgstr "" #: cps/admin.py:586 -msgid "Are you sure you want to change the selected restrictions for the selected user(s)?" +msgid "" +"Are you sure you want to change the selected restrictions for the " +"selected user(s)?" msgstr "" #: cps/admin.py:588 -msgid "Are you sure you want to change the selected visibility restrictions for the selected user(s)?" +msgid "" +"Are you sure you want to change the selected visibility restrictions for " +"the selected user(s)?" msgstr "" #: cps/admin.py:590 -msgid "Are you sure you want to change shelf sync behavior for the selected user(s)?" +msgid "" +"Are you sure you want to change shelf sync behavior for the selected " +"user(s)?" msgstr "" #: cps/admin.py:592 @@ -263,7 +273,9 @@ msgid "LDAP Member User Filter Has Unmatched Parenthesis" msgstr "" #: cps/admin.py:1134 -msgid "LDAP CACertificate, Certificate or Key Location is not Valid, Please Enter Correct Path" +msgid "" +"LDAP CACertificate, Certificate or Key Location is not Valid, Please " +"Enter Correct Path" msgstr "" #: cps/admin.py:1176 cps/admin.py:1278 cps/admin.py:1375 cps/admin.py:1482 @@ -478,113 +490,121 @@ msgstr "" msgid "Custom Column No.%(column)d is not existing in calibre database" msgstr "" -#: cps/editbooks.py:306 cps/editbooks.py:308 +#: cps/editbooks.py:305 cps/editbooks.py:307 msgid "Book Format Successfully Deleted" msgstr "" -#: cps/editbooks.py:315 cps/editbooks.py:317 +#: cps/editbooks.py:314 cps/editbooks.py:316 msgid "Book Successfully Deleted" msgstr "" -#: cps/editbooks.py:373 cps/editbooks.py:760 cps/web.py:528 cps/web.py:1719 +#: cps/editbooks.py:372 cps/editbooks.py:759 cps/web.py:528 cps/web.py:1719 #: cps/web.py:1760 cps/web.py:1827 -msgid "Oops! Selected book title is unavailable. File does not exist or is not accessible" +msgid "" +"Oops! Selected book title is unavailable. File does not exist or is not " +"accessible" msgstr "" -#: cps/editbooks.py:407 +#: cps/editbooks.py:406 msgid "edit metadata" msgstr "" -#: cps/editbooks.py:455 +#: cps/editbooks.py:454 #, python-format msgid "%(seriesindex)s is not a valid number, skipping" msgstr "" -#: cps/editbooks.py:491 +#: cps/editbooks.py:490 cps/editbooks.py:954 #, python-format -msgid "%(langname)s is not a valid language" +msgid "'%(langname)s' is not a valid language" msgstr "" -#: cps/editbooks.py:631 cps/editbooks.py:974 +#: cps/editbooks.py:630 cps/editbooks.py:981 #, python-format msgid "File extension '%(ext)s' is not allowed to be uploaded to this server" msgstr "" -#: cps/editbooks.py:635 cps/editbooks.py:978 +#: cps/editbooks.py:634 cps/editbooks.py:985 msgid "File to be uploaded must have an extension" msgstr "" -#: cps/editbooks.py:647 +#: cps/editbooks.py:646 #, python-format msgid "Failed to create path %(path)s (Permission denied)." msgstr "" -#: cps/editbooks.py:652 +#: cps/editbooks.py:651 #, python-format msgid "Failed to store file %(file)s." msgstr "" -#: cps/editbooks.py:670 cps/editbooks.py:1065 cps/web.py:1680 +#: cps/editbooks.py:669 cps/editbooks.py:1072 cps/web.py:1680 #, python-format msgid "Database error: %(error)s." msgstr "" -#: cps/editbooks.py:675 +#: cps/editbooks.py:674 #, python-format msgid "File format %(ext)s added to %(book)s" msgstr "" -#: cps/editbooks.py:811 +#: cps/editbooks.py:810 msgid "Identifiers are not Case Sensitive, Overwriting Old Identifier" msgstr "" -#: cps/editbooks.py:845 +#: cps/editbooks.py:844 msgid "Metadata successfully updated" msgstr "" -#: cps/editbooks.py:854 +#: cps/editbooks.py:857 msgid "Error editing book, please check logfile for details" msgstr "" -#: cps/editbooks.py:892 -msgid "Uploaded book probably exists in the library, consider to change before upload new: " +#: cps/editbooks.py:895 +msgid "" +"Uploaded book probably exists in the library, consider to change before " +"upload new: " msgstr "" -#: cps/editbooks.py:986 +#: cps/editbooks.py:993 #, python-format msgid "File %(filename)s could not saved to temp dir" msgstr "" -#: cps/editbooks.py:1005 +#: cps/editbooks.py:1012 #, python-format msgid "Failed to Move Cover File %(file)s: %(error)s" msgstr "" -#: cps/editbooks.py:1052 +#: cps/editbooks.py:1059 #, python-format msgid "File %(file)s uploaded" msgstr "" -#: cps/editbooks.py:1077 +#: cps/editbooks.py:1084 msgid "Source or destination format for conversion missing" msgstr "" -#: cps/editbooks.py:1085 +#: cps/editbooks.py:1092 #, python-format msgid "Book successfully queued for converting to %(book_format)s" msgstr "" -#: cps/editbooks.py:1089 +#: cps/editbooks.py:1096 #, python-format msgid "There was an error converting this book: %(res)s" msgstr "" #: cps/gdrive.py:58 -msgid "Google Drive setup not completed, try to deactivate and activate Google Drive again" +msgid "" +"Google Drive setup not completed, try to deactivate and activate Google " +"Drive again" msgstr "" #: cps/gdrive.py:95 -msgid "Callback domain is not verified, please follow steps to verify domain in google developer console" +msgid "" +"Callback domain is not verified, please follow steps to verify domain in " +"google developer console" msgstr "" #: cps/helper.py:80 @@ -659,7 +679,9 @@ msgstr "" #: cps/helper.py:333 #, python-format -msgid "Deleting book %(id)s from database only, book path in database not valid: %(path)s" +msgid "" +"Deleting book %(id)s from database only, book path in database not valid:" +" %(path)s" msgstr "" #: cps/helper.py:388 @@ -751,7 +773,9 @@ msgid "Unknown Status" msgstr "" #: cps/kobo_auth.py:131 -msgid "PLease access calibre-web from non localhost to get valid api_endpoint for kobo device" +msgid "" +"PLease access calibre-web from non localhost to get valid api_endpoint " +"for kobo device" msgstr "" #: cps/kobo_auth.py:134 cps/kobo_auth.py:162 @@ -828,7 +852,7 @@ msgstr "" msgid "{} Stars" msgstr "" -#: cps/remotelogin.py:65 cps/templates/layout.html:86 +#: cps/remotelogin.py:65 cps/templates/layout.html:84 #: cps/templates/login.html:4 cps/templates/login.html:21 cps/web.py:1600 msgid "Login" msgstr "" @@ -1030,7 +1054,7 @@ msgstr "" msgid "Sorry you are not allowed to remove a book from this shelf" msgstr "" -#: cps/shelf.py:228 cps/templates/layout.html:142 +#: cps/shelf.py:228 cps/templates/layout.html:140 msgid "Create a Shelf" msgstr "" @@ -1093,7 +1117,9 @@ msgid "No update available. You already have the latest version installed" msgstr "" #: cps/updater.py:428 -msgid "A new update is available. Click on the button below to update to the latest version." +msgid "" +"A new update is available. Click on the button below to update to the " +"latest version." msgstr "" #: cps/updater.py:446 @@ -1106,7 +1132,9 @@ msgstr "" #: cps/updater.py:465 cps/updater.py:479 cps/updater.py:490 #, python-format -msgid "A new update is available. Click on the button below to update to version: %(version)s" +msgid "" +"A new update is available. Click on the button below to update to " +"version: %(version)s" msgstr "" #: cps/updater.py:507 @@ -1165,7 +1193,7 @@ msgstr "" msgid "Advanced Search" msgstr "" -#: cps/templates/book_edit.html:239 cps/templates/feed.xml:33 +#: cps/templates/book_edit.html:235 cps/templates/feed.xml:33 #: cps/templates/index.xml:11 cps/templates/layout.html:45 #: cps/templates/layout.html:48 cps/templates/search_form.html:226 #: cps/web.py:755 cps/web.py:1090 @@ -1184,7 +1212,7 @@ msgstr "" msgid "File formats list" msgstr "" -#: cps/templates/layout.html:75 cps/templates/tasks.html:7 cps/web.py:1069 +#: cps/templates/layout.html:73 cps/templates/tasks.html:7 cps/web.py:1069 msgid "Tasks" msgstr "" @@ -1233,7 +1261,7 @@ msgstr "" msgid "E-Mail server is not configured, please contact your administrator!" msgstr "" -#: cps/templates/layout.html:87 cps/templates/register.html:17 cps/web.py:1486 +#: cps/templates/layout.html:85 cps/templates/register.html:17 cps/web.py:1486 #: cps/web.py:1493 cps/web.py:1499 cps/web.py:1518 cps/web.py:1522 #: cps/web.py:1528 msgid "Register" @@ -1253,7 +1281,9 @@ msgstr "" #: cps/web.py:1559 #, python-format -msgid "Fallback Login as: '%(nickname)s', LDAP Server not reachable, or user not known" +msgid "" +"Fallback Login as: '%(nickname)s', LDAP Server not reachable, or user not" +" known" msgstr "" #: cps/web.py:1565 @@ -1344,7 +1374,7 @@ msgstr "" msgid "Send to Kindle E-mail Address" msgstr "" -#: cps/templates/admin.html:17 cps/templates/layout.html:78 +#: cps/templates/admin.html:17 cps/templates/layout.html:76 #: cps/templates/user_table.html:143 msgid "Admin" msgstr "" @@ -1354,7 +1384,7 @@ msgstr "" msgid "Password" msgstr "" -#: cps/templates/admin.html:20 cps/templates/layout.html:67 +#: cps/templates/admin.html:20 cps/templates/layout.html:66 #: cps/templates/user_table.html:145 msgid "Upload" msgstr "" @@ -1545,7 +1575,7 @@ msgid "OK" msgstr "" #: cps/templates/admin.html:215 cps/templates/admin.html:229 -#: cps/templates/book_edit.html:217 cps/templates/book_table.html:124 +#: cps/templates/book_edit.html:213 cps/templates/book_table.html:124 #: cps/templates/config_db.html:54 cps/templates/config_edit.html:359 #: cps/templates/config_view_edit.html:173 cps/templates/modal_dialogs.html:64 #: cps/templates/modal_dialogs.html:99 cps/templates/modal_dialogs.html:117 @@ -1643,13 +1673,13 @@ msgstr "" msgid "Book Title" msgstr "" -#: cps/templates/book_edit.html:62 cps/templates/book_edit.html:274 -#: cps/templates/book_edit.html:292 cps/templates/search_form.html:12 +#: cps/templates/book_edit.html:62 cps/templates/book_edit.html:270 +#: cps/templates/book_edit.html:288 cps/templates/search_form.html:12 msgid "Author" msgstr "" -#: cps/templates/book_edit.html:67 cps/templates/book_edit.html:279 -#: cps/templates/book_edit.html:294 cps/templates/search_form.html:153 +#: cps/templates/book_edit.html:67 cps/templates/book_edit.html:275 +#: cps/templates/book_edit.html:290 cps/templates/search_form.html:153 msgid "Description" msgstr "" @@ -1657,15 +1687,15 @@ msgstr "" msgid "Identifiers" msgstr "" -#: cps/templates/book_edit.html:76 cps/templates/book_edit.html:303 +#: cps/templates/book_edit.html:76 cps/templates/book_edit.html:299 msgid "Identifier Type" msgstr "" -#: cps/templates/book_edit.html:77 cps/templates/book_edit.html:304 +#: cps/templates/book_edit.html:77 cps/templates/book_edit.html:300 msgid "Identifier Value" msgstr "" -#: cps/templates/book_edit.html:78 cps/templates/book_edit.html:305 +#: cps/templates/book_edit.html:78 cps/templates/book_edit.html:301 #: cps/templates/user_table.html:24 msgid "Remove" msgstr "" @@ -1686,89 +1716,91 @@ msgstr "" msgid "Rating" msgstr "" -#: cps/templates/book_edit.html:104 -msgid "Fetch Cover from URL (JPEG - Image will be downloaded and stored in database)" +#: cps/templates/book_edit.html:103 +msgid "" +"Fetch Cover from URL (JPEG - Image will be downloaded and stored in " +"database)" msgstr "" -#: cps/templates/book_edit.html:108 +#: cps/templates/book_edit.html:107 msgid "Upload Cover from Local Disk" msgstr "" -#: cps/templates/book_edit.html:114 +#: cps/templates/book_edit.html:112 msgid "Published Date" msgstr "" -#: cps/templates/book_edit.html:123 cps/templates/book_edit.html:276 -#: cps/templates/book_edit.html:293 cps/templates/detail.html:164 +#: cps/templates/book_edit.html:121 cps/templates/book_edit.html:272 +#: cps/templates/book_edit.html:289 cps/templates/detail.html:164 #: cps/templates/search_form.html:16 msgid "Publisher" msgstr "" -#: cps/templates/book_edit.html:127 cps/templates/detail.html:131 +#: cps/templates/book_edit.html:125 cps/templates/detail.html:131 #: cps/templates/user_edit.html:33 msgid "Language" msgstr "" -#: cps/templates/book_edit.html:137 cps/templates/search_form.html:45 +#: cps/templates/book_edit.html:135 cps/templates/search_form.html:45 #: cps/templates/search_form.html:164 msgid "Yes" msgstr "" -#: cps/templates/book_edit.html:138 cps/templates/search_form.html:46 +#: cps/templates/book_edit.html:136 cps/templates/search_form.html:46 #: cps/templates/search_form.html:165 msgid "No" msgstr "" -#: cps/templates/book_edit.html:203 +#: cps/templates/book_edit.html:200 msgid "Upload Format" msgstr "" -#: cps/templates/book_edit.html:212 +#: cps/templates/book_edit.html:208 msgid "View Book on Save" msgstr "" -#: cps/templates/book_edit.html:215 cps/templates/book_edit.html:233 +#: cps/templates/book_edit.html:211 cps/templates/book_edit.html:229 msgid "Fetch Metadata" msgstr "" -#: cps/templates/book_edit.html:216 cps/templates/config_db.html:53 +#: cps/templates/book_edit.html:212 cps/templates/config_db.html:53 #: cps/templates/config_edit.html:358 cps/templates/config_view_edit.html:172 #: cps/templates/email_edit.html:65 cps/templates/shelf_edit.html:25 #: cps/templates/shelf_order.html:41 cps/templates/user_edit.html:139 msgid "Save" msgstr "" -#: cps/templates/book_edit.html:236 +#: cps/templates/book_edit.html:232 msgid "Keyword" msgstr "" -#: cps/templates/book_edit.html:237 +#: cps/templates/book_edit.html:233 msgid "Search keyword" msgstr "" -#: cps/templates/book_edit.html:243 +#: cps/templates/book_edit.html:239 msgid "Click the cover to load metadata to the form" msgstr "" -#: cps/templates/book_edit.html:250 cps/templates/book_edit.html:289 +#: cps/templates/book_edit.html:246 cps/templates/book_edit.html:285 msgid "Loading..." msgstr "" -#: cps/templates/book_edit.html:254 cps/templates/layout.html:64 -#: cps/templates/layout.html:188 cps/templates/modal_dialogs.html:34 +#: cps/templates/book_edit.html:250 cps/templates/layout.html:63 +#: cps/templates/layout.html:186 cps/templates/modal_dialogs.html:34 #: cps/templates/user_edit.html:160 msgid "Close" msgstr "" -#: cps/templates/book_edit.html:281 cps/templates/book_edit.html:295 +#: cps/templates/book_edit.html:277 cps/templates/book_edit.html:291 msgid "Source" msgstr "" -#: cps/templates/book_edit.html:290 +#: cps/templates/book_edit.html:286 msgid "Search error!" msgstr "" -#: cps/templates/book_edit.html:291 +#: cps/templates/book_edit.html:287 msgid "No Result(s) found! Please try another keyword." msgstr "" @@ -1970,6 +2002,10 @@ msgstr "" msgid "Enable Uploads" msgstr "" +#: cps/templates/config_edit.html:108 +msgid "(Please ensure users having also upload rights)" +msgstr "" + #: cps/templates/config_edit.html:112 msgid "Allowed Upload Fileformats" msgstr "" @@ -2064,7 +2100,9 @@ msgid "SSL" msgstr "" #: cps/templates/config_edit.html:210 -msgid "LDAP CACertificate Path (Only needed for Client Certificate Authentication)" +msgid "" +"LDAP CACertificate Path (Only needed for Client Certificate " +"Authentication)" msgstr "" #: cps/templates/config_edit.html:217 @@ -2329,7 +2367,7 @@ msgid "Add to shelf" msgstr "" #: cps/templates/detail.html:267 cps/templates/detail.html:284 -#: cps/templates/feed.xml:79 cps/templates/layout.html:139 +#: cps/templates/feed.xml:79 cps/templates/layout.html:137 #: cps/templates/search.html:20 msgid "(Public)" msgstr "" @@ -2404,7 +2442,7 @@ msgstr "" msgid "Denied Domains (Blacklist)" msgstr "" -#: cps/templates/feed.xml:21 cps/templates/layout.html:172 +#: cps/templates/feed.xml:21 cps/templates/layout.html:170 msgid "Next" msgstr "" @@ -2514,7 +2552,7 @@ msgstr "" msgid "Books ordered by file formats" msgstr "" -#: cps/templates/index.xml:119 cps/templates/layout.html:137 +#: cps/templates/index.xml:119 cps/templates/layout.html:135 #: cps/templates/search_form.html:87 msgid "Shelves" msgstr "" @@ -2535,48 +2573,48 @@ msgstr "" msgid "Search Library" msgstr "" -#: cps/templates/layout.html:64 cps/templates/layout.html:119 +#: cps/templates/layout.html:63 cps/templates/layout.html:117 msgid "Uploading..." msgstr "" -#: cps/templates/layout.html:64 +#: cps/templates/layout.html:63 msgid "Error" msgstr "" -#: cps/templates/layout.html:64 +#: cps/templates/layout.html:63 msgid "Upload done, processing, please wait..." msgstr "" -#: cps/templates/layout.html:78 cps/templates/read.html:71 +#: cps/templates/layout.html:76 cps/templates/read.html:71 #: cps/templates/readcbr.html:84 cps/templates/readcbr.html:108 msgid "Settings" msgstr "" -#: cps/templates/layout.html:80 +#: cps/templates/layout.html:78 msgid "Account" msgstr "" -#: cps/templates/layout.html:82 +#: cps/templates/layout.html:80 msgid "Logout" msgstr "" -#: cps/templates/layout.html:120 +#: cps/templates/layout.html:118 msgid "Please do not refresh the page" msgstr "" -#: cps/templates/layout.html:130 +#: cps/templates/layout.html:128 msgid "Browse" msgstr "" -#: cps/templates/layout.html:143 cps/templates/stats.html:3 +#: cps/templates/layout.html:141 cps/templates/stats.html:3 msgid "About" msgstr "" -#: cps/templates/layout.html:157 +#: cps/templates/layout.html:155 msgid "Previous" msgstr "" -#: cps/templates/layout.html:184 +#: cps/templates/layout.html:182 msgid "Book Details" msgstr "" @@ -2657,7 +2695,9 @@ msgid "Important Kobo Note: deleted books will remain on any paired Kobo device. msgstr "" #: cps/templates/modal_dialogs.html:57 -msgid "Books must first be archived and the device synced before a book can safely be deleted." +msgid "" +"Books must first be archived and the device synced before a book can " +"safely be deleted." msgstr "" #: cps/templates/modal_dialogs.html:76 From 3f913133037de44942aa08098425986d91ad979f Mon Sep 17 00:00:00 2001 From: Jonathan Fenske <929220+jfenske89@users.noreply.github.com> Date: Tue, 30 Nov 2021 22:24:34 -0600 Subject: [PATCH 03/40] Update epub.js send the CSRF token when adding bookmarks --- cps/static/js/reading/epub.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cps/static/js/reading/epub.js b/cps/static/js/reading/epub.js index edafa82c..7942bfbd 100644 --- a/cps/static/js/reading/epub.js +++ b/cps/static/js/reading/epub.js @@ -61,11 +61,14 @@ var reader; this.removeBookmark(bookmark); }.bind(this)); } + + var csrftoken = $("input[name='csrf_token']").val(); // Save to database $.ajax(calibre.bookmarkUrl, { method: "post", - data: { bookmark: location || "" } + data: { bookmark: location || "" }, + headers: { "X-CSRFToken": csrftoken } }).fail(function (xhr, status, error) { alert(error); }); From 66874f8163ef3199bc33c9888f3857475a524587 Mon Sep 17 00:00:00 2001 From: Jonathan Fenske <929220+jfenske89@users.noreply.github.com> Date: Tue, 30 Nov 2021 22:25:45 -0600 Subject: [PATCH 04/40] Update read.html include the CSR token input --- cps/templates/read.html | 1 + 1 file changed, 1 insertion(+) diff --git a/cps/templates/read.html b/cps/templates/read.html index 3d2566e0..1766eb1b 100644 --- a/cps/templates/read.html +++ b/cps/templates/read.html @@ -17,6 +17,7 @@ From 222929e7413f97c4b81b093d1f21a8586d5c605d Mon Sep 17 00:00:00 2001 From: cbartondock Date: Thu, 23 Dec 2021 18:05:20 -0500 Subject: [PATCH 17/40] Fixed extra s in scholar metadata --- cps/metadata_provider/scholar.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cps/metadata_provider/scholar.py b/cps/metadata_provider/scholar.py index 6e13c768..9aa0ab87 100644 --- a/cps/metadata_provider/scholar.py +++ b/cps/metadata_provider/scholar.py @@ -19,20 +19,23 @@ from scholarly import scholarly from cps.services.Metadata import Metadata - +import pprint +pp = pprint.PrettyPrinter(indent=4) class scholar(Metadata): __name__ = "Google Scholar" __id__ = "googlescholar" - def search(self, query, generic_cover=""): + def search(self, query, generic_cover=None): val = list() if self.active: scholar_gen = scholarly.search_pubs(' '.join(query.split('+'))) i = 0 for publication in scholar_gen: + print(f"PUBLICATION {i + 1}") + pp.pprint(publication) v = dict() - v['id'] = "1234" # publication['bib'].get('title') + v['id'] = publication['url_scholarbib'].split(':')[1] v['title'] = publication['bib'].get('title') v['authors'] = publication['bib'].get('author', []) v['description'] = publication['bib'].get('abstract', "") @@ -41,8 +44,8 @@ class scholar(Metadata): v['publishedDate'] = publication['bib'].get('pub_year')+"-01-01" else: v['publishedDate'] = "" - v['tags'] = "" - v['ratings'] = 0 + v['tags'] = [] + v['rating'] = 0 v['series'] = "" v['cover'] = generic_cover v['url'] = publication.get('pub_url') or publication.get('eprint_url') or "", @@ -55,6 +58,7 @@ class scholar(Metadata): i += 1 if (i >= 10): break + pp.pprint(val) return val From 4edd1914b4d2b90a826b199167ca55e34258b7c4 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Thu, 23 Dec 2021 23:16:41 -0500 Subject: [PATCH 18/40] Fixed google scholar issues --- cps/metadata_provider/scholar.py | 7 +------ cps/search_metadata.py | 4 ++-- cps/static/js/get_meta.js | 4 +--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/cps/metadata_provider/scholar.py b/cps/metadata_provider/scholar.py index 9aa0ab87..5ff078b9 100644 --- a/cps/metadata_provider/scholar.py +++ b/cps/metadata_provider/scholar.py @@ -19,21 +19,17 @@ from scholarly import scholarly from cps.services.Metadata import Metadata -import pprint -pp = pprint.PrettyPrinter(indent=4) class scholar(Metadata): __name__ = "Google Scholar" __id__ = "googlescholar" - def search(self, query, generic_cover=None): + def search(self, query, generic_cover=""): val = list() if self.active: scholar_gen = scholarly.search_pubs(' '.join(query.split('+'))) i = 0 for publication in scholar_gen: - print(f"PUBLICATION {i + 1}") - pp.pprint(publication) v = dict() v['id'] = publication['url_scholarbib'].split(':')[1] v['title'] = publication['bib'].get('title') @@ -58,7 +54,6 @@ class scholar(Metadata): i += 1 if (i >= 10): break - pp.pprint(val) return val diff --git a/cps/search_metadata.py b/cps/search_metadata.py index e837fe21..b88f222f 100644 --- a/cps/search_metadata.py +++ b/cps/search_metadata.py @@ -103,9 +103,9 @@ def metadata_search(): data = list() active = current_user.view_settings.get('metadata', {}) if query: - static_cover = url_for('static', filename='generic_cover.jpg') + generic_cover = "" with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: - meta = {executor.submit(c.search, query, static_cover): c for c in cl if active.get(c.__id__, True)} + meta = {executor.submit(c.search, query, generic_cover): c for c in cl if active.get(c.__id__, True)} for future in concurrent.futures.as_completed(meta): data.extend(future.result()) return Response(json.dumps(data), mimetype='application/json') diff --git a/cps/static/js/get_meta.js b/cps/static/js/get_meta.js index 51ab740d..2ad4d53b 100644 --- a/cps/static/js/get_meta.js +++ b/cps/static/js/get_meta.js @@ -40,7 +40,7 @@ $(function () { $("#book_title").val(book.title); $("#tags").val(uniqueTags.join(", ")); $("#rating").data("rating").setValue(Math.round(book.rating)); - if(book.cover !== null){ + if(book.cover){ $(".cover img").attr("src", book.cover); $("#cover_url").val(book.cover); } @@ -128,9 +128,7 @@ $(function () { e.preventDefault(); keyword = $("#keyword").val(); $('.pill').each(function(){ - // console.log($(this).data('control')); $(this).data("initial", $(this).prop('checked')); - // console.log($(this).data('initial')); }); doSearch(keyword); }); From 785726deee13b4d56f6c3503dd57c1e3eb7d6f30 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 25 Dec 2021 10:09:11 +0100 Subject: [PATCH 19/40] Migrated some routes to POST - delete shelf, import ldap users - delete_kobo token, kobo force full sync - shutdown, reconnect, shutdown --- cps/admin.py | 10 +++++----- cps/editbooks.py | 17 ++++++----------- cps/kobo_auth.py | 8 ++------ cps/shelf.py | 9 +++++---- cps/static/js/main.js | 29 ++++++++++++++++++----------- cps/templates/shelf.html | 22 ++++------------------ cps/web.py | 5 +++-- 7 files changed, 43 insertions(+), 57 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 1c228e49..29f5fb20 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -129,11 +129,11 @@ def admin_forbidden(): abort(403) -@admi.route("/shutdown") +@admi.route("/shutdown", methods=["POST"]) @login_required @admin_required def shutdown(): - task = int(request.args.get("parameter").strip()) + task = request.get_json().get('parameter', -1) showtext = {} if task in (0, 1): # valid commandos received # close all database connections @@ -906,7 +906,7 @@ def list_restriction(res_type, user_id): response.headers["Content-Type"] = "application/json; charset=utf-8" return response -@admi.route("/ajax/fullsync") +@admi.route("/ajax/fullsync", methods=["POST"]) @login_required def ajax_fullsync(): count = ub.session.query(ub.KoboSyncedBooks).filter(current_user.id == ub.KoboSyncedBooks.user_id).delete() @@ -1626,7 +1626,7 @@ def edit_user(user_id): page="edituser") -@admi.route("/admin/resetpassword/") +@admi.route("/admin/resetpassword/", methods=["POST"]) @login_required @admin_required def reset_user_password(user_id): @@ -1802,7 +1802,7 @@ def ldap_import_create_user(user, user_data): return 0, message -@admi.route('/import_ldap_users') +@admi.route('/import_ldap_users', methods=["POST"]) @login_required @admin_required def import_ldap_users(): diff --git a/cps/editbooks.py b/cps/editbooks.py index 21dc3ba0..b6fdc164 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -26,6 +26,8 @@ import json from shutil import copyfile from uuid import uuid4 from markupsafe import escape +from functools import wraps + try: from lxml.html.clean import clean_html except ImportError: @@ -51,13 +53,6 @@ from .tasks.upload import TaskUpload from .render_template import render_title_template from .usermanagement import login_required_if_no_ano -try: - from functools import wraps -except ImportError: - pass # We're not using Python 3 - - - editbook = Blueprint('editbook', __name__) log = logger.create() @@ -237,14 +232,14 @@ def modify_identifiers(input_identifiers, db_identifiers, db_session): changed = True return changed, error -@editbook.route("/ajax/delete/") +@editbook.route("/ajax/delete/", methods=["POST"]) @login_required def delete_book_from_details(book_id): return Response(delete_book_from_table(book_id, "", True), mimetype='application/json') -@editbook.route("/delete/", defaults={'book_format': ""}) -@editbook.route("/delete//") +@editbook.route("/delete/", defaults={'book_format': ""}, methods=["POST"]) +@editbook.route("/delete//", methods=["POST"]) @login_required def delete_book_ajax(book_id, book_format): return delete_book_from_table(book_id, book_format, False) @@ -1014,7 +1009,7 @@ def move_coverfile(meta, db_book): category="error") -@editbook.route("/upload", methods=["GET", "POST"]) +@editbook.route("/upload", methods=["POST"]) @login_required_if_no_ano @upload_required def upload(): diff --git a/cps/kobo_auth.py b/cps/kobo_auth.py index a51095c8..8d46b26a 100644 --- a/cps/kobo_auth.py +++ b/cps/kobo_auth.py @@ -62,6 +62,7 @@ particular calls to non-Kobo specific endpoints such as the CalibreWeb book down from binascii import hexlify from datetime import datetime from os import urandom +from functools import wraps from flask import g, Blueprint, url_for, abort, request from flask_login import login_user, current_user, login_required @@ -70,11 +71,6 @@ from flask_babel import gettext as _ from . import logger, config, calibre_db, db, helper, ub, lm from .render_template import render_title_template -try: - from functools import wraps -except ImportError: - pass # We're not using Python 3 - log = logger.create() @@ -167,7 +163,7 @@ def generate_auth_token(user_id): ) -@kobo_auth.route("/deleteauthtoken/") +@kobo_auth.route("/deleteauthtoken/", methods=["POST"]) @login_required def delete_auth_token(user_id): # Invalidate any prevously generated Kobo Auth token for this user. diff --git a/cps/shelf.py b/cps/shelf.py index 5f6a66bf..19c2d68e 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -56,7 +56,7 @@ def check_shelf_view_permissions(cur_shelf): return True -@shelf.route("/shelf/add//") +@shelf.route("/shelf/add//", methods=["POST"]) @login_required def add_to_shelf(shelf_id, book_id): xhr = request.headers.get('X-Requested-With') == 'XMLHttpRequest' @@ -112,7 +112,7 @@ def add_to_shelf(shelf_id, book_id): return "", 204 -@shelf.route("/shelf/massadd/") +@shelf.route("/shelf/massadd/", methods=["POST"]) @login_required def search_to_shelf(shelf_id): shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() @@ -164,7 +164,7 @@ def search_to_shelf(shelf_id): return redirect(url_for('web.index')) -@shelf.route("/shelf/remove//") +@shelf.route("/shelf/remove//", methods=["POST"]) @login_required def remove_from_shelf(shelf_id, book_id): xhr = request.headers.get('X-Requested-With') == 'XMLHttpRequest' @@ -323,12 +323,13 @@ def delete_shelf_helper(cur_shelf): ub.session_commit("successfully deleted Shelf {}".format(cur_shelf.name)) -@shelf.route("/shelf/delete/") +@shelf.route("/shelf/delete/", methods=["POST"]) @login_required def delete_shelf(shelf_id): cur_shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() try: delete_shelf_helper(cur_shelf) + flash(_("Shelf successfully deleted"), category="success") except InvalidRequestError: ub.session.rollback() log.error("Settings DB is not Writeable") diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 585d2296..6cef22f8 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -179,7 +179,7 @@ $("#delete_confirm").click(function() { if (ajaxResponse) { path = getPath() + "/ajax/delete/" + deleteId; $.ajax({ - method:"get", + method:"post", url: path, timeout: 900, success:function(data) { @@ -376,9 +376,11 @@ $(function() { $("#restart").click(function() { $.ajax({ + method:"post", + contentType: "application/json; charset=utf-8", dataType: "json", - url: window.location.pathname + "/../../shutdown", - data: {"parameter":0}, + url: getPath() + "/shutdown", + data: JSON.stringify({"parameter":0}), success: function success() { $("#spinner").show(); setTimeout(restartTimer, 3000); @@ -387,9 +389,11 @@ $(function() { }); $("#shutdown").click(function() { $.ajax({ + method:"post", + contentType: "application/json; charset=utf-8", dataType: "json", - url: window.location.pathname + "/../../shutdown", - data: {"parameter":1}, + url: getPath() + "/shutdown", + data: JSON.stringify({"parameter":1}), success: function success(data) { return alert(data.text); } @@ -447,9 +451,11 @@ $(function() { $("#DialogContent").html(""); $("#spinner2").show(); $.ajax({ + method:"post", + contentType: "application/json; charset=utf-8", dataType: "json", url: getPath() + "/shutdown", - data: {"parameter":2}, + data: JSON.stringify({"parameter":2}), success: function success(data) { $("#spinner2").hide(); $("#DialogContent").html(data.text); @@ -527,7 +533,7 @@ $(function() { $(this).data('value'), function (value) { $.ajax({ - method: "get", + method: "post", url: getPath() + "/kobo_auth/deleteauthtoken/" + value, }); $("#config_delete_kobo_token").hide(); @@ -574,7 +580,7 @@ $(function() { function(value){ path = getPath() + "/ajax/fullsync" $.ajax({ - method:"get", + method:"post", url: path, timeout: 900, success:function(data) { @@ -638,7 +644,7 @@ $(function() { else { $("#InvalidDialog").modal('show'); } - } else { + } else { changeDbSettings(); } } @@ -685,7 +691,7 @@ $(function() { "GeneralDeleteModal", $(this).data('value'), function(value){ - window.location.href = window.location.pathname + "/../../shelf/delete/" + value + $("#delete_shelf").closest("form").submit() } ); @@ -734,7 +740,8 @@ $(function() { $("#DialogContent").html(""); $("#spinner2").show(); $.ajax({ - method:"get", + method:"post", + contentType: "application/json; charset=utf-8", dataType: "json", url: getPath() + "/import_ldap_users", success: function success(data) { diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index 4f74a4da..5bb9317e 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -2,14 +2,16 @@ {% block body %}

{{title}}

+
{% if g.user.role_download() %} {{ _('Download') }} {% endif %} {% if g.user.is_authenticated %} {% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %} - -
{{ _('Delete this Shelf') }}
+ +
{{ _('Delete this Shelf') }}
{{ _('Edit Shelf Properties') }} +
{% if entries.__len__() %} {{ _('Arrange books manually') }} @@ -84,22 +86,6 @@ {% endfor %}
- - {% endblock %} {% block modal %} {{ delete_confirm_modal() }} diff --git a/cps/web.py b/cps/web.py index f203783b..81c37711 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1055,7 +1055,8 @@ def get_tasks_status(): return render_title_template('tasks.html', entries=answer, title=_(u"Tasks"), page="tasks") -@app.route("/reconnect") +# method is available without login and not protected by CSRF to make it easy reachable +@app.route("/reconnect", methods=['GET']) def reconnect(): calibre_db.reconnect_db(config, ub.app_DB_path) return json.dumps({}) @@ -1435,7 +1436,7 @@ def download_link(book_id, book_format, anyname): return get_download_link(book_id, book_format, client) -@web.route('/send///') +@web.route('/send///', methods=["POST"]) @login_required @download_required def send_to_kindle(book_id, book_format, convert): From 573c9f9fb495f4408d31c8a272702a099fb463d4 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 25 Dec 2021 10:35:08 +0100 Subject: [PATCH 20/40] Improved logging (right stacklevel on mail exceptions) Updated jsonschema requirements --- cps/logger.py | 13 ++++--------- cps/tasks/mail.py | 12 ++++++------ optional-requirements.txt | 2 +- setup.cfg | 2 +- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/cps/logger.py b/cps/logger.py index 5847188b..053d0bd3 100644 --- a/cps/logger.py +++ b/cps/logger.py @@ -42,20 +42,15 @@ logging.addLevelName(logging.CRITICAL, "CRIT") class _Logger(logging.Logger): - def debug_or_exception(self, message, *args, **kwargs): + def debug_or_exception(self, message, stacklevel=2, *args, **kwargs): if sys.version_info > (3, 7): if is_debug_enabled(): - self.exception(message, stacklevel=2, *args, **kwargs) + self.exception(message, stacklevel=stacklevel, *args, **kwargs) else: - self.error(message, stacklevel=2, *args, **kwargs) - elif sys.version_info > (3, 0): - if is_debug_enabled(): - self.exception(message, stack_info=True, *args, **kwargs) - else: - self.error(message, *args, **kwargs) + self.error(message, stacklevel=stacklevel, *args, **kwargs) else: if is_debug_enabled(): - self.exception(message, *args, **kwargs) + self.exception(message, stack_info=True, *args, **kwargs) else: self.error(message, *args, **kwargs) diff --git a/cps/tasks/mail.py b/cps/tasks/mail.py index 05b2175f..03526c8b 100644 --- a/cps/tasks/mail.py +++ b/cps/tasks/mail.py @@ -158,10 +158,10 @@ class TaskEmail(CalibreTask): else: self.send_gmail_email(msg) except MemoryError as e: - log.debug_or_exception(e) + log.debug_or_exception(e, stacklevel=3) self._handleError(u'MemoryError sending e-mail: {}'.format(str(e))) except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e: - log.debug_or_exception(e) + log.debug_or_exception(e, stacklevel=3) if hasattr(e, "smtp_error"): text = e.smtp_error.decode('utf-8').replace("\n", '. ') elif hasattr(e, "message"): @@ -171,11 +171,11 @@ class TaskEmail(CalibreTask): else: text = '' self._handleError(u'Smtplib Error sending e-mail: {}'.format(text)) - except socket.error as e: - log.debug_or_exception(e) + except (socket.error) as e: + log.debug_or_exception(e, stacklevel=3) self._handleError(u'Socket Error sending e-mail: {}'.format(e.strerror)) except Exception as ex: - log.debug_or_exception(ex) + log.debug_or_exception(ex, stacklevel=3) self._handleError(u'Error sending e-mail: {}'.format(ex)) def send_standard_email(self, msg): @@ -248,7 +248,7 @@ class TaskEmail(CalibreTask): data = file_.read() file_.close() except IOError as e: - log.debug_or_exception(e) + log.debug_or_exception(e, stacklevel=3) log.error(u'The requested file could not be read. Maybe wrong permissions?') return None # Set mimetype diff --git a/optional-requirements.txt b/optional-requirements.txt index 3fac14ca..c0009c94 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -38,4 +38,4 @@ natsort>=2.2.0,<8.1.0 comicapi>=2.2.0,<2.3.0 #Kobo integration -jsonschema>=3.2.0,<4.3.0 +jsonschema>=3.2.0,<4.4.0 diff --git a/setup.cfg b/setup.cfg index 87f6055f..95f3502d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -87,7 +87,7 @@ comics = natsort>=2.2.0,<8.1.0 comicapi>= 2.2.0,<2.3.0 kobo = - jsonschema>=3.2.0,<4.3.0 + jsonschema>=3.2.0,<4.4.0 From f39dc100b458e86d195a007619da7292af7033e1 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 25 Dec 2021 21:39:58 +0100 Subject: [PATCH 21/40] Migrated some routes to POST - shelf massadd - resetpassword - delete shelf - send to kindle --- cps/static/js/details.js | 2 +- cps/static/js/main.js | 36 +++++++++++++++++++++++++++++++++--- cps/templates/detail.html | 6 +++--- cps/templates/search.html | 2 +- cps/templates/shelf.html | 4 ++-- cps/templates/user_edit.html | 2 +- 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/cps/static/js/details.js b/cps/static/js/details.js index 9caf9470..3a7def32 100644 --- a/cps/static/js/details.js +++ b/cps/static/js/details.js @@ -62,7 +62,7 @@ $("#archived_cb").on("change", function() { $("#shelf-actions").on("click", "[data-shelf-action]", function (e) { e.preventDefault(); - $.get(this.href) + $.post(this.href) .done(function() { var $this = $(this); switch ($this.data("shelf-action")) { diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 6cef22f8..e8da76ef 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -20,6 +20,20 @@ function getPath() { return jsFileLocation.substr(0, jsFileLocation.search("/static/js/libs/jquery.min.js")); // the js folder path } +function postButton(event, action){ + event.preventDefault(); + var newForm = jQuery('
', { + "action": action, + 'target': "_top", + 'method': "post" + }).append(jQuery('', { + 'name': 'csrf_token', + 'value': $("input[name=\'csrf_token\']").val(), + 'type': 'hidden' + })).appendTo('body'); + newForm.submit(); +} + function elementSorter(a, b) { a = +a.slice(0, -2); b = +b.slice(0, -2); @@ -71,6 +85,22 @@ $(document).on("change", "select[data-controlall]", function() { } }); +/*$(document).on("click", "#sendbtn", function (event) { + postButton(event, $(this).data('action')); +}); + +$(document).on("click", ".sendbutton", function (event) { + // $(".sendbutton").on("click", "body", function(event) { + postButton(event, $(this).data('action')); +});*/ + +$(document).on("click", ".postAction", function (event) { + // $(".sendbutton").on("click", "body", function(event) { + postButton(event, $(this).data('action')); +}); + + + // Syntax has to be bind not on, otherwise problems with firefox $(".container-fluid").bind("dragenter dragover", function () { if($("#btn-upload").length && !$('body').hasClass('shelforder')) { @@ -685,13 +715,14 @@ $(function() { }); }); - $("#delete_shelf").click(function() { + $("#delete_shelf").click(function(event) { confirmDialog( $(this).attr('id'), "GeneralDeleteModal", $(this).data('value'), function(value){ - $("#delete_shelf").closest("form").submit() + postButton(event, $("#delete_shelf").data("action")); + // $("#delete_shelf").closest("form").submit() } ); @@ -775,4 +806,3 @@ $(function() { }); }); }); - diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 0ecaf903..1fd5f09a 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -38,16 +38,16 @@ {% endif %} {% if g.user.kindle_mail and kindle_list %} {% if kindle_list.__len__() == 1 %} - {{kindle_list[0]['text']}} +
{{kindle_list[0]['text']}}
{% else %}
-
diff --git a/cps/templates/search.html b/cps/templates/search.html index 627beaf8..32339803 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -17,7 +17,7 @@ diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index 5bb9317e..adfead60 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -2,14 +2,14 @@ {% block body %}

{{title}}

- + {% if g.user.role_download() %} {{ _('Download') }} {% endif %} {% if g.user.is_authenticated %} {% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %} -
{{ _('Delete this Shelf') }}
+
{{ _('Delete this Shelf') }}
{{ _('Edit Shelf Properties') }} {% if entries.__len__() %} diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index e6fbdb74..de7a4fb3 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -17,7 +17,7 @@
{% if ( g.user and g.user.role_passwd() or g.user.role_admin() ) and not content.role_anonymous() %} {% if g.user and g.user.role_admin() and not new_user and not profile and ( mail_configured and content.email if content.email != None ) %} - {{_('Reset user Password')}} + {{_('Reset user Password')}} {% endif %}
From 47f5e2ffb4253b57271e76444e465da425752239 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 26 Dec 2021 10:31:04 +0100 Subject: [PATCH 22/40] Remove python2 urllib imports Fix for "javascript:" script links in identifier --- cps/db.py | 3 +++ cps/helper.py | 5 +---- cps/kobo.py | 6 +----- cps/redirect.py | 6 ++---- cps/services/SyncToken.py | 7 ++----- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/cps/db.py b/cps/db.py index 9c5b5657..470ecc1c 100644 --- a/cps/db.py +++ b/cps/db.py @@ -23,6 +23,7 @@ import re import ast import json from datetime import datetime +from urllib.parse import quote from sqlalchemy import create_engine from sqlalchemy import Table, Column, ForeignKey, CheckConstraint @@ -166,6 +167,8 @@ class Identifiers(Base): return u"https://portal.issn.org/resource/ISSN/{0}".format(self.val) elif format_type == "isfdb": return u"http://www.isfdb.org/cgi-bin/pl.cgi?{0}".format(self.val) + elif self.val.lower().startswith("javascript:"): + return quote(self.val) else: return u"{0}".format(self.val) diff --git a/cps/helper.py b/cps/helper.py index b8499a12..e8a0b738 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -38,11 +38,8 @@ from sqlalchemy.sql.expression import true, false, and_, text, func from werkzeug.datastructures import Headers from werkzeug.security import generate_password_hash from markupsafe import escape +from urllib.parse import quote -try: - from urllib.parse import quote -except ImportError: - from urllib import quote try: import unidecode diff --git a/cps/kobo.py b/cps/kobo.py index e0395855..b5ff000e 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -23,11 +23,7 @@ import os import uuid from time import gmtime, strftime import json - -try: - from urllib import unquote -except ImportError: - from urllib.parse import unquote +from urllib.parse import unquote from flask import ( Blueprint, diff --git a/cps/redirect.py b/cps/redirect.py index d491b353..8bd68109 100644 --- a/cps/redirect.py +++ b/cps/redirect.py @@ -27,10 +27,8 @@ # http://flask.pocoo.org/snippets/62/ -try: - from urllib.parse import urlparse, urljoin -except ImportError: - from urlparse import urlparse, urljoin +from urllib.parse import urlparse, urljoin + from flask import request, url_for, redirect diff --git a/cps/services/SyncToken.py b/cps/services/SyncToken.py index 85ed5032..2e23efe2 100644 --- a/cps/services/SyncToken.py +++ b/cps/services/SyncToken.py @@ -21,11 +21,8 @@ import sys from base64 import b64decode, b64encode from jsonschema import validate, exceptions, __version__ from datetime import datetime -try: - # pylint: disable=unused-import - from urllib import unquote -except ImportError: - from urllib.parse import unquote + +from urllib.parse import unquote from flask import json from .. import logger From 3e0d8763c377d2146462811e3e4ccf13f0d312ce Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 26 Dec 2021 10:46:43 +0100 Subject: [PATCH 23/40] Prevent 2 public shelfs with same names due to changing public property --- cps/shelf.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cps/shelf.py b/cps/shelf.py index 19c2d68e..b1fbdd04 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -248,12 +248,13 @@ def create_edit_shelf(shelf, page_title, page, shelf_id=False): if not current_user.role_edit_shelfs() and to_save.get("is_public") == "on": flash(_(u"Sorry you are not allowed to create a public shelf"), category="error") return redirect(url_for('web.index')) - shelf.is_public = 1 if to_save.get("is_public") else 0 + is_public = 1 if to_save.get("is_public") else 0 if config.config_kobo_sync: shelf.kobo_sync = True if to_save.get("kobo_sync") else False shelf_title = to_save.get("title", "") - if check_shelf_is_unique(shelf, shelf_title, shelf_id): + if check_shelf_is_unique(shelf, shelf_title, is_public, shelf_id): shelf.name = shelf_title + shelf.is_public = is_public if not shelf_id: shelf.user_id = int(current_user.id) ub.session.add(shelf) @@ -284,12 +285,12 @@ def create_edit_shelf(shelf, page_title, page, shelf_id=False): sync_only_selected_shelves=sync_only_selected_shelves) -def check_shelf_is_unique(shelf, title, shelf_id=False): +def check_shelf_is_unique(shelf, title, is_public, shelf_id=False): if shelf_id: ident = ub.Shelf.id != shelf_id else: ident = true() - if shelf.is_public == 1: + if is_public == 1: is_shelf_name_unique = ub.session.query(ub.Shelf) \ .filter((ub.Shelf.name == title) & (ub.Shelf.is_public == 1)) \ .filter(ident) \ From f22e4d996c0f647b506cd42c60407a9ee8c78818 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Mon, 27 Dec 2021 09:31:32 +0100 Subject: [PATCH 24/40] Proxy kobo library sync at the end of local sync --- cps/kobo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/kobo.py b/cps/kobo.py index b5ff000e..c74a3230 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -321,7 +321,7 @@ def HandleSyncRequest(): def generate_sync_response(sync_token, sync_results, set_cont=False): extra_headers = {} - if config.config_kobo_proxy: + if config.config_kobo_proxy and not set_cont: # Merge in sync results from the official Kobo store. try: store_response = make_request_to_kobo_store(sync_token) From 0548fbb685569851ec5a37b3650c5b6c54ee4447 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Mon, 27 Dec 2021 09:37:52 +0100 Subject: [PATCH 25/40] Bugfix post commands without updater --- cps/templates/admin.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 9728cb6d..6cd7815e 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -188,9 +188,8 @@ - - {% if feature_support['updater'] %} + {% if feature_support['updater'] %}
{{_('Check for Update')}}
From ae1f515446e7ee1f31700df42b810a0ce1061cf5 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Mon, 27 Dec 2021 20:02:42 +0100 Subject: [PATCH 26/40] Bugfix uncheck all ekements in books list and user list Improved testability for books list --- cps/static/js/table.js | 30 +++++++++++++++--------------- cps/templates/book_table.html | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cps/static/js/table.js b/cps/static/js/table.js index e98f6a8b..112ca957 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -47,15 +47,15 @@ $(function() { var rows = rowsAfter; if (e.type === "uncheck-all") { - rows = rowsBefore; + selections = []; + } else { + var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { + return row.id; + }); + + var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; + selections = window._[func](selections, ids); } - - var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { - return row.id; - }); - - var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; - selections = window._[func](selections, ids); if (selections.length >= 2) { $("#merge_books").removeClass("disabled"); $("#merge_books").attr("aria-disabled", false); @@ -540,14 +540,14 @@ $(function() { var rows = rowsAfter; if (e.type === "uncheck-all") { - rows = rowsBefore; + selections = []; + } else { + var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { + return row.id; + }); + var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; + selections = window._[func](selections, ids); } - - var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { - return row.id; - }); - var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; - selections = window._[func](selections, ids); handle_header_buttons(); }); }); diff --git a/cps/templates/book_table.html b/cps/templates/book_table.html index fb0cfed8..eb5c1bff 100644 --- a/cps/templates/book_table.html +++ b/cps/templates/book_table.html @@ -120,8 +120,8 @@
From c095ee3c144765ed559861caef2d0b045f704329 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 28 Dec 2021 11:31:32 +0100 Subject: [PATCH 27/40] Fix #2243 (whitespaces are trimmed also for normal search) --- cps/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 81c37711..e139848e 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1069,7 +1069,7 @@ def reconnect(): def search(): term = request.args.get("query") if term: - return redirect(url_for('web.books_list', data="search", sort_param='stored', query=term)) + return redirect(url_for('web.books_list', data="search", sort_param='stored', query=term.strip())) else: return render_title_template('search.html', searchterm="", From a90177afa0bd1846cf7cbb92b93b770aff065082 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 28 Dec 2021 20:17:51 +0100 Subject: [PATCH 28/40] Better version output in about page (exe file, pyPi, git commit string removed if empty) --- cps/about.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cps/about.py b/cps/about.py index ba5a99af..7e839520 100644 --- a/cps/about.py +++ b/cps/about.py @@ -74,13 +74,22 @@ opt = dep_check.load_dependencys(True) for i in (req + opt): ret[i[1]] = i[0] +if constants.NIGHTLY_VERSION[0] == "$Format:%H$": + calibre_web_version = constants.STABLE_VERSION['version'] +else: + calibre_web_version = (constants.STABLE_VERSION['version'] + ' - ' + + constants.NIGHTLY_VERSION[0].replace('%','%%') + ' - ' + + constants.NIGHTLY_VERSION[1].replace('%','%%')) +if getattr(sys, 'frozen', False): + calibre_web_version += " - Exe-Version" +elif constants.HOME_CONFIG: + calibre_web_version += " - pyPi" + if not ret: _VERSIONS = OrderedDict( Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()), Python=sys.version, - Calibre_Web=constants.STABLE_VERSION['version'] + ' - ' - + constants.NIGHTLY_VERSION[0].replace('%','%%') + ' - ' - + constants.NIGHTLY_VERSION[1].replace('%','%%'), + Calibre_Web=calibre_web_version, WebServer=server.VERSION, Flask=flask.__version__, Flask_Login=flask_loginVersion, @@ -110,9 +119,7 @@ else: _VERSIONS = OrderedDict( Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()), Python = sys.version, - Calibre_Web = constants.STABLE_VERSION['version'] + ' - ' - + constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - ' - + constants.NIGHTLY_VERSION[1].replace('%', '%%'), + Calibre_Web=calibre_web_version, Werkzeug = werkzeug.__version__, Jinja2=jinja2.__version__, pySqlite = sqlite3.version, From c1030dfd1340ff65f9b4ea2d20a8c048b7db2e14 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Thu, 30 Dec 2021 14:44:35 +0100 Subject: [PATCH 29/40] Update dependency scholary --- optional-requirements.txt | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/optional-requirements.txt b/optional-requirements.txt index c0009c94..b90951aa 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -31,7 +31,7 @@ SQLAlchemy-Utils>=0.33.5,<0.38.0 # extracting metadata rarfile>=2.7 -scholarly>=1.2.0, <1.5 +scholarly>=1.2.0, <1.6 # other natsort>=2.2.0,<8.1.0 diff --git a/setup.cfg b/setup.cfg index 95f3502d..a81102b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -82,7 +82,7 @@ oauth = SQLAlchemy-Utils>=0.33.5,<0.38.0 metadata = rarfile>=2.7 - scholarly>=1.2.0,<1.5 + scholarly>=1.2.0,<1.6 comics = natsort>=2.2.0,<8.1.0 comicapi>= 2.2.0,<2.3.0 From bbadfa22511c2ae8fb4cdcaa326ccc1be66a07f4 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 4 Jan 2022 21:11:52 +0100 Subject: [PATCH 30/40] bugfixes load metadata --- cps/metadata_provider/scholar.py | 2 +- cps/templates/book_edit.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cps/metadata_provider/scholar.py b/cps/metadata_provider/scholar.py index 5ff078b9..df387831 100644 --- a/cps/metadata_provider/scholar.py +++ b/cps/metadata_provider/scholar.py @@ -43,7 +43,7 @@ class scholar(Metadata): v['tags'] = [] v['rating'] = 0 v['series'] = "" - v['cover'] = generic_cover + v['cover'] = "" v['url'] = publication.get('pub_url') or publication.get('eprint_url') or "", v['source'] = { "id": self.__id__, diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index cac3219c..9d2ac14e 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -226,7 +226,7 @@