Compare commits

..
891 Commits
Author SHA1 Message Date
Ozzie Isaacs 54d06e580d Release version 0.6.12 2021-05-22 14:08:46 +02:00
Ozzie Isaacs 7b1d23eba4 Restored Discord Widget 2021-05-22 10:03:48 +02:00
Ozzie Isaacs 2502c279fc Update discord 2021-05-22 09:57:47 +02:00
Ozzie Isaacs 878fc8c2fd Added download stat badge 2021-05-21 20:58:10 +02:00
Ozzie Isaacs 64902eebcb Merge remote-tracking branch 'batches/patch-2' into master 2021-05-21 20:54:06 +02:00
flying-sausages e520f6afc4 Add Shields to README.md 2021-05-20 22:48:51 +02:00
Ozzie Isaacs 0cc1ae9324 Updated Testresult for Linux 2021-05-20 17:54:25 +02:00
Ozzie Isaacs bd4fde9e63 Fix #1992 handle invalid numbers of books seriesindex 2021-05-19 19:54:44 +02:00
Ozzie Isaacs c85cfa90a4 Update testresults on windows
Added encoding on fb2 upload
2021-05-19 19:21:09 +02:00
Ozzie Isaacs a0449b50c8 Downgrade flask -> to slow during reboot 2021-05-17 17:54:43 +02:00
Ozzie Isaacs 394b063b8c Fixes for caliblur theme 2021-05-16 13:25:29 +02:00
Ozzie Isaacs b62d84424e Merge remote-tracking branch 'comic/comic_viewer_changes' into master 2021-05-16 13:19:28 +02:00
Ozzie Isaacs 20b84a9459 Unified translations
Update translations for release
2021-05-16 09:37:45 +02:00
Ozzie Isaacs dafc68f049 Updated requirements 2021-05-16 09:03:47 +02:00
Ozzie Isaacs 4745fc0db1 Bugfix search for publish dates and custom column dates
Bugfix save umplauts in comments unescaped (as calibre does)
Improved testability
2021-05-15 07:51:32 +02:00
Ozzie Isaacs b009dfe4ee Always use bootstrap datepicker 2021-05-14 19:58:06 +02:00
Ozzie Isaacs eba94f430c Updated js libs 2021-05-14 09:29:24 +02:00
Ozzie Isaacs 06347b7e3c Bugfixes from testrun 2021-05-14 08:26:56 +02:00
Ozzie Isaacs 6bc426b21d Fix edit_books.js 2021-05-14 07:29:48 +02:00
Ozzie Isaacs 4a849aab7f Merge remote-tracking branch 'requirements/patch-1' into master 2021-05-13 16:28:54 +02:00
Ozzie Isaacs ad2d0c84e4 Update swedish translation 2021-05-13 16:28:02 +02:00
Ozzie Isaacs 6bf360fbfb Added "comments" type to supported custom columns 2021-05-13 14:00:01 +02:00
Ozzie Isaacs 380292a8aa Custom column datetime now searchable (#1984) 2021-05-13 13:31:36 +02:00
jonyxx-alt f9949da745 Update Swedish translation
Upload files that has been updated
2021-05-13 11:04:57 +00:00
Ozzie Isaacs b0cc52e0aa Enable custom column datetime (adv. search not working yet) #1984 2021-05-13 10:39:36 +02:00
Ozzie Isaacs 9ef705650b Access pages with stored order per default (#1987)
Fix for toggle-text of enable-sort button on shelf page
2021-05-13 09:41:27 +02:00
Ozzie Isaacs c6dadbe75e restrictions are now applied to kobo sync requests (Fix #1938) 2021-05-13 09:17:01 +02:00
Robert Schütz 21026340ad remove singledispatch from requirements
It's not used anywhere.
2021-05-05 14:30:00 +02:00
Ozzieisaacs 541c8c4b93 Improved error handling for disapearing custom column linked to visiblility restrictions 2021-05-01 20:52:48 +02:00
Ozzieisaacs b97373bf37 Improved error handling for disapearing custom column linked to read status 2021-05-01 18:42:57 +02:00
Ozzieisaacs c0b561cb5a Better input check for custom_columns 2021-05-01 17:10:29 +02:00
Ozzieisaacs bd3ccfd0a9 Merge remote-tracking branch 'cn/master' into master 2021-05-01 16:33:47 +02:00
Ozzieisaacs 5470acd3af Fix #1964 (RefreshError with unconfigured gdrive) 2021-05-01 12:45:28 +02:00
Ozzie Isaacs 64696fe973 Bugfixes edit user list (Fix #1938) 2021-05-01 08:36:39 +02:00
Ozzie Isaacs ed2fa4cdd8 Update error handling for user list (#1938) 2021-04-28 20:49:16 +02:00
dalin 03cca1d1c0 update Simplified Chinese 2021-04-28 16:15:21 +08:00
dalin 354b075885 Merge remote-tracking branch 'upstream/master' 2021-04-28 14:15:42 +08:00
Ozzie Isaacs de7f039b99 Update list user editor (#1938) 2021-04-27 20:01:17 +02:00
Ozzie Isaacs 19797d5d23 Merge remote-tracking branch 'it/patch-24' into master 2021-04-26 19:05:25 +02:00
Ozzie Isaacs 144c2b5fc7 Renaming ipadress - ip_address
Bugfix user table
Result testrun
Updated cn translation
2021-04-26 19:03:01 +02:00
GarcaMan 7da40d1c2e Added option to remove Y-Scrollbar and reset page scroll 2021-04-25 19:59:53 +00:00
Ozzie Isaacs 4e3a5ca33b Added additional debug messages, catch additional errors in updater 2021-04-25 11:30:53 +02:00
Ozzie Isaacs 97e4707f72 user list column value and tags editor (#1938)
Bugfixes for massedit in user list (#1938)
Changed no. of debug messages
2021-04-25 10:43:01 +02:00
Ozzie Isaacs 450ee43677 Additional logging for emails 2021-04-22 19:14:56 +02:00
Ozzie Isaacs c0b2e886d2 bugfix books list with selected books and stored on state 2021-04-21 19:28:22 +02:00
Ozzie Isaacs bb4749c65b Result for testrun
Added mass delete of users
refactores user table refresh
Bugfix for sorting with selected users
Bugfix delete books #1938
2021-04-21 19:23:56 +02:00
ElQuimm 5aa37c68a2 Updated version of italian.po
Thank you.
2021-04-19 10:11:26 +02:00
Ozzie Isaacs 6e5a1a1f4d Merge remote-tracking branch 'add_Babelio/patch-1' into master 2021-04-18 12:05:00 +02:00
Ozzie Isaacs b624ce16c3 Merge remote-tracking branch 'it/patch-23' into master 2021-04-18 12:04:08 +02:00
Ozzie Isaacs 3be5b5f919 Merge remote-tracking branch 'comic_reader/master' into master 2021-04-18 12:02:21 +02:00
Ozzie Isaacs 04ac5b69ac Further improvements on user list #1938 2021-04-18 12:01:11 +02:00
Ozzie Isaacs 9cc14ac5c7 Fix for #1905 prevent invalid json data in gmail_token 2021-04-18 11:33:14 +02:00
BuildTools 755eb1405b Fix progress bar direction 2021-04-18 04:25:45 +09:00
subdiox 0138294b36 Fix an issue that space key doesn't work intentionally when inverting reading direction 2021-04-18 03:20:41 +09:00
Ozzie Isaacs c0a4addf30 Cancel button in User edit now leads to the right page back #1938 2021-04-17 18:30:55 +02:00
Ozzie Isaacs 39bbee0eeb Books sort with non Books table column working #1938 2021-04-17 10:27:30 +02:00
Ozzie Isaacs 39dda3f534 Fix opds login with colon in password #1952 2021-04-15 18:02:52 +02:00
Ozzie Isaacs 1cb8dbe795 Update migration routine 2021-04-15 17:42:39 +02:00
Ozzie Isaacs e13820bbf0 Update exception upon migration of database #1935 2021-04-15 12:05:03 +02:00
malletfils 3973362457 Update db.py
Just adding support for Babelio (french website about books) in the link section
2021-04-14 19:57:02 +02:00
Ozzie Isaacs b38877e193 Document change 2021-04-13 19:47:55 +02:00
Ozzie Isaacs 0e1dbb5377 Copy author names for displaying (#1935) 2021-04-13 19:41:44 +02:00
Ozzie Isaacs f07cc8b103 Update optional-requirements: flask-dance
Catch error for invalid oauth tokens
Fixes for displaying error messages on deleting books from list
Fixes for displaying error messages on deleting bookformats
Removed non working sorting in books list
2021-04-13 19:26:10 +02:00
Ozzie Isaacs 67775bc797 Update requirements
Catch error for invalid oauth tokens
Fixes for displaying error messages on deleting books from list
Fixes for displaying error messages on deleting bookformats
2021-04-13 19:08:02 +02:00
ElQuimm 05933a5f0c Updated italian message.po
I have not removed the #, fuzzy lines, but modified the corresponding values.
2021-04-13 18:51:50 +02:00
Ozzie Isaacs d32b2ca524 Prevent traceback after delete user
flash message in case last admin role is removed #1938
2021-04-12 19:04:27 +02:00
Ozzie Isaacs d0a895628e Prevent delete of Guest user #1938 2021-04-12 18:45:44 +02:00
Ozzie Isaacs 90f2b3fb21 Refactored list checkbox sort 2021-04-12 18:39:09 +02:00
Ozzie Isaacs 0f95800dde Update sqlalchemy-utils dependency for oauth
Sort for state checkbox in user list and books list working
2021-04-12 18:23:25 +02:00
Ozzieisaacs 04971f8672 Bugfix wrong js file in user list 2021-04-11 20:01:40 +02:00
Ozzieisaacs b6177b27f4 Sorting of users in table according to selection possible 2021-04-11 19:59:20 +02:00
Ozzieisaacs ae97e87506 Delete user working from user table (#1938)
Comment in helper
2021-04-10 11:32:25 +02:00
Ozzie Isaacs 2d73f541c0 Bugfix sort books list and user list
Prevent transferring password hash to client
2021-04-08 19:37:08 +02:00
Ozzie Isaacs 7561eabe52 Implement Backend to deny editing Guest rights restriction #1938 2021-04-07 18:56:17 +02:00
Ozzie Isaacs 067fb1b0b7 Prevent delete Guest user and redirect to admin page after user delete 2021-04-07 18:47:48 +02:00
Ozzie Isaacs 78071841cc After Deleting a book the list page is still displayed #1938 2021-04-07 18:19:48 +02:00
Ozzie Isaacs fac232229e Added missing ead/unread category in user list #1938 2021-04-07 17:49:19 +02:00
Ozzie Isaacs a43021e87c Fix for #1938 2021-04-07 17:46:17 +02:00
Ozzie Isaacs 1a0de3b3cf Merge remote-tracking branch 'de_translation/patch-1' into master 2021-04-06 18:08:32 +02:00
Ozzie Isaacs 947154dc9c Merge branch 'development' into master 2021-04-06 18:06:25 +02:00
Ozzie Isaacs 8acd1f1fe4 Code refactoring and improved error handling for edit user list
Update teststatus
2021-04-06 17:29:42 +02:00
Ozzie Isaacs 665210e506 Fixes for book edit with title sort and author sort 2021-04-04 14:01:06 +02:00
Ozzie Isaacs 91b9370a21 Merge branch 'master' into development
# Conflicts:
#	cps/static/css/libs/bootstrap-table.min.css
#	cps/static/js/libs/bootstrap-table/bootstrap-table-editable.min.js
#	cps/static/js/libs/bootstrap-table/bootstrap-table.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-af-ZA.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ar-SA.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-bg-BG.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ca-ES.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-cs-CZ.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-da-DK.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-de-DE.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-el-GR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-en-US.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-AR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-CL.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-CR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-ES.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-MX.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-NI.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-SP.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-et-EE.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-eu-EU.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fa-IR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fi-FI.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr-BE.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr-CH.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr-FR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr-LU.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-he-IL.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hr-HR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hu-HU.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-id-ID.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-it-IT.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ja-JP.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ka-GE.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ko-KR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ms-MY.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-nb-NO.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-nl-BE.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-nl-NL.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pl-PL.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pt-BR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pt-PT.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ro-RO.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ru-RU.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sk-SK.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sr-Cyrl-RS.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sr-Latn-RS.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sv-SE.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-th-TH.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-tr-TR.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-uk-UA.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ur-PK.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-uz-Latn-UZ.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-vi-VN.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js
#	cps/static/js/libs/bootstrap-table/locale/bootstrap-table-zh-TW.min.js
2021-04-02 17:13:22 +02:00
Ozzie Isaacs ca0aa600b4 Bugfix german translation 2021-04-02 17:12:26 +02:00
Ozzie Isaacs 1c42c4c969 Update bootstrap-table
Fixes for book edit
2021-04-02 17:11:16 +02:00
Ozzie Isaacs 6e406311c3 Fix #1928 (ldap_import_user_filter missing in to_save) 2021-04-02 08:40:29 +02:00
robochud 87884c1af2 Update messages.po
very little typo
2021-03-31 00:56:12 +02:00
Ozzie Isaacs c0623a949c Merge remote-tracking branch 'caliblur/master' into master 2021-03-29 20:54:04 +02:00
cbartondock 42a23ea23c removed some dumb graphical inconsistencies 2021-03-29 14:35:48 -04:00
cbartondock 710c31d1ca Fixed book details not loading after infinite scroll 2021-03-29 14:13:22 -04:00
cbartondock f637ba4dad Fixed border display in book details 2021-03-29 13:52:09 -04:00
Ozzie Isaacs 80d2c60cef Update testresults 2021-03-29 18:03:09 +02:00
Ozzie Isaacs b17d71e4c3 Update optional-requirements.txt
Bugfix Mail task after convert task
2021-03-28 20:36:08 +02:00
Ozzie Isaacs 3c5bd3a605 Added gmail.json file to excluded file, added file also to excluded file during update 2021-03-28 15:01:56 +02:00
Ozzie Isaacs 7cc8d1e693 remove file 2021-03-28 14:58:07 +02:00
Ozzie Isaacs 99520d54a5 Added ability to send emails via gmail (#1905)
Gmail email sending
2021-03-28 14:51:01 +02:00
Ozzie Isaacs e10a8c078b Merge branch 'master' into development
# Conflicts:
#	cps/templates/email_edit.html
2021-03-27 18:36:11 +01:00
Ozzie Isaacs 7a196fed7c Prevent empty email port and server address(#1906) 2021-03-27 18:34:57 +01:00
Ozzie Isaacs c418c7e725 Prevent empty email from field (#1906) 2021-03-27 18:31:49 +01:00
Ozzie Isaacs e35748deff Fix wording and tabs 2021-03-27 17:30:54 +01:00
Ozzie Isaacs b57efbe31c Fix wording and tabs 2021-03-27 17:30:10 +01:00
Ozzie Isaacs 8f91437701 Implementation for gmail server with OAuth2 started 2021-03-27 16:36:24 +01:00
Ozzie Isaacs a7eb547ca4 Renamed brazilian datepicker file 2021-03-27 12:40:23 +01:00
Ozzie Isaacs 0ceb12f74f Renamed brazilian datepicker file 2021-03-27 12:40:01 +01:00
Ozzie Isaacs 4960624de7 Merge branch 'master' into development 2021-03-27 12:20:28 +01:00
Ozzie Isaacs 2c92f24d89 Added Brazilian translation 2021-03-27 12:20:07 +01:00
Ozzie Isaacs 0b7c679dba Changed test email message (fix #657) 2021-03-27 09:48:43 +01:00
Ozzie Isaacs aab3cdc58a Changed test email message 2021-03-27 09:47:43 +01:00
Ozzie Isaacs 3c63f5b204 Merge branch 'master' into development 2021-03-27 09:46:12 +01:00
Ozzie Isaacs 0b97bbf827 Merge remote-tracking branch 'div_a/use-kobo-for-download-link' into master 2021-03-27 09:39:44 +01:00
Ozzie Isaacs 970dbb0c59 Merge branch 'master' into development
# Conflicts:
#	cps/opds.py
#	cps/templates/admin.html
2021-03-27 09:38:12 +01:00
Ozzie Isaacs d21d3c2ceb Merge remote-tracking branch 'div_a/use-btn-anchors' into master 2021-03-27 09:33:28 +01:00
Ozzie Isaacs 0f6493b8ce Update Teststatus 2021-03-27 09:30:59 +01:00
Ozzie Isaacs f26beec1d3 Updated pdf reader 2021-03-25 18:57:40 +01:00
Ozzie Isaacs c4225e29ed Updated pdf reader 2021-03-25 18:57:25 +01:00
Ozzie Isaacs 9243326cd3 Updated testresult 2021-03-25 18:30:31 +01:00
Ozzie Isaacs 86beb8023a Downgrade sqlachemy, as it breaks oauth 2021-03-24 18:47:59 +01:00
Ozzie Isaacs f4e134742b Fix updater
Bugfixes from testruns
Update Testresults
2021-03-24 18:46:03 +01:00
Ozzie Isaacs 2b17bf4114 Update tests
Fixes upload book
2021-03-23 18:57:04 +01:00
Ozzie Isaacs c4f0fc8f7b Update tests
Fixes upload book
2021-03-23 17:57:49 +01:00
Ozzie Isaacs 3d6c836e7d Update tests 2021-03-23 17:39:51 +01:00
Gavin Mogan c279055af4 Use the kobo auth'd version for download link when proxied -- Fixes #1908 2021-03-22 18:08:41 -07:00
Gavin Mogan 657cba042a Use btn classes on anchors not div so the entire button is clickable 2021-03-22 17:25:38 -07:00
Ozzie Isaacs 7a58e48cae Bugfixes opds feed 2021-03-22 19:01:18 +01:00
Ozzie Isaacs 670eab62bf Update opds feed with letters for all titles, authors, categories and series 2021-03-22 17:46:15 +01:00
Ozzie Isaacs fc85586809 Bugfixes for sqlalchemy 1.4.0 2021-03-22 16:33:21 +01:00
Ozzie Isaacs 837fc4988d Letterize authors 2021-03-21 20:21:10 +01:00
Ozzie Isaacs 4664b47851 Fixed alphabetical order in list and grid view
Completed download section
2021-03-21 19:31:32 +01:00
Ozzie Isaacs 9864d932e0 Changed user.nickname to user.name
Added function to view downloads of all users for admins
2021-03-21 18:55:02 +01:00
Ozzie Isaacs 436f60caa9 refactored some functions 2021-03-21 14:17:07 +01:00
Ozzie Isaacs e9530eda9d Bugfix from refactoring 2021-03-21 13:46:13 +01:00
Ozzie Isaacs f4ddac16f9 Improved error logging for #1905 2021-03-21 11:58:51 +01:00
Ozzie Isaacs 33bdc07f55 Fix for #1845 (ods not working in Moonreader an Librera)
Fix opds search with wrong parameter no longer causes error 500
2021-03-21 11:57:42 +01:00
Ozzie Isaacs 130a4ed2d3 Fix opds and error logging in mail 2021-03-21 11:54:39 +01:00
Ozzie Isaacs 59ebc1af8a Code refactoring 2021-03-21 08:20:04 +01:00
Ozzie Isaacs 82e15d2e98 Merge branch 'master' into development
# Conflicts:
#	test/Calibre-Web TestSummary_Linux.html
2021-03-21 07:28:52 +01:00
Ozzie Isaacs 9c842f1895 Bugfixes pdf xmp parsing 2021-03-21 07:28:35 +01:00
Ozzie Isaacs 8cc849488b Code cosmetics 2021-03-21 07:15:38 +01:00
Ozzie Isaacs fcaa232967 Merge remote-tracking branch 'origin/master' into master 2021-03-21 07:11:37 +01:00
Ozzie Isaacs d3f8153b90 Merge branch 'master' into development 2021-03-20 19:34:16 +01:00
Ozzie Isaacs 99ecf22790 Merge remote-tracking branch 'origin/master' into master 2021-03-20 18:10:42 +01:00
Ozzie Isaacs b1b7ee65b4 Refactored advanced search 2021-03-20 18:10:27 +01:00
Ozzie Isaacs 6889456662 Merge remote-tracking branch 'adv_search/master' into master 2021-03-20 17:48:21 +01:00
Ozzie Isaacs 081553dc9f Disable blank issue templates 2021-03-20 16:27:47 +01:00
Ozzie Isaacs 5d8d796807 Compatibility for sqlalchemy 2.0 2021-03-20 10:09:08 +01:00
Ozzie Isaacs f3d88fc746 Update sqlalchemy 1.4 working 2021-03-20 09:31:29 +01:00
Ozzie Isaacs d87ccae6c9 Merge branch 'master' into development
# Conflicts:
#	cps/server.py
#	test/Calibre-Web TestSummary_Linux.html
2021-03-19 20:33:38 +01:00
Ozzie Isaacs 2760a7816d Fix metadata recognition fb2 files 2021-03-19 20:32:15 +01:00
Ozzie Isaacs 8f5c649d0f Updated dependency comicapi (removed pypdf2)
Updated dependency pyPDF2 ->pyPDF3
Fixed broken updater in case of http error
Bugfixes from testrun
Bugfix load cover for BasicMetadata
2021-03-19 13:35:52 +01:00
Ozzie Isaacs fcf9e7a1ef Upload pdf fixes:
Handle no title
Handle no author
Fix import of more than one language
Add missing pdf upload publisher handling
2021-03-17 19:06:51 +01:00
Ozzie Isaacs 2be7b6480a Merge remote-tracking branch 'pdf/XMP_Metadata3' into master 2021-03-17 19:05:26 +01:00
cbartondock f5ded86c02 removed extraneous logs 2021-03-16 19:18:57 -04:00
rra 8abfaf0ffd Parse XMP metadata in separate function, add exception, try multiple metadata formats 2021-03-16 17:53:33 +01:00
Ozzie Isaacs b070ba142f Selects are working in user management with generic confirm dialog 2021-03-16 15:52:31 +01:00
Ozzie Isaacs bd7c6828bf Selects are working in user management 2021-03-16 15:03:38 +01:00
cbartondock d0671ec58c Merge branch 'master' of https://github.com/janeczku/calibre-web 2021-03-15 21:09:51 -04:00
cbartondock 1e40ffd1cc merge changes 2021-03-15 21:08:41 -04:00
Ozzie Isaacs da2c3e9ed7 Edit user mass change checkbox working 2021-03-15 16:46:27 +01:00
Ozzie Isaacs f62d6abb69 Merge branch 'master' into development
# Conflicts:
#	cps/server.py
#	test/Calibre-Web TestSummary_Linux.html
2021-03-15 13:53:23 +01:00
Ozzie Isaacs 12ad7a6322 Suppress some errors 2021-03-15 13:52:44 +01:00
Ozzie Isaacs b75247ea3a Suppress some errors 2021-03-15 13:48:05 +01:00
Ozzie Isaacs 9a963bbe79 Refactored code
Testrun
2021-03-15 13:10:17 +01:00
Ozzie Isaacs 994bc8b0e4 Removed dropdown button on single file listen/read (Fix #1840) 2021-03-15 09:06:40 +01:00
Ozzie Isaacs 2451605033 Merge remote-tracking branch 'djvu/read-djvu' into master 2021-03-15 08:43:25 +01:00
Ozzie Isaacs 10942527f3 Merge branch 'master' into development
# Conflicts:
#	test/Calibre-Web TestSummary_Linux.html
2021-03-15 08:22:12 +01:00
Ozzie Isaacs 4909ed5ccd Merge remote-tracking branch 'cliblur/master' into development
# Conflicts:
#	cps/static/css/style.css
2021-03-15 08:21:44 +01:00
Ozzie Isaacs 5cf5df68dc Merge remote-tracking branch 'cliblur/master' into master 2021-03-15 08:19:56 +01:00
Ozzie Isaacs dd32cc99ea Merge remote-tracking branch 'es/patch-1' into master 2021-03-15 08:17:14 +01:00
Ozzie Isaacs 79092dc8eb Merge remote-tracking branch 'it/patch-21' into master 2021-03-15 08:11:41 +01:00
Ozzie Isaacs 6229e4610a Updated teststatus and bugfix convert ebooks 2021-03-15 08:10:42 +01:00
Northguy bfe36d3f4a change in color definition
Making color the same as in:
.container-fluid .book .meta .author, .container-fluid .book .meta .author > a {
    color: hsla(0, 0%, 100%, .45)
}
2021-03-15 00:12:02 +01:00
Northguy d42bf44fad Added same color for series name and series number 2021-03-14 23:46:33 +01:00
rra 33e352819c Merge remote-tracking branch 'upstream/master' into XMP_Metadata3 2021-03-14 19:58:26 +01:00
Ozzie Isaacs 53ee0aaee1 Some functions refactored 2021-03-14 17:34:47 +01:00
Ozzie Isaacs 42707a19bd Code cosmetics 2021-03-14 16:57:33 +01:00
Ozzie Isaacs 0888706790 Code cosmetics 2021-03-14 16:53:01 +01:00
Ozzie Isaacs 16453a05f8 Code cosmetics 2021-03-14 16:02:37 +01:00
Ozzie Isaacs 2fbb7466d3 Code cosmetics 2021-03-14 15:44:40 +01:00
Ozzie Isaacs f29f94f45f Code cosmetics 2021-03-14 15:41:36 +01:00
Ozzie Isaacs cd973868fc Code cosmetics 2021-03-14 15:29:34 +01:00
Ozzie Isaacs 3c35f02cac Code cosmetics 2021-03-14 15:18:45 +01:00
Ozzie Isaacs 22c93e2389 Merge branch 'master' into development 2021-03-14 15:06:20 +01:00
Ozzie Isaacs 8c751eb532 Some code cosmetics 2021-03-14 15:06:09 +01:00
Ozzie Isaacs 4df443e007 Some code cosmetics 2021-03-14 14:40:04 +01:00
Ozzie Isaacs f52fa41439 Fix restart server
Some code cosmetics
2021-03-14 14:29:40 +01:00
Ozzie Isaacs f77d72fd86 Merge branch 'master' into development
# Conflicts:
#	cps/static/css/style.css
2021-03-14 14:06:33 +01:00
Ozzie Isaacs 9b80c84794 Some code cosmetics 2021-03-14 14:05:36 +01:00
Ozzie Isaacs 725fc658f8 Some code cosmetics 2021-03-14 13:28:52 +01:00
Ozzie Isaacs e4e27662f5 Merge remote-tracking branch 'url/patch-1' into master 2021-03-14 08:35:37 +01:00
cbartondock 83474da7b5 fixed being able to click through dropdown in advanced search results 2021-03-07 22:54:34 -05:00
cbartondock 9146e5f287 fixed advanced search mass add to shelves in caliblur 2021-03-07 19:53:54 -05:00
cbartondock ff4502c63a Made shelf search user specific 2021-03-07 15:23:05 -05:00
cbartondock 9711bd8fe1 added actions boxes to drop downs 2021-03-06 22:34:39 -05:00
cbartondock 05139e53be advanced shelf search is working 2021-03-06 22:15:18 -05:00
cbartondock 870b2642a9 advanced shelf search is almost working 2021-03-06 21:54:39 -05:00
ElQuimm d31b26ae7d Updated italian message.po
Have a nice day.
2021-03-04 14:26:36 +01:00
Zaroz 5511925ba2 Removed elif "url" identifier format type
Removed elif "url" identifier format type, since else output is identical
2021-03-03 21:18:08 -06:00
Angel Docampo f96b20717d Updated spanish messages.po
Corrected a grammatical error
2021-03-04 00:01:03 +01:00
Zaroz 940c9c45d7 Updated db.py
changed __repr__ else statement to allow for custom id entries
2021-03-02 23:46:02 -06:00
Ozzie Isaacs 87d6008dfc Fix for #1870 (png was missing in supported picture formats for comic viewer) 2021-02-27 09:23:34 +01:00
Ozzie Isaacs b9c0c8d2dc Update bootstrap table to 1.18.2 2021-02-20 20:03:39 +01:00
Ozzie Isaacs 81c30d5fd5 Add missing files from bootstrap editable
Added user-table single-select header for locale and default-language
2021-02-20 19:55:51 +01:00
Ozzie Isaacs 0aa33d88a5 Merge branch 'master' into development 2021-02-20 14:19:39 +01:00
Ozzie Isaacs e64a504bb1 Working Locale and default language selection in user table edit 2021-02-20 14:18:27 +01:00
jvoisin bc876a159e Declare variables before using them
It should fix the following stacktrace:

```
[2021-02-18 14:46:14,771] ERROR {cps:1891} Exception on / [GET]
Traceback (most recent call last):
  File "/opt/calibre/vendor/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/calibre/vendor/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/calibre/vendor/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/calibre/vendor/flask/_compat.py", line 39, in reraise
    raise value
  File "/opt/calibre/vendor/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/calibre/vendor/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/calibre/cps/usermanagement.py", line 38, in decorated_view
    return login_required(func)(*args, **kwargs)
  File "/opt/calibre/vendor/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/opt/calibre/cps/web.py", line 719, in index
    return render_books_list("newest", sort_param, 1, page)
  File "/opt/calibre/cps/web.py", line 422, in render_books_list
    entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books, True, order)
  File "/opt/calibre/cps/db.py", line 610, in fill_indexpage
    return self.fill_indexpage_with_archived_books(page, pagesize, database, db_filter, order, False, *join)
  File "/opt/calibre/cps/db.py", line 635, in fill_indexpage_with_archived_books
    #    book = self.order_authors(book)
UnboundLocalError: local variable 'entries' referenced before assignment
```
2021-02-18 17:02:58 +01:00
Ozzieisaacs 4aa1a838ed Removed f-strings, making it compatible with python 3.5 2021-02-15 14:17:05 +01:00
Ozzieisaacs 095a51edd0 Convert tabs to spaces in server.py (related to #1862) 2021-02-15 13:33:42 +01:00
Ozzie Isaacs a3a11bdf3f Changed checkbox states are saved on server 2021-02-14 17:49:40 +01:00
Ozzie Isaacs 70b503f3d4 Merge branch 'master' into development
# Conflicts:
#	test/Calibre-Web TestSummary_Linux.html
2021-02-13 14:36:42 +01:00
Ozzie Isaacs bbf609b880 Fix #1859 (Upload of jpg files without installed imagemagick doesn't work) 2021-02-13 14:34:41 +01:00
Ozzie Isaacs 0992bafe30 Bulk User management 2021-02-13 13:17:02 +01:00
Ozzie Isaacs c810c5275a Merge branch 'master' into development 2021-02-09 18:05:32 +01:00
Ozzie Isaacs 3c1b06872d Updated testresults
Changed optional-requirements
Prevent redirect 308 on /<data> routes (#1854)
2021-02-09 18:04:56 +01:00
Ozzie Isaacs cefdd2f66c suppress asyncio message always on restart or shutdown 2021-02-08 20:39:21 +01:00
Ozzie Isaacs 5dac13b1da Revert change in ub.py 2021-02-08 20:17:02 +01:00
Ozzie Isaacs 8aebf48193 Update handling for package data 2021-02-08 20:09:36 +01:00
Ozzie Isaacs fbb905957b Prevent redirect 308 on /<data> routes 2021-02-08 20:09:36 +01:00
Ozzie Isaacs e0ce135838 Move "create_engine" call 2021-02-08 20:09:36 +01:00
Ozzie Isaacs 60497c60c1 Update creating Home_Config variable for packaging support, added .HOMEDIR to ignored filename during update 2021-02-07 09:20:37 +01:00
Ozzie Isaacs 251a77c8b4 Merge branch 'master' into Development
Improved packaging support
2021-02-07 08:54:29 +01:00
Ozzie Isaacs 7b7494b8a4 Added executable folder to gitignore 2021-02-06 21:42:29 +01:00
Ozzie Isaacs 9390dcdd43 Update optional requirements 2021-02-06 11:33:20 +01:00
Ozzie Isaacs e6fb460071 New restart routine for executable files
Fix log in updater
New source option updater available
2021-02-06 09:42:27 +01:00
Ozzie Isaacs 6137fdeb33 Version bump 2021-02-02 19:11:02 +01:00
Ozzie Isaacs 4a4d02ea6a Added translations 2021-02-02 19:04:55 +01:00
Ozzie Isaacs be26e5f152 Update Teststatus
Update Version
2021-02-02 18:52:31 +01:00
Ozzie Isaacs 127bfba135 fix wrong path in get_update_status js function 2021-02-01 19:00:10 +01:00
Ozzie Isaacs 7efae3c125 Renamed "Recently Added" to "Books" 2021-01-31 19:20:43 +01:00
Ozzie Isaacs 1e5af21000 Fix #1843 (get path to script via html file and known js file instead of randomly picking last one) 2021-01-31 19:01:34 +01:00
Ozzie Isaacs 33a0a4c173 Changed function for getting path in js file 2021-01-31 18:55:32 +01:00
Ozzie Isaacs eeb7974e05 User table:
Added button for single user edit
Added delete-trash-icon (not working)
Roles are displayed correct per user
Guest user is not visible if anonymous browsing is disabled
2021-01-31 14:54:45 +01:00
Ozzie Isaacs f45ea1a31c Merge branch 'master' into development 2021-01-31 13:21:47 +01:00
Ozzie Isaacs a866dbaa80 Fix mimetype in comic reader 2021-01-31 11:21:09 +01:00
Ozzie Isaacs 62447d6b89 Basic User edit in tables 2021-01-31 10:17:57 +01:00
Ozzie Isaacs 93f0724b83 Merge branch 'development' into master 2021-01-31 09:11:35 +01:00
Ozzie Isaacs 724762843d Update Teststatus 2021-01-31 09:10:42 +01:00
Ozzie Isaacs ff16afbf0b Merge branch 'master' into development 2021-01-30 17:55:45 +01:00
Ozzie Isaacs 9d7ef25062 Fix Kobo sync & Update Teststatus 2021-01-30 17:55:17 +01:00
Ozzie Isaacs 88078d65e9 Fix #1482 (do not shorten title in book detail page) 2021-01-30 14:57:59 +01:00
Ozzie Isaacs b07a97c17e Merge remote-tracking branch 'webp/comic-webp' into master 2021-01-30 14:56:26 +01:00
Ozzie Isaacs 41e7d65e2a Merge remote-tracking branch 'caliblur/master' into master 2021-01-30 14:54:16 +01:00
Ozzie Isaacs 7fa5865cf6 Merge remote-tracking branch 'autoconv/kepub_autoconv' into development
# Conflicts:
#	cps/kobo.py
#	cps/kobo_auth.py
2021-01-30 14:47:18 +01:00
Ozzie Isaacs e0b8fe3b1a Merge branch 'master' into development 2021-01-30 14:41:46 +01:00
Ozzie Isaacs 4a11dd1e16 Fix mistyping "option" 2021-01-28 20:20:59 +01:00
Ozzie Isaacs 34a474101f Fix #1838 (Log message on failed OPDS login) 2021-01-28 20:05:58 +01:00
Ozzie Isaacs e6799e7a04 Improved detection of invalid email addresses (#1831) upon registering 2021-01-27 19:18:40 +01:00
Ozzie Isaacs 0f83f9992c Added swipe support for epub reader (fixes #925)
Cleaned reader js include files
2021-01-24 14:19:46 +01:00
Ozzie Isaacs d2ad78eb40 Added swipe support for comic reader and txt reader (#925)
Bugfix for txt file not present on serving file
2021-01-24 11:28:17 +01:00
Ozzie Isaacs 0b32738f4e Fix Store UI settings in flask session for guest user (#1820)
Updated testresults
Fix Filepicker (absolute instead of abs)
2021-01-24 07:31:40 +01:00
Ozzie Isaacs a9cedb3fca Add logger to db.py 2021-01-23 13:35:30 +01:00
Ozzie Isaacs 51f9cd4bb4 Fix english language names 2021-01-18 21:24:13 +01:00
Ozzie Isaacs a1668e2411 Version Bump 2021-01-17 16:37:54 +01:00
Ozzie Isaacs 9418045a2c Updated Translation
Version bump
Fixed errors in requirements file(s)
2021-01-17 16:28:28 +01:00
Ozzie Isaacs a7da6d210a Added hint for python 2 2021-01-17 10:30:56 +01:00
chbmb 59a41dc844 Correct name for LinuxServer
Nothing important, but it's LinuxServer not Linuxuser.
2021-01-17 09:54:16 +01:00
Ozzie Isaacs e09f2c9beb Added Password change on cli 2021-01-17 09:17:46 +01:00
Ozzie Isaacs 4bc3c8d9ac Added missing mimetype (fix #1811) 2021-01-17 07:54:28 +01:00
Ozzie Isaacs 9acea8adf4 Fixed logging of exception in debug_or_exception handler for python version <3.8 2021-01-12 20:51:49 +01:00
Ozzie Isaacs e5f754ed0e improved session handling 2021-01-11 14:18:01 +01:00
Ozzie Isaacs 263a8f9048 Added catching of missing invalid_request 2021-01-10 14:57:54 +01:00
Ozzie Isaacs 6f9e52792a No autoflush on metadata.db change 2021-01-10 11:01:54 +01:00
Ozzie Isaacs 4a9b01e93b Added IntegrityError to catched error 2021-01-10 10:23:14 +01:00
Ozzie Isaacs b7de23e895 Merge remote-tracking branch 'fix/unused_imports' into master 2021-01-10 10:18:01 +01:00
Ozzie Isaacs f358f78da8 Merge remove duplicate ids 2021-01-10 10:16:58 +01:00
jvoisin b8ab66369e Remove some unused imports 2021-01-07 17:59:08 +01:00
jvoisin 54a78d5565 Remove duplicate id from the search form 2021-01-07 17:40:18 +01:00
mmonkey b4324cd685 Merge remote-tracking branch 'upstream/master' into master 2021-01-04 12:24:11 -06:00
Ozzieisaacs ca212c8737 Kobo sync limit set to 100
Remove python2 support from readme
2021-01-04 18:45:47 +01:00
Ozzieisaacs 6fe4ed3e24 Merge branch 'master' into Develop 2021-01-03 19:28:12 +01:00
Ozzieisaacs a659f2e49d Improved logging for emails
Removed private data from debug export
2021-01-03 19:27:34 +01:00
OzzieIsaacs 760fbbb357 Fix shelf time_created vs. time_last_modified 2021-01-03 16:41:38 +01:00
OzzieIsaacs 56388145b5 Fixes from testrun 2021-01-03 15:40:17 +01:00
Ozzieisaacs cd60db417c Code refactor shelf handling 2021-01-03 11:53:06 +01:00
Ozzieisaacs 5cce01215f Code refactoring ub.session.commit()
Code cosmentics admin.py
2021-01-03 09:53:34 +01:00
mmonkey bc8bdfe385 Merge remote-tracking branch 'upstream/master' into master 2021-01-02 20:21:15 -06:00
Ozzieisaacs 4578af7a6d Fix export of logfiles (#1794) 2021-01-02 20:38:11 +01:00
Ozzieisaacs 9e1cdd8f57 Merge remote-tracking branch 'it/patch-20' into master
# Conflicts:
#	cps/translations/it/LC_MESSAGES/messages.po
2021-01-02 19:37:59 +01:00
OzzieIsaacs 682c3b834f Revert unrar5 experiment 2021-01-02 15:32:06 +01:00
OzzieIsaacs e269bab186 Merge branch 'Develop' into master 2021-01-02 14:54:43 +01:00
OzzieIsaacs 33a89c5d89 Updated test status on Linux 2021-01-02 14:54:10 +01:00
Ozzie Isaacs 139047b22b Updated test status on windows 2021-01-02 14:16:33 +01:00
OzzieIsaacs 9b50114852 Fixes from testrun 2021-01-02 07:51:55 +01:00
Ozzieisaacs b100d198e8 Merge branch 'master' into Develop
Remove relate to referrer for tag/custom column allow / deny dialog
2020-12-31 15:12:37 +01:00
Ozzieisaacs 7849f2fb4b Remove relate to referrer for tag/custom column allow / deny dialog 2020-12-31 15:08:56 +01:00
Ozzieisaacs b35ecddde3 Added Id on Filechooser dialog for testability 2020-12-31 09:54:40 +01:00
Ozzieisaacs bde7921016 Fix modal path id for calibre db filepicker
Fix SyncToken last-Book-id missing
2020-12-30 10:05:15 +01:00
Ethan Lin ee28e3346b Merge pull request #21 from janeczku/master
merge from janeczku/master
2020-12-29 10:31:41 +08:00
Ozzieisaacs d33b0587cb Advanced search tags are now multiselects (#1240) 2020-12-28 13:44:17 +01:00
Ozzieisaacs 7e0ed537b7 irst steps Advanced search with mulitselects 2020-12-27 19:12:27 +01:00
Ozzieisaacs 1e351eb01d Search for read status 2020-12-27 18:59:33 +01:00
Ozzieisaacs 1a83bddf8c Merge bubble read status 2020-12-27 13:53:21 +01:00
Ozzieisaacs 2a63c35743 Activate serverside filepicker with parameter in unconfigured state 2020-12-27 11:27:15 +01:00
Ozzieisaacs 27dcbcd7e1 paged and orderable shelfs
Fix for non writable settings db with non configured calibre-web
2020-12-27 10:24:51 +01:00
mmonkey 0cf4c7b7b7 Merge remote-tracking branch 'upstream/master' into master 2020-12-24 03:01:55 -06:00
ElQuimm 623372387d Update italian message.po
Merry Christmas and Happy Holidays :-)
2020-12-23 13:45:19 +01:00
OzzieIsaacs abf0f4d699 Updated Testresult
Fixed delete book call
2020-12-23 10:08:54 +01:00
Ozzieisaacs 2bea447de5 Fix show archived books 2020-12-23 09:07:49 +01:00
Ozzieisaacs f6538b6110 New delete user button
refactored confirm dialogs
2020-12-21 19:50:12 +01:00
Ozzieisaacs 2d3ae71a3d Fixed button for email config (Fix #1766) 2020-12-21 19:13:55 +01:00
Ozzieisaacs 9a20faf640 Revert accidentally deleted lines in caliblur! theme 2020-12-17 19:10:02 +01:00
andylizi 123493ee59 Fix #1255 (support webp in comic viewer) 2020-12-17 23:54:06 +08:00
mmonkey 2d498dd138 Preserve publisher links, and fix formatting in custom columns for CaliBlur theme. 2020-12-16 00:58:45 -06:00
Ozzieisaacs 376214e2d2 Pinned greenlet to 0.4.16 max 2020-12-13 18:33:20 +01:00
Ozzieisaacs 62da469fd1 Shelfs are now paginated (sorting buttons are disabled)
Changed gevent dependencys
2020-12-13 18:32:44 +01:00
Ozzieisaacs d64009e23e preparation for filtered and ordered shelfs 2020-12-13 13:54:09 +01:00
Ozzieisaacs fd8b642d64 Code cosmetics css
Code cosmetics js
Fixes for links with remote_login
2020-12-13 09:53:18 +01:00
OzzieIsaacs d5ed5cd665 Fixes from tests 2020-12-12 15:16:22 +01:00
OzzieIsaacs fa95d064ff Fix get_sidebar_config 2020-12-12 12:03:11 +01:00
Ozzieisaacs 1905e0ee6f refactoring to prevent web.py being the middle of the universe 2020-12-12 11:23:17 +01:00
Ozzieisaacs 96b18faea1 Merge remote-tracking branch 'nl/master' into master 2020-12-12 10:06:16 +01:00
Ozzieisaacs 0d7f2e157a Update Download Debug package
- include config
- bugfix for stream logger
2020-12-12 10:02:11 +01:00
Marcel 2d66936d8b NL translation update
NL translation update
2020-12-12 09:24:01 +01:00
Ozzieisaacs b637a63e71 Refactored exception logging 2020-12-12 08:11:00 +01:00
Ozzieisaacs 1ae778d81e Fix #1753 (errorhandling on route serve_book) 2020-12-12 06:49:44 +01:00
Ozzieisaacs f4412ee96b Fix #1753 (errorhandling on route serve_book) 2020-12-12 06:41:12 +01:00
Ozzieisaacs 9130aceb5a Changed admin page 2020-12-11 20:55:09 +01:00
Ozzieisaacs b8336c03c3 Changed admin page 2020-12-11 20:54:24 +01:00
Ozzieisaacs 76c3ade394 Changed logging in worker thread 2020-12-11 17:03:18 +01:00
Ozzieisaacs d9b22fd513 log exceptions only in debug mode 2020-12-11 16:46:02 +01:00
Ozzieisaacs 88ea998f8b Only register gdrive callback if gdrive is enabled
With enabled gdrive return on change if no watch callback is configured, instead of send request to google drive
2020-12-11 15:56:42 +01:00
Ozzieisaacs 8b605aeaa8 Only register gdrive callback if gdrive is enabled 2020-12-11 15:53:10 +01:00
Ozzie Isaacs db91577485 Use calibre-web folder in tempdir on upload cover and metadata backup
fix upload cover on windows (slash vs. backslash)
2020-12-11 13:34:29 +01:00
Ozzie Isaacs 5d9404863d Fix detection and removal of metadata.db ending in calibre-directory
Update requirements
2020-12-11 09:11:17 +01:00
Ozzieisaacs d3986ca14a Server side file browser 2020-12-11 08:37:37 +01:00
Ozzieisaacs 2508c1abb2 Started implement server side filechooser 2020-12-10 14:41:45 +01:00
OzzieIsaacs 983e3b2274 Bugfix allowed formats for comics
Bugfix editing archived books
2020-12-09 19:02:10 +01:00
Ozzieisaacs 72a02e087c Update optional pydrive requirement
Bugfix cover url download for Wand insted of Pillow
Fix for gdrive with unknown certificates
2020-12-09 15:14:08 +01:00
Ozzieisaacs 352b4a0b73 Remove Pillow as dependency 2020-12-09 14:18:39 +01:00
Ozzieisaacs d957b2d20f Fix detect correct encoding for txt-reader 2020-12-09 11:04:29 +01:00
Ozzieisaacs dcab8af8ab Fixes for kobo sync 2020-12-09 09:41:23 +01:00
OzzieIsaacs e1987c34d9 Revert expire on commit 2020-12-09 08:49:18 +01:00
OzzieIsaacs a80a8aab1c Fix LDAP import user 2020-12-08 20:13:36 +01:00
OzzieIsaacs d6fbcdb09d Fix merge problem (ub prefix in ub.py) 2020-12-08 13:56:17 +01:00
OzzieIsaacs d39b28b011 Fix for existing book format with gdrive 2020-12-08 13:34:15 +01:00
OzzieIsaacs 8f36128fe3 Merge branch 'session' into Develop 2020-12-08 11:49:39 +01:00
OzzieIsaacs 986d4c99bd Fix oauth ub session 2020-12-08 11:24:20 +01:00
Ozzieisaacs f677dcb1f4 Fix missing optional parameter initSession 2020-12-08 08:19:18 +01:00
Ozzieisaacs 1a9b220ec2 Session no longer expires on commit (only in worker thread) 2020-12-08 08:04:46 +01:00
Ozzieisaacs d15d252af7 Session no longer expires on commit 2020-12-08 08:01:42 +01:00
Ozzieisaacs 5e3618716d Fix missing session rollback on commit error 2020-12-07 19:53:34 +01:00
Ozzieisaacs f13522559d Fixed problems on startup with config session 2020-12-07 13:51:52 +01:00
Ozzieisaacs 777c2726d3 Changed session_handing 2020-12-07 08:52:52 +01:00
Ozzieisaacs c25afdc203 Chunked sync 2020-12-06 13:21:25 +01:00
Ozzieisaacs c25f6d7c38 Prefer kepub in kobo sync 2020-12-06 06:01:10 +01:00
Ozzieisaacs 388e46ee81 Merge remote-tracking branch 'prefer_kepub/prefer-kepub' into master (send kepub instead of epub) 2020-12-06 05:57:56 +01:00
Ozzieisaacs 242866948f Merge branch 'master' into Develop 2020-12-05 08:34:12 +01:00
Ozzieisaacs 15bb0ce990 Fix for #1439 (send kepub file instead of epub for kobo epub3 request)
Fix archived books are editable
2020-12-04 19:23:36 +01:00
Ozzieisaacs a82911ea5d Fixed missing variable exception 2020-12-04 14:50:34 +01:00
Ozzieisaacs 9a8f20317b Update ldap import user -> improve error messages 2020-12-04 11:13:39 +01:00
Ozzieisaacs b605a0f622 Update error message LDAP import user 2020-12-03 21:25:02 +01:00
Ozzieisaacs 046a074c3a Catch attribute error on ldap import user
Fixes for Login with Windows AD
2020-12-03 20:15:31 +01:00
Ozzieisaacs 7c96fac95c Removed unnecessary parameters 2020-12-03 17:33:30 +01:00
Ozzieisaacs a3ef53102d Fix warning message on ldap import 2020-12-03 17:08:51 +01:00
Ozzieisaacs 68513b775b Wording 2020-12-03 16:20:31 +01:00
Ozzieisaacs a79dcc93f6 Fixed description for LDAP filter 2020-12-03 16:19:42 +01:00
Ozzieisaacs 7aabfc573b Merge branch 'master' into Develop
# Conflicts:
#	cps/admin.py
#	cps/config_sql.py
#	cps/templates/config_edit.html
#	cps/web.py
2020-12-03 16:03:37 +01:00
Ozzieisaacs 22dde5d18e Merge remote-tracking branch 'ldap_import/feat/ldap-import-user-identifier' into Develop
# Conflicts:
#	cps/admin.py
2020-12-03 16:02:38 +01:00
Ozzieisaacs 56505457eb Merge remote-tracking branch 'ldap_import/feat/ldap-import-user-identifier' into master
# Conflicts:
#	cps/admin.py
2020-12-03 16:01:15 +01:00
Ozzieisaacs 5930c6d5fb remove parenthesis in LDAP Message 2020-12-03 14:22:37 +01:00
Ozzie Isaacs 6b162a4e49 Updated windows testresult 2020-12-03 11:36:40 +01:00
Ozzieisaacs c3b9888b31 Fix #1739 (opds download with anonymous browsing enabled) -> download rights of guest user are now respected again 2020-12-03 09:42:41 +01:00
Ozzieisaacs cb8dfdde4c Fix #1739 (opds download with anonymous browsing enabled) 2020-12-03 08:25:36 +01:00
OzzieIsaacs ff5d333fc8 Updated testresult 2020-12-02 18:23:28 +01:00
Ozzieisaacs 8eb4b6288a Added id's for testablility 2020-12-02 18:19:30 +01:00
Ozzieisaacs f18836be90 Fix for #1435 (download not allowed with for opds links, with ldap login and a cookie in the download request) 2020-12-02 14:19:49 +01:00
Ozzieisaacs 3372070a58 Fix change title regex
Merge branch 'Develop' into master
2020-12-02 11:09:55 +01:00
Ozzieisaacs f99e2ebd13 Changed wording for tooltips 2020-12-02 09:08:56 +01:00
Ozzieisaacs 4feb26eefb Added series order option (#1715)
Added authors order option (#1301)
Added tooltips for ordering options
Fixed ratings, formats, languages order option
2020-12-01 14:51:25 +01:00
Ozzieisaacs 2da7cd2064 Merge remote-tracking branch 'it/patch-18' into master 2020-12-01 14:11:25 +01:00
Ozzieisaacs 9d7daf7afd Kobo links to /v1/products/books/external are responded
Merge remote-tracking branch 'kobo/patch-1' into master
2020-12-01 14:03:03 +01:00
Ozzieisaacs cb1ebc1cd0 Drag 'n drop for files 2020-12-01 13:52:41 +01:00
Ozzieisaacs 6ad56a0859 Merge branch 'master' into Develop 2020-11-30 18:37:14 +01:00
Ozzieisaacs 8515781564 Fix #1727 (import rarfile 4.0 fails on python3.5) 2020-11-30 18:36:45 +01:00
ElQuimm 7e2bfbd255 update italian message.po
some minors changes.
2020-11-26 14:35:15 +01:00
Jennifer Thakar e2325f7ba4 Forward Overdrive requests to Kobo Store
When loading books from OverDrive, Kobo readers make requests to `/v1/products/books/external/<overdrive ids>`.
This adds a route to forward these requests to the Kobo Store, so that OverDrive still works when using Calibre-Web's Kobo sync server.
2020-11-22 15:06:37 -08:00
OzzieIsaacs 9afdab8c52 Fix from merge convert_from _to 2020-11-22 11:57:10 +01:00
Ozzieisaacs f620d4a9ca Fix LDAP errors 2020-11-22 11:19:14 +01:00
Ozzieisaacs fb1e763bbe Fix browser caching problem on change cover 2020-11-22 10:07:25 +01:00
Ozzieisaacs ecea7e7493 Revert "Fix browser caching problem on change cover"
This reverts commit b9536812f4.
2020-11-22 10:06:54 +01:00
Ozzieisaacs 560ade00b4 Fix browser caching problem on change cover 2020-11-22 10:03:10 +01:00
Ozzieisaacs 81ea24ad54 Merge branch 'master' into df 2020-11-22 09:34:11 +01:00
Ozzieisaacs 747b25046a Merge branch 'master' into Develop 2020-11-22 09:16:27 +01:00
Ozzieisaacs b9536812f4 Fix browser caching problem on change cover 2020-11-22 09:09:41 +01:00
Ozzieisaacs eed2f0a430 Merge remote-tracking branch 'comic/master' into master 2020-11-22 08:45:02 +01:00
Ozzieisaacs 31fe8cd263 Improvement for #1721 (shrinked generic cover) 2020-11-22 08:28:52 +01:00
Ozzieisaacs a3fadbaa1a Shrinked size of generic cover 2020-11-22 08:28:10 +01:00
Ozzieisaacs e2be655d74 Update LDAP, fix Windows AD login (#1697) 2020-11-22 08:17:00 +01:00
Ozzieisaacs 2cd653c773 Merge remote-tracking branch 'origin/Develop' into Develop 2020-11-22 08:08:57 +01:00
Ozzieisaacs 6538aff02f Merge branch 'master' into Develop 2020-11-22 08:08:27 +01:00
OzzieIsaacs c1e3dec9be Limit max requests version to 2.25 (testing problem) 2020-11-21 17:21:18 +01:00
Ozzieisaacs 42c13ae135 Fix for #1718 (fetch of metadata from google without cover leads to exception) 2020-11-20 20:35:07 +01:00
Ozzieisaacs 9bd51c650b Add config options for client certificate authentication 2020-11-20 19:47:50 +01:00
Ozzieisaacs ba1c1c87c4 Merge remote-tracking branch 'kobo/feature/use-kobo-specific-download-urls' into Develop 2020-11-20 19:47:25 +01:00
Ozzieisaacs ceefba2743 Fix for #1550 (password prompt for LDAP and anonymous browsing) 2020-11-15 17:16:01 +01:00
Ozzieisaacs 70da46b05e Merge branch 'master' into Develop 2020-11-15 16:15:02 +01:00
Ozzieisaacs 32b7b39223 Added function to download debug information 2020-11-15 14:25:27 +01:00
verglor 2343c79126 Use djvu_html5 to read djvu format in browser 2020-11-15 13:19:37 +01:00
verglor 09a5a69f86 djvu_html5 0.3.0-beta1 static assets 2020-11-15 13:09:32 +01:00
Ozzieisaacs 4081895a78 exclude _pysqlite.so from being overwritten 2020-11-14 15:53:56 +01:00
Ozzieisaacs a522566a0c Merge remote-tracking branch 'kepubify/patch-1' into master 2020-11-14 13:24:58 +01:00
Ozzieisaacs 013c4e9c35 Merge remote-tracking branch 'epub/recompute_epub' into master 2020-11-14 13:22:42 +01:00
Ozzieisaacs 067f289050 Merge remote-tracking branch 'comic/comic' into master 2020-11-14 13:21:56 +01:00
Ozzieisaacs 06511b92aa Merge remote-tracking branch 'epub/GruberMarkus-patch-1' into master 2020-11-14 13:20:26 +01:00
Ozzieisaacs 32f4c9eabf Merge remote-tracking branch 'fr/master' into master 2020-11-14 13:16:08 +01:00
Ozzieisaacs 14bc345883 Merge remote-tracking branch 'audio/fix-audio-icon' into master 2020-11-14 13:14:21 +01:00
Ozzieisaacs d76b4fd7ea Merge remote-tracking branch 'it/patch-17' into master 2020-11-14 13:12:36 +01:00
ElQuimm 83cdd7e9fb update italian message.po
some minor update to the translation.
2020-11-13 11:17:46 +01:00
verglor 50441bae62 Fix missing audio icon for other audio formats than mp3 2020-11-10 18:08:22 +01:00
Martin 5b0766a9b0 Correct spelling 2020-11-10 10:06:37 +01:00
Martin d979fe8e5f fix fr translation : sed cryptage/chiffrement 2020-11-10 10:04:47 +01:00
Markus Gruber f2c52fd278 Update jszip to 3.5.0. Update epub.js to 0.3.88.
Fixes several problems when viewing EPUBs in a browser, for example when jumping to a certain chapter in the table of contents does not work.
2020-11-09 15:47:27 +01:00
Ozzieisaacs 87d60308f2 Merge remote-tracking branch 'caliblur/issue/caliblur-981' into master 2020-11-08 19:29:10 +01:00
L0garithmic 64ebc56c87 Kepubify
the current link sends you to a specific version. The link I suggest, sends you to the "latest" version.
2020-11-08 09:31:53 -06:00
Ozzieisaacs 58d485cbb5 Fix #1702 (invalid timestamps during kobo sync caused by malformed database) 2020-11-07 12:49:39 +01:00
Ozzieisaacs e99dd3310c Exchanged douban apikey 2020-11-07 12:18:33 +01:00
Ozzieisaacs 400f6e02a5 Fix #1668 (upload of books with language set to different than UI language and not showing all books)
Fix for only showing external port if kobo is really activated in admin menu
2020-11-07 11:44:02 +01:00
jvoisin 700b0609df Don't recompute metadata for epubs 2020-11-06 21:36:49 +01:00
cbartondock bc52f90ed4 Merge remote-tracking branch 'upstream/master' 2020-11-02 11:36:45 -05:00
Ozzieisaacs 0771546dad Log exception on user import 2020-11-01 18:25:38 +01:00
jvoisin 95a1a71a66 Minor refactor of comic.py 2020-10-31 22:28:24 +01:00
OzzieIsaacs b9b8e3f632 Update testresults 2020-10-31 20:12:22 +01:00
Ozzieisaacs 1e03a2ae40 Merge branch 'master' into Develop 2020-10-31 20:07:41 +01:00
Ozzieisaacs 25da6aeeca Merge remote-tracking branch 'sec_fixes/space' into master 2020-10-31 20:04:42 +01:00
Ozzieisaacs 00b422807b Merge remote-tracking branch 'sec_fixes/edit_auth' into master 2020-10-31 20:04:12 +01:00
Ozzieisaacs 130701a7bb Merge remote-tracking branch 'sec_fixes/admin_update' into master 2020-10-31 20:02:42 +01:00
Ozzieisaacs ff88e68904 Add missing locale files 2020-10-31 19:58:22 +01:00
Ozzieisaacs 55fcf23d2b Merge remote-tracking branch 'sec_fixes/negate' into master 2020-10-31 19:37:47 +01:00
Ozzieisaacs 1b0b4c4cc5 Merge remote-tracking branch 'sec_fixes/ldap' into master 2020-10-31 19:29:17 +01:00
Ozzieisaacs cd57731593 Merge remote-tracking branch 'sec_fixes/unused_imports' into master 2020-10-31 19:24:46 +01:00
Ozzieisaacs 37a80b935d Added greek translation 2020-10-31 19:20:00 +01:00
Ozzieisaacs 4d61aec153 Merge remote-tracking branch 'zh/trans' into master 2020-10-31 19:07:10 +01:00
Ozzieisaacs 1adf25d50b Update Italian translation 2020-10-31 19:06:09 +01:00
Julian Naydichev ae33aee3f6 When serving a download URL via KoboSync, use a URL that is specific to Kobo 2020-10-31 14:50:08 +01:00
jvoisin 2c99e71626 Remove a superfluous space 2020-10-29 18:17:32 +01:00
jvoisin e7f7775efa Require edit permissions to edit books, even via ajax 2020-10-29 14:52:20 +01:00
jvoisin 8b60a19577 Don't leak to non-admin users the current installed version 2020-10-29 14:03:18 +01:00
Ozzieisaacs 5701e08db9 Fix for #1668 2020-10-28 20:37:52 +01:00
Ozzie Isaacs 72a2fc49f8 Update Windows testresults 2020-10-28 20:23:19 +01:00
jvoisin d2617322c6 Negate a condition
- removes two levels of indentation
- makes it clear that if the wrong tokens are provided nothing will happen
- remove a useless nested function
2020-10-27 19:41:05 +01:00
jvoisin fa82745f64 Put import_ldap_users behind a login 2020-10-27 19:26:04 +01:00
jvoisin 19b2a334e4 Remove unused imports 2020-10-27 11:06:43 +01:00
vagra 627c2adf08 SImple Chinese translation updated. 2020-10-26 22:56:58 +08:00
ElQuimm e3e137ca50 updated italian message.po 2020-10-22 16:31:25 +02:00
cbartondock 0978be580f Merge remote-tracking branch 'upstream/master' 2020-10-21 13:01:25 -04:00
Ozzieisaacs 5792838333 Add OSError to catched Gevent Error 2020-10-20 17:38:37 +02:00
Ozzieisaacs f9995583a5 Merge remote-tracking branch 'translate/patch-1' into master 2020-10-20 17:12:25 +02:00
KN4CK3R 4cc68bd139 Fixed typo. 2020-10-20 13:45:01 +02:00
cbartondock d2510ad1bc Merge remote-tracking branch 'upstream/master' 2020-10-17 21:46:26 -04:00
celogeek 4d81d3613c display the check when books are read 2020-10-17 16:49:57 +02:00
celogeek 7d28963a32 connect read books to all render 2020-10-17 16:49:38 +02:00
celogeek b2594468b4 add helper to get all read books 2020-10-17 16:49:06 +02:00
celogeek 754b9832e9 fix height container 2020-10-17 13:30:19 +02:00
celogeek 097ac879ea render read 2020-10-17 13:24:46 +02:00
Ozzieisaacs bc0416cbb4 Fix for #1660 (advanced search for custom columns working, headline for advanced search working) 2020-10-16 20:24:15 +02:00
Ozzieisaacs 2814617e4b Fix for #1660 (Pagination in advanced search not working, error 500 for no filter in advanced search)
Fix #1666 (Pagination in search not working)
2020-10-16 19:56:24 +02:00
cbartondock da9dfd166d fixed incorrect cover widths 2020-10-16 13:51:48 -04:00
cbartondock 1be07a42df Flex display to fix columns issue 2020-10-16 13:41:48 -04:00
cbartondock 1d83a6a898 distinguish convert from and convert to extensions 2020-10-16 11:51:59 -04:00
Ghighi 2ff286b672 natural solution, pagination is changing on new page 2020-10-16 00:43:57 +03:00
Ozzie Isaacs e8620a0986 Fix logging error on windows with invalid goodreads key/secret 2020-10-14 20:48:01 +02:00
Ozzie Isaacs 7fb18bbdc7 Update Testresults on windows 2020-10-14 19:54:58 +02:00
Ozzieisaacs 5b67b687d3 Removed remaining code from view downloaded books in user section
Fixes for #1661
2020-10-13 19:45:27 +02:00
Ghighi Eftimie 9adcfa99f4 trigger infinite scroll script only on templates where .load-more class is present 2020-10-11 22:35:56 +03:00
Ghighi Eftimie e723aaa5f6 fix for history state (+1 not needed) 2020-10-11 21:56:49 +03:00
Ozzie Isaacs d128b037a5 Fix for editing files on windows 2020-10-11 18:01:26 +02:00
Ozzieisaacs 99fda00442 Merge remote-tracking branch 'caliblur/issue/caliblur-1560' into master 2020-10-11 12:43:21 +02:00
Ghighi Eftimie f574f8faf0 better js check 2020-10-10 18:34:55 +03:00
Ghighi Eftimie cedfa90d76 fix for #981 2020-10-10 17:51:46 +03:00
Ghighi Eftimie f1e6f6e505 fixes for #1560 2020-10-10 14:58:06 +03:00
Ghighi Eftimie b4f95cced7 Merge remote-tracking branch 'upstream/master' 2020-10-10 14:51:55 +03:00
Ozzieisaacs e16c0caebb Fix opds search 2020-10-10 12:53:10 +02:00
Ozzieisaacs 52489a484a Merge remote-tracking branch 'Knepherbird/master' into master
# Conflicts:
#	cps/jinjia.py
#	cps/templates/detail.html
#	cps/templates/discover.html
#	cps/templates/index.html
#	cps/web.py
2020-10-10 12:47:49 +02:00
Ozzieisaacs e1d5c2c578 Merge remote-tracking branch 'caliblur/issue/caliblur-1594' into master 2020-10-10 12:29:30 +02:00
Ozzieisaacs 49f49632ad Renamed CalibLur.css 2020-10-10 12:22:52 +02:00
Ghighi Eftimie 6dadc6fb1e same fix but hopefully better 2020-10-10 13:15:02 +03:00
Ozzieisaacs a58a2f5fe4 Added missing file for tr locale of datepicker 2020-10-10 11:53:15 +02:00
Ghighi Eftimie c33c6bbff0 fix for #1594 2020-10-10 12:39:52 +03:00
Ozzieisaacs 093f90d4c1 Update translation files 2020-10-10 11:38:40 +02:00
Ozzieisaacs 20ffa325d3 Fix #1642 2020-10-10 10:53:08 +02:00
Ghighi Eftimie 5027304801 Merge remote-tracking branch 'upstream/master' 2020-10-10 11:50:19 +03:00
Ozzieisaacs 85d5afd6d9 Merge branch 'Develop' into master 2020-10-10 10:38:11 +02:00
OzzieIsaacs df295e92ee Merge remote-tracking branch 'origin/Develop' into Develop 2020-10-10 10:33:12 +02:00
Ozzieisaacs 2e67bd2407 Fix add to shelf from search 2020-10-10 10:32:53 +02:00
OzzieIsaacs 9aa01ee8cf Merge branch 'master' into Develop 2020-10-10 10:14:33 +02:00
OzzieIsaacs 6b993ad329 Update test results 2020-10-10 10:14:09 +02:00
OzzieIsaacs d70ded0993 Fix for search 2020-10-10 07:47:27 +02:00
OzzieIsaacs 3dacdcc8bb Merge remote-tracking branch 'worker/db' into Develop 2020-10-10 07:31:08 +02:00
OzzieIsaacs bb03026589 Fixes from merge problems 2020-10-10 07:30:03 +02:00
Ghighi Eftimie 2f69e3141e Merge remote-tracking branch 'upstream/master' 2020-10-07 09:16:34 +03:00
Ozzieisaacs 1f4564da76 Merge remote-tracking branch 'es/patch-1' into master 2020-10-06 21:48:42 +02:00
OzzieIsaacs 3b8e5ddfb3 Merge remote-tracking branch 'worker/db' into Develop
# Conflicts:
#	cps/tasks/convert.py
2020-10-06 21:40:47 +02:00
Nacho Soler edc293f96a Update
Add some missings translations
2020-10-06 16:43:00 +02:00
blitzmann 3fa4149bb0 Fix reference issue 2020-10-05 23:15:42 -04:00
OzzieIsaacs 4b68a6ff23 Updates tests 2020-10-04 19:25:06 +02:00
Ozzieisaacs 28116c49dc Merge branch 'worker_task' into Develop 2020-10-04 19:23:32 +02:00
Ozzieisaacs 6e6f144b7a Paginated search and advanced search
Wraparound on books list deactivated
2020-10-04 19:23:06 +02:00
Ozzieisaacs e3f4f24c3e Fixes for failed email and conversions with gdrive 2020-10-04 13:59:33 +02:00
Ozzieisaacs eb37e3a52b Fix UI Deelete Buttons in Edit Books page
Fix Conversion of multiple formats of one book in the queue with gdrive
2020-10-04 12:09:52 +02:00
Ozzieisaacs 95d540630e Change ldap_certpath to file 2020-10-04 06:15:35 +02:00
Ozzieisaacs 23d66a0d68 Fix 2020-10-03 21:43:48 +02:00
Ozzieisaacs 0d64692c84 Fix for convert + email task with gdrive 2020-09-30 19:29:57 +02:00
Ozzieisaacs 1cb640e51e Update minimum required version of SQLAlchemy (Fix #1641) 2020-09-29 18:19:00 +02:00
Ozzieisaacs 2d98285545 Update minimum required version of SQLAlchemy 2020-09-29 18:16:56 +02:00
OzzieIsaacs 376001100a Bugfixes from last testrun 2020-09-28 21:24:47 +02:00
Ozzieisaacs e2954249f8 Update chinese translation 2020-09-27 19:22:41 +02:00
Ozzieisaacs cc0b0196f4 Store UI settings in flask session for guest user 2020-09-27 19:12:10 +02:00
Ozzieisaacs 6dfa171b4e Added id's for testing
moved downloaded books section
2020-09-27 16:00:17 +02:00
Ozzieisaacs b140073988 Merge branch 'master' into Develop
Fix #1629 (Gevent Tracebacks with SSL encryption)
2020-09-27 13:02:25 +02:00
Ozzieisaacs c22bc857b0 Fix #1629 (Gevent Tracebacks with SSL encryption) 2020-09-27 13:00:07 +02:00
Ozzieisaacs 497fbdcdfc Save view settings 2020-09-27 12:37:41 +02:00
Ozzieisaacs 861f1b2ca3 Merge branch 'master' into Develop
# Conflicts:
#	test/Calibre-Web TestSummary_Linux.html
2020-09-27 08:54:32 +02:00
Ozzieisaacs 6108ef4c89 Version update to 0.6.10 Beta 2020-09-27 07:43:56 +02:00
OzzieIsaacs a9c0bcb4a2 Updated testresults
Version bump for release
2020-09-27 07:15:03 +02:00
Ozzie Isaacs 8f9de05768 Update Test results windows 2020-09-27 06:33:41 +02:00
Ozzieisaacs e61e94f0fa Merge remote-tracking branch 'it/patch-15' into master
Updated Translations
2020-09-26 16:19:34 +02:00
Ozzieisaacs 85aac02593 Merge remote-tracking branch 'css/master' into master 2020-09-26 16:13:53 +02:00
Ozzieisaacs 9a678c41fe Fix error from merge 2020-09-26 09:42:40 +02:00
Ozzieisaacs 7c8f6ce62f Merge branch 'master' into Develop
# Conflicts:
#	cps/comic.py
#	cps/editbooks.py
#	cps/isoLanguages.py
2020-09-26 07:54:38 +02:00
Ozzieisaacs 9a896ea81e Removed logging of headers as it caused trouble while showing logfile in UI 2020-09-26 07:51:29 +02:00
Ozzieisaacs 422c1893c0 Fix for the fix cover_url 2020-09-24 11:02:12 +02:00
ElQuimm f1cb5276d7 Update italian message.po
removed typo line 127
2020-09-24 10:54:06 +02:00
Ozzieisaacs bed1b24340 Fixes from test of upload restrictions 2020-09-24 10:54:02 +02:00
Ozzieisaacs da909ff084 Fixes from test of upload restrictions 2020-09-23 20:50:34 +02:00
Ozzieisaacs 8f743b70a4 Revert the tolino stuff 2020-09-22 20:25:58 +02:00
Ozzieisaacs a761017116 Additional debug output for #1527 2020-09-21 19:09:02 +02:00
Ozzieisaacs f06cc25a99 Fix for immediate logout with next="/logout"
Fix tolino per default with deactivated Strict-Transport-Security
2020-09-21 18:34:39 +02:00
Ozzieisaacs eff8480d5c Show listen in browser formats in lowercase 2020-09-21 18:24:50 +02:00
Ozzieisaacs eec303de49 Fix #1621 (Link to contributing.md file wrong) 2020-09-21 14:18:23 +02:00
ElQuimm 07a936c5e8 italian version of messages.po updated 2020-09-21 10:53:29 +02:00
Ryan Long a6002a2c6c 1622_updated_css 2020-09-20 23:41:20 -04:00
Ozzieisaacs 7ba014ba49 Fix "is not a valid language" on upload of comic books
Fix metadata excration of comic books
updated bootstrap table
updated handling of upload formats restrictions
2020-09-20 15:05:52 +02:00
Ozzieisaacs 165c649f31 Fix "is not a valid language" on upload 2020-09-20 11:44:03 +02:00
Ozzieisaacs 4cf71dd336 Fix "is not a valid language" on upload 2020-09-20 11:41:44 +02:00
Ozzieisaacs c0a401216b Add links to contribution guidelines 2020-09-20 10:10:58 +02:00
Ozzieisaacs 2d712a3841 Fix #1612 2020-09-20 10:03:05 +02:00
Ozzieisaacs a2b5b4dd17 Merge remote-tracking branch 'identifier/master' into master 2020-09-20 10:01:46 +02:00
blitzmann 0480edce2a Clarify need for WeakSet 2020-09-18 21:52:45 -04:00
Alexander Yakovlev 4eded82102 Add ISFDB 2020-09-15 17:39:13 +07:00
Alexander Yakovlev ec4ff83465 Add ISSN tags 2020-09-15 13:50:34 +07:00
Alexander Yakovlev 8745b8b051 nice title for Litres tags 2020-09-15 13:47:57 +07:00
Alexander Yakovlev 4e28c3cadb add Litres references 2020-09-15 13:41:01 +07:00
blitzmann 76c724c783 Remove global session object, this is now wrapped in the CalibreDB class 2020-09-13 21:37:47 -04:00
blitzmann 032cb59388 Fix resetting the session when first configuring the calibre-db on first boot up 2020-09-13 13:16:11 -04:00
OzzieIsaacs e29247774c Bugfixes for uploading books to GDrive with new worker 2020-09-12 13:55:36 +02:00
blitzmann 18d16f9a8b Initial attempt at setting up CalibreDB as a class that carries the engine and DB connection, and the instance being the session 2020-09-11 22:52:40 -04:00
OzzieIsaacs d137735be1 Fix #805 (First request to gdrive fails) 2020-09-11 20:56:54 +02:00
dickreckard 65929c02bc isolanguage parsing of xmp data 2020-09-11 10:49:45 +00:00
root 22466d6b98 xmp data processing added to the uploader 2020-09-11 10:08:55 +00:00
dickreckard 23fe79c618 Update uploader.py 2020-09-11 03:42:19 +02:00
OzzieIsaacs b202ca5619 Updated test result 2020-09-09 07:00:09 +02:00
OzzieIsaacs 7929711fea Improvements for file uploading format restriction 2020-09-08 20:57:39 +02:00
OzzieIsaacs 49a028a599 Bugfix not unlink generic cover on upload 2020-09-08 19:04:04 +02:00
OzzieIsaacs 670cbcd336 Merge branch 'master' into Develop 2020-09-07 21:33:11 +02:00
Ozzieisaacs 449d31e8a1 Refactored update_dir_structure_file 2020-09-07 21:26:59 +02:00
Ozzieisaacs fe82583813 Merge branch 'database_fix' into Develop 2020-09-07 21:23:35 +02:00
Ozzieisaacs 1450a21d00 Fix links to amazon (#1461) 2020-09-07 18:27:43 +02:00
Ozzieisaacs ae15544aed Merge branch 'master' into database_fix
# Conflicts:
#	cps/editbooks.py
2020-09-07 18:21:33 +02:00
Ozzieisaacs 4b7a37cf7d Bugfix empty email attachment size 2020-09-07 18:19:54 +02:00
dickreckard cb7727900c Update uploader.py
default cover changed from none to pdf_preview when metadata parsing fails
2020-09-07 13:30:03 +02:00
Ozzieisaacs e012726cd4 Fix #1461 (parse Amazon_* identifiers) 2020-09-06 19:31:31 +02:00
Ozzieisaacs f49688fdb9 Fix #1461 (parse Amazon_* identifiers) 2020-09-06 19:31:03 +02:00
Ozzieisaacs e32b017431 Revert "Test revert global Session"
This reverts commit 393869e538.
2020-09-06 10:59:34 +02:00
Ozzieisaacs 393869e538 Test revert global Session 2020-09-06 10:27:10 +02:00
Ozzieisaacs d3bde0408f Improvederror handling for editing identifier 2020-09-05 18:47:28 +02:00
Ozzieisaacs 34d3225984 Errorhandling edit identifier 2020-09-05 18:46:11 +02:00
Ozzieisaacs eaed53e25b Fix for author edit error (2 same sort_authors lead maybe to choose wrong one) 2020-09-05 18:23:14 +02:00
OzzieIsaacs feacbe8ebd Possible Fix for database crash after adding new format and accessing calibre database afterwards 2020-09-05 10:24:32 +02:00
norangebit bdf6052388 Conversion to kepub when creating a sync token 2020-09-03 21:57:14 +02:00
Ozzieisaacs ec0a0190e7 Merge remote-tracking branch 'polish/master' into master 2020-09-01 20:18:29 +02:00
norangebit 99d653eece Add automatic conversion in kepub
Automatic conversion from epub to kepub of new book on Kobo sync.
2020-09-01 19:27:14 +02:00
OzzieIsaacs f825c5ae83 Merge branch 'master' into Develop 2020-09-01 19:26:13 +02:00
OzzieIsaacs 173484c30e Fix #1002, #1581 (Public shelfs not accessible as guest user) 2020-09-01 19:25:57 +02:00
OzzieIsaacs 884270093b Merge remote-tracking branch 'worker/tasks' into Develop 2020-08-31 13:00:13 +02:00
Dawid Gliwka 62e7ab8c2b Update polish translation 2020-08-30 21:17:56 +02:00
blitzmann ded480207b Add link to convert task, fixes #1589 2020-08-30 13:54:51 -04:00
blitzmann ef49e2b5b3 Revert daemon in favor of timeout 2020-08-30 13:49:45 -04:00
blitzmann b0a055a870 Rename email.py -> mail.py to avoid shadowing standard email module 2020-08-30 13:31:59 -04:00
blitzmann 9b9e29a3b6 Implement worker thread as a daemon 2020-08-30 13:29:42 -04:00
OzzieIsaacs 1a9a436cbe Fixed wrong translation string
Removed unused variables from callback in server.py
Update Testresults
2020-08-30 17:11:11 +02:00
OzzieIsaacs 62dd29d2f3 Renamed email to mail due to naming conflict in python2 2020-08-30 08:49:53 +02:00
OzzieIsaacs d406d91856 Merge remote-tracking branch 'worker/tasks' into Develop 2020-08-30 08:32:09 +02:00
OzzieIsaacs 98494c610a Merge branch 'master' into Develop 2020-08-30 08:31:35 +02:00
OzzieIsaacs 649a553fa4 Merge remote-tracking branch 'metadata/master' into master 2020-08-30 08:30:32 +02:00
OzzieIsaacs e17a06d7bd Merge remote-tracking branch 'oauth/oauth-typo' into master 2020-08-30 08:28:27 +02:00
OzzieIsaacs 4b14cc6a74 Merge remote-tracking branch 'oauth/oauth-typo' into Develop 2020-08-30 08:28:14 +02:00
OzzieIsaacs 65560ab65e Merge remote-tracking branch 'google_oauth/patch-1' into master 2020-08-30 08:26:48 +02:00
OzzieIsaacs b65095fd0f Merge remote-tracking branch 'google_oauth/patch-1' into Develop 2020-08-30 08:26:34 +02:00
OzzieIsaacs 28733179d2 Merge remote-tracking branch 'caliblur/editMetaFix' into Develop 2020-08-30 08:25:17 +02:00
OzzieIsaacs 960d23ca50 Merge remote-tracking branch 'caliblur/blurPaginationFix' into Develop 2020-08-30 08:23:06 +02:00
Michael Knepher 057f70ea9c Add author sort 2020-08-29 18:53:00 -07:00
blitzmann 3e378bd665 Some more clean up 2020-08-29 21:04:49 -04:00
blitzmann c120138f26 Fixes for pagination ugliness for caliBlur! style 2020-08-29 20:58:30 -04:00
blitzmann 31b20362ec caliBlur! style: Fixes issue with edit metadata button not getting styled correctly 2020-08-29 18:45:23 -04:00
blitzmann e7eb5b6ea6 Improvements to task processing
* Moves clean up to separate function for organization
* moves the `self.dequeued.append(item)` immediately after `self.queue.get()` so that we don't wait for it to show up

(cherry picked from commit bc9372e88f0c8855694431f811702d7fb899a97e)
2020-08-29 12:25:33 -04:00
OzzieIsaacs fe91ed815e Updated testresults with merged new worker 2020-08-29 12:46:12 +02:00
OzzieIsaacs 9e5cad0dc8 Merge new worker thread 2020-08-29 11:14:52 +02:00
OzzieIsaacs 36cbc42363 Better test output html file 2020-08-28 16:51:53 +02:00
blitzmann 4cb82ea9bd Revert testing condition that decreased number of tasks kept 2020-08-27 21:49:55 -04:00
blitzmann 572ac4a17b Fix for deleting old, completed tasks
(cherry picked from commit e066d7a4b0f47d3327696a11795cdc923ff0f6f3)
2020-08-27 21:46:20 -04:00
Ozzie Isaacs 6c552f6b43 Update tests Windows 2020-08-27 22:29:47 +02:00
Ozzie Isaacs 9723129436 Updated dependency comicapi version 2020-08-27 21:03:36 +02:00
Ozzie Isaacs dc5191f8ba Added unrar binary is found on windows 2020-08-27 21:01:45 +02:00
OzzieIsaacs d79726899f Updated testresult linux 2020-08-26 21:44:31 +02:00
Ozzie Isaacs 8ab5710098 Updated testresuts Windows 2020-08-26 21:43:58 +02:00
OzzieIsaacs 61d628d596 oauth problem solved 2020-08-26 18:22:56 +02:00
Sean Leonard 078fc25845 Remove Google+ OAuth scope
The scope is no longer available per https://developers.google.com/+/api-shutdown

Fixes #1472 
Fixes #1573
2020-08-26 08:56:56 -07:00
Marvel Renju 67eb4b317a Fix typo
google oauth provider obtain link was pointing to github
2020-08-26 03:15:39 +01:00
blitzmann 6322919bc7 Merge branch 'Develop' into tasks
# Conflicts:
#	cps/db.py
2020-08-25 00:15:41 -04:00
blitzmann b81b8a1dea Fix registration email 2020-08-25 00:05:20 -04:00
blitzmann f3a3797850 Fail the convert task if the email subtask fails 2020-08-24 21:28:55 -04:00
blitzmann 5ec1283bb1 Remove threading for the calibre DB class 2020-08-24 21:03:59 -04:00
blitzmann 8634b0c6f0 Remove left over placeholder code 2020-08-24 21:00:15 -04:00
Ozzie Isaacs d89830af61 Fix anonymous user has no modified_flag error 2020-08-24 21:00:13 +02:00
Ozzie Isaacs ef1736b571 Fix error on guest user (view settings missing) 2020-08-24 20:38:06 +02:00
Dave Mogle d951ee4b83 Prefer kepub (#1439)
Only offer kepub download URL over Kobo sync API when available
2020-08-24 13:43:54 -04:00
blitzmann 04081f62c4 Delete old worker thread class / logic 2020-08-23 23:34:41 -04:00
blitzmann 0f28dc5e55 Remove the queue stuff for CalibreDB (is no longer used) 2020-08-23 23:17:07 -04:00
blitzmann 508f49df18 Remove completed tasks and sort the tasks by date added when calling .tasks 2020-08-23 23:00:23 -04:00
blitzmann bec280c6b1 Add some error handling 2020-08-23 21:51:44 -04:00
blitzmann 6a8ae9c0c4 Merge remote-tracking branch 'upstream/master' into tasks
# Conflicts:
#	cps/helper.py
2020-08-23 21:38:56 -04:00
blitzmann ac22483f98 Add error handling to the email task within the convert task 2020-08-23 21:35:05 -04:00
blitzmann 59d56d5c83 py27 support (I think) and some clean up 2020-08-23 21:21:55 -04:00
OzzieIsaacs cdaad2fb4a Merge branch 'master' into Develop 2020-08-23 21:23:00 +02:00
OzzieIsaacs 843279bacb Merge remote-tracking branch 'jef/jef/download-kobo' into master 2020-08-23 21:22:44 +02:00
blitzmann a000de0270 Some clean up 2020-08-23 13:33:57 -04:00
blitzmann bf41b04cfa Remove convert task from db.py - with the fixed from #1565, this no longer seems to be needed 2020-08-23 13:07:24 -04:00
blitzmann 9ce2e8ea53 Fix progress indication for emails that have been completed. 2020-08-23 12:58:24 -04:00
OzzieIsaacs f066926fc9 Merge branch 'master' into Develop 2020-08-23 10:56:10 +02:00
OzzieIsaacs 4c38b0ab10 Prepare for save name sort order 2020-08-23 10:56:00 +02:00
OzzieIsaacs cf35c9dcef Merge remote-tracking branch 'name/patch-2' into master 2020-08-23 10:53:18 +02:00
OzzieIsaacs 45ff9394f2 Fix comma separated author names during for upload 2020-08-23 09:44:42 +02:00
blitzmann 414043ded1 Remove references to old worker, turn off calibre_db task queue (for now until I can determine if it's needed still), and attempt to re-implement email progress tracking (not working at the moment) 2020-08-22 23:35:48 -04:00
blitzmann 2533c9c14e Continue converting tasks - email and upload tasks 2020-08-22 22:44:28 -04:00
blitzmann f10f0dada6 First working PoC with a new task structure 2020-08-22 16:31:00 -04:00
OzzieIsaacs 282859bc1b Merge remote-tracking branch 'github/master' into master 2020-08-22 15:38:40 +02:00
OzzieIsaacs a3ae97a5a3 Fix #1574 (author name not shown in change book order in shelfs) 2020-08-22 15:37:40 +02:00
OzzieIsaacs ed8275a20b Fix #1574 (author name not shown in change book order in shelfs) 2020-08-22 15:35:21 +02:00
OzzieIsaacs f2add3f788 Migration of view settings working in User database
Book Merge gives now feedback on what is done
2020-08-22 10:27:09 +02:00
OzzieIsaacs ad144922fb Merge with master 2020-08-22 09:23:29 +02:00
OzzieIsaacs b9c0f2a3d3 Merge remote-tracking branch 'origin/master' into master 2020-08-21 19:27:19 +02:00
OzzieIsaacs 0cc07362b8 Fix for #1573 2020-08-21 19:26:58 +02:00
Brandon Ingli 4ee5dcaff3 Elevate Log Messages in web.py
Elevates login failure log messages and register failure log messages from INFO to WARNING, "Unknown Error" to ERROR, and fixes misspelling of "address" in web.py log messages. Misspelling remains in variable names to avoid breaking changes.
2020-08-17 11:29:10 -05:00
Ozzie Isaacs 4d44746a88 Change settings database gdrive watch to JSON 2020-08-15 15:07:03 +02:00
OzzieIsaacs 1535bdbcd8 Merge remote-tracking branch 'memorydatabase/issue/1564' 2020-08-15 12:08:59 +02:00
OzzieIsaacs ecb160b28d Merge remote-tracking branch 'pypy/fix-pypy3-settings-database-error' 2020-08-15 10:58:08 +02:00
OzzieIsaacs 7e9941def0 Updated test results 2020-08-14 21:02:59 +02:00
OzzieIsaacs f9c6fb30bf Excluded series type again, as it causes problems upon reconnect 2020-08-14 19:43:54 +02:00
Ozzie Isaacs 94ad93ebd7 Added series like custom columns #1501 2020-08-11 18:56:34 +02:00
blitzmann 0e1ec5034e Fix for #1564 - using memory database in multiple threads.
See also: https://docs.sqlalchemy.org/en/13/dialects/sqlite.html#using-a-memory-database-in-multiple-threads
2020-08-11 12:44:55 -04:00
Marvel Renju 76b0505bd9 Change all "conn = engine.connect()" statements to "with engine.connect() as conn:" in ub.py
Changed all the statements in ub.py to use python context managers so that conn.close() is called automatically.  (https://docs.sqlalchemy.org/en/13/core/connections.html)
2020-08-10 03:42:36 +01:00
OzzieIsaacs b309c1fc91 Fix filenames (Escape "\") for searching calibre excecutable on windows 2020-08-09 15:11:54 +02:00
OzzieIsaacs b9a802a19c Merge remote-tracking branch 'cover_path/patch-1' 2020-08-09 14:54:36 +02:00
OzzieIsaacs a882ad3e65 Merge remote-tracking branch 'contrib/patch-1' 2020-08-09 14:52:01 +02:00
Ryan Holmes 969105b205 Trim whitespace from filename
This avoids an OSError when the book's metadata has whitespace at the end of it.
2020-08-09 01:08:00 -04:00
Ryan Holmes 28bfb06c67 Revert the deletion of another line
This was done by mistake, whoops!
2020-08-09 00:57:30 -04:00
Ryan Holmes 704dcb3e58 Move assignment of new_coverpath
With the assignment originally being within the try, if the try failed, the exception wouldn't have access to the value
2020-08-09 00:55:56 -04:00
Efreak a7e723d8d4 Spelling/grammar in CONTRIBUTING.md 2020-08-08 01:06:19 +00:00
Ren Wei 4c6f5096be get metadata, typo, if no result from google, it will display the noresult msg, regardless of the others results. 2020-08-01 15:12:20 +08:00
Ozzie Isaacs 1a1d105fae Fix #1538 (Floating point numbers showing 2 decimals on details page 2020-07-23 19:31:48 +02:00
Ozzie Isaacs 42a0639bb5 Fix #1533 (Invalid LDAP Cert Path no longer crashes app) 2020-07-23 19:23:57 +02:00
Ozzie Isaacs e27b08203d Fix #1531 (white background on transparent cover instead of black one) 2020-07-23 18:41:38 +02:00
Clément Poissonnier 1ca4583896 feat(ldap): add a field that allows to override LDAP User Object Filter when a user is imported 2020-07-23 12:12:00 +02:00
Ozzie Isaacs 25fc6f1937 Further fixes for #1530 (Handle improper migrated database with config_mature_content_tags, allowed_tags, denied_tags, denied_column_value, allowed_column_value NULL instead of "") 2020-07-22 18:44:11 +02:00
Ozzie Isaacs 0ccc3f7252 Fixes for windows (moving files not allowed -> Close pdf after metadata extracting, add os.path.normcase to path while renaming folders, as thi caused also trouble
Added hint for missing ghostcript on cover extraction
2020-07-21 20:14:08 +02:00
Ozzie Isaacs 66acd1821d Update Gdrive integration (Error Handling on Callback and wording) 2020-07-21 18:01:38 +02:00
Ozzie Isaacs 93a0217d5f Fix for #1530 (Handle improper migrated database with config_mature_content_tags NULL instead of "") 2020-07-20 20:28:10 +02:00
Jef LeCompte 711a697570 Merge remote-tracking branch 'upstream/master' into jef/download-kobo 2020-07-13 01:50:38 -04:00
Ozzieisaacs f8139f3198 Store last selected view for sidebar (not for categories, series, publishers, ..)
Started making search paged
2020-07-11 12:09:34 +02:00
Ozzieisaacs df01022f49 Added save user view settings 2020-07-08 21:18:38 +02:00
Ozzieisaacs 450411a732 #1344 (Support Multiple authors, but not showing up on Kobo reader)
Fix for #1439 (reading progress was not stored, as user login was wrong)
2020-07-05 20:54:36 +02:00
Ozzieisaacs f80c67828b Fix #1500 (Custom ratings of increment 0.5 are allowed) 2020-07-05 14:35:57 +02:00
Ozzieisaacs d1889a5e06 Fix #1502 (program info only visible in about section if user is admin) 2020-07-05 14:00:40 +02:00
Ozzieisaacs 12263ff02f Fix #1423 (OverflowError thrown during sync on some Linux Systems if one of the timestamps is outside range 1970 to 2038) 2020-07-05 13:55:59 +02:00
Ozzieisaacs 76f914cbc2 Fixed logging in SyncToken 2020-07-05 13:52:29 +02:00
Ozzieisaacs c1f5252b3f Fix #1509 (OSError thrown during sync on Windows if one of the timestamps is outside range 1970 to 2038) 2020-07-05 13:40:33 +02:00
Ozzieisaacs 20c6f79a44 Changed behavior delete books with subfolders (additional warning message, but book is deleted) 2020-07-05 10:44:49 +02:00
Ozzieisaacs ee6f1405d4 Fix #1456 (Added route to robots.txt) 2020-07-04 21:22:19 +02:00
Ozzieisaacs ee3541d74e Fix kobo links for reverse proxies with subdomains (and docker?) #1470 2020-07-04 13:35:08 +02:00
Jef LeCompte e048388213 feat(api): include external port option
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
2020-07-03 12:58:58 -04:00
Ozzieisaacs 3ff3431b17 Merge branch 'master' into Develop 2020-06-30 19:59:38 +02:00
Ozzieisaacs 8608ff11f7 Fix #1507 (Password generation on python2 working again) 2020-06-30 19:58:07 +02:00
Michael Knepher 7e0d9fbace series_index filter to show x.0 as x 2020-06-29 23:34:26 -07:00
Ozzieisaacs c6c9cfea22 Merging books basically working 2020-06-29 20:14:48 +02:00
Ozzieisaacs a758976c69 Merge branch 'master' into Develop 2020-06-29 18:47:16 +02:00
OzzieIsaacs a14192b7e0 Updated testresults 2020-06-28 22:31:18 +02:00
OzzieIsaacs 601464083b Fix for task wrap around 2020-06-28 13:44:21 +02:00
Ozzieisaacs ccca5d4d1c Merge branch 'master' into Develop
# Conflicts:
#	cps/templates/layout.html
2020-06-28 12:11:46 +02:00
Ozzieisaacs ba10657829 Add fix for read only gdrive file 2020-06-28 12:06:27 +02:00
Ozzieisaacs 6315655f93 Re-add missing po files 2020-06-28 12:05:16 +02:00
Ozzieisaacs 533cb23b73 Merge remote-tracking branch 'next/bug/login-next-get-param' 2020-06-28 10:01:41 +02:00
Ozzieisaacs 0b95424a0d Merge remote-tracking branch 'issue_template/patch-1' 2020-06-28 09:50:58 +02:00
Ozzieisaacs 852f252d13 Prevent invalid variable
Make text in kobo_auth_screen consistent
2020-06-28 09:48:05 +02:00
Ozzieisaacs 080042882f Merge remote-tracking branch 'cz/master' 2020-06-28 09:33:18 +02:00
Ozzieisaacs dde5b08c47 Re enabled gevent as dependency
Fix #1399 (Calibre-web starting with installed and not activated gdrive denpendencies without internet connection again)
2020-06-27 13:36:33 +02:00
Ozzieisaacs 88d2c60ee8 Catch some errors related to non writable settings db 2020-06-27 13:22:16 +02:00
Ghighi Eftimie eeff5a5d43 fix for hidden input 'next' on login form 2020-06-27 12:00:08 +03:00
Michael Knepher 67dd4a72b0 Add series info to all book "meta" displays 2020-06-26 12:26:36 -07:00
Ozzieisaacs a0b8cc21cc Fix #1503 (js error on login screen) 2020-06-23 15:07:14 +02:00
Ozzieisaacs 329a7a03a5 Fix for errors editing/uploading books with duplicate tags/authors/language names
Additional parsing of epubs for cover files
Fix for change of database with linked read_column and read column isn't present any more
2020-06-22 19:11:58 +02:00
Ozzieisaacs d0a3503d74 Fix #1493 (stay logged in with enabled remember token, use remember token) 2020-06-20 19:02:23 +02:00
Ozzieisaacs 59b78f9984 enable disabling of remember_me function 2020-06-20 15:41:26 +02:00
Ozzieisaacs bf75f16169 Updated Chinese translation 2020-06-20 13:55:34 +02:00
Ozzieisaacs 2f833dc457 Fix login with remember me token 2020-06-20 13:46:12 +02:00
Ozzieisaacs 22344a3971 Improvements for delete book 2020-06-18 20:39:45 +02:00
Ozzieisaacs 8dde6ba60f UI improvements table buttons 2020-06-12 21:40:09 +02:00
Ozzieisaacs d44f283a05 View status in books table is stored 2020-06-12 16:15:54 +02:00
Ozzieisaacs c18d5786dd Improved validation check 2020-06-12 13:45:07 +02:00
Ozzieisaacs f26ccfe16c Table edit: validator routine to prevent empty fields working 2020-06-11 21:36:12 +02:00
Ozzieisaacs 1c681ee378 Improvements for books table editor 2020-06-11 21:19:09 +02:00
flying-sausages 4c1ae44bbe Fixed inconsistencies in bug report template, improved examples 2020-06-11 14:59:51 +01:00
Ozzieisaacs 94b5ec91cc Title in table translatable
Edit some elements in table possible
Checkbox state is kept over page change in book table
Fix missing div in layout
2020-06-11 08:48:23 +02:00
Ozzieisaacs 6bfbf3ee41 Update layout 2020-06-11 08:35:23 +02:00
Lukáš Heroudek fc24fa337e Updated CZ translation 2020-06-09 21:15:09 +01:00
Ozzieisaacs 7b4306b1d6 UI improvements (same colors of buttons, etc.)
Changed Editable default value
2020-06-09 20:46:02 +02:00
Ozzieisaacs 4516cc0d65 Listen button only visible if user has read permissions
Audioformat fix
Table edit functions only available if user has edit rights
2020-06-08 21:57:52 +02:00
Ozzieisaacs 308784c601 Hide listen button if user has no read/listen permissions 2020-06-08 21:56:40 +02:00
Ozzieisaacs 9145c9a52c Fix #1397 (Reenabled m4a, m4b audio playback) 2020-06-08 21:50:11 +02:00
Ozzieisaacs 4038cb5b85 Internal paged Search prepared
Search for table list is working
2020-06-08 17:34:03 +02:00
Ozzieisaacs 628658972c Merge branch 'master' into Develop 2020-06-07 19:39:17 +02:00
Ozzieisaacs db0fe9a755 Fix for #1474 (old comicapi with installed unrar, but missing unrar-lib) 2020-06-07 15:41:53 +02:00
Ozzieisaacs fdf10e3d2e Fix #1473 (reconnect not working via web-route access) 2020-06-07 14:11:41 +02:00
Ozzieisaacs ded3e06a9b Updated french translation 2020-06-07 06:48:51 +02:00
Ozzieisaacs 0dd0605a1f Book list for merging 2020-06-06 21:21:10 +02:00
Ozzieisaacs 827b0c6e50 Changed pubdate to timestamp 2020-06-06 09:52:35 +02:00
Ozzieisaacs d1b533848d Changed pubdate to timestamp 2020-06-05 20:13:39 +02:00
Ozzieisaacs 13ae28edab Fix #1449 (Shelf download menu wasn't working for books with more than one format) 2020-06-04 20:34:31 +02:00
Ozzieisaacs 82253219e8 Fix #1449 (Shelf download menu wasn't working for books with more than one format) 2020-06-04 20:33:14 +02:00
Ozzieisaacs 94592b74a6 Merge branch 'master' into Develop 2020-06-03 20:15:55 +02:00
Ozzieisaacs eef2112e1e #1430 (changed color of rating stars) 2020-06-03 20:14:07 +02:00
Ozzieisaacs b83d56eff2 Version bump 2020-06-03 19:10:36 +02:00
Ozzieisaacs 4c539b6db4 Fix #1448 (Public shelfs are accessible even if not logged in) 2020-06-03 19:10:07 +02:00
OzzieIsaacs 2ad329e64c Preparation for release 2020-06-02 22:12:36 +02:00
Ozzieisaacs 4de89ec6ce Merge remote-tracking branch 'it/patch-14' 2020-06-02 20:58:17 +02:00
Ozzieisaacs fc885c8fa2 Merge remote-tracking branch 'cz/patch-1' 2020-06-02 20:51:31 +02:00
Ozzieisaacs ef2c98ba39 Fix #1453 (error unrar binary not found) 2020-06-02 20:51:08 +02:00
ElQuimm 41d922867e updated italian version of message.po
Thank you.
2020-06-02 09:02:44 +02:00
Ozzieisaacs 89223760e6 Merge branch 'master' into Develop 2020-06-01 10:58:49 +02:00
Ozzieisaacs 9a8a1f75ca For for error unrar binary not found 2020-06-01 10:54:41 +02:00
flying-sausages 52e8e7e4b0 Some czech translations 2020-05-31 22:51:41 +01:00
OzzieIsaacs 93f65484de Update Teststatus 2020-05-29 09:11:52 +02:00
Ozzieisaacs 7d08cde8b8 Update error handling cover upload 2020-05-29 06:59:40 +02:00
Ozzieisaacs d3c2bf7dd4 Merge remote-tracking branch 'es/patch-1' 2020-05-28 18:50:16 +02:00
Michael Knepher 54cf3652b0 Add series name and index to book cover info 2020-05-27 21:57:59 -07:00
Ozzieisaacs 5607d2086d Added error handling for cover upload 2020-05-27 20:41:16 +02:00
Ozzieisaacs 27ed918896 Enabled search for archived books 2020-05-27 19:19:17 +02:00
Ozzieisaacs 9b2df9cfd9 Fix #1441 (list copy function not available on python2, crashes edit metadata) 2020-05-27 18:38:50 +02:00
Michael Knepher 5dd08e438c Merge remote-tracking branch 'upstream/master' 2020-05-27 09:06:43 -07:00
Ozzieisaacs 2f8c8c3a28 Merge remote-tracking branch '/wolviex' 2020-05-27 10:50:13 +02:00
Wolviex dde7cf18f7 removed extra reference to calibre_db (calibre_db.calibre_db..) typo? 2020-05-27 01:41:15 -07:00
Rafael Roa 48aadbf716 Update messages.po 2020-05-26 23:28:29 +02:00
Ozzieisaacs 5514af60e5 Merge remote-tracking branch 'it/patch-13' 2020-05-26 18:43:12 +02:00
ElQuimm e8449eb02f Updated version of italian message.po
Thank you.
2020-05-26 18:37:15 +02:00
Ozzieisaacs 9ea21a7ecb Possible fix for #1436 2020-05-26 18:20:32 +02:00
Ozzieisaacs fec86c2862 Update Grid/list view of series 2020-05-26 15:19:32 +02:00
Ozzieisaacs 11e5d4c5b7 Merge remote-tracking branch 'es/patch-2' 2020-05-25 21:57:26 +02:00
Ozzieisaacs b852fb0e26 Merge branch 'Develop' 2020-05-25 21:30:21 +02:00
Ozzieisaacs 0fc18bf3b1 Fix for #1398 (prevent empty series_index field) 2020-05-25 19:34:31 +02:00
Rafael Roa d4be584782 Update messages.po
Here is the whole file traslated
2020-05-25 17:35:46 +02:00
Knepherbird 2120d72901 Merge pull request #3 from janeczku/master
Merging current upstream master
2020-05-24 15:25:49 -07:00
Ozzieisaacs 6f9c08f906 Fix typo RarExecutable 2020-05-24 20:54:23 +02:00
Ozzieisaacs 70c666c380 Upload book without reload complete library 2020-05-24 20:40:58 +02:00
Ozzieisaacs 46197d82b5 Edit and Upload books refactored 2020-05-24 20:19:43 +02:00
Ozzie Isaacs e4eab17595 Fix version detect of binaries on windows 2020-05-24 17:24:54 +02:00
Ozzieisaacs cf10244f20 Fix for failed recovery of config_logfile 2020-05-24 09:59:45 +02:00
Ozzieisaacs 570684d308 Fix custom bool column not visible in adv search if linked to read status 2020-05-23 21:26:39 +02:00
Ozzieisaacs 244db8d894 Fix from tests advanced search for custom columns 2020-05-23 21:17:58 +02:00
Ozzieisaacs 96d6018ecc Added ability to view comicapi version
Changed required comicapi version
Unified "cannot" and "Cannot" texts
Removed annoying "was already removed" string from log
2020-05-23 16:20:19 +02:00
OzzieIsaacs 73ad6dd0c4 Fix kobo sync (sync tags) 2020-05-23 14:40:50 +02:00
OzzieIsaacs d0e15da352 Fix lcase function 2020-05-23 12:51:48 +02:00
Ozzieisaacs b1b293a3ec Fix order_authors 2020-05-23 11:09:50 +02:00
Ozzieisaacs 5f0660a4e5 Refactored helper.py and db.py 2020-05-23 10:16:29 +02:00
Ozzieisaacs ec3a3a73ef Merge branch 'master' into Develop 2020-05-23 08:50:24 +02:00
Ozzieisaacs 087c4c5929 Merge remote-tracking branch 'opds/master' 2020-05-23 08:48:08 +02:00
Ozzieisaacs e0ee2e0801 Merge remote-tracking branch 'typo/master' 2020-05-23 08:47:08 +02:00
Michael Knepher c79a9e9858 Fix typo "Shelfs" to "Shelves" 2020-05-22 11:43:52 -07:00
OzzieIsaacs b3fdce36af Update Testresults 2020-05-22 09:01:39 +02:00
OzzieIsaacs b7535b9526 Merging master branch
- fix title sort function
- fix focus on search
2020-05-21 22:31:29 +02:00
OzzieIsaacs 0cf1cc5587 Fixes from tests 2020-05-21 22:26:19 +02:00
Ozzieisaacs 098dab889a Fixed title sorting routine 2020-05-21 19:37:54 +02:00
Ozzieisaacs cc856c7cd1 Merge remote-tracking branch 'search_focus/activate-search-focus-if-search-in-progress' 2020-05-21 19:18:02 +02:00
Ozzieisaacs a20a155d39 Merge remote-tracking branch 'typo/patch-2' into Develop 2020-05-21 19:14:29 +02:00
Ozzieisaacs 1a458fe39f Fix for #1407 converting books should now be possible again 2020-05-21 18:16:11 +02:00
celogeek 051ffdda35 activate search focus if search in progress 2020-05-21 16:42:02 +02:00
OzzieIsaacs a48418364c Fiexes from tests 2020-05-21 13:54:28 +02:00
Ozzieisaacs b75497231e Additional fix for #1407 (metadata.db is now held in memory, app.db is attached to it -> joins between both databases possible -> book_read_link is joined for getting result) 2020-05-21 09:28:35 +02:00
Knepherbird 5cceeb6ef2 Fix: correct property typo
Correcting 'box-sizeing' to 'box-sizing'
2020-05-19 13:10:25 -07:00
Ozzieisaacs 29b94c5615 Fix for #1407 (to many read books lead to to large sql query) -> only fix for linked calibre-column 2020-05-19 21:36:22 +02:00
Ozzieisaacs 81fc1eccd3 Fix for #1407 (to many read books lead to to large sql query) -> only fix for linked calibre-column 2020-05-19 21:35:56 +02:00
Braincoke 22fae51c9d Fix XML parsing error when using OPDS feeds
Using the OPDS feeds with MoonReader yielded the following error:
"Error parsing XML: unbound prefix".
This was due to a missing namespace in the feed.xml template.
See https://github.com/janeczku/calibre-web/issues/1403 for more
information.
2020-05-18 20:07:02 +02:00
Ozzieisaacs 4332f7a640 Better detection of localhost for kobo sync (possibly related to #1400) 2020-05-17 21:44:12 +02:00
Ozzieisaacs d0e603e62d Better detection of localhost for kobo sync 2020-05-17 21:42:25 +02:00
Ozzieisaacs 38c28f4358 Merge branch 'master' into Develop
# Conflicts:
#	cps/admin.py
#	cps/constants.py
#	cps/static/css/caliBlur.min.css
#	cps/uploader.py
2020-05-17 16:22:58 +02:00
Ozzieisaacs 742799b4ac Added missing float custom column to search form 2020-05-17 16:10:10 +02:00
Ozzieisaacs 5405dc5141 Fix for #1387 (saving settings with enabled gdrive metadata watch led to crash) 2020-05-17 11:15:46 +02:00
Ozzieisaacs 013793f989 Fix for #1391 (Kobo sync not working if series is given, but no series_index) 2020-05-17 10:46:48 +02:00
Ozzieisaacs 2468cf63cc Fix for #1397 (changed supported audio files)
Changed max gevent version
Fix for #1397 (changed supported audio files)
2020-05-17 10:07:36 +02:00
Ozzieisaacs 8e9b5d7e50 Merge remote-tracking branch 'caliblur/master' 2020-05-15 21:01:08 +02:00
Ozzieisaacs a33515d907 Merge remote-tracking branch 'refactor/refactor_uploader' 2020-05-15 20:36:00 +02:00
Ozzieisaacs a276a33081 Merge remote-tracking branch 'nl/master' 2020-05-15 20:34:30 +02:00
h1f0x e325c3dbf6 fixed div selection in caliBlur.js 2020-05-14 12:29:52 +02:00
h1f0x b3fef625a8 Fixed Calibur views: series, authors, publishers, ratings, file formats, detail view 2020-05-14 11:57:38 +02:00
Ozzieisaacs 13994a5f96 Merge branch 'master' into Develop 2020-05-13 20:16:29 +02:00
Ozzieisaacs e8ac62cdd8 Moved password replace to prevent incomplete session 2020-05-13 20:15:35 +02:00
Ozzieisaacs 1bc7134ec2 Fix error 500 on reset password in debug mode 2020-05-13 20:04:43 +02:00
Ozzieisaacs 273572f44c Merge branch 'master' into Develop
# Conflicts:
#	cps/ub.py
2020-05-13 20:03:54 +02:00
Ozzieisaacs ac37483d47 Fix for #1391 (kobo sync errors out if read/unread books had been present in app.db during initial database migration) 2020-05-13 19:43:14 +02:00
Ozzieisaacs 0cc2b49296 Merge branch 'master' into Develop
# Conflicts:
#	cps/templates/book_edit.html
2020-05-12 19:10:19 +02:00
Ozzieisaacs 44d5adc16f Fix #1390 2020-05-12 19:08:51 +02:00
Ozzieisaacs f749fc641b Temporary fix for #1390 2020-05-12 17:42:24 +02:00
Ozzieisaacs 87c76c09e2 temporary fix for #1390 2020-05-12 17:41:49 +02:00
Ozzieisaacs e787f9dd9f Automatic username (#1172) 2020-05-12 17:23:58 +02:00
Ozzieisaacs ec7d5b17ab Added table view for books 2020-05-12 16:32:26 +02:00
Ozzieisaacs 47641eee59 Merge branch 'master' into Develop 2020-05-12 16:16:04 +02:00
Ozzieisaacs 42abe28cc1 Fix for #1389 (import ldap users with whitespaces) 2020-05-12 16:13:56 +02:00
Ozzieisaacs b48afa38ac Fix #1386 (Add asin to recognized identifiers) 2020-05-12 14:44:57 +02:00
Ozzieisaacs f7269d8df2 Fix for #1385 (Private shelves are listed twice in the "Add to shelf" dropdown menu) 2020-05-12 14:39:13 +02:00
Ozzieisaacs ce0fab8d2f Fix duplicate shelf names in "search" 2020-05-12 14:37:13 +02:00
Ozzieisaacs 33472567de Improved Debug output on send email 2020-05-11 19:28:22 +02:00
Ozzieisaacs f5e12328dc Fix for #1382 (Restrictions with "&" in it can't be deleted) 2020-05-11 18:41:34 +02:00
Ozzieisaacs 486c0f2937 Fix for #1382 (Restrictions with "&" in it can't be deleted) 2020-05-11 18:41:16 +02:00
jvoisin e69c4cd1dc Refactor a bit cps/uploader.py 2020-05-11 13:15:30 +02:00
Marcel e0d3ccd8d1 Update messages.po 2020-05-10 21:05:39 +02:00
Ozzieisaacs 16a3deec2c Merge branch 'master' into Develop
# Conflicts:
#	cps/helper.py
2020-05-10 19:24:55 +02:00
OzzieIsaacs 92db00692a Merge all headers to download response
Updated test results
2020-05-10 14:58:18 +02:00
OzzieIsaacs fe88010a72 Merge remote-tracking branch 'sec_fixes/minor_fix_caliblur' 2020-05-10 14:57:19 +02:00
OzzieIsaacs 99ae4be2c2 Merge remote-tracking branch 'sec_fixes/bump_jquery' 2020-05-10 10:43:20 +02:00
OzzieIsaacs a9085752c1 Fix error "email" not in to_save 2020-05-10 10:26:22 +02:00
OzzieIsaacs e1fbc9255c Merge remote-tracking branch 'sec_fixes/bump_underscore' 2020-05-10 10:26:01 +02:00
OzzieIsaacs f33e25ac40 Merge remote-tracking branch 'sec_fixes/cookies_improvement' 2020-05-10 10:22:21 +02:00
OzzieIsaacs 51365ab006 Merge remote-tracking branch 'sec_fixes/strong_session_protection' 2020-05-10 10:21:19 +02:00
OzzieIsaacs d61b7e48d7 Merge remote-tracking branch 'sec_fixes/random_password' 2020-05-10 10:18:40 +02:00
OzzieIsaacs f590b24f85 Merge remote-tracking branch 'sec_fixes/https' 2020-05-10 10:17:36 +02:00
Ozzieisaacs 308fd55483 #1141 (Setting for file size limit on email) 2020-05-09 20:29:17 +02:00
Ozzieisaacs fefb44e612 #1356 (fixes for readonly metadata.db)
Fix remove trailing metadata.db at entering calibre_db_path
2020-05-09 19:54:28 +02:00
jvoisin dd3b562f1a Change some links from http to https 2020-05-09 17:11:56 +02:00
jvoisin 30c9aa3df9 Minor fixes to caliBlur.js
- Add alt attributes to images
- Fix a broken tag
2020-05-09 17:07:22 +02:00
jvoisin 688184e255 Bump jquery 2020-05-09 17:00:03 +02:00
Ozzieisaacs 75fb7c2e95 Allowing upload extensions (#1119) 2020-05-09 16:54:22 +02:00
jvoisin 264b4b669e Bump underscorejs version from 1.9.1 to 1.12.2 2020-05-09 16:54:21 +02:00
Ozzieisaacs 51f12c51ad Fix #1361 (covers of archived books not shown) 2020-05-09 16:37:02 +02:00
Ozzieisaacs 03d134697c Fix #1361 (covers of archived books not shown) 2020-05-09 16:36:08 +02:00
Ozzie Isaacs e706e1a68d Update CONTRIBUTING.md 2020-05-09 16:15:52 +02:00
Ozzieisaacs ff3f42db95 Fix #1364 (translated format identifier)
Updated french Translation
2020-05-09 16:12:55 +02:00
Ozzieisaacs e8aedeac36 Refactored admin.py 2020-05-09 16:00:31 +02:00
Ozzie Isaacs 2bf6b263ed correction of contribution guideline 2020-05-09 15:58:10 +02:00
jvoisin bf166b757a Improve a bit the cookie's hardening
- Samesite for session cookies as well as the remember me ones
- Httponly
2020-05-09 14:42:28 +02:00
jvoisin b4165335a7 Use strong sessions protection
See https://flask-login.readthedocs.io/en/latest/#session-protection for
details
2020-05-09 14:34:14 +02:00
jvoisin 2a1bf2fa71 Generate strong random passwords 2020-05-09 14:24:20 +02:00
Ozzieisaacs 718d50a037 Starting again without traceback (moved gdriveutil import) 2020-05-09 12:17:28 +02:00
Ozzieisaacs 41960ada4a Autodetect binaries 2020-05-09 11:04:35 +02:00
Ozzieisaacs 0a02caad04 Improvements 2020-05-09 11:01:00 +02:00
Ozzieisaacs ff75bdba9e Merge branch 'master' into Develop 2020-05-08 19:05:08 +02:00
Ozzieisaacs 189243a9b0 Merge remote-tracking branch 'publisher_sort/patch-1' 2020-05-08 15:04:45 +02:00
Ozzieisaacs 34e339c506 Merge remote-tracking branch 'it/patch-12' 2020-05-08 14:59:51 +02:00
Ozzieisaacs a437c603c6 Merge remote-tracking branch 'kepubify/Develop' into Develop
# Conflicts:
#	cps/admin.py
#	cps/helper.py
#	cps/templates/config_edit.html
#	cps/web.py
2020-05-08 14:53:21 +02:00
Ozzieisaacs 4e940f7fa0 Added response header for improving security 2020-05-08 14:49:12 +02:00
Knepherbird 69fde7dead Update web.py
Set db.Publishers query to order by name column, because publishers.sort column is empty.
2020-05-07 13:55:59 -07:00
Ozzieisaacs 4368c182a0 Make goodreads compatible for betterreads dependency 2020-05-06 20:57:54 +02:00
Ozzieisaacs 48f4b12c0e Merge branch 'master' into Develop
# Conflicts:
#	cps/editbooks.py
2020-05-06 18:47:33 +02:00
Ozzieisaacs 6a6c1b6b21 Fix for #1358, #1355 2020-05-06 16:25:03 +02:00
Ozzieisaacs 51808d2ad4 Version Bump 2020-05-05 20:31:12 +02:00
ElQuimm 148f1109c6 updated messages.po
just a little update for coherence with Read/da leggere -> Archived/da archiviare.
Sorry :-)
2020-05-04 20:56:58 +02:00
Ozzieisaacs e1439b529b Config Options for limiting email size, change username to e-mail adress, use kepubify
Added work on Unrar5 decompression (breaks comic reader totally)
2020-05-04 18:19:30 +02:00
Ozzieisaacs 0adcd1b3d9 UI Improvements
Added additional restrictions to Calibre DB interface
2020-05-03 10:55:33 +02:00
Ozzieisaacs fcefd8031a Fix #985 (png and webp are extracted as cover files from comic files) 2020-05-02 11:24:30 +02:00
Ozzieisaacs 64bebaa1d1 Update Upload formats 2020-05-02 10:46:00 +02:00
Ozzieisaacs 0138ff9e16 Added additional config options 2020-05-02 10:18:01 +02:00
Ozzieisaacs 9bc085a23e Fixes for comic reader 2020-05-02 09:35:14 +02:00
Ozzieisaacs 0a92d79ec0 Merge remote-tracking branch 'cover-series/feature/add-cover-serie-view' into Develop
# Conflicts:
#	cps/static/css/style.css
#	cps/ub.py
#	cps/web.py
2020-05-01 17:25:13 +02:00
Ozzieisaacs b95f6563cc Merge remote-tracking branch 'read-config/remove-duplicate-read-status-without-filter' into Develop 2020-05-01 17:19:13 +02:00
celogeek ca2bcc647d Handle read config
Allow advance search
Remove duplicate status on show
2020-04-19 12:50:58 +02:00
pthiben b90048d72e fix badge color on grid view to match list view 2020-04-18 23:41:01 -04:00
pthiben a5fe08e84c Fix button color that now matches HEAD on master
Update name for HTML Series that changed with HEAD
2020-04-18 23:32:15 -04:00
pthiben 2874cf531c Merge remote-tracking branch 'origin/feature/add-cover-serie-view' into feature/add-cover-serie-view
# Conflicts:
#	cps/ub.py
#	cps/web.py
2020-04-18 23:27:56 -04:00
pthiben ea7058e896 Update button lables: it seems strange to click on 'Grid' to get the list view and vice versa 2020-04-18 23:23:56 -04:00
pthiben 38bb10d36b apply suggestion from @OzzieIsaacs that fixes sorting with caliblur theme.
@OzzieIsaacs : I have no idea what the consequences are about this CSS style change. I played around in caliblur and did not notice anything weird, but I'm no calibre-web hardcore user
2020-04-18 23:23:56 -04:00
pthiben 58943bb156 update filtering so that it also uses isotope everywhere.
Fix asc/desc that did not match list view
2020-04-18 23:23:56 -04:00
pthiben 2d66da3cb9 restrict button for grid<->list switch to series lists 2020-04-18 23:23:56 -04:00
pthiben b7efbf9040 resynced grid view with list view
Changed drop-down menu to button, with same style as the other buttons. I'll probably have to make a last sync with master for final approval
2020-04-18 23:23:56 -04:00
pthiben 5222e157cb fix standard theme badges so that they stand on top left corner instead of top right: each element's width in the list seems to be double the size of the image, so right alignment gets tricky. https://github.com/janeczku/calibre-web/pull/986#issuecomment-517999218 suggests top-left alignment which does make a lot of sense. Using this for now. Maintainer might have a better idea to fix it 2020-04-18 23:23:55 -04:00
pthiben 1e3a948977 fix linter errors
Fix the sorting
Save the sorting state
Remove unnecessary filter
Add support for grid view
2020-04-18 23:22:51 -04:00
pthiben 20cc5107da Update button lables: it seems strange to click on 'Grid' to get the list view and vice versa 2020-04-18 22:57:25 -04:00
pthiben a6a4d5f09b apply suggestion from @OzzieIsaacs that fixes sorting with caliblur theme.
@OzzieIsaacs : I have no idea what the consequences are about this CSS style change. I played around in caliblur and did not notice anything weird, but I'm no calibre-web hardcore user
2020-04-18 22:56:24 -04:00
pthiben 028c53287d update filtering so that it also uses isotope everywhere.
Fix asc/desc that did not match list view
2020-04-18 22:54:58 -04:00
pthiben 24a9bea137 restrict button for grid<->list switch to series lists 2020-04-18 22:16:49 -04:00
pthiben ef1a2d1730 resynced grid view with list view
Changed drop-down menu to button, with same style as the other buttons. I'll probably have to make a last sync with master for final approval
2020-04-18 22:10:21 -04:00
pthiben 6abff36e07 fix standard theme badges so that they stand on top left corner instead of top right: each element's width in the list seems to be double the size of the image, so right alignment gets tricky. https://github.com/janeczku/calibre-web/pull/986#issuecomment-517999218 suggests top-left alignment which does make a lot of sense. Using this for now. Maintainer might have a better idea to fix it 2020-04-18 20:36:27 -04:00
pthiben 4ef7615d88 Merge remote-tracking branch 'origin/feature/add-cover-serie-view' into feature/add-cover-serie-view
# Conflicts:
#	cps/ub.py
2020-04-14 14:53:23 -04:00
pthiben 77c2783a3e fix linter errors
Fix the sorting
Save the sorting state
Remove unnecessary filter
Add support for grid view
2020-04-14 14:48:06 -04:00
pthiben 5b1dfc123f fix linter errors
Fix the sorting
Save the sorting state
Remove unnecessary filter
Add support for grid view
2020-04-13 17:27:14 -04:00
Vincent Kriek 38a255e069 Add automatic epub to kepub conversion using kepubify 2019-08-18 21:44:19 +02:00
623 changed files with 136635 additions and 99960 deletions
+8 -7
View File
@@ -6,6 +6,7 @@ labels: ''
assignees: '' assignees: ''
--- ---
<!-- Please have a look at our [Contributing Guidelines](https://github.com/janeczku/calibre-web/blob/master/CONTRIBUTING.md) -->
**Describe the bug/problem** **Describe the bug/problem**
A clear and concise description of what the bug is. If you are asking for support, please check our [Wiki](https://github.com/janeczku/calibre-web/wiki) if your question is already answered there. A clear and concise description of what the bug is. If you are asking for support, please check our [Wiki](https://github.com/janeczku/calibre-web/wiki) if your question is already answered there.
@@ -27,12 +28,12 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
**Environment (please complete the following information):** **Environment (please complete the following information):**
- OS: [e.g. Windows 10/raspian] - OS: [e.g. Windows 10/Raspberry Pi OS]
- Python version [e.g. python2.7] - Python version: [e.g. python2.7]
- Calibre-Web version [e.g. 0.6.5 or master@16.02.20, 19:55 ]: - Calibre-Web version: [e.g. 0.6.8 or 087c4c59 (git rev-parse --short HEAD)]:
- Docker container [ None/Technosoft2000/Linuxuser]: - Docker container: [None/Technosoft2000/LinuxServer]:
- Special Hardware [e.g. Rasperry Pi Zero] - Special Hardware: [e.g. Rasperry Pi Zero]
- Browser [e.g. chrome, safari] - Browser: [e.g. Chrome 83.0.4103.97, Safari 13.3.7, Firefox 68.0.1 ESR]
**Additional context** **Additional context**
Add any other context about the problem here. [e.g. access via reverse proxy] Add any other context about the problem here. [e.g. access via reverse proxy, database background sync, special database location]
+1
View File
@@ -0,0 +1 @@
blank_issues_enabled: false
@@ -7,6 +7,8 @@ assignees: ''
--- ---
<!-- Please have a look at our [Contributing Guidelines](https://github.com/janeczku/calibre-web/blob/master/CONTRIBUTING.md) -->
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+2 -1
View File
@@ -10,6 +10,7 @@ env/
venv/ venv/
eggs/ eggs/
dist/ dist/
executable/
build/ build/
vendor/ vendor/
.eggs/ .eggs/
@@ -29,4 +30,4 @@ vendor/
settings.yaml settings.yaml
gdrive_credentials gdrive_credentials
client_secrets.json client_secrets.json
gmail.json
+11 -14
View File
@@ -1,30 +1,30 @@
## How to contribute to Calibre-Web ## How to contribute to Calibre-Web
First of all, we would like to thank you for reading this text. we are happy you are willing to contribute to Calibre-Web First of all, we would like to thank you for reading this text. We are happy you are willing to contribute to Calibre-Web.
### **General** ### **General**
**Communication language** is english. Google translated texts are not as bad as you might think, they are usually understandable, so don't worry if you generate your post that way. **Communication language** is English. Google translated texts are not as bad as you might think, they are usually understandable, so don't worry if you generate your post that way.
**Calibre-Web** is not **Calibre**. If you are having a question regarding Calibre please post this at their [repository](https://github.com/kovidgoyal/calibre). **Calibre-Web** is not **Calibre**. If you are having a question regarding Calibre please post this at their [repository](https://github.com/kovidgoyal/calibre).
**Docker-Containers** of Calibre-Web are maintained by different persons than the people who drive Calibre-Web. If we come to the conclusion during our analysis that the problem is related to Docker, we might ask you to open a new issue at the reprository of the Docker Container. **Docker-Containers** of Calibre-Web are maintained by different persons than the people who drive Calibre-Web. If we come to the conclusion during our analysis that the problem is related to Docker, we might ask you to open a new issue at the repository of the Docker Container.
If you are having **Basic Installation Problems** with python or it's dependencies, please consider using your favorite search engine to find a solution. In case you can't find a solution, we are happy to help you. If you are having **Basic Installation Problems** with python or its dependencies, please consider using your favorite search engine to find a solution. In case you can't find a solution, we are happy to help you.
We can offer only very limited support regarding configuration of **Reverse-Proxy Installations**, **OPDS-Reader** or other programs in combination with Calibre-Web. We can offer only very limited support regarding configuration of **Reverse-Proxy Installations**, **OPDS-Reader** or other programs in combination with Calibre-Web.
### **Translation** ### **Translation**
Some of the user languages in Calibre-Web having missing translations. We are happy to add the missing texts if you are translate them. Create a Pull Request, create an issue with the .po file attached, or write an email to "ozzie.fernandez.isaacs@googlemail.com" with attached translation file. To display all book languages in your native language an additional file is used (iso_language_names.py). The content of this file is autogenerated with the corresponding translations of Calibre, please do not edit this file on your own. Some of the user languages in Calibre-Web having missing translations. We are happy to add the missing texts if you translate them. Create a Pull Request, create an issue with the .po file attached, or write an email to "ozzie.fernandez.isaacs@googlemail.com" with attached translation file. To display all book languages in your native language an additional file is used (iso_language_names.py). The content of this file is auto-generated with the corresponding translations of Calibre, please do not edit this file on your own.
### **Documentation** ### **Documentation**
The Calibre-Web documentation is hosted in the Github [Wiki](https://github.com/janeczku/calibre-web/wiki). The Wiki is open to everybody, if you find a problem, feel free to correct it. If information is missing, you are welcome to add it. The content will be reviewed time by time. Please try to be consitent with the form with the other Wiki pages (e.g. the project name is Calibre-Web with 2 capital letters and a dash in between). The Calibre-Web documentation is hosted in the Github [Wiki](https://github.com/janeczku/calibre-web/wiki). The Wiki is open to everybody, if you find a problem, feel free to correct it. If information is missing, you are welcome to add it. The content will be reviewed time by time. Please try to be consistent with the form with the other Wiki pages (e.g. the project name is Calibre-Web with 2 capital letters and a dash in between).
### **Reporting a bug** ### **Reporting a bug**
Do not open up a GitHub issue if the bug is a **security vulnerability** in Calibre-Web. Please write intead an email to "ozzie.fernandez.isaacs@googlemail.com". Do not open up a GitHub issue if the bug is a **security vulnerability** in Calibre-Web. Instead, please write an email to "ozzie.fernandez.isaacs@googlemail.com".
Ensure the ***bug was not already reported** by searching on GitHub under [Issues](https://github.com/janeczku/calibre-web/issues). Please also check if a solution for your problem can be found in the [wiki](https://github.com/janeczku/calibre-web/wiki). Ensure the ***bug was not already reported** by searching on GitHub under [Issues](https://github.com/janeczku/calibre-web/issues). Please also check if a solution for your problem can be found in the [wiki](https://github.com/janeczku/calibre-web/wiki).
@@ -32,18 +32,15 @@ If you're unable to find an **open issue** addressing the problem, open a [new o
### **Feature Request** ### **Feature Request**
If there is afeature missing in Calibre-Web and you can't find a feature request in the [Issues](https://github.com/janeczku/calibre-web/issues) section, you could create a [feature request](https://github.com/janeczku/calibre-web/issues/new?assignees=&labels=&template=feature_request.md&title=). If there is a feature missing in Calibre-Web and you can't find a feature request in the [Issues](https://github.com/janeczku/calibre-web/issues) section, you could create a [feature request](https://github.com/janeczku/calibre-web/issues/new?assignees=&labels=&template=feature_request.md&title=).
We will not extend Calibre-Web with any more login abilitys or add further files storages, or file syncing ability. Furthermore Calibre-Web is made for home usage for company inhouse usage, so requests regarding any sorts of social interaction capability, payment routines, search engine or web site analytics integration will not be implemeted. We will not extend Calibre-Web with any more login abilities or add further files storages, or file syncing ability. Furthermore Calibre-Web is made for home usage for company in-house usage, so requests regarding any sorts of social interaction capability, payment routines, search engine or web site analytics integration will not be implemented.
### **Contributing code to Calibre-Web** ### **Contributing code to Calibre-Web**
Open a new GitHub pull request with the patch. Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. Open a new GitHub pull request with the patch. Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
In case your code enhances features of Calibre-Web: Create your pull request for the development branch if your enhancement consits of more than some lines of code in a local section of Calibre-Webs code. This makes it easier to test it and check all implication before it's made public. In case your code enhances features of Calibre-Web: Create your pull request for the development branch if your enhancement consists of more than some lines of code in a local section of Calibre-Webs code. This makes it easier to test it and check all implication before it's made public.
Please check if your code runs on Python 2.7 (still necessary in 2020) and mainly on python 3. If possible and the feature is related to operating system functions, try to check it on Windows and Linux. Please check if your code runs on Python 2.7 (still necessary in 2020) and mainly on python 3. If possible and the feature is related to operating system functions, try to check it on Windows and Linux.
Calibre-Web is automatically tested on Linux in combination with python 3.7. The code for testing is in a [seperate repo](https://github.com/OzzieIsaacs/calibre-web-test) on Github. It uses unittest and performs real system tests with selenium, would be great if you could consider also writing some tests. Calibre-Web is automatically tested on Linux in combination with python 3.7. The code for testing is in a [separate repo](https://github.com/OzzieIsaacs/calibre-web-test) on Github. It uses unit tests and performs real system tests with selenium; it would be great if you could consider also writing some tests.
A static code analysis is done by Codacy, but it's partly broken and doesn't run automatically. You could check your code with ESLint before contributing, a configuration file can be found in the projects root folder. A static code analysis is done by Codacy, but it's partly broken and doesn't run automatically. You could check your code with ESLint before contributing, a configuration file can be found in the projects root folder.
+17 -11
View File
@@ -2,6 +2,8 @@
Calibre-Web is a web app providing a clean interface for browsing, reading and downloading eBooks using an existing [Calibre](https://calibre-ebook.com) database. Calibre-Web is a web app providing a clean interface for browsing, reading and downloading eBooks using an existing [Calibre](https://calibre-ebook.com) database.
![GitHub License](https://img.shields.io/github/license/janeczku/calibre-web) ![GitHub Downloads](https://img.shields.io/github/downloads/janeczku/calibre-web/total) ![GitHub commit activity](https://img.shields.io/github/commit-activity/w/janeczku/calibre-web?logo=github) [![Discord](https://img.shields.io/discord/838810113564344381?label=Discord&logo=discord)](https://discord.gg/h2VsJ2NEfB)
*This software is a fork of [library](https://github.com/mutschler/calibreserver) and licensed under the GPL v3 License.* *This software is a fork of [library](https://github.com/mutschler/calibreserver) and licensed under the GPL v3 License.*
![Main screen](https://github.com/janeczku/calibre-web/wiki/images/main_screen.png) ![Main screen](https://github.com/janeczku/calibre-web/wiki/images/main_screen.png)
@@ -12,7 +14,7 @@ Calibre-Web is a web app providing a clean interface for browsing, reading and d
- full graphical setup - full graphical setup
- User management with fine-grained per-user permissions - User management with fine-grained per-user permissions
- Admin interface - Admin interface
- User Interface in czech, dutch, english, finnish, french, german, hungarian, italian, japanese, khmer, polish, russian, simplified chinese, spanish, swedish, turkish, ukrainian - User Interface in brazilian, czech, dutch, english, finnish, french, german, greek, hungarian, italian, japanese, khmer, polish, russian, simplified chinese, spanish, swedish, turkish, ukrainian
- OPDS feed for eBook reader apps - OPDS feed for eBook reader apps
- Filter and search by titles, authors, tags, series and language - Filter and search by titles, authors, tags, series and language
- Create a custom book collection (shelves) - Create a custom book collection (shelves)
@@ -22,7 +24,7 @@ Calibre-Web is a web app providing a clean interface for browsing, reading and d
- Support for public user registration - Support for public user registration
- Send eBooks to Kindle devices with the click of a button - Send eBooks to Kindle devices with the click of a button
- Sync your Kobo devices through Calibre-Web with your Calibre library - Sync your Kobo devices through Calibre-Web with your Calibre library
- Support for reading eBooks directly in the browser (.txt, .epub, .pdf, .cbr, .cbt, .cbz) - Support for reading eBooks directly in the browser (.txt, .epub, .pdf, .cbr, .cbt, .cbz, .djvu)
- Upload new books in many formats, including audio formats (.mp3, .m4a, .m4b) - Upload new books in many formats, including audio formats (.mp3, .m4a, .m4b)
- Support for Calibre Custom Columns - Support for Calibre Custom Columns
- Ability to hide content based on categories and Custom Column content per user - Ability to hide content based on categories and Custom Column content per user
@@ -32,8 +34,8 @@ Calibre-Web is a web app providing a clean interface for browsing, reading and d
## Quick start ## Quick start
1. Install dependencies by running `pip3 install --target vendor -r requirements.txt` (python3.x) or `pip install --target vendor -r requirements.txt` (python2.7). 1. Install dependencies by running `pip3 install --target vendor -r requirements.txt` (python3.x). Alternativly set up a python virtual environment.
2. Execute the command: `python cps.py` (or `nohup python cps.py` - recommended if you want to exit the terminal window) 2. Execute the command: `python3 cps.py` (or `nohup python3 cps.py` - recommended if you want to exit the terminal window)
3. Point your browser to `http://localhost:8083` or `http://localhost:8083/opds` for the OPDS catalog 3. Point your browser to `http://localhost:8083` or `http://localhost:8083/opds` for the OPDS catalog
4. Set `Location of Calibre database` to the path of the folder where your Calibre library (metadata.db) lives, push "submit" button\ 4. Set `Location of Calibre database` to the path of the folder where your Calibre library (metadata.db) lives, push "submit" button\
Optionally a Google Drive can be used to host the calibre library [-> Using Google Drive integration](https://github.com/janeczku/calibre-web/wiki/Configuration#using-google-drive-integration) Optionally a Google Drive can be used to host the calibre library [-> Using Google Drive integration](https://github.com/janeczku/calibre-web/wiki/Configuration#using-google-drive-integration)
@@ -48,29 +50,27 @@ Please note that running the above install command can fail on some versions of
## Requirements ## Requirements
python 3.x+, (Python 2.7+) python 3.x+
Optionally, to enable on-the-fly conversion from one ebook format to another when using the send-to-kindle feature, or during editing of ebooks metadata: Optionally, to enable on-the-fly conversion from one ebook format to another when using the send-to-kindle feature, or during editing of ebooks metadata:
[Download and install](https://calibre-ebook.com/download) the Calibre desktop program for your platform and enter the folder including program name (normally /opt/calibre/ebook-convert, or C:\Program Files\calibre\ebook-convert.exe) in the field "calibre's converter tool" on the setup page. [Download and install](https://calibre-ebook.com/download) the Calibre desktop program for your platform and enter the folder including program name (normally /opt/calibre/ebook-convert, or C:\Program Files\calibre\ebook-convert.exe) in the field "calibre's converter tool" on the setup page.
\*** DEPRECATED \*** Support will be removed in future releases [Download](https://github.com/pgaskin/kepubify/releases/latest) Kepubify tool for your platform and place the binary starting with `kepubify` in Linux: `\opt\kepubify` Windows: `C:\Program Files\kepubify`.
[Download](http://www.amazon.com/gp/feature.html?docId=1000765211) Amazon's KindleGen tool for your platform and place the binary named `kindlegen` in the `vendor` folder.
## Docker Images ## Docker Images
Pre-built Docker images are available in these Docker Hub repositories: Pre-built Docker images are available in these Docker Hub repositories:
#### **Technosoft2000 - x64** #### **Technosoft2000 - x64**
+ Docker Hub - [https://hub.docker.com/r/technosoft2000/calibre-web/](https://hub.docker.com/r/technosoft2000/calibre-web/) + Docker Hub - [https://hub.docker.com/r/technosoft2000/calibre-web](https://hub.docker.com/r/technosoft2000/calibre-web)
+ Github - [https://github.com/Technosoft2000/docker-calibre-web](https://github.com/Technosoft2000/docker-calibre-web) + Github - [https://github.com/Technosoft2000/docker-calibre-web](https://github.com/Technosoft2000/docker-calibre-web)
Includes the Calibre `ebook-convert` binary. Includes the Calibre `ebook-convert` binary.
+ The "path to convertertool" should be set to `/opt/calibre/ebook-convert` + The "path to convertertool" should be set to `/opt/calibre/ebook-convert`
#### **LinuxServer - x64, armhf, aarch64** #### **LinuxServer - x64, armhf, aarch64**
+ Docker Hub - [https://hub.docker.com/r/linuxserver/calibre-web/](https://hub.docker.com/r/linuxserver/calibre-web/) + Docker Hub - [https://hub.docker.com/r/linuxserver/calibre-web](https://hub.docker.com/r/linuxserver/calibre-web)
+ Github - [https://github.com/linuxserver/docker-calibre-web](https://github.com/linuxserver/docker-calibre-web) + Github - [https://github.com/linuxserver/docker-calibre-web](https://github.com/linuxserver/docker-calibre-web)
+ Github - (Optional Calibre layer) - [https://github.com/linuxserver/docker-calibre-web/tree/calibre](https://github.com/linuxserver/docker-calibre-web/tree/calibre) + Github - (Optional Calibre layer) - [https://github.com/linuxserver/docker-calibre-web/tree/calibre](https://github.com/linuxserver/docker-calibre-web/tree/calibre)
@@ -82,6 +82,12 @@ Pre-built Docker images are available in these Docker Hub repositories:
+ The "path to convertertool" should be set to `/usr/bin/ebook-convert` + The "path to convertertool" should be set to `/usr/bin/ebook-convert`
+ The "path to unrar" should be set to `/usr/bin/unrar` + The "path to unrar" should be set to `/usr/bin/unrar`
# Wiki # Contact
Just reach us out on [Discord](https://discord.gg/h2VsJ2NEfB)
For further information, How To's and FAQ please check the [Wiki](https://github.com/janeczku/calibre-web/wiki) For further information, How To's and FAQ please check the [Wiki](https://github.com/janeczku/calibre-web/wiki)
# Contributing to Calibre-Web
Please have a look at our [Contributing Guidelines](https://github.com/janeczku/calibre-web/blob/master/CONTRIBUTING.md)
+7
View File
@@ -41,6 +41,8 @@ from cps.shelf import shelf
from cps.admin import admi from cps.admin import admi
from cps.gdrive import gdrive from cps.gdrive import gdrive
from cps.editbooks import editbook from cps.editbooks import editbook
from cps.remotelogin import remotelogin
from cps.error_handler import init_errorhandler
try: try:
from cps.kobo import kobo, get_kobo_activated from cps.kobo import kobo, get_kobo_activated
@@ -58,12 +60,17 @@ except ImportError:
def main(): def main():
app = create_app() app = create_app()
init_errorhandler()
app.register_blueprint(web) app.register_blueprint(web)
app.register_blueprint(opds) app.register_blueprint(opds)
app.register_blueprint(jinjia) app.register_blueprint(jinjia)
app.register_blueprint(about) app.register_blueprint(about)
app.register_blueprint(shelf) app.register_blueprint(shelf)
app.register_blueprint(admi) app.register_blueprint(admi)
app.register_blueprint(remotelogin)
# if config.config_use_google_drive:
app.register_blueprint(gdrive) app.register_blueprint(gdrive)
app.register_blueprint(editbook) app.register_blueprint(editbook)
if kobo_available: if kobo_available:
+20 -5
View File
@@ -37,6 +37,7 @@ from . import config_sql, logger, cache_buster, cli, ub, db
from .reverseproxy import ReverseProxied from .reverseproxy import ReverseProxied
from .server import WebServer from .server import WebServer
mimetypes.init() mimetypes.init()
mimetypes.add_type('application/xhtml+xml', '.xhtml') mimetypes.add_type('application/xhtml+xml', '.xhtml')
mimetypes.add_type('application/epub+zip', '.epub') mimetypes.add_type('application/epub+zip', '.epub')
@@ -44,6 +45,7 @@ mimetypes.add_type('application/fb2+zip', '.fb2')
mimetypes.add_type('application/x-mobipocket-ebook', '.mobi') mimetypes.add_type('application/x-mobipocket-ebook', '.mobi')
mimetypes.add_type('application/x-mobipocket-ebook', '.prc') mimetypes.add_type('application/x-mobipocket-ebook', '.prc')
mimetypes.add_type('application/vnd.amazon.ebook', '.azw') mimetypes.add_type('application/vnd.amazon.ebook', '.azw')
mimetypes.add_type('application/x-mobi8-ebook', '.azw3')
mimetypes.add_type('application/x-cbr', '.cbr') mimetypes.add_type('application/x-cbr', '.cbr')
mimetypes.add_type('application/x-cbz', '.cbz') mimetypes.add_type('application/x-cbz', '.cbz')
mimetypes.add_type('application/x-cbt', '.cbt') mimetypes.add_type('application/x-cbt', '.cbt')
@@ -56,16 +58,22 @@ mimetypes.add_type('application/ogg', '.ogg')
mimetypes.add_type('application/ogg', '.oga') mimetypes.add_type('application/ogg', '.oga')
app = Flask(__name__) app = Flask(__name__)
app.config.update(
SESSION_COOKIE_HTTPONLY=True,
SESSION_COOKIE_SAMESITE='Lax',
REMEMBER_COOKIE_SAMESITE='Lax', # will be available in flask-login 0.5.1 earliest
)
lm = LoginManager() lm = LoginManager()
lm.login_view = 'web.login' lm.login_view = 'web.login'
lm.anonymous_user = ub.Anonymous lm.anonymous_user = ub.Anonymous
lm.session_protection = 'strong'
ub.init_db(cli.settingspath) ub.init_db(cli.settingspath)
# pylint: disable=no-member # pylint: disable=no-member
config = config_sql.load_configuration(ub.session) config = config_sql.load_configuration(ub.session)
searched_ids = {}
web_server = WebServer() web_server = WebServer()
babel = Babel() babel = Babel()
@@ -75,23 +83,30 @@ log = logger.create()
from . import services from . import services
db.CalibreDB.setup_db(config, cli.settingspath)
calibre_db = db.CalibreDB()
def create_app(): def create_app():
app.wsgi_app = ReverseProxied(app.wsgi_app) app.wsgi_app = ReverseProxied(app.wsgi_app)
# For python2 convert path to unicode # For python2 convert path to unicode
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
app.static_folder = app.static_folder.decode('utf-8') app.static_folder = app.static_folder.decode('utf-8')
app.root_path = app.root_path.decode('utf-8') app.root_path = app.root_path.decode('utf-8')
app.instance_path = app.instance_path .decode('utf-8') app.instance_path = app.instance_path.decode('utf-8')
cache_buster.init_cache_busting(app) if os.environ.get('FLASK_DEBUG'):
cache_buster.init_cache_busting(app)
log.info('Starting Calibre Web...') log.info('Starting Calibre Web...')
if sys.version_info < (3, 0):
log.info('Python2 is EOL since end of 2019, this version of Calibre-Web is no longer supporting Python2 please consider upgrading to Python3')
print('Python2 is EOL since end of 2019, this version of Calibre-Web is no longer supporting Python2 please consider upgrading to Python3')
Principal(app) Principal(app)
lm.init_app(app) lm.init_app(app)
app.secret_key = os.getenv('SECRET_KEY', config_sql.get_flask_session_key(ub.session)) app.secret_key = os.getenv('SECRET_KEY', config_sql.get_flask_session_key(ub.session))
web_server.init_app(app, config) web_server.init_app(app, config)
db.setup_db(config)
babel.init_app(app) babel.init_app(app)
_BABEL_TRANSLATIONS.update(str(item) for item in babel.list_translations()) _BABEL_TRANSLATIONS.update(str(item) for item in babel.list_translations())
@@ -112,7 +127,7 @@ def get_locale():
user = getattr(g, 'user', None) user = getattr(g, 'user', None)
# user = None # user = None
if user is not None and hasattr(user, "locale"): if user is not None and hasattr(user, "locale"):
if user.nickname != 'Guest': # if the account is the guest account bypass the config lang settings if user.name != 'Guest': # if the account is the guest account bypass the config lang settings
return user.locale return user.locale
preferred = list() preferred = list()
+23 -9
View File
@@ -30,13 +30,14 @@ import babel, pytz, requests, sqlalchemy
import werkzeug, flask, flask_login, flask_principal, jinja2 import werkzeug, flask, flask_login, flask_principal, jinja2
from flask_babel import gettext as _ from flask_babel import gettext as _
from . import db, converter, uploader, server, isoLanguages, constants from . import db, calibre_db, converter, uploader, server, isoLanguages, constants
from .web import render_title_template from .render_template import render_title_template
try: try:
from flask_login import __version__ as flask_loginVersion from flask_login import __version__ as flask_loginVersion
except ImportError: except ImportError:
from flask_login.__about__ import __version__ as flask_loginVersion from flask_login.__about__ import __version__ as flask_loginVersion
try: try:
# pylint: disable=unused-import
import unidecode import unidecode
# _() necessary to make babel aware of string for translation # _() necessary to make babel aware of string for translation
unidecode_version = _(u'installed') unidecode_version = _(u'installed')
@@ -48,6 +49,11 @@ try:
except ImportError: except ImportError:
flask_danceVersion = None flask_danceVersion = None
try:
from greenlet import __version__ as greenlet_Version
except ImportError:
greenlet_Version = None
from . import services from . import services
about = flask.Blueprint('about', __name__) about = flask.Blueprint('about', __name__)
@@ -77,18 +83,26 @@ _VERSIONS = OrderedDict(
python_LDAP = services.ldapVersion if bool(services.ldapVersion) else None, python_LDAP = services.ldapVersion if bool(services.ldapVersion) else None,
Goodreads = u'installed' if bool(services.goodreads_support) else None, Goodreads = u'installed' if bool(services.goodreads_support) else None,
jsonschema = services.SyncToken.__version__ if bool(services.SyncToken) else None, jsonschema = services.SyncToken.__version__ if bool(services.SyncToken) else None,
flask_dance = flask_danceVersion flask_dance = flask_danceVersion,
greenlet = greenlet_Version
) )
_VERSIONS.update(uploader.get_versions()) _VERSIONS.update(uploader.get_versions())
def collect_stats():
_VERSIONS['ebook converter'] = _(converter.get_calibre_version())
_VERSIONS['unrar'] = _(converter.get_unrar_version())
_VERSIONS['kepubify'] = _(converter.get_kepubify_version())
return _VERSIONS
@about.route("/stats") @about.route("/stats")
@flask_login.login_required @flask_login.login_required
def stats(): def stats():
counter = db.session.query(db.Books).count() counter = calibre_db.session.query(db.Books).count()
authors = db.session.query(db.Authors).count() authors = calibre_db.session.query(db.Authors).count()
categorys = db.session.query(db.Tags).count() categorys = calibre_db.session.query(db.Tags).count()
series = db.session.query(db.Series).count() series = calibre_db.session.query(db.Series).count()
_VERSIONS['ebook converter'] = _(converter.get_version()) return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=collect_stats(),
return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=_VERSIONS,
categorycounter=categorys, seriecounter=series, title=_(u"Statistics"), page="stat") categorycounter=categorys, seriecounter=series, title=_(u"Statistics"), page="stat")
+1231 -481
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -49,7 +49,7 @@ def init_cache_busting(app):
# compute version component # compute version component
rooted_filename = os.path.join(dirpath, filename) rooted_filename = os.path.join(dirpath, filename)
with open(rooted_filename, 'rb') as f: with open(rooted_filename, 'rb') as f:
file_hash = hashlib.md5(f.read()).hexdigest()[:7] file_hash = hashlib.md5(f.read()).hexdigest()[:7] # nosec
# save version to tables # save version to tables
file_path = rooted_filename.replace(static_folder, "") file_path = rooted_filename.replace(static_folder, "")
@@ -64,6 +64,7 @@ def init_cache_busting(app):
return filename.split("?", 1)[0] return filename.split("?", 1)[0]
@app.url_defaults @app.url_defaults
# pylint: disable=unused-variable
def reverse_to_cache_busted_url(endpoint, values): def reverse_to_cache_busted_url(endpoint, values):
""" """
Make `url_for` produce busted filenames when using the 'static' endpoint. Make `url_for` produce busted filenames when using the 'static' endpoint.
+18 -11
View File
@@ -45,6 +45,7 @@ parser.add_argument('-v', '--version', action='version', help='Shows version num
version=version_info()) version=version_info())
parser.add_argument('-i', metavar='ip-address', help='Server IP-Address to listen') parser.add_argument('-i', metavar='ip-address', help='Server IP-Address to listen')
parser.add_argument('-s', metavar='user:pass', help='Sets specific username to new password') parser.add_argument('-s', metavar='user:pass', help='Sets specific username to new password')
parser.add_argument('-f', action='store_true', help='Enables filepicker in unconfigured mode')
args = parser.parse_args() args = parser.parse_args()
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
@@ -70,7 +71,7 @@ if args.c:
if os.path.isfile(args.c): if os.path.isfile(args.c):
certfilepath = args.c certfilepath = args.c
else: else:
print("Certfilepath is invalid. Exiting...") print("Certfile path is invalid. Exiting...")
sys.exit(1) sys.exit(1)
if args.c == "": if args.c == "":
@@ -80,7 +81,7 @@ if args.k:
if os.path.isfile(args.k): if os.path.isfile(args.k):
keyfilepath = args.k keyfilepath = args.k
else: else:
print("Keyfilepath is invalid. Exiting...") print("Keyfile path is invalid. Exiting...")
sys.exit(1) sys.exit(1)
if (args.k and not args.c) or (not args.k and args.c): if (args.k and not args.c) or (not args.k and args.c):
@@ -90,23 +91,29 @@ if (args.k and not args.c) or (not args.k and args.c):
if args.k == "": if args.k == "":
keyfilepath = "" keyfilepath = ""
# handle and check ipadress argument # handle and check ip address argument
ipadress = args.i or None ip_address = args.i or None
if ipadress: if ip_address:
try: try:
# try to parse the given ip address with socket # try to parse the given ip address with socket
if hasattr(socket, 'inet_pton'): if hasattr(socket, 'inet_pton'):
if ':' in ipadress: if ':' in ip_address:
socket.inet_pton(socket.AF_INET6, ipadress) socket.inet_pton(socket.AF_INET6, ip_address)
else: else:
socket.inet_pton(socket.AF_INET, ipadress) socket.inet_pton(socket.AF_INET, ip_address)
else: else:
# on windows python < 3.4, inet_pton is not available # on windows python < 3.4, inet_pton is not available
# inet_atom only handles IPv4 addresses # inet_atom only handles IPv4 addresses
socket.inet_aton(ipadress) socket.inet_aton(ip_address)
except socket.error as err: except socket.error as err:
print(ipadress, ':', err) print(ip_address, ':', err)
sys.exit(1) sys.exit(1)
# handle and check user password argument # handle and check user password argument
user_password = args.s or None user_credentials = args.s or None
if user_credentials and ":" not in user_credentials:
print("No valid 'username:password' format")
sys.exit(3)
# Handles enabling of filepicker
filepicker = args.f or None
+89 -63
View File
@@ -26,80 +26,109 @@ from .constants import BookMeta
log = logger.create() log = logger.create()
try:
from wand.image import Image
use_IM = True
except (ImportError, RuntimeError) as e:
use_IM = False
try: try:
from comicapi.comicarchive import ComicArchive, MetaDataStyle from comicapi.comicarchive import ComicArchive, MetaDataStyle
use_comic_meta = True use_comic_meta = True
except ImportError as e: try:
log.debug('cannot import comicapi, extracting comic metadata will not work: %s', e) from comicapi import __version__ as comic_version
except ImportError:
comic_version = ''
except (ImportError, LookupError) as e:
log.debug('Cannot import comicapi, extracting comic metadata will not work: %s', e)
import zipfile import zipfile
import tarfile import tarfile
try: try:
import rarfile import rarfile
use_rarfile = True use_rarfile = True
except ImportError as e: except (ImportError, SyntaxError) as e:
log.debug('cannot import rarfile, extracting cover files from rar files will not work: %s', e) log.debug('Cannot import rarfile, extracting cover files from rar files will not work: %s', e)
use_rarfile = False use_rarfile = False
use_comic_meta = False use_comic_meta = False
NO_JPEG_EXTENSIONS = ['.png', '.webp', '.bmp']
COVER_EXTENSIONS = ['.png', '.webp', '.bmp', '.jpg', '.jpeg']
def _extractCover(tmp_file_name, original_file_extension, rarExceutable): def _cover_processing(tmp_file_name, img, extension):
cover_data = extension = None tmp_cover_name = os.path.join(os.path.dirname(tmp_file_name), 'cover.jpg')
if use_comic_meta: if use_IM:
archive = ComicArchive(tmp_file_name) # convert to jpg because calibre only supports jpg
for index, name in enumerate(archive.getPageNameList()): if extension in NO_JPEG_EXTENSIONS:
with Image(filename=tmp_file_name) as imgc:
imgc.format = 'jpeg'
imgc.transform_colorspace('rgb')
imgc.save(tmp_cover_name)
return tmp_cover_name
if not img:
return None
with open(tmp_cover_name, 'wb') as f:
f.write(img)
return tmp_cover_name
def _extract_Cover_from_archive(original_file_extension, tmp_file_name, rarExecutable):
cover_data = None
if original_file_extension.upper() == '.CBZ':
cf = zipfile.ZipFile(tmp_file_name)
for name in cf.namelist():
ext = os.path.splitext(name) ext = os.path.splitext(name)
if len(ext) > 1: if len(ext) > 1:
extension = ext[1].lower() extension = ext[1].lower()
if extension == '.jpg' or extension == '.jpeg': if extension in COVER_EXTENSIONS:
cover_data = archive.getPage(index) cover_data = cf.read(name)
break break
else: elif original_file_extension.upper() == '.CBT':
if original_file_extension.upper() == '.CBZ': cf = tarfile.TarFile(tmp_file_name)
cf = zipfile.ZipFile(tmp_file_name) for name in cf.getnames():
for name in cf.namelist(): ext = os.path.splitext(name)
ext = os.path.splitext(name) if len(ext) > 1:
if len(ext) > 1: extension = ext[1].lower()
extension = ext[1].lower() if extension in COVER_EXTENSIONS:
if extension == '.jpg' or extension == '.jpeg': cover_data = cf.extractfile(name).read()
cover_data = cf.read(name) break
break elif original_file_extension.upper() == '.CBR' and use_rarfile:
elif original_file_extension.upper() == '.CBT': try:
cf = tarfile.TarFile(tmp_file_name) rarfile.UNRAR_TOOL = rarExecutable
cf = rarfile.RarFile(tmp_file_name)
for name in cf.getnames(): for name in cf.getnames():
ext = os.path.splitext(name) ext = os.path.splitext(name)
if len(ext) > 1: if len(ext) > 1:
extension = ext[1].lower() extension = ext[1].lower()
if extension == '.jpg' or extension == '.jpeg': if extension in COVER_EXTENSIONS:
cover_data = cf.extractfile(name).read() cover_data = cf.read(name)
break break
elif original_file_extension.upper() == '.CBR' and use_rarfile: except Exception as ex:
try: log.debug('Rarfile failed with error: %s', ex)
rarfile.UNRAR_TOOL = rarExceutable return cover_data
cf = rarfile.RarFile(tmp_file_name)
for name in cf.getnames():
ext = os.path.splitext(name)
if len(ext) > 1:
extension = ext[1].lower()
if extension == '.jpg' or extension == '.jpeg':
cover_data = cf.read(name)
break
except Exception as e:
log.debug('Rarfile failed with error: %s', e)
prefix = os.path.dirname(tmp_file_name)
if cover_data:
tmp_cover_name = prefix + '/cover' + extension
image = open(tmp_cover_name, 'wb')
image.write(cover_data)
image.close()
else:
tmp_cover_name = None
return tmp_cover_name
def get_comic_info(tmp_file_path, original_file_name, original_file_extension, rarExceutable): def _extractCover(tmp_file_name, original_file_extension, rarExecutable):
cover_data = extension = None
if use_comic_meta: if use_comic_meta:
archive = ComicArchive(tmp_file_path, rar_exe_path=rarExceutable) archive = ComicArchive(tmp_file_name, rar_exe_path=rarExecutable)
for index, name in enumerate(archive.getPageNameList()):
ext = os.path.splitext(name)
if len(ext) > 1:
extension = ext[1].lower()
if extension in COVER_EXTENSIONS:
cover_data = archive.getPage(index)
break
else:
cover_data = _extract_Cover_from_archive(original_file_extension, tmp_file_name, rarExecutable)
return _cover_processing(tmp_file_name, cover_data, extension)
def get_comic_info(tmp_file_path, original_file_name, original_file_extension, rarExecutable):
if use_comic_meta:
archive = ComicArchive(tmp_file_path, rar_exe_path=rarExecutable)
if archive.seemsToBeAComicArchive(): if archive.seemsToBeAComicArchive():
if archive.hasMetadata(MetaDataStyle.CIX): if archive.hasMetadata(MetaDataStyle.CIX):
style = MetaDataStyle.CIX style = MetaDataStyle.CIX
@@ -111,35 +140,32 @@ def get_comic_info(tmp_file_path, original_file_name, original_file_extension, r
# if style is not None: # if style is not None:
loadedMetadata = archive.readMetadata(style) loadedMetadata = archive.readMetadata(style)
lang = loadedMetadata.language lang = loadedMetadata.language or ""
if lang: loadedMetadata.language = isoLanguages.get_lang3(lang)
if len(lang) == 2:
loadedMetadata.language = isoLanguages.get(part1=lang).name
elif len(lang) == 3:
loadedMetadata.language = isoLanguages.get(part3=lang).name
else:
loadedMetadata.language = ""
return BookMeta( return BookMeta(
file_path=tmp_file_path, file_path=tmp_file_path,
extension=original_file_extension, extension=original_file_extension,
title=loadedMetadata.title or original_file_name, title=loadedMetadata.title or original_file_name,
author=" & ".join([credit["person"] for credit in loadedMetadata.credits if credit["role"] == "Writer"]) or u'Unknown', author=" & ".join([credit["person"]
cover=_extractCover(tmp_file_path, original_file_extension, rarExceutable), for credit in loadedMetadata.credits if credit["role"] == "Writer"]) or u'Unknown',
cover=_extractCover(tmp_file_path, original_file_extension, rarExecutable),
description=loadedMetadata.comments or "", description=loadedMetadata.comments or "",
tags="", tags="",
series=loadedMetadata.series or "", series=loadedMetadata.series or "",
series_id=loadedMetadata.issue or "", series_id=loadedMetadata.issue or "",
languages=loadedMetadata.language) languages=loadedMetadata.language,
publisher="")
return BookMeta( return BookMeta(
file_path=tmp_file_path, file_path=tmp_file_path,
extension=original_file_extension, extension=original_file_extension,
title=original_file_name, title=original_file_name,
author=u'Unknown', author=u'Unknown',
cover=_extractCover(tmp_file_path, original_file_extension, rarExceutable), cover=_extractCover(tmp_file_path, original_file_extension, rarExecutable),
description="", description="",
tags="", tags="",
series="", series="",
series_id="", series_id="",
languages="") languages="",
publisher="")
+135 -49
View File
@@ -19,13 +19,19 @@
from __future__ import division, print_function, unicode_literals from __future__ import division, print_function, unicode_literals
import os import os
import json
import sys import sys
import json
from sqlalchemy import exc, Column, String, Integer, SmallInteger, Boolean, BLOB from sqlalchemy import Column, String, Integer, SmallInteger, Boolean, BLOB, JSON
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.exc import OperationalError
from sqlalchemy.sql.expression import text
try:
# Compatibility with sqlalchemy 2.0
from sqlalchemy.orm import declarative_base
except ImportError:
from sqlalchemy.ext.declarative import declarative_base
from . import constants, cli, logger, ub from . import constants, cli, logger
log = logger.create() log = logger.create()
@@ -35,7 +41,7 @@ class _Flask_Settings(_Base):
__tablename__ = 'flask_settings' __tablename__ = 'flask_settings'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
flask_session_key = Column(BLOB, default="") flask_session_key = Column(BLOB, default=b"")
def __init__(self, key): def __init__(self, key):
self.flask_session_key = key self.flask_session_key = key
@@ -53,9 +59,13 @@ class _Settings(_Base):
mail_login = Column(String, default='mail@example.com') mail_login = Column(String, default='mail@example.com')
mail_password = Column(String, default='mypassword') mail_password = Column(String, default='mypassword')
mail_from = Column(String, default='automailer <mail@example.com>') mail_from = Column(String, default='automailer <mail@example.com>')
mail_size = Column(Integer, default=25*1024*1024)
mail_server_type = Column(SmallInteger, default=0)
mail_gmail_token = Column(JSON, default={})
config_calibre_dir = Column(String) config_calibre_dir = Column(String)
config_port = Column(Integer, default=constants.DEFAULT_PORT) config_port = Column(Integer, default=constants.DEFAULT_PORT)
config_external_port = Column(Integer, default=constants.DEFAULT_PORT)
config_certfile = Column(String) config_certfile = Column(String)
config_keyfile = Column(String) config_keyfile = Column(String)
@@ -64,7 +74,7 @@ class _Settings(_Base):
config_random_books = Column(Integer, default=4) config_random_books = Column(Integer, default=4)
config_authors_max = Column(Integer, default=0) config_authors_max = Column(Integer, default=0)
config_read_column = Column(Integer, default=0) config_read_column = Column(Integer, default=0)
config_title_regex = Column(String, default=u'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+') config_title_regex = Column(String, default=r'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+')
config_mature_content_tags = Column(String, default='') config_mature_content_tags = Column(String, default='')
config_theme = Column(Integer, default=0) config_theme = Column(Integer, default=0)
@@ -91,35 +101,38 @@ class _Settings(_Base):
config_use_google_drive = Column(Boolean, default=False) config_use_google_drive = Column(Boolean, default=False)
config_google_drive_folder = Column(String) config_google_drive_folder = Column(String)
config_google_drive_watch_changes_response = Column(String) config_google_drive_watch_changes_response = Column(JSON, default={})
config_use_goodreads = Column(Boolean, default=False) config_use_goodreads = Column(Boolean, default=False)
config_goodreads_api_key = Column(String) config_goodreads_api_key = Column(String)
config_goodreads_api_secret = Column(String) config_goodreads_api_secret = Column(String)
config_register_email = Column(Boolean, default=False)
config_login_type = Column(Integer, default=0) config_login_type = Column(Integer, default=0)
config_kobo_proxy = Column(Boolean, default=False) config_kobo_proxy = Column(Boolean, default=False)
config_ldap_provider_url = Column(String, default='example.org') config_ldap_provider_url = Column(String, default='example.org')
config_ldap_port = Column(SmallInteger, default=389) config_ldap_port = Column(SmallInteger, default=389)
config_ldap_authentication = Column(SmallInteger, default=constants.LDAP_AUTH_SIMPLE) config_ldap_authentication = Column(SmallInteger, default=constants.LDAP_AUTH_SIMPLE)
config_ldap_serv_username = Column(String, default='cn=admin,dc=example,dc=org') config_ldap_serv_username = Column(String, default='cn=admin,dc=example,dc=org')
config_ldap_serv_password = Column(String, default="") config_ldap_serv_password = Column(String, default="")
config_ldap_encryption = Column(SmallInteger, default=0) config_ldap_encryption = Column(SmallInteger, default=0)
config_ldap_cacert_path = Column(String, default="")
config_ldap_cert_path = Column(String, default="") config_ldap_cert_path = Column(String, default="")
config_ldap_key_path = Column(String, default="")
config_ldap_dn = Column(String, default='dc=example,dc=org') config_ldap_dn = Column(String, default='dc=example,dc=org')
config_ldap_user_object = Column(String, default='uid=%s') config_ldap_user_object = Column(String, default='uid=%s')
config_ldap_member_user_object = Column(String, default='') #
config_ldap_openldap = Column(Boolean, default=True) config_ldap_openldap = Column(Boolean, default=True)
config_ldap_group_object_filter = Column(String, default='(&(objectclass=posixGroup)(cn=%s))') config_ldap_group_object_filter = Column(String, default='(&(objectclass=posixGroup)(cn=%s))')
config_ldap_group_members_field = Column(String, default='memberUid') config_ldap_group_members_field = Column(String, default='memberUid')
config_ldap_group_name = Column(String, default='calibreweb') config_ldap_group_name = Column(String, default='calibreweb')
config_ebookconverter = Column(Integer, default=0) config_kepubifypath = Column(String, default=None)
config_converterpath = Column(String) config_converterpath = Column(String, default=None)
config_calibre = Column(String) config_calibre = Column(String)
config_rarfile_location = Column(String) config_rarfile_location = Column(String, default=None)
config_upload_formats = Column(String, default=','.join(constants.EXTENSIONS_UPLOAD))
config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE) config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE)
@@ -140,6 +153,23 @@ class _ConfigSQL(object):
self.config_calibre_dir = None self.config_calibre_dir = None
self.load() self.load()
change = False
if self.config_converterpath == None: # pylint: disable=access-member-before-definition
change = True
self.config_converterpath = autodetect_calibre_binary()
if self.config_kepubifypath == None: # pylint: disable=access-member-before-definition
change = True
self.config_kepubifypath = autodetect_kepubify_binary()
if self.config_rarfile_location == None: # pylint: disable=access-member-before-definition
change = True
self.config_rarfile_location = autodetect_unrar_binary()
if change:
self.save()
def _read_from_storage(self): def _read_from_storage(self):
if self._settings is None: if self._settings is None:
log.debug("_ConfigSQL._read_from_storage") log.debug("_ConfigSQL._read_from_storage")
@@ -160,8 +190,9 @@ class _ConfigSQL(object):
return None return None
return self.config_keyfile return self.config_keyfile
def get_config_ipaddress(self): @staticmethod
return cli.ipadress or "" def get_config_ipaddress():
return cli.ip_address or ""
def _has_role(self, role_flag): def _has_role(self, role_flag):
return constants.has_flag(self.config_default_role, role_flag) return constants.has_flag(self.config_default_role, role_flag)
@@ -197,20 +228,20 @@ class _ConfigSQL(object):
return self.show_element_new_user(constants.DETAIL_RANDOM) return self.show_element_new_user(constants.DETAIL_RANDOM)
def list_denied_tags(self): def list_denied_tags(self):
mct = self.config_denied_tags.split(",") mct = self.config_denied_tags or ""
return [t.strip() for t in mct] return [t.strip() for t in mct.split(",")]
def list_allowed_tags(self): def list_allowed_tags(self):
mct = self.config_allowed_tags.split(",") mct = self.config_allowed_tags or ""
return [t.strip() for t in mct] return [t.strip() for t in mct.split(",")]
def list_denied_column_values(self): def list_denied_column_values(self):
mct = self.config_denied_column_value.split(",") mct = self.config_denied_column_value or ""
return [t.strip() for t in mct] return [t.strip() for t in mct.split(",")]
def list_allowed_column_values(self): def list_allowed_column_values(self):
mct = self.config_allowed_column_value.split(",") mct = self.config_allowed_column_value or ""
return [t.strip() for t in mct] return [t.strip() for t in mct.split(",")]
def get_log_level(self): def get_log_level(self):
return logger.get_level_name(self.config_log_level) return logger.get_level_name(self.config_log_level)
@@ -219,18 +250,18 @@ class _ConfigSQL(object):
return {k:v for k, v in self.__dict__.items() if k.startswith('mail_')} return {k:v for k, v in self.__dict__.items() if k.startswith('mail_')}
def get_mail_server_configured(self): def get_mail_server_configured(self):
return not bool(self.mail_server == constants.DEFAULT_MAIL_SERVER) return bool((self.mail_server != constants.DEFAULT_MAIL_SERVER and self.mail_server_type == 0)
or (self.mail_gmail_token != {} and self.mail_server_type == 1))
def set_from_dictionary(self, dictionary, field, convertor=None, default=None, encode=None): def set_from_dictionary(self, dictionary, field, convertor=None, default=None, encode=None):
'''Possibly updates a field of this object. """Possibly updates a field of this object.
The new value, if present, is grabbed from the given dictionary, and optionally passed through a convertor. The new value, if present, is grabbed from the given dictionary, and optionally passed through a convertor.
:returns: `True` if the field has changed value :returns: `True` if the field has changed value
''' """
new_value = dictionary.get(field, default) new_value = dictionary.get(field, default)
if new_value is None: if new_value is None:
# log.debug("_ConfigSQL set_from_dictionary field '%s' not found", field)
return False return False
if field not in self.__dict__: if field not in self.__dict__:
@@ -247,10 +278,17 @@ class _ConfigSQL(object):
if current_value == new_value: if current_value == new_value:
return False return False
# log.debug("_ConfigSQL set_from_dictionary '%s' = %r (was %r)", field, new_value, current_value)
setattr(self, field, new_value) setattr(self, field, new_value)
return True return True
def toDict(self):
storage = {}
for k, v in self.__dict__.items():
if k[0] != '_' and not k.endswith("password") and not k.endswith("secret"):
storage[k] = v
return storage
def load(self): def load(self):
'''Load all configuration values from the underlying storage.''' '''Load all configuration values from the underlying storage.'''
s = self._read_from_storage() # type: _Settings s = self._read_from_storage() # type: _Settings
@@ -263,17 +301,27 @@ class _ConfigSQL(object):
v = column.default.arg v = column.default.arg
setattr(self, k, v) setattr(self, k, v)
if self.config_google_drive_watch_changes_response:
self.config_google_drive_watch_changes_response = json.loads(self.config_google_drive_watch_changes_response)
have_metadata_db = bool(self.config_calibre_dir) have_metadata_db = bool(self.config_calibre_dir)
if have_metadata_db: if have_metadata_db:
if not self.config_use_google_drive: if not self.config_use_google_drive:
db_file = os.path.join(self.config_calibre_dir, 'metadata.db') db_file = os.path.join(self.config_calibre_dir, 'metadata.db')
have_metadata_db = os.path.isfile(db_file) have_metadata_db = os.path.isfile(db_file)
self.db_configured = have_metadata_db self.db_configured = have_metadata_db
constants.EXTENSIONS_UPLOAD = [x.lstrip().rstrip().lower() for x in self.config_upload_formats.split(',')]
logger.setup(self.config_logfile, self.config_log_level) if os.environ.get('FLASK_DEBUG'):
logfile = logger.setup(logger.LOG_TO_STDOUT, logger.logging.DEBUG)
else:
# pylint: disable=access-member-before-definition
logfile = logger.setup(self.config_logfile, self.config_log_level)
if logfile != self.config_logfile:
log.warning("Log path %s not valid, falling back to default", self.config_logfile)
self.config_logfile = logfile
self._session.merge(s)
try:
self._session.commit()
except OperationalError as e:
log.error('Database error: %s', e)
self._session.rollback()
def save(self): def save(self):
'''Apply all configuration values to the underlying storage.''' '''Apply all configuration values to the underlying storage.'''
@@ -287,7 +335,11 @@ class _ConfigSQL(object):
log.debug("_ConfigSQL updating storage") log.debug("_ConfigSQL updating storage")
self._session.merge(s) self._session.merge(s)
self._session.commit() try:
self._session.commit()
except OperationalError as e:
log.error('Database error: %s', e)
self._session.rollback()
self.load() self.load()
def invalidate(self, error=None): def invalidate(self, error=None):
@@ -306,7 +358,7 @@ def _migrate_table(session, orm_class):
if column_name[0] != '_': if column_name[0] != '_':
try: try:
session.query(column).first() session.query(column).first()
except exc.OperationalError as err: except OperationalError as err:
log.debug("%s: %s", column_name, err.args[0]) log.debug("%s: %s", column_name, err.args[0])
if column.default is not None: if column.default is not None:
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
@@ -316,31 +368,65 @@ def _migrate_table(session, orm_class):
column_default = "" column_default = ""
else: else:
if isinstance(column.default.arg, bool): if isinstance(column.default.arg, bool):
column_default = ("DEFAULT %r" % int(column.default.arg)) column_default = "DEFAULT {}".format(int(column.default.arg))
else: else:
column_default = ("DEFAULT %r" % column.default.arg) column_default = "DEFAULT `{}`".format(column.default.arg)
alter_table = "ALTER TABLE %s ADD COLUMN `%s` %s %s" % (orm_class.__tablename__, if isinstance(column.type, JSON):
column_type = "JSON"
else:
column_type = column.type
alter_table = text("ALTER TABLE %s ADD COLUMN `%s` %s %s" % (orm_class.__tablename__,
column_name, column_name,
column.type, column_type,
column_default) column_default))
log.debug(alter_table) log.debug(alter_table)
session.execute(alter_table) session.execute(alter_table)
changed = True changed = True
except json.decoder.JSONDecodeError as e:
log.error("Database corrupt column: {}".format(column_name))
log.debug(e)
if changed: if changed:
session.commit() try:
session.commit()
except OperationalError:
session.rollback()
def autodetect_calibre_binary(): def autodetect_calibre_binary():
if sys.platform == "win32": if sys.platform == "win32":
calibre_path = ["C:\\program files\calibre\calibre-convert.exe", calibre_path = ["C:\\program files\\calibre\\ebook-convert.exe",
"C:\\program files(x86)\calibre\calibre-convert.exe"] "C:\\program files(x86)\\calibre\\ebook-convert.exe",
"C:\\program files(x86)\\calibre2\\ebook-convert.exe",
"C:\\program files\\calibre2\\ebook-convert.exe"]
else: else:
calibre_path = ["/opt/calibre/ebook-convert"] calibre_path = ["/opt/calibre/ebook-convert"]
for element in calibre_path: for element in calibre_path:
if os.path.isfile(element) and os.access(element, os.X_OK): if os.path.isfile(element) and os.access(element, os.X_OK):
return element return element
return None return ""
def autodetect_unrar_binary():
if sys.platform == "win32":
calibre_path = ["C:\\program files\\WinRar\\unRAR.exe",
"C:\\program files(x86)\\WinRar\\unRAR.exe"]
else:
calibre_path = ["/usr/bin/unrar"]
for element in calibre_path:
if os.path.isfile(element) and os.access(element, os.X_OK):
return element
return ""
def autodetect_kepubify_binary():
if sys.platform == "win32":
calibre_path = ["C:\\program files\\kepubify\\kepubify-windows-64Bit.exe",
"C:\\program files(x86)\\kepubify\\kepubify-windows-64Bit.exe"]
else:
calibre_path = ["/opt/kepubify/kepubify-linux-64bit", "/opt/kepubify/kepubify-linux-32bit"]
for element in calibre_path:
if os.path.isfile(element) and os.access(element, os.X_OK):
return element
return ""
def _migrate_database(session): def _migrate_database(session):
# make sure the table is created, if it does not exist # make sure the table is created, if it does not exist
@@ -357,12 +443,12 @@ def load_configuration(session):
session.commit() session.commit()
conf = _ConfigSQL(session) conf = _ConfigSQL(session)
# Migrate from global restrictions to user based restrictions # Migrate from global restrictions to user based restrictions
if bool(conf.config_default_show & constants.MATURE_CONTENT) and conf.config_denied_tags == "": #if bool(conf.config_default_show & constants.MATURE_CONTENT) and conf.config_denied_tags == "":
conf.config_denied_tags = conf.config_mature_content_tags # conf.config_denied_tags = conf.config_mature_content_tags
conf.save() # conf.save()
session.query(ub.User).filter(ub.User.mature_content != True). \ # session.query(ub.User).filter(ub.User.mature_content != True). \
update({"denied_tags": conf.config_mature_content_tags}, synchronize_session=False) # update({"denied_tags": conf.config_mature_content_tags}, synchronize_session=False)
session.commit() # session.commit()
return conf return conf
def get_flask_session_key(session): def get_flask_session_key(session):
+37 -12
View File
@@ -21,7 +21,11 @@ import sys
import os import os
from collections import namedtuple from collections import namedtuple
HOME_CONFIG = False # if installed via pip this variable is set to true (empty file with name .HOMEDIR present)
HOME_CONFIG = os.path.isfile(os.path.join(os.path.dirname(os.path.abspath(__file__)), '.HOMEDIR'))
#In executables updater is not available, so variable is set to False there
UPDATER_AVAILABLE = True
# Base dir is parent of current file, necessary if called from different folder # Base dir is parent of current file, necessary if called from different folder
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
@@ -40,7 +44,7 @@ if HOME_CONFIG:
os.makedirs(home_dir) os.makedirs(home_dir)
CONFIG_DIR = os.environ.get('CALIBRE_DBPATH', home_dir) CONFIG_DIR = os.environ.get('CALIBRE_DBPATH', home_dir)
else: else:
CONFIG_DIR = os.environ.get('CALIBRE_DBPATH', BASE_DIR) CONFIG_DIR = os.environ.get('CALIBRE_DBPATH', BASE_DIR)
ROLE_USER = 0 << 0 ROLE_USER = 0 << 0
@@ -81,9 +85,31 @@ SIDEBAR_PUBLISHER = 1 << 12
SIDEBAR_RATING = 1 << 13 SIDEBAR_RATING = 1 << 13
SIDEBAR_FORMAT = 1 << 14 SIDEBAR_FORMAT = 1 << 14
SIDEBAR_ARCHIVED = 1 << 15 SIDEBAR_ARCHIVED = 1 << 15
SIDEBAR_DOWNLOAD = 1 << 16
SIDEBAR_LIST = 1 << 17
sidebar_settings = {
"detail_random": DETAIL_RANDOM,
"sidebar_language": SIDEBAR_LANGUAGE,
"sidebar_series": SIDEBAR_SERIES,
"sidebar_category": SIDEBAR_CATEGORY,
"sidebar_random": SIDEBAR_RANDOM,
"sidebar_author": SIDEBAR_AUTHOR,
"sidebar_best_rated": SIDEBAR_BEST_RATED,
"sidebar_read_and_unread": SIDEBAR_READ_AND_UNREAD,
"sidebar_recent": SIDEBAR_RECENT,
"sidebar_sorted": SIDEBAR_SORTED,
"sidebar_publisher": SIDEBAR_PUBLISHER,
"sidebar_rating": SIDEBAR_RATING,
"sidebar_format": SIDEBAR_FORMAT,
"sidebar_archived": SIDEBAR_ARCHIVED,
"sidebar_download": SIDEBAR_DOWNLOAD,
"sidebar_list": SIDEBAR_LIST,
}
ADMIN_USER_ROLES = sum(r for r in ALL_ROLES.values()) & ~ROLE_ANONYMOUS ADMIN_USER_ROLES = sum(r for r in ALL_ROLES.values()) & ~ROLE_ANONYMOUS
ADMIN_USER_SIDEBAR = (SIDEBAR_ARCHIVED << 1) - 1 ADMIN_USER_SIDEBAR = (SIDEBAR_LIST << 1) - 1
UPDATE_STABLE = 0 << 0 UPDATE_STABLE = 0 << 0
AUTO_UPDATE_STABLE = 1 << 0 AUTO_UPDATE_STABLE = 1 << 0
@@ -100,7 +126,7 @@ LDAP_AUTH_SIMPLE = 0
DEFAULT_MAIL_SERVER = "mail.example.org" DEFAULT_MAIL_SERVER = "mail.example.org"
DEFAULT_PASSWORD = "admin123" DEFAULT_PASSWORD = "admin123" # nosec
DEFAULT_PORT = 8083 DEFAULT_PORT = 8083
env_CALIBRE_PORT = os.environ.get("CALIBRE_PORT", DEFAULT_PORT) env_CALIBRE_PORT = os.environ.get("CALIBRE_PORT", DEFAULT_PORT)
try: try:
@@ -110,12 +136,11 @@ except ValueError:
del env_CALIBRE_PORT del env_CALIBRE_PORT
EXTENSIONS_AUDIO = {'mp3', 'm4a', 'm4b'} EXTENSIONS_AUDIO = {'mp3', 'mp4', 'ogg', 'opus', 'wav', 'flac', 'm4a', 'm4b'}
EXTENSIONS_CONVERT = {'pdf', 'epub', 'mobi', 'azw3', 'docx', 'rtf', 'fb2', 'lit', 'lrf', 'txt', 'htmlz', 'rtf', 'odt'} EXTENSIONS_CONVERT_FROM = ['pdf', 'epub', 'mobi', 'azw3', 'docx', 'rtf', 'fb2', 'lit', 'lrf', 'txt', 'htmlz', 'rtf', 'odt','cbz','cbr']
EXTENSIONS_UPLOAD = {'txt', 'pdf', 'epub', 'mobi', 'azw', 'azw3', 'cbr', 'cbz', 'cbt', 'djvu', 'prc', 'doc', 'docx', EXTENSIONS_CONVERT_TO = ['pdf', 'epub', 'mobi', 'azw3', 'docx', 'rtf', 'fb2', 'lit', 'lrf', 'txt', 'htmlz', 'rtf', 'odt']
'fb2', 'html', 'rtf', 'lit', 'odt', 'mp3', 'm4a', 'm4b'} EXTENSIONS_UPLOAD = {'txt', 'pdf', 'epub', 'kepub', 'mobi', 'azw', 'azw3', 'cbr', 'cbz', 'cbt', 'djvu', 'prc', 'doc', 'docx',
# EXTENSIONS_READER = set(['txt', 'pdf', 'epub', 'zip', 'cbz', 'tar', 'cbt'] + 'fb2', 'html', 'rtf', 'lit', 'odt', 'mp3', 'mp4', 'ogg', 'opus', 'wav', 'flac', 'm4a', 'm4b'}
# (['rar','cbr'] if feature_support['rar'] else []))
def has_flag(value, bit_flag): def has_flag(value, bit_flag):
@@ -127,9 +152,9 @@ def selected_roles(dictionary):
# :rtype: BookMeta # :rtype: BookMeta
BookMeta = namedtuple('BookMeta', 'file_path, extension, title, author, cover, description, tags, series, ' BookMeta = namedtuple('BookMeta', 'file_path, extension, title, author, cover, description, tags, series, '
'series_id, languages') 'series_id, languages, publisher')
STABLE_VERSION = {'version': '0.6.7'} STABLE_VERSION = {'version': '0.6.12'}
NIGHTLY_VERSION = {} NIGHTLY_VERSION = {}
NIGHTLY_VERSION[0] = '$Format:%H$' NIGHTLY_VERSION[0] = '$Format:%H$'
+14 -9
View File
@@ -29,8 +29,8 @@ log = logger.create()
# _() necessary to make babel aware of string for translation # _() necessary to make babel aware of string for translation
_NOT_CONFIGURED = _('not configured') _NOT_CONFIGURED = _('not configured')
_NOT_INSTALLED = 'not installed' _NOT_INSTALLED = _('not installed')
_EXECUTION_ERROR = 'Execution permissions missing' _EXECUTION_ERROR = _('Execution permissions missing')
def _get_command_version(path, pattern, argument=None): def _get_command_version(path, pattern, argument=None):
@@ -48,10 +48,15 @@ def _get_command_version(path, pattern, argument=None):
return _NOT_INSTALLED return _NOT_INSTALLED
def get_version(): def get_calibre_version():
version = None return _get_command_version(config.config_converterpath, r'ebook-convert.*\(calibre', '--version') \
if config.config_ebookconverter == 1: or _NOT_CONFIGURED
version = _get_command_version(config.config_converterpath, r'Amazon kindlegen\(')
elif config.config_ebookconverter == 2:
version = _get_command_version(config.config_converterpath, r'ebook-convert.*\(calibre', '--version') def get_unrar_version():
return version or _NOT_CONFIGURED return _get_command_version(config.config_rarfile_location, r'UNRAR.*\d') or _NOT_CONFIGURED
def get_kepubify_version():
return _get_command_version(config.config_kepubifypath, r'kepubify\s','--version') or _NOT_CONFIGURED
Executable → Regular
+588 -188
View File
@@ -22,59 +22,86 @@ import sys
import os import os
import re import re
import ast import ast
import json
from datetime import datetime
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy import Table, Column, ForeignKey from sqlalchemy import Table, Column, ForeignKey, CheckConstraint
from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float, DateTime from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float
from sqlalchemy.orm import relationship, sessionmaker, scoped_session from sqlalchemy.orm import relationship, sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm.collections import InstrumentedList
from sqlalchemy.ext.declarative import DeclarativeMeta
from sqlalchemy.exc import OperationalError
try:
# Compatibility with sqlalchemy 2.0
from sqlalchemy.orm import declarative_base
except ImportError:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.pool import StaticPool
from sqlalchemy.sql.expression import and_, true, false, text, func, or_
from sqlalchemy.ext.associationproxy import association_proxy
from flask_login import current_user
from babel import Locale as LC
from babel.core import UnknownLocaleError
from flask_babel import gettext as _
from flask import flash
from . import logger, ub, isoLanguages
from .pagination import Pagination
session = None from weakref import WeakSet
cc_exceptions = ['datetime', 'comments', 'composite', 'series']
try:
import unidecode
use_unidecode = True
except ImportError:
use_unidecode = False
log = logger.create()
cc_exceptions = ['composite', 'series']
cc_classes = {} cc_classes = {}
engine = None
Base = declarative_base() Base = declarative_base()
books_authors_link = Table('books_authors_link', Base.metadata, books_authors_link = Table('books_authors_link', Base.metadata,
Column('book', Integer, ForeignKey('books.id'), primary_key=True), Column('book', Integer, ForeignKey('books.id'), primary_key=True),
Column('author', Integer, ForeignKey('authors.id'), primary_key=True) Column('author', Integer, ForeignKey('authors.id'), primary_key=True)
) )
books_tags_link = Table('books_tags_link', Base.metadata, books_tags_link = Table('books_tags_link', Base.metadata,
Column('book', Integer, ForeignKey('books.id'), primary_key=True), Column('book', Integer, ForeignKey('books.id'), primary_key=True),
Column('tag', Integer, ForeignKey('tags.id'), primary_key=True) Column('tag', Integer, ForeignKey('tags.id'), primary_key=True)
) )
books_series_link = Table('books_series_link', Base.metadata, books_series_link = Table('books_series_link', Base.metadata,
Column('book', Integer, ForeignKey('books.id'), primary_key=True), Column('book', Integer, ForeignKey('books.id'), primary_key=True),
Column('series', Integer, ForeignKey('series.id'), primary_key=True) Column('series', Integer, ForeignKey('series.id'), primary_key=True)
) )
books_ratings_link = Table('books_ratings_link', Base.metadata, books_ratings_link = Table('books_ratings_link', Base.metadata,
Column('book', Integer, ForeignKey('books.id'), primary_key=True), Column('book', Integer, ForeignKey('books.id'), primary_key=True),
Column('rating', Integer, ForeignKey('ratings.id'), primary_key=True) Column('rating', Integer, ForeignKey('ratings.id'), primary_key=True)
) )
books_languages_link = Table('books_languages_link', Base.metadata, books_languages_link = Table('books_languages_link', Base.metadata,
Column('book', Integer, ForeignKey('books.id'), primary_key=True), Column('book', Integer, ForeignKey('books.id'), primary_key=True),
Column('lang_code', Integer, ForeignKey('languages.id'), primary_key=True) Column('lang_code', Integer, ForeignKey('languages.id'), primary_key=True)
) )
books_publishers_link = Table('books_publishers_link', Base.metadata, books_publishers_link = Table('books_publishers_link', Base.metadata,
Column('book', Integer, ForeignKey('books.id'), primary_key=True), Column('book', Integer, ForeignKey('books.id'), primary_key=True),
Column('publisher', Integer, ForeignKey('publishers.id'), primary_key=True) Column('publisher', Integer, ForeignKey('publishers.id'), primary_key=True)
) )
class Identifiers(Base): class Identifiers(Base):
__tablename__ = 'identifiers' __tablename__ = 'identifiers'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
type = Column(String) type = Column(String(collation='NOCASE'), nullable=False, default="isbn")
val = Column(String) val = Column(String(collation='NOCASE'), nullable=False)
book = Column(Integer, ForeignKey('books.id')) book = Column(Integer, ForeignKey('books.id'), nullable=False)
def __init__(self, val, id_type, book): def __init__(self, val, id_type, book):
self.val = val self.val = val
@@ -82,57 +109,82 @@ class Identifiers(Base):
self.book = book self.book = book
def formatType(self): def formatType(self):
if self.type == "amazon": format_type = self.type.lower()
if format_type == 'amazon':
return u"Amazon" return u"Amazon"
elif self.type == "isbn": elif format_type.startswith("amazon_"):
return u"Amazon.{0}".format(format_type[7:])
elif format_type == "isbn":
return u"ISBN" return u"ISBN"
elif self.type == "doi": elif format_type == "doi":
return u"DOI" return u"DOI"
elif self.type == "goodreads": elif format_type == "douban":
return u"Douban"
elif format_type == "goodreads":
return u"Goodreads" return u"Goodreads"
elif self.type == "google": elif format_type == "babelio":
return u"Babelio"
elif format_type == "google":
return u"Google Books" return u"Google Books"
elif self.type == "kobo": elif format_type == "kobo":
return u"Kobo" return u"Kobo"
if self.type == "lubimyczytac": elif format_type == "litres":
return u"ЛитРес"
elif format_type == "issn":
return u"ISSN"
elif format_type == "isfdb":
return u"ISFDB"
if format_type == "lubimyczytac":
return u"Lubimyczytac" return u"Lubimyczytac"
else: else:
return self.type return self.type
def __repr__(self): def __repr__(self):
if self.type == "amazon": format_type = self.type.lower()
return u"https://amzn.com/{0}".format(self.val) if format_type == "amazon" or format_type == "asin":
elif self.type == "isbn": return u"https://amazon.com/dp/{0}".format(self.val)
return u"http://www.worldcat.org/isbn/{0}".format(self.val) elif format_type.startswith('amazon_'):
elif self.type == "doi": return u"https://amazon.{0}/dp/{1}".format(format_type[7:], self.val)
return u"http://dx.doi.org/{0}".format(self.val) elif format_type == "isbn":
elif self.type == "goodreads": return u"https://www.worldcat.org/isbn/{0}".format(self.val)
return u"http://www.goodreads.com/book/show/{0}".format(self.val) elif format_type == "doi":
elif self.type == "douban": return u"https://dx.doi.org/{0}".format(self.val)
elif format_type == "goodreads":
return u"https://www.goodreads.com/book/show/{0}".format(self.val)
elif format_type == "babelio":
return u"https://www.babelio.com/livres/titre/{0}".format(self.val)
elif format_type == "douban":
return u"https://book.douban.com/subject/{0}".format(self.val) return u"https://book.douban.com/subject/{0}".format(self.val)
elif self.type == "google": elif format_type == "google":
return u"https://books.google.com/books?id={0}".format(self.val) return u"https://books.google.com/books?id={0}".format(self.val)
elif self.type == "kobo": elif format_type == "kobo":
return u"https://www.kobo.com/ebook/{0}".format(self.val) return u"https://www.kobo.com/ebook/{0}".format(self.val)
elif self.type == "lubimyczytac": elif format_type == "lubimyczytac":
return u" http://lubimyczytac.pl/ksiazka/{0}".format(self.val) return u"https://lubimyczytac.pl/ksiazka/{0}/ksiazka".format(self.val)
elif self.type == "url": elif format_type == "litres":
return u"{0}".format(self.val) return u"https://www.litres.ru/{0}".format(self.val)
elif format_type == "issn":
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)
else: else:
return u"" return u"{0}".format(self.val)
class Comments(Base): class Comments(Base):
__tablename__ = 'comments' __tablename__ = 'comments'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
text = Column(String) text = Column(String(collation='NOCASE'), nullable=False)
book = Column(Integer, ForeignKey('books.id')) book = Column(Integer, ForeignKey('books.id'), nullable=False)
def __init__(self, text, book): def __init__(self, text, book):
self.text = text self.text = text
self.book = book self.book = book
def get(self):
return self.text
def __repr__(self): def __repr__(self):
return u"<Comments({0})>".format(self.text) return u"<Comments({0})>".format(self.text)
@@ -141,11 +193,14 @@ class Tags(Base):
__tablename__ = 'tags' __tablename__ = 'tags'
id = Column(Integer, primary_key=True, autoincrement=True) id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String) name = Column(String(collation='NOCASE'), unique=True, nullable=False)
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
def get(self):
return self.name
def __repr__(self): def __repr__(self):
return u"<Tags('{0})>".format(self.name) return u"<Tags('{0})>".format(self.name)
@@ -154,15 +209,18 @@ class Authors(Base):
__tablename__ = 'authors' __tablename__ = 'authors'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
name = Column(String) name = Column(String(collation='NOCASE'), unique=True, nullable=False)
sort = Column(String) sort = Column(String(collation='NOCASE'))
link = Column(String) link = Column(String, nullable=False, default="")
def __init__(self, name, sort, link): def __init__(self, name, sort, link):
self.name = name self.name = name
self.sort = sort self.sort = sort
self.link = link self.link = link
def get(self):
return self.name
def __repr__(self): def __repr__(self):
return u"<Authors('{0},{1}{2}')>".format(self.name, self.sort, self.link) return u"<Authors('{0},{1}{2}')>".format(self.name, self.sort, self.link)
@@ -171,13 +229,16 @@ class Series(Base):
__tablename__ = 'series' __tablename__ = 'series'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
name = Column(String) name = Column(String(collation='NOCASE'), unique=True, nullable=False)
sort = Column(String) sort = Column(String(collation='NOCASE'))
def __init__(self, name, sort): def __init__(self, name, sort):
self.name = name self.name = name
self.sort = sort self.sort = sort
def get(self):
return self.name
def __repr__(self): def __repr__(self):
return u"<Series('{0},{1}')>".format(self.name, self.sort) return u"<Series('{0},{1}')>".format(self.name, self.sort)
@@ -186,11 +247,14 @@ class Ratings(Base):
__tablename__ = 'ratings' __tablename__ = 'ratings'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
rating = Column(Integer) rating = Column(Integer, CheckConstraint('rating>-1 AND rating<11'), unique=True)
def __init__(self, rating): def __init__(self, rating):
self.rating = rating self.rating = rating
def get(self):
return self.rating
def __repr__(self): def __repr__(self):
return u"<Ratings('{0}')>".format(self.rating) return u"<Ratings('{0}')>".format(self.rating)
@@ -199,11 +263,17 @@ class Languages(Base):
__tablename__ = 'languages' __tablename__ = 'languages'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
lang_code = Column(String) lang_code = Column(String(collation='NOCASE'), nullable=False, unique=True)
def __init__(self, lang_code): def __init__(self, lang_code):
self.lang_code = lang_code self.lang_code = lang_code
def get(self):
if self.language_name:
return self.language_name
else:
return self.lang_code
def __repr__(self): def __repr__(self):
return u"<Languages('{0}')>".format(self.lang_code) return u"<Languages('{0}')>".format(self.lang_code)
@@ -212,25 +282,29 @@ class Publishers(Base):
__tablename__ = 'publishers' __tablename__ = 'publishers'
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
name = Column(String) name = Column(String(collation='NOCASE'), nullable=False, unique=True)
sort = Column(String) sort = Column(String(collation='NOCASE'))
def __init__(self, name, sort): def __init__(self, name, sort):
self.name = name self.name = name
self.sort = sort self.sort = sort
def get(self):
return self.name
def __repr__(self): def __repr__(self):
return u"<Publishers('{0},{1}')>".format(self.name, self.sort) return u"<Publishers('{0},{1}')>".format(self.name, self.sort)
class Data(Base): class Data(Base):
__tablename__ = 'data' __tablename__ = 'data'
__table_args__ = {'schema': 'calibre'}
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
book = Column(Integer, ForeignKey('books.id')) book = Column(Integer, ForeignKey('books.id'), nullable=False)
format = Column(String) format = Column(String(collation='NOCASE'), nullable=False)
uncompressed_size = Column(Integer) uncompressed_size = Column(Integer, nullable=False)
name = Column(String) name = Column(String, nullable=False)
def __init__(self, book, book_format, uncompressed_size, name): def __init__(self, book, book_format, uncompressed_size, name):
self.book = book self.book = book
@@ -238,6 +312,10 @@ class Data(Base):
self.uncompressed_size = uncompressed_size self.uncompressed_size = uncompressed_size
self.name = name self.name = name
# ToDo: Check
def get(self):
return self.name
def __repr__(self): def __repr__(self):
return u"<Data('{0},{1}{2}{3}')>".format(self.book, self.format, self.uncompressed_size, self.name) return u"<Data('{0},{1}{2}{3}')>".format(self.book, self.format, self.uncompressed_size, self.name)
@@ -245,22 +323,24 @@ class Data(Base):
class Books(Base): class Books(Base):
__tablename__ = 'books' __tablename__ = 'books'
DEFAULT_PUBDATE = "0101-01-01 00:00:00+00:00" DEFAULT_PUBDATE = datetime(101, 1, 1, 0, 0, 0, 0) # ("0101-01-01 00:00:00+00:00")
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String) title = Column(String(collation='NOCASE'), nullable=False, default='Unknown')
sort = Column(String) sort = Column(String(collation='NOCASE'))
author_sort = Column(String) author_sort = Column(String(collation='NOCASE'))
timestamp = Column(TIMESTAMP) timestamp = Column(TIMESTAMP, default=datetime.utcnow)
pubdate = Column(String) pubdate = Column(TIMESTAMP, default=DEFAULT_PUBDATE)
series_index = Column(String) series_index = Column(String, nullable=False, default="1.0")
last_modified = Column(TIMESTAMP) last_modified = Column(TIMESTAMP, default=datetime.utcnow)
path = Column(String) path = Column(String, default="", nullable=False)
has_cover = Column(Integer) has_cover = Column(Integer, default=0)
uuid = Column(String) uuid = Column(String)
isbn = Column(String(collation='NOCASE'), default="")
flags = Column(Integer, nullable=False, default=1)
authors = relationship('Authors', secondary=books_authors_link, backref='books') authors = relationship('Authors', secondary=books_authors_link, backref='books')
tags = relationship('Tags', secondary=books_tags_link, backref='books',order_by="Tags.name") tags = relationship('Tags', secondary=books_tags_link, backref='books', order_by="Tags.name")
comments = relationship('Comments', backref='books') comments = relationship('Comments', backref='books')
data = relationship('Data', backref='books') data = relationship('Data', backref='books')
series = relationship('Series', secondary=books_series_link, backref='books') series = relationship('Series', secondary=books_series_link, backref='books')
@@ -279,7 +359,8 @@ class Books(Base):
self.series_index = series_index self.series_index = series_index
self.last_modified = last_modified self.last_modified = last_modified
self.path = path self.path = path
self.has_cover = has_cover self.has_cover = (has_cover != None)
def __repr__(self): def __repr__(self):
return u"<Books('{0},{1}{2}{3}{4}{5}{6}{7}{8}')>".format(self.title, self.sort, self.author_sort, return u"<Books('{0},{1}{2}{3}{4}{5}{6}{7}{8}')>".format(self.title, self.sort, self.author_sort,
@@ -290,6 +371,7 @@ class Books(Base):
def atom_timestamp(self): def atom_timestamp(self):
return (self.timestamp.strftime('%Y-%m-%dT%H:%M:%S+00:00') or '') return (self.timestamp.strftime('%Y-%m-%dT%H:%M:%S+00:00') or '')
class Custom_Columns(Base): class Custom_Columns(Base):
__tablename__ = 'custom_columns' __tablename__ = 'custom_columns'
@@ -310,131 +392,449 @@ class Custom_Columns(Base):
return display_dict return display_dict
def update_title_sort(config, conn=None): class AlchemyEncoder(json.JSONEncoder):
# user defined sort function for calibre databases (Series, etc.)
def _title_sort(title):
# calibre sort stuff
title_pat = re.compile(config.config_title_regex, re.IGNORECASE)
match = title_pat.search(title)
if match:
prep = match.group(1)
title = title.replace(prep, '') + ', ' + prep
return title.strip()
conn = conn or session.connection().connection.connection def default(self, o):
conn.create_function("title_sort", 1, _title_sort) if isinstance(o.__class__, DeclarativeMeta):
# an SQLAlchemy class
fields = {}
for field in [x for x in dir(o) if not x.startswith('_') and x != 'metadata' and x!="password"]:
if field == 'books':
continue
data = o.__getattribute__(field)
try:
if isinstance(data, str):
data = data.replace("'", "\'")
elif isinstance(data, InstrumentedList):
el = list()
for ele in data:
if ele.get:
el.append(ele.get())
else:
el.append(json.dumps(ele, cls=AlchemyEncoder))
if field == 'authors':
data = " & ".join(el)
else:
data = ",".join(el)
if data == '[]':
data = ""
else:
json.dumps(data)
fields[field] = data
except Exception:
fields[field] = ""
# a json-encodable dict
return fields
return json.JSONEncoder.default(self, o)
def setup_db(config): class CalibreDB():
dispose() _init = False
global engine engine = None
config = None
session_factory = None
# This is a WeakSet so that references here don't keep other CalibreDB
# instances alive once they reach the end of their respective scopes
instances = WeakSet()
if not config.config_calibre_dir: def __init__(self, expire_on_commit=True):
config.invalidate() """ Initialize a new CalibreDB session
return False """
self.session = None
if self._init:
self.initSession(expire_on_commit)
dbpath = os.path.join(config.config_calibre_dir, "metadata.db") self.instances.add(self)
if not os.path.exists(dbpath):
config.invalidate()
return False
try: def initSession(self, expire_on_commit=True):
engine = create_engine('sqlite:///{0}'.format(dbpath), self.session = self.session_factory()
echo=False, self.session.expire_on_commit = expire_on_commit
isolation_level="SERIALIZABLE", self.update_title_sort(self.config)
connect_args={'check_same_thread': False})
conn = engine.connect()
# conn.text_factory = lambda b: b.decode(errors = 'ignore') possible fix for #1302
except Exception as e:
config.invalidate(e)
return False
config.db_configured = True
update_title_sort(config, conn.connection)
if not cc_classes:
cc = conn.execute("SELECT id, datatype FROM custom_columns")
@classmethod
def setup_db_cc_classes(self, cc):
cc_ids = [] cc_ids = []
books_custom_column_links = {} books_custom_column_links = {}
for row in cc: for row in cc:
if row.datatype not in cc_exceptions: if row.datatype not in cc_exceptions:
books_custom_column_links[row.id] = Table('books_custom_column_' + str(row.id) + '_link', Base.metadata, if row.datatype == 'series':
Column('book', Integer, ForeignKey('books.id'), dicttable = {'__tablename__': 'books_custom_column_' + str(row.id) + '_link',
primary_key=True), 'id': Column(Integer, primary_key=True),
Column('value', Integer, 'book': Column(Integer, ForeignKey('books.id'),
ForeignKey('custom_column_' + str(row.id) + '.id'), primary_key=True),
primary_key=True) 'map_value': Column('value', Integer,
) ForeignKey('custom_column_' +
str(row.id) + '.id'),
primary_key=True),
'extra': Column(Float),
'asoc': relationship('custom_column_' + str(row.id), uselist=False),
'value': association_proxy('asoc', 'value')
}
books_custom_column_links[row.id] = type(str('books_custom_column_' + str(row.id) + '_link'),
(Base,), dicttable)
if row.datatype in ['rating', 'text', 'enumeration']:
books_custom_column_links[row.id] = Table('books_custom_column_' + str(row.id) + '_link',
Base.metadata,
Column('book', Integer, ForeignKey('books.id'),
primary_key=True),
Column('value', Integer,
ForeignKey('custom_column_' +
str(row.id) + '.id'),
primary_key=True)
)
cc_ids.append([row.id, row.datatype]) cc_ids.append([row.id, row.datatype])
if row.datatype == 'bool':
ccdict = {'__tablename__': 'custom_column_' + str(row.id), ccdict = {'__tablename__': 'custom_column_' + str(row.id),
'id': Column(Integer, primary_key=True), 'id': Column(Integer, primary_key=True)}
'book': Column(Integer, ForeignKey('books.id')), if row.datatype == 'float':
'value': Column(Boolean)} ccdict['value'] = Column(Float)
elif row.datatype == 'int': elif row.datatype == 'int':
ccdict = {'__tablename__': 'custom_column_' + str(row.id), ccdict['value'] = Column(Integer)
'id': Column(Integer, primary_key=True), elif row.datatype == 'datetime':
'book': Column(Integer, ForeignKey('books.id')), ccdict['value'] = Column(TIMESTAMP)
'value': Column(Integer)} elif row.datatype == 'bool':
elif row.datatype == 'float': ccdict['value'] = Column(Boolean)
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
'id': Column(Integer, primary_key=True),
'book': Column(Integer, ForeignKey('books.id')),
'value': Column(Float)}
else: else:
ccdict = {'__tablename__': 'custom_column_' + str(row.id), ccdict['value'] = Column(String)
'id': Column(Integer, primary_key=True), if row.datatype in ['float', 'int', 'bool', 'datetime', 'comments']:
'value': Column(String)} ccdict['book'] = Column(Integer, ForeignKey('books.id'))
cc_classes[row.id] = type(str('Custom_Column_' + str(row.id)), (Base,), ccdict) cc_classes[row.id] = type(str('custom_column_' + str(row.id)), (Base,), ccdict)
for cc_id in cc_ids: for cc_id in cc_ids:
if (cc_id[1] == 'bool') or (cc_id[1] == 'int') or (cc_id[1] == 'float'): if cc_id[1] in ['bool', 'int', 'float', 'datetime', 'comments']:
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]], setattr(Books,
primaryjoin=( 'custom_column_' + str(cc_id[0]),
Books.id == cc_classes[cc_id[0]].book), relationship(cc_classes[cc_id[0]],
backref='books')) primaryjoin=(
Books.id == cc_classes[cc_id[0]].book),
backref='books'))
elif cc_id[1] == 'series':
setattr(Books,
'custom_column_' + str(cc_id[0]),
relationship(books_custom_column_links[cc_id[0]],
backref='books'))
else: else:
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]], setattr(Books,
secondary=books_custom_column_links[cc_id[0]], 'custom_column_' + str(cc_id[0]),
backref='books')) relationship(cc_classes[cc_id[0]],
secondary=books_custom_column_links[cc_id[0]],
backref='books'))
return cc_classes
@classmethod
def setup_db(cls, config, app_db_path):
cls.config = config
cls.dispose()
# toDo: if db changed -> delete shelfs, delete download books, delete read boks, kobo sync??
if not config.config_calibre_dir:
config.invalidate()
return False
dbpath = os.path.join(config.config_calibre_dir, "metadata.db")
if not os.path.exists(dbpath):
config.invalidate()
return False
try:
cls.engine = create_engine('sqlite://',
echo=False,
isolation_level="SERIALIZABLE",
connect_args={'check_same_thread': False},
poolclass=StaticPool)
with cls.engine.begin() as connection:
connection.execute(text("attach database '{}' as calibre;".format(dbpath)))
connection.execute(text("attach database '{}' as app_settings;".format(app_db_path)))
conn = cls.engine.connect()
# conn.text_factory = lambda b: b.decode(errors = 'ignore') possible fix for #1302
except Exception as ex:
config.invalidate(ex)
return False
config.db_configured = True
if not cc_classes:
try:
cc = conn.execute("SELECT id, datatype FROM custom_columns")
cls.setup_db_cc_classes(cc)
except OperationalError as e:
log.debug_or_exception(e)
cls.session_factory = scoped_session(sessionmaker(autocommit=False,
autoflush=True,
bind=cls.engine))
for inst in cls.instances:
inst.initSession()
cls._init = True
return True
def get_book(self, book_id):
return self.session.query(Books).filter(Books.id == book_id).first()
def get_filtered_book(self, book_id, allow_show_archived=False):
return self.session.query(Books).filter(Books.id == book_id). \
filter(self.common_filters(allow_show_archived)).first()
def get_book_by_uuid(self, book_uuid):
return self.session.query(Books).filter(Books.uuid == book_uuid).first()
def get_book_format(self, book_id, file_format):
return self.session.query(Data).filter(Data.book == book_id).filter(Data.format == file_format).first()
# Language and content filters for displaying in the UI
def common_filters(self, allow_show_archived=False):
if not allow_show_archived:
archived_books = (
ub.session.query(ub.ArchivedBook)
.filter(ub.ArchivedBook.user_id == int(current_user.id))
.filter(ub.ArchivedBook.is_archived == True)
.all()
)
archived_book_ids = [archived_book.book_id for archived_book in archived_books]
archived_filter = Books.id.notin_(archived_book_ids)
else:
archived_filter = true()
if current_user.filter_language() != "all":
lang_filter = Books.languages.any(Languages.lang_code == current_user.filter_language())
else:
lang_filter = true()
negtags_list = current_user.list_denied_tags()
postags_list = current_user.list_allowed_tags()
neg_content_tags_filter = false() if negtags_list == [''] else Books.tags.any(Tags.name.in_(negtags_list))
pos_content_tags_filter = true() if postags_list == [''] else Books.tags.any(Tags.name.in_(postags_list))
if self.config.config_restricted_column:
try:
pos_cc_list = current_user.allowed_column_value.split(',')
pos_content_cc_filter = true() if pos_cc_list == [''] else \
getattr(Books, 'custom_column_' + str(self.config.config_restricted_column)). \
any(cc_classes[self.config.config_restricted_column].value.in_(pos_cc_list))
neg_cc_list = current_user.denied_column_value.split(',')
neg_content_cc_filter = false() if neg_cc_list == [''] else \
getattr(Books, 'custom_column_' + str(self.config.config_restricted_column)). \
any(cc_classes[self.config.config_restricted_column].value.in_(neg_cc_list))
except (KeyError, AttributeError):
pos_content_cc_filter = false()
neg_content_cc_filter = true()
log.error(u"Custom Column No.%d is not existing in calibre database",
self.config.config_restricted_column)
flash(_("Custom Column No.%(column)d is not existing in calibre database",
column=self.config.config_restricted_column),
category="error")
else:
pos_content_cc_filter = true()
neg_content_cc_filter = false()
return and_(lang_filter, pos_content_tags_filter, ~neg_content_tags_filter,
pos_content_cc_filter, ~neg_content_cc_filter, archived_filter)
@staticmethod
def get_checkbox_sorted(inputlist, state, offset, limit, order):
outcome = list()
elementlist = {ele.id: ele for ele in inputlist}
for entry in state:
try:
outcome.append(elementlist[entry])
except KeyError:
pass
del elementlist[entry]
for entry in elementlist:
outcome.append(elementlist[entry])
if order == "asc":
outcome.reverse()
return outcome[offset:offset + limit]
# Fill indexpage with all requested data from database
def fill_indexpage(self, page, pagesize, database, db_filter, order, *join):
return self.fill_indexpage_with_archived_books(page, pagesize, database, db_filter, order, False, *join)
def fill_indexpage_with_archived_books(self, page, pagesize, database, db_filter, order, allow_show_archived,
*join):
pagesize = pagesize or self.config.config_books_per_page
if current_user.show_detail_random():
randm = self.session.query(Books) \
.filter(self.common_filters(allow_show_archived)) \
.order_by(func.random()) \
.limit(self.config.config_random_books).all()
else:
randm = false()
off = int(int(pagesize) * (page - 1))
query = self.session.query(database)
if len(join) == 3:
query = query.outerjoin(join[0], join[1]).outerjoin(join[2])
elif len(join) == 2:
query = query.outerjoin(join[0], join[1])
elif len(join) == 1:
query = query.outerjoin(join[0])
query = query.filter(db_filter)\
.filter(self.common_filters(allow_show_archived))
entries = list()
pagination = list()
try:
pagination = Pagination(page, pagesize,
len(query.all()))
entries = query.order_by(*order).offset(off).limit(pagesize).all()
except Exception as ex:
log.debug_or_exception(ex)
#for book in entries:
# book = self.order_authors(book)
return entries, randm, pagination
# Orders all Authors in the list according to authors sort
def order_authors(self, entry):
sort_authors = entry.author_sort.split('&')
authors_ordered = list()
error = False
ids = [a.id for a in entry.authors]
for auth in sort_authors:
results = self.session.query(Authors).filter(Authors.sort == auth.lstrip().strip()).all()
# ToDo: How to handle not found authorname
if not len(results):
error = True
break
for r in results:
if r.id in ids:
authors_ordered.append(r)
if not error:
entry.authors = authors_ordered
return entry
def get_typeahead(self, database, query, replace=('', ''), tag_filter=true()):
query = query or ''
self.session.connection().connection.connection.create_function("lower", 1, lcase)
entries = self.session.query(database).filter(tag_filter). \
filter(func.lower(database.name).ilike("%" + query + "%")).all()
json_dumps = json.dumps([dict(name=r.name.replace(*replace)) for r in entries])
return json_dumps
def check_exists_book(self, authr, title):
self.session.connection().connection.connection.create_function("lower", 1, lcase)
q = list()
authorterms = re.split(r'\s*&\s*', authr)
for authorterm in authorterms:
q.append(Books.authors.any(func.lower(Authors.name).ilike("%" + authorterm + "%")))
return self.session.query(Books) \
.filter(and_(Books.authors.any(and_(*q)), func.lower(Books.title).ilike("%" + title + "%"))).first()
def search_query(self, term, *join):
term.strip().lower()
self.session.connection().connection.connection.create_function("lower", 1, lcase)
q = list()
authorterms = re.split("[, ]+", term)
for authorterm in authorterms:
q.append(Books.authors.any(func.lower(Authors.name).ilike("%" + authorterm + "%")))
query = self.session.query(Books)
if len(join) == 3:
query = query.outerjoin(join[0], join[1]).outerjoin(join[2])
elif len(join) == 2:
query = query.outerjoin(join[0], join[1])
elif len(join) == 1:
query = query.outerjoin(join[0])
return query.filter(self.common_filters(True)).filter(
or_(Books.tags.any(func.lower(Tags.name).ilike("%" + term + "%")),
Books.series.any(func.lower(Series.name).ilike("%" + term + "%")),
Books.authors.any(and_(*q)),
Books.publishers.any(func.lower(Publishers.name).ilike("%" + term + "%")),
func.lower(Books.title).ilike("%" + term + "%")
))
# read search results from calibre-database and return it (function is used for feed and simple search
def get_search_results(self, term, offset=None, order=None, limit=None, *join):
order = order or [Books.sort]
pagination = None
result = self.search_query(term, *join).order_by(*order).all()
result_count = len(result)
if offset != None and limit != None:
offset = int(offset)
limit_all = offset + int(limit)
pagination = Pagination((offset / (int(limit)) + 1), limit, result_count)
else:
offset = 0
limit_all = result_count
ub.store_ids(result)
return result[offset:limit_all], result_count, pagination
# Creates for all stored languages a translated speaking name in the array for the UI
def speaking_language(self, languages=None):
from . import get_locale
if not languages:
languages = self.session.query(Languages) \
.join(books_languages_link) \
.join(Books) \
.filter(self.common_filters()) \
.group_by(text('books_languages_link.lang_code')).all()
for lang in languages:
try:
cur_l = LC.parse(lang.lang_code)
lang.name = cur_l.get_language_name(get_locale())
except UnknownLocaleError:
lang.name = _(isoLanguages.get(part3=lang.lang_code).name)
return languages
def update_title_sort(self, config, conn=None):
# user defined sort function for calibre databases (Series, etc.)
def _title_sort(title):
# calibre sort stuff
title_pat = re.compile(config.config_title_regex, re.IGNORECASE)
match = title_pat.search(title)
if match:
prep = match.group(1)
title = title[len(prep):] + ', ' + prep
return title.strip()
conn = conn or self.session.connection().connection.connection
conn.create_function("title_sort", 1, _title_sort)
@classmethod
def dispose(cls):
# global session
for inst in cls.instances:
old_session = inst.session
inst.session = None
if old_session:
try:
old_session.close()
except Exception:
pass
if old_session.bind:
try:
old_session.bind.dispose()
except Exception:
pass
for attr in list(Books.__dict__.keys()):
if attr.startswith("custom_column_"):
setattr(Books, attr, None)
for db_class in cc_classes.values():
Base.metadata.remove(db_class.__table__)
cc_classes.clear()
for table in reversed(Base.metadata.sorted_tables):
name = table.key
if name.startswith("custom_column_") or name.startswith("books_custom_column_"):
if table is not None:
Base.metadata.remove(table)
def reconnect_db(self, config, app_db_path):
self.dispose()
self.engine.dispose()
self.setup_db(config, app_db_path)
global session def lcase(s):
Session = scoped_session(sessionmaker(autocommit=False, try:
autoflush=False, return unidecode.unidecode(s.lower())
bind=engine)) except Exception as ex:
session = Session() log = logger.create()
return True log.debug_or_exception(ex)
return s.lower()
def dispose():
global session
old_session = session
session = None
if old_session:
try: old_session.close()
except: pass
if old_session.bind:
try: old_session.bind.dispose()
except Exception: pass
for attr in list(Books.__dict__.keys()):
if attr.startswith("custom_column_"):
setattr(Books, attr, None)
for db_class in cc_classes.values():
Base.metadata.remove(db_class.__table__)
cc_classes.clear()
for table in reversed(Base.metadata.sorted_tables):
name = table.key
if name.startswith("custom_column_") or name.startswith("books_custom_column_"):
if table is not None:
Base.metadata.remove(table)
def reconnect_db(config):
session.close()
engine.dispose()
setup_db(config)
+65
View File
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
# Copyright (C) 2012-2019 cervinko, idalin, SiphonSquirrel, ouzklcn, akushsky,
# OzzieIsaacs, bodybybuddha, jkrehm, matthazinski, janeczku
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import shutil
import glob
import zipfile
import json
from io import BytesIO
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import os
from flask import send_file
from . import logger, config
from .about import collect_stats
log = logger.create()
def assemble_logfiles(file_name):
log_list = sorted(glob.glob(file_name + '*'), reverse=True)
wfd = StringIO()
for f in log_list:
with open(f, 'r') as fd:
shutil.copyfileobj(fd, wfd)
wfd.seek(0)
return send_file(wfd,
as_attachment=True,
attachment_filename=os.path.basename(file_name))
def send_debug():
file_list = glob.glob(logger.get_logfile(config.config_logfile) + '*')
file_list.extend(glob.glob(logger.get_accesslogfile(config.config_access_logfile) + '*'))
for element in [logger.LOG_TO_STDOUT, logger.LOG_TO_STDERR]:
if element in file_list:
file_list.remove(element)
memory_zip = BytesIO()
with zipfile.ZipFile(memory_zip, 'w', compression=zipfile.ZIP_DEFLATED) as zf:
zf.writestr('settings.txt', json.dumps(config.toDict()))
zf.writestr('libs.txt', json.dumps(collect_stats()))
for fp in file_list:
zf.write(fp, os.path.basename(fp))
memory_zip.seek(0)
return send_file(memory_zip,
as_attachment=True,
attachment_filename="Calibre-Web-debug-pack.zip")
+812 -461
View File
File diff suppressed because it is too large Load Diff
+48 -40
View File
@@ -22,9 +22,11 @@ import zipfile
from lxml import etree from lxml import etree
from . import isoLanguages from . import isoLanguages
from .helper import split_authors
from .constants import BookMeta from .constants import BookMeta
def extractCover(zipFile, coverFile, coverpath, tmp_file_name): def extractCover(zipFile, coverFile, coverpath, tmp_file_name):
if coverFile is None: if coverFile is None:
return None return None
@@ -64,11 +66,11 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
tmp = p.xpath('dc:%s/text()' % s, namespaces=ns) tmp = p.xpath('dc:%s/text()' % s, namespaces=ns)
if len(tmp) > 0: if len(tmp) > 0:
if s == 'creator': if s == 'creator':
epub_metadata[s] = ' & '.join(p.xpath('dc:%s/text()' % s, namespaces=ns)) epub_metadata[s] = ' & '.join(split_authors(tmp))
elif s == 'subject': elif s == 'subject':
epub_metadata[s] = ', '.join(p.xpath('dc:%s/text()' % s, namespaces=ns)) epub_metadata[s] = ', '.join(tmp)
else: else:
epub_metadata[s] = p.xpath('dc:%s/text()' % s, namespaces=ns)[0] epub_metadata[s] = tmp[0]
else: else:
epub_metadata[s] = u'Unknown' epub_metadata[s] = u'Unknown'
@@ -82,29 +84,32 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
else: else:
epub_metadata['description'] = "" epub_metadata['description'] = ""
if epub_metadata['language'] == u'Unknown': lang = epub_metadata['language'].split('-', 1)[0].lower()
epub_metadata['language'] = "" epub_metadata['language'] = isoLanguages.get_lang3(lang)
else:
lang = epub_metadata['language'].split('-', 1)[0].lower()
if len(lang) == 2:
epub_metadata['language'] = isoLanguages.get(part1=lang).name
elif len(lang) == 3:
epub_metadata['language'] = isoLanguages.get(part3=lang).name
else:
epub_metadata['language'] = ""
series = tree.xpath("/pkg:package/pkg:metadata/pkg:meta[@name='calibre:series']/@content", namespaces=ns) epub_metadata = parse_epbub_series(ns, tree, epub_metadata)
if len(series) > 0:
epub_metadata['series'] = series[0]
else:
epub_metadata['series'] = ''
series_id = tree.xpath("/pkg:package/pkg:metadata/pkg:meta[@name='calibre:series_index']/@content", namespaces=ns) coverfile = parse_ebpub_cover(ns, tree, epubZip, coverpath, tmp_file_path)
if len(series_id) > 0:
epub_metadata['series_id'] = series_id[0]
else:
epub_metadata['series_id'] = '1'
if not epub_metadata['title']:
title = original_file_name
else:
title = epub_metadata['title']
return BookMeta(
file_path=tmp_file_path,
extension=original_file_extension,
title=title.encode('utf-8').decode('utf-8'),
author=epub_metadata['creator'].encode('utf-8').decode('utf-8'),
cover=coverfile,
description=epub_metadata['description'],
tags=epub_metadata['subject'].encode('utf-8').decode('utf-8'),
series=epub_metadata['series'].encode('utf-8').decode('utf-8'),
series_id=epub_metadata['series_id'].encode('utf-8').decode('utf-8'),
languages=epub_metadata['language'],
publisher="")
def parse_ebpub_cover(ns, tree, epubZip, coverpath, tmp_file_path):
coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href", namespaces=ns) coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href", namespaces=ns)
coverfile = None coverfile = None
if len(coversection) > 0: if len(coversection) > 0:
@@ -122,25 +127,28 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
markupTree = etree.fromstring(markup) markupTree = etree.fromstring(markup)
# no matter xhtml or html with no namespace # no matter xhtml or html with no namespace
imgsrc = markupTree.xpath("//*[local-name() = 'img']/@src") imgsrc = markupTree.xpath("//*[local-name() = 'img']/@src")
# imgsrc maybe startwith "../"" so fullpath join then relpath to cwd # Alternative image source
filename = os.path.relpath(os.path.join(os.path.dirname(os.path.join(coverpath, coversection[0])), imgsrc[0])) if not len(imgsrc):
coverfile = extractCover(epubZip, filename, "", tmp_file_path) imgsrc = markupTree.xpath("//attribute::*[contains(local-name(), 'href')]")
if len(imgsrc):
# imgsrc maybe startwith "../"" so fullpath join then relpath to cwd
filename = os.path.relpath(os.path.join(os.path.dirname(os.path.join(coverpath, coversection[0])),
imgsrc[0]))
coverfile = extractCover(epubZip, filename, "", tmp_file_path)
else: else:
coverfile = extractCover(epubZip, coversection[0], coverpath, tmp_file_path) coverfile = extractCover(epubZip, coversection[0], coverpath, tmp_file_path)
return coverfile
if not epub_metadata['title']: def parse_epbub_series(ns, tree, epub_metadata):
title = original_file_name series = tree.xpath("/pkg:package/pkg:metadata/pkg:meta[@name='calibre:series']/@content", namespaces=ns)
if len(series) > 0:
epub_metadata['series'] = series[0]
else: else:
title = epub_metadata['title'] epub_metadata['series'] = ''
return BookMeta( series_id = tree.xpath("/pkg:package/pkg:metadata/pkg:meta[@name='calibre:series_index']/@content", namespaces=ns)
file_path=tmp_file_path, if len(series_id) > 0:
extension=original_file_extension, epub_metadata['series_id'] = series_id[0]
title=title.encode('utf-8').decode('utf-8'), else:
author=epub_metadata['creator'].encode('utf-8').decode('utf-8'), epub_metadata['series_id'] = '1'
cover=coverfile, return epub_metadata
description=epub_metadata['description'],
tags=epub_metadata['subject'].encode('utf-8').decode('utf-8'),
series=epub_metadata['series'].encode('utf-8').decode('utf-8'),
series_id=epub_metadata['series_id'].encode('utf-8').decode('utf-8'),
languages=epub_metadata['language'])
+67
View File
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
# Copyright (C) 2018-2020 OzzieIsaacs
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import traceback
from flask import render_template
from werkzeug.exceptions import default_exceptions
try:
from werkzeug.exceptions import FailedDependency
except ImportError:
from werkzeug.exceptions import UnprocessableEntity as FailedDependency
from . import config, app, logger, services
log = logger.create()
# custom error page
def error_http(error):
return render_template('http_error.html',
error_code="Error {0}".format(error.code),
error_name=error.name,
issue=False,
instance=config.config_calibre_web_title
), error.code
def internal_error(error):
return render_template('http_error.html',
error_code="Internal Server Error",
error_name=str(error),
issue=True,
error_stack=traceback.format_exc().split("\n"),
instance=config.config_calibre_web_title
), 500
def init_errorhandler():
# http error handling
for ex in default_exceptions:
if ex < 500:
app.register_error_handler(ex, error_http)
elif ex == 500:
app.register_error_handler(ex, internal_error)
if services.ldap:
# Only way of catching the LDAPException upon logging in with LDAP server down
@app.errorhandler(services.ldap.LDAPException)
# pylint: disable=unused-variable
def handle_exception(e):
log.debug('LDAP server not accessible while trying to login to opds feed')
return error_http(FailedDependency())
+15 -14
View File
@@ -29,52 +29,53 @@ def get_fb2_info(tmp_file_path, original_file_extension):
'l': 'http://www.w3.org/1999/xlink', 'l': 'http://www.w3.org/1999/xlink',
} }
fb2_file = open(tmp_file_path) fb2_file = open(tmp_file_path, encoding="utf-8")
tree = etree.fromstring(fb2_file.read()) tree = etree.fromstring(fb2_file.read().encode())
authors = tree.xpath('/fb:FictionBook/fb:description/fb:title-info/fb:author', namespaces=ns) authors = tree.xpath('/fb:FictionBook/fb:description/fb:title-info/fb:author', namespaces=ns)
def get_author(element): def get_author(element):
last_name = element.xpath('fb:last-name/text()', namespaces=ns) last_name = element.xpath('fb:last-name/text()', namespaces=ns)
if len(last_name): if len(last_name):
last_name = last_name[0].encode('utf-8') last_name = last_name[0]
else: else:
last_name = u'' last_name = u''
middle_name = element.xpath('fb:middle-name/text()', namespaces=ns) middle_name = element.xpath('fb:middle-name/text()', namespaces=ns)
if len(middle_name): if len(middle_name):
middle_name = middle_name[0].encode('utf-8') middle_name = middle_name[0]
else: else:
middle_name = u'' middle_name = u''
first_name = element.xpath('fb:first-name/text()', namespaces=ns) first_name = element.xpath('fb:first-name/text()', namespaces=ns)
if len(first_name): if len(first_name):
first_name = first_name[0].encode('utf-8') first_name = first_name[0]
else: else:
first_name = u'' first_name = u''
return (first_name.decode('utf-8') + u' ' return (first_name + u' '
+ middle_name.decode('utf-8') + u' ' + middle_name + u' '
+ last_name.decode('utf-8')).encode('utf-8') + last_name)
author = str(", ".join(map(get_author, authors))) author = str(", ".join(map(get_author, authors)))
title = tree.xpath('/fb:FictionBook/fb:description/fb:title-info/fb:book-title/text()', namespaces=ns) title = tree.xpath('/fb:FictionBook/fb:description/fb:title-info/fb:book-title/text()', namespaces=ns)
if len(title): if len(title):
title = str(title[0].encode('utf-8')) title = str(title[0])
else: else:
title = u'' title = u''
description = tree.xpath('/fb:FictionBook/fb:description/fb:publish-info/fb:book-name/text()', namespaces=ns) description = tree.xpath('/fb:FictionBook/fb:description/fb:publish-info/fb:book-name/text()', namespaces=ns)
if len(description): if len(description):
description = str(description[0].encode('utf-8')) description = str(description[0])
else: else:
description = u'' description = u''
return BookMeta( return BookMeta(
file_path=tmp_file_path, file_path=tmp_file_path,
extension=original_file_extension, extension=original_file_extension,
title=title.decode('utf-8'), title=title,
author=author.decode('utf-8'), author=author,
cover=None, cover=None,
description=description.decode('utf-8'), description=description,
tags="", tags="",
series="", series="",
series_id="", series_id="",
languages="") languages="",
publisher="")
+54 -55
View File
@@ -34,24 +34,23 @@ from flask import Blueprint, flash, request, redirect, url_for, abort
from flask_babel import gettext as _ from flask_babel import gettext as _
from flask_login import login_required from flask_login import login_required
from . import logger, gdriveutils, config, ub, calibre_db
from .admin import admin_required
gdrive = Blueprint('gdrive', __name__, url_prefix='/gdrive')
log = logger.create()
try: try:
from googleapiclient.errors import HttpError from googleapiclient.errors import HttpError
except ImportError: except ImportError as err:
pass log.debug("Cannot import googleapiclient, using GDrive will not work: %s", err)
from . import logger, gdriveutils, config, db
from .web import admin_required
gdrive = Blueprint('gdrive', __name__)
log = logger.create()
current_milli_time = lambda: int(round(time() * 1000)) current_milli_time = lambda: int(round(time() * 1000))
gdrive_watch_callback_token = 'target=calibreweb-watch_files' gdrive_watch_callback_token = 'target=calibreweb-watch_files' #nosec
@gdrive.route("/gdrive/authenticate") @gdrive.route("/authenticate")
@login_required @login_required
@admin_required @admin_required
def authenticate_google_drive(): def authenticate_google_drive():
@@ -64,7 +63,7 @@ def authenticate_google_drive():
return redirect(authUrl) return redirect(authUrl)
@gdrive.route("/gdrive/callback") @gdrive.route("/callback")
def google_drive_callback(): def google_drive_callback():
auth_code = request.args.get('code') auth_code = request.args.get('code')
if not auth_code: if not auth_code:
@@ -73,41 +72,37 @@ def google_drive_callback():
credentials = gdriveutils.Gauth.Instance().auth.flow.step2_exchange(auth_code) credentials = gdriveutils.Gauth.Instance().auth.flow.step2_exchange(auth_code)
with open(gdriveutils.CREDENTIALS, 'w') as f: with open(gdriveutils.CREDENTIALS, 'w') as f:
f.write(credentials.to_json()) f.write(credentials.to_json())
except ValueError as error: except (ValueError, AttributeError) as error:
log.error(error) log.error(error)
return redirect(url_for('admin.configuration')) return redirect(url_for('admin.configuration'))
@gdrive.route("/gdrive/watch/subscribe") @gdrive.route("/watch/subscribe")
@login_required @login_required
@admin_required @admin_required
def watch_gdrive(): def watch_gdrive():
if not config.config_google_drive_watch_changes_response: if not config.config_google_drive_watch_changes_response:
with open(gdriveutils.CLIENT_SECRETS, 'r') as settings: with open(gdriveutils.CLIENT_SECRETS, 'r') as settings:
filedata = json.load(settings) filedata = json.load(settings)
if filedata['web']['redirect_uris'][0].endswith('/'): address = filedata['web']['redirect_uris'][0].rstrip('/').replace('/gdrive/callback', '/gdrive/watch/callback')
filedata['web']['redirect_uris'][0] = filedata['web']['redirect_uris'][0][:-((len('/gdrive/callback')+1))]
else:
filedata['web']['redirect_uris'][0] = filedata['web']['redirect_uris'][0][:-(len('/gdrive/callback'))]
address = '%s/gdrive/watch/callback' % filedata['web']['redirect_uris'][0]
notification_id = str(uuid4()) notification_id = str(uuid4())
try: try:
result = gdriveutils.watchChange(gdriveutils.Gdrive.Instance().drive, notification_id, result = gdriveutils.watchChange(gdriveutils.Gdrive.Instance().drive, notification_id,
'web_hook', address, gdrive_watch_callback_token, current_milli_time() + 604800*1000) 'web_hook', address, gdrive_watch_callback_token, current_milli_time() + 604800*1000)
config.config_google_drive_watch_changes_response = json.dumps(result) config.config_google_drive_watch_changes_response = result
# after save(), config_google_drive_watch_changes_response will be a json object, not string
config.save() config.save()
except HttpError as e: except HttpError as e:
reason=json.loads(e.content)['error']['errors'][0] reason=json.loads(e.content)['error']['errors'][0]
if reason['reason'] == u'push.webhookUrlUnauthorized': if reason['reason'] == u'push.webhookUrlUnauthorized':
flash(_(u'Callback domain is not verified, please follow steps to verify domain in google developer console'), category="error") flash(_(u'Callback domain is not verified, '
u'please follow steps to verify domain in google developer console'), category="error")
else: else:
flash(reason['message'], category="error") flash(reason['message'], category="error")
return redirect(url_for('admin.configuration')) return redirect(url_for('admin.configuration'))
@gdrive.route("/gdrive/watch/revoke") @gdrive.route("/watch/revoke")
@login_required @login_required
@admin_required @admin_required
def revoke_watch_gdrive(): def revoke_watch_gdrive():
@@ -118,44 +113,48 @@ def revoke_watch_gdrive():
last_watch_response['resourceId']) last_watch_response['resourceId'])
except HttpError: except HttpError:
pass pass
config.config_google_drive_watch_changes_response = None config.config_google_drive_watch_changes_response = {}
config.save() config.save()
return redirect(url_for('admin.configuration')) return redirect(url_for('admin.configuration'))
@gdrive.route("/gdrive/watch/callback", methods=['GET', 'POST']) @gdrive.route("/watch/callback", methods=['GET', 'POST'])
def on_received_watch_confirmation(): def on_received_watch_confirmation():
if not config.config_google_drive_watch_changes_response:
return ''
if request.headers.get('X-Goog-Channel-Token') != gdrive_watch_callback_token \
or request.headers.get('X-Goog-Resource-State') != 'change' \
or not request.data:
return ''
log.debug('%r', request.headers) log.debug('%r', request.headers)
if request.headers.get('X-Goog-Channel-Token') == gdrive_watch_callback_token \ log.debug('%r', request.data)
and request.headers.get('X-Goog-Resource-State') == 'change' \ log.info('Change received from gdrive')
and request.data:
data = request.data try:
j = json.loads(request.data)
log.info('Getting change details')
response = gdriveutils.getChangeById(gdriveutils.Gdrive.Instance().drive, j['id'])
log.debug('%r', response)
if response:
if sys.version_info < (3, 0):
dbpath = os.path.join(config.config_calibre_dir, "metadata.db")
else:
dbpath = os.path.join(config.config_calibre_dir, "metadata.db").encode()
if not response['deleted'] and response['file']['title'] == 'metadata.db' \
and response['file']['md5Checksum'] != hashlib.md5(dbpath): # nosec
tmp_dir = os.path.join(tempfile.gettempdir(), 'calibre_web')
if not os.path.isdir(tmp_dir):
os.mkdir(tmp_dir)
def updateMetaData(): log.info('Database file updated')
log.info('Change received from gdrive') copyfile(dbpath, os.path.join(tmp_dir, "metadata.db_" + str(current_milli_time())))
log.debug('%r', data) log.info('Backing up existing and downloading updated metadata.db')
try: gdriveutils.downloadFile(None, "metadata.db", os.path.join(tmp_dir, "tmp_metadata.db"))
j = json.loads(data) log.info('Setting up new DB')
log.info('Getting change details') # prevent error on windows, as os.rename does on existing files, also allow cross hdd move
response = gdriveutils.getChangeById(gdriveutils.Gdrive.Instance().drive, j['id']) move(os.path.join(tmp_dir, "tmp_metadata.db"), dbpath)
log.debug('%r', response) calibre_db.reconnect_db(config, ub.app_DB_path)
if response: except Exception as ex:
if sys.version_info < (3, 0): log.debug_or_exception(ex)
dbpath = os.path.join(config.config_calibre_dir, "metadata.db")
else:
dbpath = os.path.join(config.config_calibre_dir, "metadata.db").encode()
if not response['deleted'] and response['file']['title'] == 'metadata.db' and response['file']['md5Checksum'] != hashlib.md5(dbpath):
tmpDir = tempfile.gettempdir()
log.info('Database file updated')
copyfile(dbpath, os.path.join(tmpDir, "metadata.db_" + str(current_milli_time())))
log.info('Backing up existing and downloading updated metadata.db')
gdriveutils.downloadFile(None, "metadata.db", os.path.join(tmpDir, "tmp_metadata.db"))
log.info('Setting up new DB')
# prevent error on windows, as os.rename does on exisiting files
move(os.path.join(tmpDir, "tmp_metadata.db"), dbpath)
db.setup_db(config)
except Exception as e:
log.exception(e)
updateMetaData()
return '' return ''
+126 -58
View File
@@ -20,22 +20,41 @@ from __future__ import division, print_function, unicode_literals
import os import os
import json import json
import shutil import shutil
import chardet
import ssl
from flask import Response, stream_with_context from flask import Response, stream_with_context
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy import Column, UniqueConstraint from sqlalchemy import Column, UniqueConstraint
from sqlalchemy import String, Integer from sqlalchemy import String, Integer
from sqlalchemy.orm import sessionmaker, scoped_session from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base try:
# Compatibility with sqlalchemy 2.0
from sqlalchemy.orm import declarative_base
except ImportError:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.exc import OperationalError, InvalidRequestError
try: try:
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from pydrive.auth import RefreshError
from apiclient import errors from apiclient import errors
from httplib2 import ServerNotFoundError
importError = None
gdrive_support = True gdrive_support = True
except ImportError: except ImportError as e:
importError = e
gdrive_support = False gdrive_support = False
try:
from pydrive2.auth import GoogleAuth
from pydrive2.drive import GoogleDrive
from pydrive2.auth import RefreshError
except ImportError as err:
try:
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from pydrive.auth import RefreshError
except ImportError as err:
importError = err
gdrive_support = False
from . import logger, cli, config from . import logger, cli, config
from .constants import CONFIG_DIR as _CONFIG_DIR from .constants import CONFIG_DIR as _CONFIG_DIR
@@ -50,6 +69,8 @@ if gdrive_support:
logger.get('googleapiclient.discovery_cache').setLevel(logger.logging.ERROR) logger.get('googleapiclient.discovery_cache').setLevel(logger.logging.ERROR)
if not logger.is_debug_enabled(): if not logger.is_debug_enabled():
logger.get('googleapiclient.discovery').setLevel(logger.logging.ERROR) logger.get('googleapiclient.discovery').setLevel(logger.logging.ERROR)
else:
log.debug("Cannot import pydrive,httplib2, using gdrive will not work: %s", importError)
class Singleton: class Singleton:
@@ -83,7 +104,7 @@ class Singleton:
except AttributeError: except AttributeError:
self._instance = self._decorated() self._instance = self._decorated()
return self._instance return self._instance
except ImportError as e: except (ImportError, NameError) as e:
log.debug(e) log.debug(e)
return None return None
@@ -97,7 +118,11 @@ class Singleton:
@Singleton @Singleton
class Gauth: class Gauth:
def __init__(self): def __init__(self):
self.auth = GoogleAuth(settings_file=SETTINGS_YAML) try:
self.auth = GoogleAuth(settings_file=SETTINGS_YAML)
except NameError as error:
log.error(error)
self.auth = None
@Singleton @Singleton
@@ -177,8 +202,8 @@ def getDrive(drive=None, gauth=None):
gauth.Refresh() gauth.Refresh()
except RefreshError as e: except RefreshError as e:
log.error("Google Drive error: %s", e) log.error("Google Drive error: %s", e)
except Exception as e: except Exception as ex:
log.exception(e) log.debug_or_exception(ex)
else: else:
# Initialize the saved creds # Initialize the saved creds
gauth.Authorize() gauth.Authorize()
@@ -192,14 +217,18 @@ def getDrive(drive=None, gauth=None):
return drive return drive
def listRootFolders(): def listRootFolders():
drive = getDrive(Gdrive.Instance().drive) try:
folder = "'root' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false" drive = getDrive(Gdrive.Instance().drive)
fileList = drive.ListFile({'q': folder}).GetList() folder = "'root' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false"
fileList = drive.ListFile({'q': folder}).GetList()
except (ServerNotFoundError, ssl.SSLError, RefreshError) as e:
log.info("GDrive Error %s" % e)
fileList = []
return fileList return fileList
def getEbooksFolder(drive): def getEbooksFolder(drive):
return getFolderInFolder('root',config.config_google_drive_folder,drive) return getFolderInFolder('root', config.config_google_drive_folder, drive)
def getFolderInFolder(parentId, folderName, drive): def getFolderInFolder(parentId, folderName, drive):
@@ -228,8 +257,13 @@ def getEbooksFolderId(drive=None):
log.error('Error gDrive, root ID not found') log.error('Error gDrive, root ID not found')
gDriveId.path = '/' gDriveId.path = '/'
session.merge(gDriveId) session.merge(gDriveId)
session.commit() try:
return session.commit()
except OperationalError as ex:
log.error("gdrive.db DB is not Writeable")
log.debug('Database error: %s', ex)
session.rollback()
return gDriveId.gdrive_id
def getFile(pathId, fileName, drive): def getFile(pathId, fileName, drive):
@@ -243,37 +277,42 @@ def getFile(pathId, fileName, drive):
def getFolderId(path, drive): def getFolderId(path, drive):
# drive = getDrive(drive) # drive = getDrive(drive)
currentFolderId = getEbooksFolderId(drive) try:
sqlCheckPath = path if path[-1] == '/' else path + '/' currentFolderId = getEbooksFolderId(drive)
storedPathName = session.query(GdriveId).filter(GdriveId.path == sqlCheckPath).first() sqlCheckPath = path if path[-1] == '/' else path + '/'
storedPathName = session.query(GdriveId).filter(GdriveId.path == sqlCheckPath).first()
if not storedPathName: if not storedPathName:
dbChange = False dbChange = False
s = path.split('/') s = path.split('/')
for i, x in enumerate(s): for i, x in enumerate(s):
if len(x) > 0: if len(x) > 0:
currentPath = "/".join(s[:i+1]) currentPath = "/".join(s[:i+1])
if currentPath[-1] != '/': if currentPath[-1] != '/':
currentPath = currentPath + '/' currentPath = currentPath + '/'
storedPathName = session.query(GdriveId).filter(GdriveId.path == currentPath).first() storedPathName = session.query(GdriveId).filter(GdriveId.path == currentPath).first()
if storedPathName: if storedPathName:
currentFolderId = storedPathName.gdrive_id currentFolderId = storedPathName.gdrive_id
else:
currentFolder = getFolderInFolder(currentFolderId, x, drive)
if currentFolder:
gDriveId = GdriveId()
gDriveId.gdrive_id = currentFolder['id']
gDriveId.path = currentPath
session.merge(gDriveId)
dbChange = True
currentFolderId = currentFolder['id']
else: else:
currentFolderId = None currentFolder = getFolderInFolder(currentFolderId, x, drive)
break if currentFolder:
if dbChange: gDriveId = GdriveId()
session.commit() gDriveId.gdrive_id = currentFolder['id']
else: gDriveId.path = currentPath
currentFolderId = storedPathName.gdrive_id session.merge(gDriveId)
dbChange = True
currentFolderId = currentFolder['id']
else:
currentFolderId = None
break
if dbChange:
session.commit()
else:
currentFolderId = storedPathName.gdrive_id
except OperationalError as ex:
log.error("gdrive.db DB is not Writeable")
log.debug('Database error: %s', ex)
session.rollback()
return currentFolderId return currentFolderId
@@ -317,7 +356,7 @@ def moveGdriveFolderRemote(origin_file, target_folder):
addParents=gFileTargetDir['id'], addParents=gFileTargetDir['id'],
removeParents=previous_parents, removeParents=previous_parents,
fields='id, parents').execute() fields='id, parents').execute()
# if previous_parents has no childs anymore, delete original fileparent # if previous_parents has no children anymore, delete original fileparent
if len(children['items']) == 1: if len(children['items']) == 1:
deleteDatabaseEntry(previous_parents) deleteDatabaseEntry(previous_parents)
drive.auth.service.files().delete(fileId=previous_parents).execute() drive.auth.service.files().delete(fileId=previous_parents).execute()
@@ -369,7 +408,8 @@ def uploadFileToEbooksFolder(destFile, f):
if len(existingFiles) > 0: if len(existingFiles) > 0:
driveFile = existingFiles[0] driveFile = existingFiles[0]
else: else:
driveFile = drive.CreateFile({'title': x, 'parents': [{"kind": "drive#fileLink", 'id': parent['id']}],}) driveFile = drive.CreateFile({'title': x,
'parents': [{"kind": "drive#fileLink", 'id': parent['id']}], })
driveFile.SetContentFile(f) driveFile.SetContentFile(f)
driveFile.Upload() driveFile.Upload()
else: else:
@@ -467,15 +507,21 @@ def getChangeById (drive, change_id):
except (errors.HttpError) as error: except (errors.HttpError) as error:
log.error(error) log.error(error)
return None return None
except Exception as e: except Exception as ex:
log.error(e) log.error(ex)
return None return None
# Deletes the local hashes database to force search for new folder names # Deletes the local hashes database to force search for new folder names
def deleteDatabaseOnChange(): def deleteDatabaseOnChange():
session.query(GdriveId).delete() try:
session.commit() session.query(GdriveId).delete()
session.commit()
except (OperationalError, InvalidRequestError) as ex:
session.rollback()
log.debug('Database error: %s', ex)
log.error(u"GDrive DB is not Writeable")
def updateGdriveCalibreFromLocal(): def updateGdriveCalibreFromLocal():
copyToDrive(Gdrive.Instance().drive, config.config_calibre_dir, False, True) copyToDrive(Gdrive.Instance().drive, config.config_calibre_dir, False, True)
@@ -489,13 +535,23 @@ def updateDatabaseOnEdit(ID,newPath):
storedPathName = session.query(GdriveId).filter(GdriveId.gdrive_id == ID).first() storedPathName = session.query(GdriveId).filter(GdriveId.gdrive_id == ID).first()
if storedPathName: if storedPathName:
storedPathName.path = sqlCheckPath storedPathName.path = sqlCheckPath
session.commit() try:
session.commit()
except OperationalError as ex:
log.error("gdrive.db DB is not Writeable")
log.debug('Database error: %s', ex)
session.rollback()
# Deletes the hashes in database of deleted book # Deletes the hashes in database of deleted book
def deleteDatabaseEntry(ID): def deleteDatabaseEntry(ID):
session.query(GdriveId).filter(GdriveId.gdrive_id == ID).delete() session.query(GdriveId).filter(GdriveId.gdrive_id == ID).delete()
session.commit() try:
session.commit()
except OperationalError as ex:
log.error("gdrive.db DB is not Writeable")
log.debug('Database error: %s', ex)
session.rollback()
# Gets cover file from gdrive # Gets cover file from gdrive
@@ -512,7 +568,12 @@ def get_cover_via_gdrive(cover_path):
permissionAdded = PermissionAdded() permissionAdded = PermissionAdded()
permissionAdded.gdrive_id = df['id'] permissionAdded.gdrive_id = df['id']
session.add(permissionAdded) session.add(permissionAdded)
session.commit() try:
session.commit()
except OperationalError as ex:
log.error("gdrive.db DB is not Writeable")
log.debug('Database error: %s', ex)
session.rollback()
return df.metadata.get('webContentLink') return df.metadata.get('webContentLink')
else: else:
return None return None
@@ -526,21 +587,24 @@ def partial(total_byte_len, part_size_limit):
return s return s
# downloads files in chunks from gdrive # downloads files in chunks from gdrive
def do_gdrive_download(df, headers): def do_gdrive_download(df, headers, convert_encoding=False):
total_size = int(df.metadata.get('fileSize')) total_size = int(df.metadata.get('fileSize'))
download_url = df.metadata.get('downloadUrl') download_url = df.metadata.get('downloadUrl')
s = partial(total_size, 1024 * 1024) # I'm downloading BIG files, so 100M chunk size is fine for me s = partial(total_size, 1024 * 1024) # I'm downloading BIG files, so 100M chunk size is fine for me
def stream(): def stream(convert_encoding):
for byte in s: for byte in s:
headers = {"Range": 'bytes=%s-%s' % (byte[0], byte[1])} headers = {"Range": 'bytes=%s-%s' % (byte[0], byte[1])}
resp, content = df.auth.Get_Http_Object().request(download_url, headers=headers) resp, content = df.auth.Get_Http_Object().request(download_url, headers=headers)
if resp.status == 206: if resp.status == 206:
if convert_encoding:
result = chardet.detect(content)
content = content.decode(result['encoding']).encode('utf-8')
yield content yield content
else: else:
log.warning('An error occurred: %s', resp) log.warning('An error occurred: %s', resp)
return return
return Response(stream_with_context(stream()), headers=headers) return Response(stream_with_context(stream(convert_encoding)), headers=headers)
_SETTINGS_YAML_TEMPLATE = """ _SETTINGS_YAML_TEMPLATE = """
@@ -583,8 +647,12 @@ def get_error_text(client_secrets=None):
if not os.path.isfile(CLIENT_SECRETS): if not os.path.isfile(CLIENT_SECRETS):
return 'client_secrets.json is missing or not readable' return 'client_secrets.json is missing or not readable'
with open(CLIENT_SECRETS, 'r') as settings: try:
filedata = json.load(settings) with open(CLIENT_SECRETS, 'r') as settings:
filedata = json.load(settings)
except PermissionError:
return 'client_secrets.json is missing or not readable'
if 'web' not in filedata: if 'web' not in filedata:
return 'client_secrets.json is not configured for web application' return 'client_secrets.json is not configured for web application'
if 'redirect_uris' not in filedata['web']: if 'redirect_uris' not in filedata['web']:
+342 -414
View File
File diff suppressed because it is too large Load Diff
+31 -4
View File
@@ -57,12 +57,39 @@ def get_language_name(locale, lang_code):
def get_language_codes(locale, language_names, remainder=None): def get_language_codes(locale, language_names, remainder=None):
language_names = set(x.strip().lower() for x in language_names if x) language_names = set(x.strip().lower() for x in language_names if x)
lang = list()
for k, v in get_language_names(locale).items(): for k, v in get_language_names(locale).items():
v = v.lower() v = v.lower()
if v in language_names: if v in language_names:
lang.append(k)
language_names.remove(v) language_names.remove(v)
yield k if remainder is not None and language_names:
if remainder is not None:
remainder.extend(language_names) remainder.extend(language_names)
return lang
def get_valid_language_codes(locale, language_names, remainder=None):
lang = list()
if "" in language_names:
language_names.remove("")
for k, __ in get_language_names(locale).items():
if k in language_names:
lang.append(k)
language_names.remove(k)
if remainder is not None and len(language_names):
remainder.extend(language_names)
return lang
def get_lang3(lang):
try:
if len(lang) == 2:
ret_value = get(part1=lang).part3
elif len(lang) == 3:
ret_value = lang
else:
ret_value = ""
except KeyError:
ret_value = lang
return ret_value
+4596 -3850
View File
File diff suppressed because it is too large Load Diff
+32 -14
View File
@@ -25,7 +25,7 @@
from __future__ import division, print_function, unicode_literals from __future__ import division, print_function, unicode_literals
import datetime import datetime
import mimetypes import mimetypes
import re from uuid import uuid4
from babel.dates import format_date from babel.dates import format_date
from flask import Blueprint, request, url_for from flask import Blueprint, request, url_for
@@ -44,6 +44,8 @@ log = logger.create()
def url_for_other_page(page): def url_for_other_page(page):
args = request.view_args.copy() args = request.view_args.copy()
args['page'] = page args['page'] = page
for get, val in request.args.items():
args[get] = val
return url_for(request.endpoint, **args) return url_for(request.endpoint, **args)
@@ -76,22 +78,18 @@ def mimetype_filter(val):
@jinjia.app_template_filter('formatdate') @jinjia.app_template_filter('formatdate')
def formatdate_filter(val): def formatdate_filter(val):
try: try:
conformed_timestamp = re.sub(r"[:]|([-](?!((\d{2}[:]\d{2})|(\d{4}))$))", '', val) return format_date(val, format='medium', locale=get_locale())
formatdate = datetime.datetime.strptime(conformed_timestamp[:15], "%Y%m%d %H%M%S")
return format_date(formatdate, format='medium', locale=get_locale())
except AttributeError as e: except AttributeError as e:
log.error('Babel error: %s, Current user locale: %s, Current User: %s', e, log.error('Babel error: %s, Current user locale: %s, Current User: %s', e,
current_user.locale, current_user.locale,
current_user.nickname current_user.name
) )
return formatdate return val
@jinjia.app_template_filter('formatdateinput') @jinjia.app_template_filter('formatdateinput')
def format_date_input(val): def format_date_input(val):
conformed_timestamp = re.sub(r"[:]|([-](?!((\d{2}[:]\d{2})|(\d{4}))$))", '', val) input_date = val.isoformat().split('T', 1)[0] # Hack to support dates <1900
date_obj = datetime.datetime.strptime(conformed_timestamp[:15], "%Y%m%d %H%M%S")
input_date = date_obj.isoformat().split('T', 1)[0] # Hack to support dates <1900
return '' if input_date == "0101-01-01" else input_date return '' if input_date == "0101-01-01" else input_date
@@ -113,8 +111,28 @@ def yesno(value, yes, no):
return yes if value else no return yes if value else no
'''@jinjia.app_template_filter('canread') @jinjia.app_template_filter('formatfloat')
def canread(ext): def formatfloat(value, decimals=1):
if isinstance(ext, db.Data): formatedstring = '%d' % value
ext = ext.format if (value % 1) != 0:
return ext.lower() in EXTENSIONS_READER''' formatedstring = ('%s.%d' % (formatedstring, (value % 1) * 10**decimals)).rstrip('0')
return formatedstring
@jinjia.app_template_filter('formatseriesindex')
def formatseriesindex_filter(series_index):
if series_index:
try:
if int(series_index) - series_index == 0:
return int(series_index)
else:
return series_index
except ValueError:
return series_index
return 0
@jinjia.app_template_filter('uuidfilter')
def uuidfilter(var):
return uuid4()
+144 -109
View File
@@ -19,8 +19,6 @@
import base64 import base64
import datetime import datetime
import itertools
import json
import sys import sys
import os import os
import uuid import uuid
@@ -41,22 +39,25 @@ from flask import (
redirect, redirect,
abort abort
) )
from flask_login import current_user, login_required from flask_login import current_user
from werkzeug.datastructures import Headers from werkzeug.datastructures import Headers
from sqlalchemy import func from sqlalchemy import func
from sqlalchemy.sql.expression import and_, or_ from sqlalchemy.sql.expression import and_
from sqlalchemy.exc import StatementError from sqlalchemy.exc import StatementError
import requests import requests
from . import config, logger, kobo_auth, db, helper, shelf as shelf_lib, ub from . import config, logger, kobo_auth, db, calibre_db, helper, shelf as shelf_lib, ub
from .helper import get_download_link
from .services import SyncToken as SyncToken from .services import SyncToken as SyncToken
from .web import download_required from .web import download_required
from .kobo_auth import requires_kobo_auth from .kobo_auth import requires_kobo_auth, get_auth_token
KOBO_FORMATS = {"KEPUB": ["KEPUB"], "EPUB": ["EPUB3", "EPUB"]} KOBO_FORMATS = {"KEPUB": ["KEPUB"], "EPUB": ["EPUB3", "EPUB"]}
KOBO_STOREAPI_URL = "https://storeapi.kobo.com" KOBO_STOREAPI_URL = "https://storeapi.kobo.com"
KOBO_IMAGEHOST_URL = "https://kbimages1-a.akamaihd.net" KOBO_IMAGEHOST_URL = "https://kbimages1-a.akamaihd.net"
SYNC_ITEM_LIMIT = 100
kobo = Blueprint("kobo", __name__, url_prefix="/kobo/<auth_token>") kobo = Blueprint("kobo", __name__, url_prefix="/kobo/<auth_token>")
kobo_auth.disable_failed_auth_redirect_for_blueprint(kobo) kobo_auth.disable_failed_auth_redirect_for_blueprint(kobo)
kobo_auth.register_url_value_preprocessor(kobo) kobo_auth.register_url_value_preprocessor(kobo)
@@ -121,7 +122,11 @@ def redirect_or_proxy_request():
def convert_to_kobo_timestamp_string(timestamp): def convert_to_kobo_timestamp_string(timestamp):
return timestamp.strftime("%Y-%m-%dT%H:%M:%SZ") try:
return timestamp.strftime("%Y-%m-%dT%H:%M:%SZ")
except AttributeError as exc:
log.debug("Timestamp not valid: {}".format(exc))
return datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
@kobo.route("/v1/library/sync") @kobo.route("/v1/library/sync")
@@ -131,7 +136,7 @@ def HandleSyncRequest():
sync_token = SyncToken.SyncToken.from_headers(request.headers) sync_token = SyncToken.SyncToken.from_headers(request.headers)
log.info("Kobo library sync request received.") log.info("Kobo library sync request received.")
if not current_app.wsgi_app.is_proxied: if not current_app.wsgi_app.is_proxied:
log.debug('Kobo: Received unproxied request, changed request port to server port') log.debug('Kobo: Received unproxied request, changed request port to external server port')
# TODO: Limit the number of books return per sync call, and rely on the sync-continuatation header # TODO: Limit the number of books return per sync call, and rely on the sync-continuatation header
# instead so that the device triggers another sync. # instead so that the device triggers another sync.
@@ -139,75 +144,93 @@ def HandleSyncRequest():
new_books_last_modified = sync_token.books_last_modified new_books_last_modified = sync_token.books_last_modified
new_books_last_created = sync_token.books_last_created new_books_last_created = sync_token.books_last_created
new_reading_state_last_modified = sync_token.reading_state_last_modified new_reading_state_last_modified = sync_token.reading_state_last_modified
new_archived_last_modified = datetime.datetime.min
sync_results = [] sync_results = []
# We reload the book database so that the user get's a fresh view of the library # We reload the book database so that the user get's a fresh view of the library
# in case of external changes (e.g: adding a book through Calibre). # in case of external changes (e.g: adding a book through Calibre).
db.reconnect_db(config) calibre_db.reconnect_db(config, ub.app_DB_path)
archived_books = ( if sync_token.books_last_id > -1:
ub.session.query(ub.ArchivedBook) changed_entries = (
.filter(ub.ArchivedBook.user_id == int(current_user.id)) calibre_db.session.query(db.Books, ub.ArchivedBook.last_modified, ub.ArchivedBook.is_archived)
.all() .join(db.Data).outerjoin(ub.ArchivedBook, db.Books.id == ub.ArchivedBook.book_id)
) .filter(db.Books.last_modified >= sync_token.books_last_modified)
.filter(db.Books.id>sync_token.books_last_id)
# We join-in books that have had their Archived bit recently modified in order to either: .filter(db.Data.format.in_(KOBO_FORMATS))
# * Restore them to the user's device. .filter(calibre_db.common_filters())
# * Delete them from the user's device. .order_by(db.Books.last_modified)
# (Ideally we would use a join for this logic, however cross-database joins don't look trivial in SqlAlchemy.) .order_by(db.Books.id)
recently_restored_or_archived_books = [] .limit(SYNC_ITEM_LIMIT)
archived_book_ids = {} )
new_archived_last_modified = datetime.datetime.min else:
for archived_book in archived_books: changed_entries = (
if archived_book.last_modified > sync_token.archive_last_modified: calibre_db.session.query(db.Books, ub.ArchivedBook.last_modified, ub.ArchivedBook.is_archived)
recently_restored_or_archived_books.append(archived_book.book_id) .join(db.Data).outerjoin(ub.ArchivedBook, db.Books.id == ub.ArchivedBook.book_id)
if archived_book.is_archived: .filter(db.Books.last_modified > sync_token.books_last_modified)
archived_book_ids[archived_book.book_id] = True .filter(db.Data.format.in_(KOBO_FORMATS))
new_archived_last_modified = max( .filter(calibre_db.common_filters())
new_archived_last_modified, archived_book.last_modified) .order_by(db.Books.last_modified)
.order_by(db.Books.id)
# sqlite gives unexpected results when performing the last_modified comparison without the datetime cast. .limit(SYNC_ITEM_LIMIT)
# It looks like it's treating the db.Books.last_modified field as a string and may fail )
# the comparison because of the +00:00 suffix.
changed_entries = (
db.session.query(db.Books)
.join(db.Data)
.filter(or_(func.datetime(db.Books.last_modified) > sync_token.books_last_modified,
db.Books.id.in_(recently_restored_or_archived_books)))
.filter(db.Data.format.in_(KOBO_FORMATS))
.all()
)
reading_states_in_new_entitlements = [] reading_states_in_new_entitlements = []
for book in changed_entries: for book in changed_entries:
kobo_reading_state = get_or_create_reading_state(book.id) formats = [data.format for data in book.Books.data]
if not 'KEPUB' in formats and config.config_kepubifypath and 'EPUB' in formats:
helper.convert_book_format(book.Books.id, config.config_calibre_dir, 'EPUB', 'KEPUB', current_user.name)
kobo_reading_state = get_or_create_reading_state(book.Books.id)
entitlement = { entitlement = {
"BookEntitlement": create_book_entitlement(book, archived=(book.id in archived_book_ids)), "BookEntitlement": create_book_entitlement(book.Books, archived=(book.is_archived == True)),
"BookMetadata": get_metadata(book), "BookMetadata": get_metadata(book.Books),
} }
if kobo_reading_state.last_modified > sync_token.reading_state_last_modified: if kobo_reading_state.last_modified > sync_token.reading_state_last_modified:
entitlement["ReadingState"] = get_kobo_reading_state_response(book, kobo_reading_state) entitlement["ReadingState"] = get_kobo_reading_state_response(book.Books, kobo_reading_state)
new_reading_state_last_modified = max(new_reading_state_last_modified, kobo_reading_state.last_modified) new_reading_state_last_modified = max(new_reading_state_last_modified, kobo_reading_state.last_modified)
reading_states_in_new_entitlements.append(book.id) reading_states_in_new_entitlements.append(book.Books.id)
if book.timestamp > sync_token.books_last_created: if book.Books.timestamp > sync_token.books_last_created:
sync_results.append({"NewEntitlement": entitlement}) sync_results.append({"NewEntitlement": entitlement})
else: else:
sync_results.append({"ChangedEntitlement": entitlement}) sync_results.append({"ChangedEntitlement": entitlement})
new_books_last_modified = max( new_books_last_modified = max(
book.last_modified, new_books_last_modified book.Books.last_modified, new_books_last_modified
) )
new_books_last_created = max(book.timestamp, new_books_last_created) new_books_last_created = max(book.Books.timestamp, new_books_last_created)
max_change = (changed_entries
.from_self()
.filter(ub.ArchivedBook.is_archived)
.order_by(func.datetime(ub.ArchivedBook.last_modified).desc())
.first()
)
if max_change:
max_change = max_change.last_modified
else:
max_change = new_archived_last_modified
new_archived_last_modified = max(new_archived_last_modified, max_change)
# no. of books returned
book_count = changed_entries.count()
# last entry:
if book_count:
books_last_id = changed_entries.all()[-1].Books.id or -1
else:
books_last_id = -1
# generate reading state data
changed_reading_states = ( changed_reading_states = (
ub.session.query(ub.KoboReadingState) ub.session.query(ub.KoboReadingState)
.filter(and_(func.datetime(ub.KoboReadingState.last_modified) > sync_token.reading_state_last_modified, .filter(and_(func.datetime(ub.KoboReadingState.last_modified) > sync_token.reading_state_last_modified,
ub.KoboReadingState.user_id == current_user.id, ub.KoboReadingState.user_id == current_user.id,
ub.KoboReadingState.book_id.notin_(reading_states_in_new_entitlements)))) ub.KoboReadingState.book_id.notin_(reading_states_in_new_entitlements))))
for kobo_reading_state in changed_reading_states.all(): for kobo_reading_state in changed_reading_states.all():
book = db.session.query(db.Books).filter(db.Books.id == kobo_reading_state.book_id).one_or_none() book = calibre_db.session.query(db.Books).filter(db.Books.id == kobo_reading_state.book_id).one_or_none()
if book: if book:
sync_results.append({ sync_results.append({
"ChangedReadingState": { "ChangedReadingState": {
@@ -222,11 +245,12 @@ def HandleSyncRequest():
sync_token.books_last_modified = new_books_last_modified sync_token.books_last_modified = new_books_last_modified
sync_token.archive_last_modified = new_archived_last_modified sync_token.archive_last_modified = new_archived_last_modified
sync_token.reading_state_last_modified = new_reading_state_last_modified sync_token.reading_state_last_modified = new_reading_state_last_modified
sync_token.books_last_id = books_last_id
return generate_sync_response(sync_token, sync_results) return generate_sync_response(sync_token, sync_results, book_count)
def generate_sync_response(sync_token, sync_results): def generate_sync_response(sync_token, sync_results, set_cont=False):
extra_headers = {} extra_headers = {}
if config.config_kobo_proxy: if config.config_kobo_proxy:
# Merge in sync results from the official Kobo store. # Merge in sync results from the official Kobo store.
@@ -240,8 +264,10 @@ def generate_sync_response(sync_token, sync_results):
extra_headers["x-kobo-sync-mode"] = store_response.headers.get("x-kobo-sync-mode") extra_headers["x-kobo-sync-mode"] = store_response.headers.get("x-kobo-sync-mode")
extra_headers["x-kobo-recent-reads"] = store_response.headers.get("x-kobo-recent-reads") extra_headers["x-kobo-recent-reads"] = store_response.headers.get("x-kobo-recent-reads")
except Exception as e: except Exception as ex:
log.error("Failed to receive or parse response from Kobo's sync endpoint: " + str(e)) log.error("Failed to receive or parse response from Kobo's sync endpoint: {}".format(ex))
if set_cont:
extra_headers["x-kobo-sync"] = "continue"
sync_token.to_headers(extra_headers) sync_token.to_headers(extra_headers)
response = make_response(jsonify(sync_results), extra_headers) response = make_response(jsonify(sync_results), extra_headers)
@@ -254,9 +280,9 @@ def generate_sync_response(sync_token, sync_results):
@download_required @download_required
def HandleMetadataRequest(book_uuid): def HandleMetadataRequest(book_uuid):
if not current_app.wsgi_app.is_proxied: if not current_app.wsgi_app.is_proxied:
log.debug('Kobo: Received unproxied request, changed request port to server port') log.debug('Kobo: Received unproxied request, changed request port to external server port')
log.info("Kobo library metadata request received for book %s" % book_uuid) log.info("Kobo library metadata request received for book %s" % book_uuid)
book = db.session.query(db.Books).filter(db.Books.uuid == book_uuid).first() book = calibre_db.get_book_by_uuid(book_uuid)
if not book or not book.data: if not book or not book.data:
log.info(u"Book %s not found in database", book_uuid) log.info(u"Book %s not found in database", book_uuid)
return redirect_or_proxy_request() return redirect_or_proxy_request()
@@ -267,19 +293,22 @@ def HandleMetadataRequest(book_uuid):
def get_download_url_for_book(book, book_format): def get_download_url_for_book(book, book_format):
if not current_app.wsgi_app.is_proxied: if not current_app.wsgi_app.is_proxied:
if ':' in request.host and not request.host.endswith(']') : if ':' in request.host and not request.host.endswith(']'):
host = "".join(request.host.split(':')[:-1]) host = "".join(request.host.split(':')[:-1])
else: else:
host = request.host host = request.host
return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format(
return "{url_scheme}://{url_base}:{url_port}/kobo/{auth_token}/download/{book_id}/{book_format}".format(
url_scheme=request.scheme, url_scheme=request.scheme,
url_base=host, url_base=host,
url_port=config.config_port, url_port=config.config_external_port,
auth_token=get_auth_token(),
book_id=book.id, book_id=book.id,
book_format=book_format.lower() book_format=book_format.lower()
) )
return url_for( return url_for(
"web.download_link", "kobo.download_book",
auth_token=kobo_auth.get_auth_token(),
book_id=book.id, book_id=book.id,
book_format=book_format.lower(), book_format=book_format.lower(),
_external=True, _external=True,
@@ -317,8 +346,15 @@ def get_description(book):
# TODO handle multiple authors # TODO handle multiple authors
def get_author(book): def get_author(book):
if not book.authors: if not book.authors:
return None return {"Contributors": None}
return book.authors[0].name if len(book.authors) > 1:
author_list = []
autor_roles = []
for author in book.authors:
autor_roles.append({"Name":author.name, "Role":"Author"})
author_list.append(author.name)
return {"ContributorRoles": autor_roles, "Contributors":author_list}
return {"ContributorRoles": [{"Name":book.authors[0].name, "Role":"Author"}], "Contributors": book.authors[0].name}
def get_publisher(book): def get_publisher(book):
@@ -332,10 +368,15 @@ def get_series(book):
return None return None
return book.series[0].name return book.series[0].name
def get_seriesindex(book):
return book.series_index or 1
def get_metadata(book): def get_metadata(book):
download_urls = [] download_urls = []
for book_data in book.data: kepub = [data for data in book.data if data.format == 'KEPUB']
for book_data in kepub if len(kepub) > 0 else book.data:
if book_data.format not in KOBO_FORMATS: if book_data.format not in KOBO_FORMATS:
continue continue
for kobo_format in KOBO_FORMATS[book_data.format]: for kobo_format in KOBO_FORMATS[book_data.format]:
@@ -354,7 +395,7 @@ def get_metadata(book):
book_uuid = book.uuid book_uuid = book.uuid
metadata = { metadata = {
"Categories": ["00000000-0000-0000-0000-000000000001",], "Categories": ["00000000-0000-0000-0000-000000000001",],
"Contributors": get_author(book), # "Contributors": get_author(book),
"CoverImageId": book_uuid, "CoverImageId": book_uuid,
"CrossRevisionId": book_uuid, "CrossRevisionId": book_uuid,
"CurrentDisplayPrice": {"CurrencyCode": "USD", "TotalAmount": 0}, "CurrentDisplayPrice": {"CurrencyCode": "USD", "TotalAmount": 0},
@@ -378,6 +419,7 @@ def get_metadata(book):
"Title": book.title, "Title": book.title,
"WorkId": book_uuid, "WorkId": book_uuid,
} }
metadata.update(get_author(book))
if get_series(book): if get_series(book):
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
@@ -386,8 +428,8 @@ def get_metadata(book):
name = get_series(book) name = get_series(book)
metadata["Series"] = { metadata["Series"] = {
"Name": get_series(book), "Name": get_series(book),
"Number": book.series_index, # ToDo Check int() ? "Number": get_seriesindex(book), # ToDo Check int() ?
"NumberFloat": float(book.series_index), "NumberFloat": float(get_seriesindex(book)),
# Get a deterministic id based on the series name. # Get a deterministic id based on the series name.
"Id": uuid.uuid3(uuid.NAMESPACE_DNS, name), "Id": uuid.uuid3(uuid.NAMESPACE_DNS, name),
} }
@@ -396,7 +438,7 @@ def get_metadata(book):
@kobo.route("/v1/library/tags", methods=["POST", "DELETE"]) @kobo.route("/v1/library/tags", methods=["POST", "DELETE"])
@login_required @requires_kobo_auth
# Creates a Shelf with the given items, and returns the shelf's uuid. # Creates a Shelf with the given items, and returns the shelf's uuid.
def HandleTagCreate(): def HandleTagCreate():
# catch delete requests, otherwise the are handeld in the book delete handler # catch delete requests, otherwise the are handeld in the book delete handler
@@ -425,12 +467,12 @@ def HandleTagCreate():
items_unknown_to_calibre = add_items_to_shelf(items, shelf) items_unknown_to_calibre = add_items_to_shelf(items, shelf)
if items_unknown_to_calibre: if items_unknown_to_calibre:
log.debug("Received request to add unknown books to a collection. Silently ignoring items.") log.debug("Received request to add unknown books to a collection. Silently ignoring items.")
ub.session.commit() ub.session_commit()
return make_response(jsonify(str(shelf.uuid)), 201) return make_response(jsonify(str(shelf.uuid)), 201)
@kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE", "PUT"]) @kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE", "PUT"])
@requires_kobo_auth
def HandleTagUpdate(tag_id): def HandleTagUpdate(tag_id):
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.uuid == tag_id, shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.uuid == tag_id,
ub.Shelf.user_id == current_user.id).one_or_none() ub.Shelf.user_id == current_user.id).one_or_none()
@@ -457,7 +499,7 @@ def HandleTagUpdate(tag_id):
shelf.name = name shelf.name = name
ub.session.merge(shelf) ub.session.merge(shelf)
ub.session.commit() ub.session_commit()
return make_response(' ', 200) return make_response(' ', 200)
@@ -471,7 +513,7 @@ def add_items_to_shelf(items, shelf):
items_unknown_to_calibre.append(item) items_unknown_to_calibre.append(item)
continue continue
book = db.session.query(db.Books).filter(db.Books.uuid == item["RevisionId"]).one_or_none() book = calibre_db.get_book_by_uuid(item["RevisionId"])
if not book: if not book:
items_unknown_to_calibre.append(item) items_unknown_to_calibre.append(item)
continue continue
@@ -485,7 +527,7 @@ def add_items_to_shelf(items, shelf):
@kobo.route("/v1/library/tags/<tag_id>/items", methods=["POST"]) @kobo.route("/v1/library/tags/<tag_id>/items", methods=["POST"])
@login_required @requires_kobo_auth
def HandleTagAddItem(tag_id): def HandleTagAddItem(tag_id):
items = None items = None
try: try:
@@ -509,13 +551,12 @@ def HandleTagAddItem(tag_id):
log.debug("Received request to add an unknown book to a collection. Silently ignoring item.") log.debug("Received request to add an unknown book to a collection. Silently ignoring item.")
ub.session.merge(shelf) ub.session.merge(shelf)
ub.session.commit() ub.session_commit()
return make_response('', 201) return make_response('', 201)
@kobo.route("/v1/library/tags/<tag_id>/items/delete", methods=["POST"]) @kobo.route("/v1/library/tags/<tag_id>/items/delete", methods=["POST"])
@login_required @requires_kobo_auth
def HandleTagRemoveItem(tag_id): def HandleTagRemoveItem(tag_id):
items = None items = None
try: try:
@@ -542,7 +583,7 @@ def HandleTagRemoveItem(tag_id):
items_unknown_to_calibre.append(item) items_unknown_to_calibre.append(item)
continue continue
book = db.session.query(db.Books).filter(db.Books.uuid == item["RevisionId"]).one_or_none() book = calibre_db.get_book_by_uuid(item["RevisionId"])
if not book: if not book:
items_unknown_to_calibre.append(item) items_unknown_to_calibre.append(item)
continue continue
@@ -550,7 +591,7 @@ def HandleTagRemoveItem(tag_id):
shelf.books.filter(ub.BookShelf.book_id == book.id).delete() shelf.books.filter(ub.BookShelf.book_id == book.id).delete()
except KeyError: except KeyError:
items_unknown_to_calibre.append(item) items_unknown_to_calibre.append(item)
ub.session.commit() ub.session_commit()
if items_unknown_to_calibre: if items_unknown_to_calibre:
log.debug("Received request to remove an unknown book to a collecition. Silently ignoring item.") log.debug("Received request to remove an unknown book to a collecition. Silently ignoring item.")
@@ -596,7 +637,7 @@ def sync_shelves(sync_token, sync_results):
"ChangedTag": tag "ChangedTag": tag
}) })
sync_token.tags_last_modified = new_tags_last_modified sync_token.tags_last_modified = new_tags_last_modified
ub.session.commit() ub.session_commit()
# Creates a Kobo "Tag" object from a ub.Shelf object # Creates a Kobo "Tag" object from a ub.Shelf object
@@ -610,7 +651,7 @@ def create_kobo_tag(shelf):
"Type": "UserTag" "Type": "UserTag"
} }
for book_shelf in shelf.books: for book_shelf in shelf.books:
book = db.session.query(db.Books).filter(db.Books.id == book_shelf.book_id).one_or_none() book = calibre_db.get_book(book_shelf.book_id)
if not book: if not book:
log.info(u"Book (id: %s) in BookShelf (id: %s) not found in book database", book_shelf.book_id, shelf.id) log.info(u"Book (id: %s) in BookShelf (id: %s) not found in book database", book_shelf.book_id, shelf.id)
continue continue
@@ -624,9 +665,9 @@ def create_kobo_tag(shelf):
@kobo.route("/v1/library/<book_uuid>/state", methods=["GET", "PUT"]) @kobo.route("/v1/library/<book_uuid>/state", methods=["GET", "PUT"])
@login_required @requires_kobo_auth
def HandleStateRequest(book_uuid): def HandleStateRequest(book_uuid):
book = db.session.query(db.Books).filter(db.Books.uuid == book_uuid).first() book = calibre_db.get_book_by_uuid(book_uuid)
if not book or not book.data: if not book or not book.data:
log.info(u"Book %s not found in database", book_uuid) log.info(u"Book %s not found in database", book_uuid)
return redirect_or_proxy_request() return redirect_or_proxy_request()
@@ -677,7 +718,7 @@ def HandleStateRequest(book_uuid):
abort(400, description="Malformed request data is missing 'ReadingStates' key") abort(400, description="Malformed request data is missing 'ReadingStates' key")
ub.session.merge(kobo_reading_state) ub.session.merge(kobo_reading_state)
ub.session.commit() ub.session_commit()
return jsonify({ return jsonify({
"RequestResult": "Success", "RequestResult": "Success",
"UpdateResults": [update_results_response], "UpdateResults": [update_results_response],
@@ -715,7 +756,7 @@ def get_or_create_reading_state(book_id):
kobo_reading_state.statistics = ub.KoboStatistics() kobo_reading_state.statistics = ub.KoboStatistics()
book_read.kobo_reading_state = kobo_reading_state book_read.kobo_reading_state = kobo_reading_state
ub.session.add(book_read) ub.session.add(book_read)
ub.session.commit() ub.session_commit()
return book_read.kobo_reading_state return book_read.kobo_reading_state
@@ -798,10 +839,10 @@ def TopLevelEndpoint():
@kobo.route("/v1/library/<book_uuid>", methods=["DELETE"]) @kobo.route("/v1/library/<book_uuid>", methods=["DELETE"])
@login_required @requires_kobo_auth
def HandleBookDeletionRequest(book_uuid): def HandleBookDeletionRequest(book_uuid):
log.info("Kobo book deletion request received for book %s" % book_uuid) log.info("Kobo book deletion request received for book %s" % book_uuid)
book = db.session.query(db.Books).filter(db.Books.uuid == book_uuid).first() book = calibre_db.get_book_by_uuid(book_uuid)
if not book: if not book:
log.info(u"Book %s not found in database", book_uuid) log.info(u"Book %s not found in database", book_uuid)
return redirect_or_proxy_request() return redirect_or_proxy_request()
@@ -818,8 +859,7 @@ def HandleBookDeletionRequest(book_uuid):
archived_book.last_modified = datetime.datetime.utcnow() archived_book.last_modified = datetime.datetime.utcnow()
ub.session.merge(archived_book) ub.session.merge(archived_book)
ub.session.commit() ub.session_commit()
return ("", 204) return ("", 204)
@@ -845,6 +885,7 @@ def HandleUserRequest(dummy=None):
@kobo.route("/v1/products/<dummy>/recommendations", methods=["GET", "POST"]) @kobo.route("/v1/products/<dummy>/recommendations", methods=["GET", "POST"])
@kobo.route("/v1/products/<dummy>/nextread", methods=["GET", "POST"]) @kobo.route("/v1/products/<dummy>/nextread", methods=["GET", "POST"])
@kobo.route("/v1/products/<dummy>/reviews", methods=["GET", "POST"]) @kobo.route("/v1/products/<dummy>/reviews", methods=["GET", "POST"])
@kobo.route("/v1/products/books/external/<dummy>", methods=["GET", "POST"])
@kobo.route("/v1/products/books/series/<dummy>", methods=["GET", "POST"]) @kobo.route("/v1/products/books/series/<dummy>", methods=["GET", "POST"])
@kobo.route("/v1/products/books/<dummy>", methods=["GET", "POST"]) @kobo.route("/v1/products/books/<dummy>", methods=["GET", "POST"])
@kobo.route("/v1/products/dailydeal", methods=["GET", "POST"]) @kobo.route("/v1/products/dailydeal", methods=["GET", "POST"])
@@ -854,17 +895,6 @@ def HandleProductsRequest(dummy=None):
return redirect_or_proxy_request() return redirect_or_proxy_request()
'''@kobo.errorhandler(404)
def handle_404(err):
# This handler acts as a catch-all for endpoints that we don't have an interest in
# implementing (e.g: v1/analytics/gettests, v1/user/recommendations, etc)
if err:
print('404')
return jsonify(error=str(err)), 404
log.debug("Unknown Request received: %s, method: %s, data: %s", request.base_url, request.method, request.data)
return redirect_or_proxy_request()'''
def make_calibre_web_auth_response(): def make_calibre_web_auth_response():
# As described in kobo_auth.py, CalibreWeb doesn't make use practical use of this auth/device API call for # As described in kobo_auth.py, CalibreWeb doesn't make use practical use of this auth/device API call for
# authentation (nor for authorization). We return a dummy response just to keep the device happy. # authentation (nor for authorization). We return a dummy response just to keep the device happy.
@@ -891,7 +921,7 @@ def HandleAuthRequest():
if config.config_kobo_proxy: if config.config_kobo_proxy:
try: try:
return redirect_or_proxy_request() return redirect_or_proxy_request()
except: except Exception:
log.error("Failed to receive or parse response from Kobo's auth endpoint. Falling back to un-proxied mode.") log.error("Failed to receive or parse response from Kobo's auth endpoint. Falling back to un-proxied mode.")
return make_calibre_web_auth_response() return make_calibre_web_auth_response()
@@ -908,13 +938,13 @@ def HandleInitRequest():
store_response_json = store_response.json() store_response_json = store_response.json()
if "Resources" in store_response_json: if "Resources" in store_response_json:
kobo_resources = store_response_json["Resources"] kobo_resources = store_response_json["Resources"]
except: except Exception:
log.error("Failed to receive or parse response from Kobo's init endpoint. Falling back to un-proxied mode.") log.error("Failed to receive or parse response from Kobo's init endpoint. Falling back to un-proxied mode.")
if not kobo_resources: if not kobo_resources:
kobo_resources = NATIVE_KOBO_RESOURCES() kobo_resources = NATIVE_KOBO_RESOURCES()
if not current_app.wsgi_app.is_proxied: if not current_app.wsgi_app.is_proxied:
log.debug('Kobo: Received unproxied request, changed request port to server port') log.debug('Kobo: Received unproxied request, changed request port to external server port')
if ':' in request.host and not request.host.endswith(']'): if ':' in request.host and not request.host.endswith(']'):
host = "".join(request.host.split(':')[:-1]) host = "".join(request.host.split(':')[:-1])
else: else:
@@ -922,8 +952,9 @@ def HandleInitRequest():
calibre_web_url = "{url_scheme}://{url_base}:{url_port}".format( calibre_web_url = "{url_scheme}://{url_base}:{url_port}".format(
url_scheme=request.scheme, url_scheme=request.scheme,
url_base=host, url_base=host,
url_port=config.config_port url_port=config.config_external_port
) )
log.debug('Kobo: Received unproxied request, changed request url to %s', calibre_web_url)
kobo_resources["image_host"] = calibre_web_url kobo_resources["image_host"] = calibre_web_url
kobo_resources["image_url_quality_template"] = unquote(calibre_web_url + kobo_resources["image_url_quality_template"] = unquote(calibre_web_url +
url_for("kobo.HandleCoverImageRequest", url_for("kobo.HandleCoverImageRequest",
@@ -932,16 +963,14 @@ def HandleInitRequest():
width="{width}", width="{width}",
height="{height}", height="{height}",
Quality='{Quality}', Quality='{Quality}',
isGreyscale='isGreyscale' isGreyscale='isGreyscale'))
))
kobo_resources["image_url_template"] = unquote(calibre_web_url + kobo_resources["image_url_template"] = unquote(calibre_web_url +
url_for("kobo.HandleCoverImageRequest", url_for("kobo.HandleCoverImageRequest",
auth_token=kobo_auth.get_auth_token(), auth_token=kobo_auth.get_auth_token(),
book_uuid="{ImageId}", book_uuid="{ImageId}",
width="{width}", width="{width}",
height="{height}", height="{height}",
isGreyscale='false' isGreyscale='false'))
))
else: else:
kobo_resources["image_host"] = url_for("web.index", _external=True).strip("/") kobo_resources["image_host"] = url_for("web.index", _external=True).strip("/")
kobo_resources["image_url_quality_template"] = unquote(url_for("kobo.HandleCoverImageRequest", kobo_resources["image_url_quality_template"] = unquote(url_for("kobo.HandleCoverImageRequest",
@@ -960,13 +989,19 @@ def HandleInitRequest():
isGreyscale='false', isGreyscale='false',
_external=True)) _external=True))
response = make_response(jsonify({"Resources": kobo_resources})) response = make_response(jsonify({"Resources": kobo_resources}))
response.headers["x-kobo-apitoken"] = "e30=" response.headers["x-kobo-apitoken"] = "e30="
return response return response
@kobo.route("/download/<book_id>/<book_format>")
@requires_kobo_auth
@download_required
def download_book(book_id, book_format):
return get_download_link(book_id, book_format, "kobo")
def NATIVE_KOBO_RESOURCES(): def NATIVE_KOBO_RESOURCES():
return { return {
"account_page": "https://secure.kobobooks.com/profile", "account_page": "https://secure.kobobooks.com/profile",
@@ -979,7 +1014,7 @@ def NATIVE_KOBO_RESOURCES():
"blackstone_header": {"key": "x-amz-request-payer", "value": "requester"}, "blackstone_header": {"key": "x-amz-request-payer", "value": "requester"},
"book": "https://storeapi.kobo.com/v1/products/books/{ProductId}", "book": "https://storeapi.kobo.com/v1/products/books/{ProductId}",
"book_detail_page": "https://store.kobobooks.com/{culture}/ebook/{slug}", "book_detail_page": "https://store.kobobooks.com/{culture}/ebook/{slug}",
"book_detail_page_rakuten": "http://books.rakuten.co.jp/rk/{crossrevisionid}", "book_detail_page_rakuten": "https://books.rakuten.co.jp/rk/{crossrevisionid}",
"book_landing_page": "https://store.kobobooks.com/ebooks", "book_landing_page": "https://store.kobobooks.com/ebooks",
"book_subscription": "https://storeapi.kobo.com/v1/products/books/subscriptions", "book_subscription": "https://storeapi.kobo.com/v1/products/books/subscriptions",
"categories": "https://storeapi.kobo.com/v1/categories", "categories": "https://storeapi.kobo.com/v1/categories",
@@ -1017,7 +1052,7 @@ def NATIVE_KOBO_RESOURCES():
"get_tests_request": "https://storeapi.kobo.com/v1/analytics/gettests", "get_tests_request": "https://storeapi.kobo.com/v1/analytics/gettests",
"giftcard_epd_redeem_url": "https://www.kobo.com/{storefront}/{language}/redeem-ereader", "giftcard_epd_redeem_url": "https://www.kobo.com/{storefront}/{language}/redeem-ereader",
"giftcard_redeem_url": "https://www.kobo.com/{storefront}/{language}/redeem", "giftcard_redeem_url": "https://www.kobo.com/{storefront}/{language}/redeem",
"help_page": "http://www.kobo.com/help", "help_page": "https://www.kobo.com/help",
"kobo_audiobooks_enabled": "False", "kobo_audiobooks_enabled": "False",
"kobo_audiobooks_orange_deal_enabled": "False", "kobo_audiobooks_orange_deal_enabled": "False",
"kobo_audiobooks_subscriptions_enabled": "False", "kobo_audiobooks_subscriptions_enabled": "False",
+20 -7
View File
@@ -64,11 +64,11 @@ from datetime import datetime
from os import urandom from os import urandom
from flask import g, Blueprint, url_for, abort, request from flask import g, Blueprint, url_for, abort, request
from flask_login import login_user, login_required from flask_login import login_user, current_user, login_required
from flask_babel import gettext as _ from flask_babel import gettext as _
from . import logger, ub, lm from . import logger, config, calibre_db, db, helper, ub, lm
from .web import render_title_template from .render_template import render_title_template
try: try:
from functools import wraps from functools import wraps
@@ -81,6 +81,7 @@ log = logger.create()
def register_url_value_preprocessor(kobo): def register_url_value_preprocessor(kobo):
@kobo.url_value_preprocessor @kobo.url_value_preprocessor
# pylint: disable=unused-variable
def pop_auth_token(__, values): def pop_auth_token(__, values):
g.auth_token = values.pop("auth_token") g.auth_token = values.pop("auth_token")
@@ -121,7 +122,11 @@ kobo_auth = Blueprint("kobo_auth", __name__, url_prefix="/kobo_auth")
@kobo_auth.route("/generate_auth_token/<int:user_id>") @kobo_auth.route("/generate_auth_token/<int:user_id>")
@login_required @login_required
def generate_auth_token(user_id): def generate_auth_token(user_id):
host = ':'.join(request.host.rsplit(':')[0:-1]) host_list = request.host.rsplit(':')
if len(host_list) == 1:
host = ':'.join(host_list)
else:
host = ':'.join(host_list[0:-1])
if host.startswith('127.') or host.lower() == 'localhost' or host.startswith('[::ffff:7f'): if host.startswith('127.') or host.lower() == 'localhost' or host.startswith('[::ffff:7f'):
warning = _('PLease access calibre-web from non localhost to get valid api_endpoint for kobo device') warning = _('PLease access calibre-web from non localhost to get valid api_endpoint for kobo device')
return render_title_template( return render_title_template(
@@ -143,7 +148,15 @@ def generate_auth_token(user_id):
auth_token.token_type = 1 auth_token.token_type = 1
ub.session.add(auth_token) ub.session.add(auth_token)
ub.session.commit() ub.session_commit()
books = calibre_db.session.query(db.Books).join(db.Data).all()
for book in books:
formats = [data.format for data in book.data]
if not 'KEPUB' in formats and config.config_kepubifypath and 'EPUB' in formats:
helper.convert_book_format(book.id, config.config_calibre_dir, 'EPUB', 'KEPUB', current_user.name)
return render_title_template( return render_title_template(
"generate_kobo_auth_url.html", "generate_kobo_auth_url.html",
title=_(u"Kobo Setup"), title=_(u"Kobo Setup"),
@@ -160,5 +173,5 @@ def delete_auth_token(user_id):
# Invalidate any prevously generated Kobo Auth token for this user. # Invalidate any prevously generated Kobo Auth token for this user.
ub.session.query(ub.RemoteAuthToken).filter(ub.RemoteAuthToken.user_id == user_id)\ ub.session.query(ub.RemoteAuthToken).filter(ub.RemoteAuthToken.user_id == user_id)\
.filter(ub.RemoteAuthToken.token_type==1).delete() .filter(ub.RemoteAuthToken.token_type==1).delete()
ub.session.commit()
return "" return ub.session_commit()
+43 -8
View File
@@ -41,10 +41,37 @@ logging.addLevelName(logging.WARNING, "WARN")
logging.addLevelName(logging.CRITICAL, "CRIT") logging.addLevelName(logging.CRITICAL, "CRIT")
class _Logger(logging.Logger):
def debug_or_exception(self, message, *args, **kwargs):
if sys.version_info > (3, 7):
if is_debug_enabled():
self.exception(message, stacklevel=2, *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)
else:
if is_debug_enabled():
self.exception(message, *args, **kwargs)
else:
self.error(message, *args, **kwargs)
def debug_no_auth(self, message, *args, **kwargs):
message = message.strip("\r\n")
if message.startswith("send: AUTH"):
self.debug(message[:16], *args, **kwargs)
else:
self.debug(message, *args, **kwargs)
def get(name=None): def get(name=None):
return logging.getLogger(name) return logging.getLogger(name)
def create(): def create():
parent_frame = inspect.stack(0)[1] parent_frame = inspect.stack(0)[1]
if hasattr(parent_frame, 'frame'): if hasattr(parent_frame, 'frame'):
@@ -54,7 +81,6 @@ def create():
parent_module = inspect.getmodule(parent_frame) parent_module = inspect.getmodule(parent_frame)
return get(parent_module.__name__) return get(parent_module.__name__)
def is_debug_enabled(): def is_debug_enabled():
return logging.root.level <= logging.DEBUG return logging.root.level <= logging.DEBUG
@@ -82,7 +108,6 @@ def _absolute_log_file(log_file, default_log_file):
if not os.path.dirname(log_file): if not os.path.dirname(log_file):
log_file = os.path.join(_CONFIG_DIR, log_file) log_file = os.path.join(_CONFIG_DIR, log_file)
return os.path.abspath(log_file) return os.path.abspath(log_file)
return default_log_file return default_log_file
@@ -100,6 +125,7 @@ def setup(log_file, log_level=None):
May be called multiple times. May be called multiple times.
''' '''
log_level = log_level or DEFAULT_LOG_LEVEL log_level = log_level or DEFAULT_LOG_LEVEL
logging.setLoggerClass(_Logger)
logging.getLogger(__package__).setLevel(log_level) logging.getLogger(__package__).setLevel(log_level)
r = logging.root r = logging.root
@@ -115,7 +141,7 @@ def setup(log_file, log_level=None):
if previous_handler: if previous_handler:
# if the log_file has not changed, don't create a new handler # if the log_file has not changed, don't create a new handler
if getattr(previous_handler, 'baseFilename', None) == log_file: if getattr(previous_handler, 'baseFilename', None) == log_file:
return return "" if log_file == DEFAULT_LOG_FILE else log_file
logging.debug("logging to %s level %s", log_file, r.level) logging.debug("logging to %s level %s", log_file, r.level)
if log_file == LOG_TO_STDERR or log_file == LOG_TO_STDOUT: if log_file == LOG_TO_STDERR or log_file == LOG_TO_STDOUT:
@@ -127,17 +153,19 @@ def setup(log_file, log_level=None):
file_handler.baseFilename = log_file file_handler.baseFilename = log_file
else: else:
try: try:
file_handler = RotatingFileHandler(log_file, maxBytes=50000, backupCount=2) file_handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=2, encoding='utf-8')
except IOError: except IOError:
if log_file == DEFAULT_LOG_FILE: if log_file == DEFAULT_LOG_FILE:
raise raise
file_handler = RotatingFileHandler(DEFAULT_LOG_FILE, maxBytes=50000, backupCount=2) file_handler = RotatingFileHandler(DEFAULT_LOG_FILE, maxBytes=100000, backupCount=2, encoding='utf-8')
log_file = ""
file_handler.setFormatter(FORMATTER) file_handler.setFormatter(FORMATTER)
for h in r.handlers: for h in r.handlers:
r.removeHandler(h) r.removeHandler(h)
h.close() h.close()
r.addHandler(file_handler) r.addHandler(file_handler)
return "" if log_file == DEFAULT_LOG_FILE else log_file
def create_access_log(log_file, log_name, formatter): def create_access_log(log_file, log_name, formatter):
@@ -150,11 +178,18 @@ def create_access_log(log_file, log_name, formatter):
access_log = logging.getLogger(log_name) access_log = logging.getLogger(log_name)
access_log.propagate = False access_log.propagate = False
access_log.setLevel(logging.INFO) access_log.setLevel(logging.INFO)
try:
file_handler = RotatingFileHandler(log_file, maxBytes=50000, backupCount=2, encoding='utf-8')
except IOError:
if log_file == DEFAULT_ACCESS_LOG:
raise
file_handler = RotatingFileHandler(DEFAULT_ACCESS_LOG, maxBytes=50000, backupCount=2, encoding='utf-8')
log_file = ""
file_handler = RotatingFileHandler(log_file, maxBytes=50000, backupCount=2)
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
access_log.addHandler(file_handler) access_log.addHandler(file_handler)
return access_log return access_log, \
"" if _absolute_log_file(log_file, DEFAULT_ACCESS_LOG) == DEFAULT_ACCESS_LOG else log_file
# Enable logging of smtp lib debug output # Enable logging of smtp lib debug output
+117 -121
View File
@@ -19,7 +19,6 @@
from __future__ import division, print_function, unicode_literals from __future__ import division, print_function, unicode_literals
from flask import session from flask import session
try: try:
from flask_dance.consumer.backend.sqla import SQLAlchemyBackend, first, _get_real_user from flask_dance.consumer.backend.sqla import SQLAlchemyBackend, first, _get_real_user
from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.orm.exc import NoResultFound
@@ -34,134 +33,131 @@ except ImportError:
except ImportError: except ImportError:
pass pass
try:
class OAuthBackend(SQLAlchemyBackend):
"""
Stores and retrieves OAuth tokens using a relational database through
the `SQLAlchemy`_ ORM.
.. _SQLAlchemy: http://www.sqlalchemy.org/ class OAuthBackend(SQLAlchemyBackend):
""" """
def __init__(self, model, session, provider_id, Stores and retrieves OAuth tokens using a relational database through
user=None, user_id=None, user_required=None, anon_user=None, the `SQLAlchemy`_ ORM.
cache=None):
self.provider_id = provider_id
super(OAuthBackend, self).__init__(model, session, user, user_id, user_required, anon_user, cache)
def get(self, blueprint, user=None, user_id=None): .. _SQLAlchemy: https://www.sqlalchemy.org/
if self.provider_id + '_oauth_token' in session and session[self.provider_id + '_oauth_token'] != '': """
return session[self.provider_id + '_oauth_token'] def __init__(self, model, session, provider_id,
# check cache user=None, user_id=None, user_required=None, anon_user=None,
cache_key = self.make_cache_key(blueprint=blueprint, user=user, user_id=user_id) cache=None):
token = self.cache.get(cache_key) self.provider_id = provider_id
if token: super(OAuthBackend, self).__init__(model, session, user, user_id, user_required, anon_user, cache)
return token
# if not cached, make database queries
query = (
self.session.query(self.model)
.filter_by(provider=self.provider_id)
)
uid = first([user_id, self.user_id, blueprint.config.get("user_id")])
u = first(_get_real_user(ref, self.anon_user)
for ref in (user, self.user, blueprint.config.get("user")))
use_provider_user_id = False
if self.provider_id + '_oauth_user_id' in session and session[self.provider_id + '_oauth_user_id'] != '':
query = query.filter_by(provider_user_id=session[self.provider_id + '_oauth_user_id'])
use_provider_user_id = True
if self.user_required and not u and not uid and not use_provider_user_id:
# raise ValueError("Cannot get OAuth token without an associated user")
return None
# check for user ID
if hasattr(self.model, "user_id") and uid:
query = query.filter_by(user_id=uid)
# check for user (relationship property)
elif hasattr(self.model, "user") and u:
query = query.filter_by(user=u)
# if we have the property, but not value, filter by None
elif hasattr(self.model, "user_id"):
query = query.filter_by(user_id=None)
# run query
try:
token = query.one().token
except NoResultFound:
token = None
# cache the result
self.cache.set(cache_key, token)
def get(self, blueprint, user=None, user_id=None):
if self.provider_id + '_oauth_token' in session and session[self.provider_id + '_oauth_token'] != '':
return session[self.provider_id + '_oauth_token']
# check cache
cache_key = self.make_cache_key(blueprint=blueprint, user=user, user_id=user_id)
token = self.cache.get(cache_key)
if token:
return token return token
def set(self, blueprint, token, user=None, user_id=None): # if not cached, make database queries
uid = first([user_id, self.user_id, blueprint.config.get("user_id")]) query = (
u = first(_get_real_user(ref, self.anon_user) self.session.query(self.model)
for ref in (user, self.user, blueprint.config.get("user"))) .filter_by(provider=self.provider_id)
)
uid = first([user_id, self.user_id, blueprint.config.get("user_id")])
u = first(_get_real_user(ref, self.anon_user)
for ref in (user, self.user, blueprint.config.get("user")))
if self.user_required and not u and not uid: use_provider_user_id = False
raise ValueError("Cannot set OAuth token without an associated user") if self.provider_id + '_oauth_user_id' in session and session[self.provider_id + '_oauth_user_id'] != '':
query = query.filter_by(provider_user_id=session[self.provider_id + '_oauth_user_id'])
use_provider_user_id = True
# if there was an existing model, delete it if self.user_required and not u and not uid and not use_provider_user_id:
existing_query = ( # raise ValueError("Cannot get OAuth token without an associated user")
self.session.query(self.model) return None
.filter_by(provider=self.provider_id) # check for user ID
) if hasattr(self.model, "user_id") and uid:
# check for user ID query = query.filter_by(user_id=uid)
has_user_id = hasattr(self.model, "user_id") # check for user (relationship property)
if has_user_id and uid: elif hasattr(self.model, "user") and u:
existing_query = existing_query.filter_by(user_id=uid) query = query.filter_by(user=u)
# check for user (relationship property) # if we have the property, but not value, filter by None
has_user = hasattr(self.model, "user") elif hasattr(self.model, "user_id"):
if has_user and u: query = query.filter_by(user_id=None)
existing_query = existing_query.filter_by(user=u) # run query
# queue up delete query -- won't be run until commit() try:
existing_query.delete() token = query.one().token
# create a new model for this token except NoResultFound:
kwargs = { token = None
"provider": self.provider_id,
"token": token,
}
if has_user_id and uid:
kwargs["user_id"] = uid
if has_user and u:
kwargs["user"] = u
self.session.add(self.model(**kwargs))
# commit to delete and add simultaneously
self.session.commit()
# invalidate cache
self.cache.delete(self.make_cache_key(
blueprint=blueprint, user=user, user_id=user_id
))
def delete(self, blueprint, user=None, user_id=None): # cache the result
query = ( self.cache.set(cache_key, token)
self.session.query(self.model)
.filter_by(provider=self.provider_id)
)
uid = first([user_id, self.user_id, blueprint.config.get("user_id")])
u = first(_get_real_user(ref, self.anon_user)
for ref in (user, self.user, blueprint.config.get("user")))
if self.user_required and not u and not uid: return token
raise ValueError("Cannot delete OAuth token without an associated user")
# check for user ID def set(self, blueprint, token, user=None, user_id=None):
if hasattr(self.model, "user_id") and uid: uid = first([user_id, self.user_id, blueprint.config.get("user_id")])
query = query.filter_by(user_id=uid) u = first(_get_real_user(ref, self.anon_user)
# check for user (relationship property) for ref in (user, self.user, blueprint.config.get("user")))
elif hasattr(self.model, "user") and u:
query = query.filter_by(user=u)
# if we have the property, but not value, filter by None
elif hasattr(self.model, "user_id"):
query = query.filter_by(user_id=None)
# run query
query.delete()
self.session.commit()
# invalidate cache
self.cache.delete(self.make_cache_key(
blueprint=blueprint, user=user, user_id=user_id,
))
except Exception: if self.user_required and not u and not uid:
pass raise ValueError("Cannot set OAuth token without an associated user")
# if there was an existing model, delete it
existing_query = (
self.session.query(self.model)
.filter_by(provider=self.provider_id)
)
# check for user ID
has_user_id = hasattr(self.model, "user_id")
if has_user_id and uid:
existing_query = existing_query.filter_by(user_id=uid)
# check for user (relationship property)
has_user = hasattr(self.model, "user")
if has_user and u:
existing_query = existing_query.filter_by(user=u)
# queue up delete query -- won't be run until commit()
existing_query.delete()
# create a new model for this token
kwargs = {
"provider": self.provider_id,
"token": token,
}
if has_user_id and uid:
kwargs["user_id"] = uid
if has_user and u:
kwargs["user"] = u
self.session.add(self.model(**kwargs))
# commit to delete and add simultaneously
self.session.commit()
# invalidate cache
self.cache.delete(self.make_cache_key(
blueprint=blueprint, user=user, user_id=user_id
))
def delete(self, blueprint, user=None, user_id=None):
query = (
self.session.query(self.model)
.filter_by(provider=self.provider_id)
)
uid = first([user_id, self.user_id, blueprint.config.get("user_id")])
u = first(_get_real_user(ref, self.anon_user)
for ref in (user, self.user, blueprint.config.get("user")))
if self.user_required and not u and not uid:
raise ValueError("Cannot delete OAuth token without an associated user")
# check for user ID
if hasattr(self.model, "user_id") and uid:
query = query.filter_by(user_id=uid)
# check for user (relationship property)
elif hasattr(self.model, "user") and u:
query = query.filter_by(user=u)
# if we have the property, but not value, filter by None
elif hasattr(self.model, "user_id"):
query = query.filter_by(user_id=None)
# run query
query.delete()
self.session.commit()
# invalidate cache
self.cache.delete(self.make_cache_key(
blueprint=blueprint, user=user, user_id=user_id,
))
+180 -170
View File
@@ -30,15 +30,20 @@ from flask_babel import gettext as _
from flask_dance.consumer import oauth_authorized, oauth_error from flask_dance.consumer import oauth_authorized, oauth_error
from flask_dance.contrib.github import make_github_blueprint, github from flask_dance.contrib.github import make_github_blueprint, github
from flask_dance.contrib.google import make_google_blueprint, google from flask_dance.contrib.google import make_google_blueprint, google
from flask_login import login_user, current_user from oauthlib.oauth2 import TokenExpiredError, InvalidGrantError
from flask_login import login_user, current_user, login_required
from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.orm.exc import NoResultFound
from . import constants, logger, config, app, ub from . import constants, logger, config, app, ub
from .web import login_required
from .oauth import OAuthBackend, backend_resultcode try:
from .oauth import OAuthBackend, backend_resultcode
except NameError:
pass
oauth_check = {} oauth_check = {}
oauthblueprints = []
oauth = Blueprint('oauth', __name__) oauth = Blueprint('oauth', __name__)
log = logger.create() log = logger.create()
@@ -84,11 +89,7 @@ def register_user_with_oauth(user=None):
except NoResultFound: except NoResultFound:
# no found, return error # no found, return error
return return
try: ub.session_commit("User {} with OAuth for provider {} registered".format(user.name, oauth_key))
ub.session.commit()
except Exception as e:
log.exception(e)
ub.session.rollback()
def logout_oauth_user(): def logout_oauth_user():
@@ -97,19 +98,122 @@ def logout_oauth_user():
session.pop(str(oauth_key) + '_oauth_user_id') session.pop(str(oauth_key) + '_oauth_user_id')
if ub.oauth_support: def oauth_update_token(provider_id, token, provider_user_id):
oauthblueprints = [] session[provider_id + "_oauth_user_id"] = provider_user_id
session[provider_id + "_oauth_token"] = token
# Find this OAuth token in the database, or create it
query = ub.session.query(ub.OAuth).filter_by(
provider=provider_id,
provider_user_id=provider_user_id,
)
try:
oauth_entry = query.one()
# update token
oauth_entry.token = token
except NoResultFound:
oauth_entry = ub.OAuth(
provider=provider_id,
provider_user_id=provider_user_id,
token=token,
)
ub.session.add(oauth_entry)
ub.session_commit()
# Disable Flask-Dance's default behavior for saving the OAuth token
# Value differrs depending on flask-dance version
return backend_resultcode
def bind_oauth_or_register(provider_id, provider_user_id, redirect_url, provider_name):
query = ub.session.query(ub.OAuth).filter_by(
provider=provider_id,
provider_user_id=provider_user_id,
)
try:
oauth_entry = query.first()
# already bind with user, just login
if oauth_entry.user:
login_user(oauth_entry.user)
log.debug(u"You are now logged in as: '%s'", oauth_entry.user.name)
flash(_(u"you are now logged in as: '%(nickname)s'", nickname= oauth_entry.user.name),
category="success")
return redirect(url_for('web.index'))
else:
# bind to current user
if current_user and current_user.is_authenticated:
oauth_entry.user = current_user
try:
ub.session.add(oauth_entry)
ub.session.commit()
flash(_(u"Link to %(oauth)s Succeeded", oauth=provider_name), category="success")
log.info("Link to {} Succeeded".format(provider_name))
return redirect(url_for('web.profile'))
except Exception as ex:
log.debug_or_exception(ex)
ub.session.rollback()
else:
flash(_(u"Login failed, No User Linked With OAuth Account"), category="error")
log.info('Login failed, No User Linked With OAuth Account')
return redirect(url_for('web.login'))
# return redirect(url_for('web.login'))
# if config.config_public_reg:
# return redirect(url_for('web.register'))
# else:
# flash(_(u"Public registration is not enabled"), category="error")
# return redirect(url_for(redirect_url))
except (NoResultFound, AttributeError):
return redirect(url_for(redirect_url))
def get_oauth_status():
status = []
query = ub.session.query(ub.OAuth).filter_by(
user_id=current_user.id,
)
try:
oauths = query.all()
for oauth_entry in oauths:
status.append(int(oauth_entry.provider))
return status
except NoResultFound:
return None
def unlink_oauth(provider):
if request.host_url + 'me' != request.referrer:
pass
query = ub.session.query(ub.OAuth).filter_by(
provider=provider,
user_id=current_user.id,
)
try:
oauth_entry = query.one()
if current_user and current_user.is_authenticated:
oauth_entry.user = current_user
try:
ub.session.delete(oauth_entry)
ub.session.commit()
logout_oauth_user()
flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success")
log.info("Unlink to {} Succeeded".format(oauth_check[provider]))
except Exception as ex:
log.debug_or_exception(ex)
ub.session.rollback()
flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error")
except NoResultFound:
log.warning("oauth %s for user %d not found", provider, current_user.id)
flash(_(u"Not Linked to %(oauth)s", oauth=provider), category="error")
return redirect(url_for('web.profile'))
def generate_oauth_blueprints():
if not ub.session.query(ub.OAuthProvider).count(): if not ub.session.query(ub.OAuthProvider).count():
oauthProvider = ub.OAuthProvider() for provider in ("github", "google"):
oauthProvider.provider_name = "github" oauthProvider = ub.OAuthProvider()
oauthProvider.active = False oauthProvider.provider_name = provider
ub.session.add(oauthProvider) oauthProvider.active = False
ub.session.commit() ub.session.add(oauthProvider)
oauthProvider = ub.OAuthProvider() ub.session_commit("{} Blueprint Created".format(provider))
oauthProvider.provider_name = "google"
oauthProvider.active = False
ub.session.add(oauthProvider)
ub.session.commit()
oauth_ids = ub.session.query(ub.OAuthProvider).all() oauth_ids = ub.session.query(ub.OAuthProvider).all()
ele1 = dict(provider_name='github', ele1 = dict(provider_name='github',
@@ -122,10 +226,10 @@ if ub.oauth_support:
ele2 = dict(provider_name='google', ele2 = dict(provider_name='google',
id=oauth_ids[1].id, id=oauth_ids[1].id,
active=oauth_ids[1].active, active=oauth_ids[1].active,
scope=["https://www.googleapis.com/auth/plus.me", "https://www.googleapis.com/auth/userinfo.email"], scope=["https://www.googleapis.com/auth/userinfo.email"],
oauth_client_id=oauth_ids[1].oauth_client_id, oauth_client_id=oauth_ids[1].oauth_client_id,
oauth_client_secret=oauth_ids[1].oauth_client_secret, oauth_client_secret=oauth_ids[1].oauth_client_secret,
obtain_link='https://github.com/settings/developers') obtain_link='https://console.developers.google.com/apis/credentials')
oauthblueprints.append(ele1) oauthblueprints.append(ele1)
oauthblueprints.append(ele2) oauthblueprints.append(ele2)
@@ -146,17 +250,23 @@ if ub.oauth_support:
app.register_blueprint(blueprint, url_prefix="/login") app.register_blueprint(blueprint, url_prefix="/login")
if element['active']: if element['active']:
register_oauth_blueprint(element['id'], element['provider_name']) register_oauth_blueprint(element['id'], element['provider_name'])
return oauthblueprints
if ub.oauth_support:
oauthblueprints = generate_oauth_blueprints()
@oauth_authorized.connect_via(oauthblueprints[0]['blueprint']) @oauth_authorized.connect_via(oauthblueprints[0]['blueprint'])
def github_logged_in(blueprint, token): def github_logged_in(blueprint, token):
if not token: if not token:
flash(_(u"Failed to log in with GitHub."), category="error") flash(_(u"Failed to log in with GitHub."), category="error")
log.error("Failed to log in with GitHub")
return False return False
resp = blueprint.session.get("/user") resp = blueprint.session.get("/user")
if not resp.ok: if not resp.ok:
flash(_(u"Failed to fetch user info from GitHub."), category="error") flash(_(u"Failed to fetch user info from GitHub."), category="error")
log.error("Failed to fetch user info from GitHub")
return False return False
github_info = resp.json() github_info = resp.json()
@@ -168,11 +278,13 @@ if ub.oauth_support:
def google_logged_in(blueprint, token): def google_logged_in(blueprint, token):
if not token: if not token:
flash(_(u"Failed to log in with Google."), category="error") flash(_(u"Failed to log in with Google."), category="error")
log.error("Failed to log in with Google")
return False return False
resp = blueprint.session.get("/oauth2/v2/userinfo") resp = blueprint.session.get("/oauth2/v2/userinfo")
if not resp.ok: if not resp.ok:
flash(_(u"Failed to fetch user info from Google."), category="error") flash(_(u"Failed to fetch user info from Google."), category="error")
log.error("Failed to fetch user info from Google")
return False return False
google_info = resp.json() google_info = resp.json()
@@ -180,117 +292,6 @@ if ub.oauth_support:
return oauth_update_token(str(oauthblueprints[1]['id']), token, google_user_id) return oauth_update_token(str(oauthblueprints[1]['id']), token, google_user_id)
def oauth_update_token(provider_id, token, provider_user_id):
session[provider_id + "_oauth_user_id"] = provider_user_id
session[provider_id + "_oauth_token"] = token
# Find this OAuth token in the database, or create it
query = ub.session.query(ub.OAuth).filter_by(
provider=provider_id,
provider_user_id=provider_user_id,
)
try:
oauth_entry = query.one()
# update token
oauth_entry.token = token
except NoResultFound:
oauth_entry = ub.OAuth(
provider=provider_id,
provider_user_id=provider_user_id,
token=token,
)
try:
ub.session.add(oauth_entry)
ub.session.commit()
except Exception as e:
log.exception(e)
ub.session.rollback()
# Disable Flask-Dance's default behavior for saving the OAuth token
# Value differrs depending on flask-dance version
return backend_resultcode
def bind_oauth_or_register(provider_id, provider_user_id, redirect_url, provider_name):
query = ub.session.query(ub.OAuth).filter_by(
provider=provider_id,
provider_user_id=provider_user_id,
)
try:
oauth_entry = query.first()
# already bind with user, just login
if oauth_entry.user:
login_user(oauth_entry.user)
log.debug(u"You are now logged in as: '%s'", oauth_entry.user.nickname)
flash(_(u"you are now logged in as: '%(nickname)s'", nickname= oauth_entry.user.nickname),
category="success")
return redirect(url_for('web.index'))
else:
# bind to current user
if current_user and current_user.is_authenticated:
oauth_entry.user = current_user
try:
ub.session.add(oauth_entry)
ub.session.commit()
flash(_(u"Link to %(oauth)s Succeeded", oauth=provider_name), category="success")
return redirect(url_for('web.profile'))
except Exception as e:
log.exception(e)
ub.session.rollback()
else:
flash(_(u"Login failed, No User Linked With OAuth Account"), category="error")
log.info('Login failed, No User Linked With OAuth Account')
return redirect(url_for('web.login'))
# return redirect(url_for('web.login'))
# if config.config_public_reg:
# return redirect(url_for('web.register'))
# else:
# flash(_(u"Public registration is not enabled"), category="error")
# return redirect(url_for(redirect_url))
except (NoResultFound, AttributeError):
return redirect(url_for(redirect_url))
def get_oauth_status():
status = []
query = ub.session.query(ub.OAuth).filter_by(
user_id=current_user.id,
)
try:
oauths = query.all()
for oauth_entry in oauths:
status.append(int(oauth_entry.provider))
return status
except NoResultFound:
return None
def unlink_oauth(provider):
if request.host_url + 'me' != request.referrer:
pass
query = ub.session.query(ub.OAuth).filter_by(
provider=provider,
user_id=current_user.id,
)
try:
oauth_entry = query.one()
if current_user and current_user.is_authenticated:
oauth_entry.user = current_user
try:
ub.session.delete(oauth_entry)
ub.session.commit()
logout_oauth_user()
flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success")
except Exception as e:
log.exception(e)
ub.session.rollback()
flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error")
except NoResultFound:
log.warning("oauth %s for user %d not found", provider, current_user.id)
flash(_(u"Not Linked to %(oauth)s.", oauth=oauth_check[provider]), category="error")
return redirect(url_for('web.profile'))
# notify on OAuth provider error # notify on OAuth provider error
@oauth_error.connect_via(oauthblueprints[0]['blueprint']) @oauth_error.connect_via(oauthblueprints[0]['blueprint'])
def github_error(blueprint, error, error_description=None, error_uri=None): def github_error(blueprint, error, error_description=None, error_uri=None):
@@ -305,39 +306,6 @@ if ub.oauth_support:
) # ToDo: Translate ) # ToDo: Translate
flash(msg, category="error") flash(msg, category="error")
@oauth.route('/link/github')
@oauth_required
def github_login():
if not github.authorized:
return redirect(url_for('github.login'))
account_info = github.get('/user')
if account_info.ok:
account_info_json = account_info.json()
return bind_oauth_or_register(oauthblueprints[0]['id'], account_info_json['id'], 'github.login', 'github')
flash(_(u"GitHub Oauth error, please retry later."), category="error")
return redirect(url_for('web.login'))
@oauth.route('/unlink/github', methods=["GET"])
@login_required
def github_login_unlink():
return unlink_oauth(oauthblueprints[0]['id'])
@oauth.route('/link/google')
@oauth_required
def google_login():
if not google.authorized:
return redirect(url_for("google.login"))
resp = google.get("/oauth2/v2/userinfo")
if resp.ok:
account_info_json = resp.json()
return bind_oauth_or_register(oauthblueprints[1]['id'], account_info_json['id'], 'google.login', 'google')
flash(_(u"Google Oauth error, please retry later."), category="error")
return redirect(url_for('web.login'))
@oauth_error.connect_via(oauthblueprints[1]['blueprint']) @oauth_error.connect_via(oauthblueprints[1]['blueprint'])
def google_error(blueprint, error, error_description=None, error_uri=None): def google_error(blueprint, error, error_description=None, error_uri=None):
msg = ( msg = (
@@ -352,7 +320,49 @@ if ub.oauth_support:
flash(msg, category="error") flash(msg, category="error")
@oauth.route('/unlink/google', methods=["GET"]) @oauth.route('/link/github')
@login_required @oauth_required
def google_login_unlink(): def github_login():
return unlink_oauth(oauthblueprints[1]['blueprint'].name) if not github.authorized:
return redirect(url_for('github.login'))
try:
account_info = github.get('/user')
if account_info.ok:
account_info_json = account_info.json()
return bind_oauth_or_register(oauthblueprints[0]['id'], account_info_json['id'], 'github.login', 'github')
flash(_(u"GitHub Oauth error, please retry later."), category="error")
log.error("GitHub Oauth error, please retry later")
except (InvalidGrantError, TokenExpiredError) as e:
flash(_(u"GitHub Oauth error: {}").format(e), category="error")
log.error(e)
return redirect(url_for('web.login'))
@oauth.route('/unlink/github', methods=["GET"])
@login_required
def github_login_unlink():
return unlink_oauth(oauthblueprints[0]['id'])
@oauth.route('/link/google')
@oauth_required
def google_login():
if not google.authorized:
return redirect(url_for("google.login"))
try:
resp = google.get("/oauth2/v2/userinfo")
if resp.ok:
account_info_json = resp.json()
return bind_oauth_or_register(oauthblueprints[1]['id'], account_info_json['id'], 'google.login', 'google')
flash(_(u"Google Oauth error, please retry later."), category="error")
log.error("Google Oauth error, please retry later")
except (InvalidGrantError, TokenExpiredError) as e:
flash(_(u"Google Oauth error: {}").format(e), category="error")
log.error(e)
return redirect(url_for('web.login'))
@oauth.route('/unlink/google', methods=["GET"])
@login_required
def google_login_unlink():
return unlink_oauth(oauthblueprints[1]['id'])
+227 -79
View File
@@ -25,15 +25,16 @@ import sys
import datetime import datetime
from functools import wraps from functools import wraps
from flask import Blueprint, request, render_template, Response, g, make_response from flask import Blueprint, request, render_template, Response, g, make_response, abort
from flask_login import current_user from flask_login import current_user
from sqlalchemy.sql.expression import func, text, or_, and_ from sqlalchemy.sql.expression import func, text, or_, and_, true
from werkzeug.security import check_password_hash from werkzeug.security import check_password_hash
from . import constants, logger, config, db, ub, services, get_locale, isoLanguages from . import constants, logger, config, db, calibre_db, ub, services, get_locale, isoLanguages
from .helper import fill_indexpage, get_download_link, get_book_cover, speaking_language from .helper import get_download_link, get_book_cover
from .pagination import Pagination from .pagination import Pagination
from .web import common_filters, get_search_results, render_read_books, download_required from .web import render_read_books
from .usermanagement import load_user_from_request
from flask_babel import gettext as _ from flask_babel import gettext as _
from babel import Locale as LC from babel import Locale as LC
from babel.core import UnknownLocaleError from babel.core import UnknownLocaleError
@@ -51,7 +52,7 @@ def requires_basic_auth_if_no_ano(f):
if not auth or auth.type != 'basic' or not check_auth(auth.username, auth.password): if not auth or auth.type != 'basic' or not check_auth(auth.username, auth.password):
return authenticate() return authenticate()
return f(*args, **kwargs) return f(*args, **kwargs)
if config.config_login_type == constants.LOGIN_LDAP and services.ldap: if config.config_login_type == constants.LOGIN_LDAP and services.ldap and config.config_anonbrowse != 1:
return services.ldap.basic_auth_required(f) return services.ldap.basic_auth_required(f)
return decorated return decorated
@@ -93,22 +94,60 @@ def feed_cc_search(query):
@opds.route("/opds/search", methods=["GET"]) @opds.route("/opds/search", methods=["GET"])
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_normal_search(): def feed_normal_search():
return feed_search(request.args.get("query").strip()) return feed_search(request.args.get("query", "").strip())
@opds.route("/opds/books")
@requires_basic_auth_if_no_ano
def feed_booksindex():
shift = 0
off = int(request.args.get("offset") or 0)
entries = calibre_db.session.query(func.upper(func.substr(db.Books.sort, 1, 1)).label('id'))\
.filter(calibre_db.common_filters()).group_by(func.upper(func.substr(db.Books.sort, 1, 1))).all()
elements = []
if off == 0:
elements.append({'id': "00", 'name':_("All")})
shift = 1
for entry in entries[
off + shift - 1:
int(off + int(config.config_books_per_page) - shift)]:
elements.append({'id': entry.id, 'name': entry.id})
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(entries) + 1)
return render_xml_template('feed.xml',
letterelements=elements,
folder='opds.feed_letter_books',
pagination=pagination)
@opds.route("/opds/books/letter/<book_id>")
@requires_basic_auth_if_no_ano
def feed_letter_books(book_id):
off = request.args.get("offset") or 0
letter = true() if book_id == "00" else func.upper(db.Books.sort).startswith(book_id)
entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books,
letter,
[db.Books.sort])
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@opds.route("/opds/new") @opds.route("/opds/new")
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_new(): def feed_new():
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, True, [db.Books.timestamp.desc()]) db.Books, True, [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@opds.route("/opds/discover") @opds.route("/opds/discover")
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_discover(): def feed_discover():
entries = db.session.query(db.Books).filter(common_filters()).order_by(func.random())\ entries = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()).order_by(func.random())\
.limit(config.config_books_per_page) .limit(config.config_books_per_page)
pagination = Pagination(1, config.config_books_per_page, int(config.config_books_per_page)) pagination = Pagination(1, config.config_books_per_page, int(config.config_books_per_page))
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@@ -118,9 +157,9 @@ def feed_discover():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_best_rated(): def feed_best_rated():
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books.ratings.any(db.Ratings.rating > 9), db.Books, db.Books.ratings.any(db.Ratings.rating > 9),
[db.Books.timestamp.desc()]) [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@@ -133,16 +172,13 @@ def feed_hot():
hot_books = all_books.offset(off).limit(config.config_books_per_page) hot_books = all_books.offset(off).limit(config.config_books_per_page)
entries = list() entries = list()
for book in hot_books: for book in hot_books:
downloadBook = db.session.query(db.Books).filter(db.Books.id == book.Downloads.book_id).first() downloadBook = calibre_db.get_book(book.Downloads.book_id)
if downloadBook: if downloadBook:
entries.append( entries.append(
db.session.query(db.Books).filter(common_filters()) calibre_db.get_filtered_book(book.Downloads.book_id)
.filter(db.Books.id == book.Downloads.book_id).first()
) )
else: else:
ub.delete_download(book.Downloads.book_id) ub.delete_download(book.Downloads.book_id)
# ub.session.query(ub.Downloads).filter(book.Downloads.book_id == ub.Downloads.book_id).delete()
# ub.session.commit()
numBooks = entries.__len__() numBooks = entries.__len__()
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1),
config.config_books_per_page, numBooks) config.config_books_per_page, numBooks)
@@ -152,12 +188,41 @@ def feed_hot():
@opds.route("/opds/author") @opds.route("/opds/author")
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_authorindex(): def feed_authorindex():
off = request.args.get("offset") or 0 shift = 0
entries = db.session.query(db.Authors).join(db.books_authors_link).join(db.Books).filter(common_filters())\ off = int(request.args.get("offset") or 0)
.group_by(text('books_authors_link.author')).order_by(db.Authors.sort).limit(config.config_books_per_page)\ entries = calibre_db.session.query(func.upper(func.substr(db.Authors.sort, 1, 1)).label('id'))\
.offset(off) .join(db.books_authors_link).join(db.Books).filter(calibre_db.common_filters())\
.group_by(func.upper(func.substr(db.Authors.sort, 1, 1))).all()
elements = []
if off == 0:
elements.append({'id': "00", 'name':_("All")})
shift = 1
for entry in entries[
off + shift - 1:
int(off + int(config.config_books_per_page) - shift)]:
elements.append({'id': entry.id, 'name': entry.id})
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(db.session.query(db.Authors).all())) len(entries) + 1)
return render_xml_template('feed.xml',
letterelements=elements,
folder='opds.feed_letter_author',
pagination=pagination)
@opds.route("/opds/author/letter/<book_id>")
@requires_basic_auth_if_no_ano
def feed_letter_author(book_id):
off = request.args.get("offset") or 0
letter = true() if book_id == "00" else func.upper(db.Authors.sort).startswith(book_id)
entries = calibre_db.session.query(db.Authors).join(db.books_authors_link).join(db.Books)\
.filter(calibre_db.common_filters()).filter(letter)\
.group_by(text('books_authors_link.author'))\
.order_by(db.Authors.sort)
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
entries.count())
entries = entries.limit(config.config_books_per_page).offset(off).all()
return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_author', pagination=pagination) return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_author', pagination=pagination)
@@ -165,10 +230,10 @@ def feed_authorindex():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_author(book_id): def feed_author(book_id):
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books,
db.Books.authors.any(db.Authors.id == book_id), db.Books.authors.any(db.Authors.id == book_id),
[db.Books.timestamp.desc()]) [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@@ -176,11 +241,14 @@ def feed_author(book_id):
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_publisherindex(): def feed_publisherindex():
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries = db.session.query(db.Publishers).join(db.books_publishers_link).join(db.Books).filter(common_filters())\ entries = calibre_db.session.query(db.Publishers)\
.group_by(text('books_publishers_link.publisher')).order_by(db.Publishers.sort)\ .join(db.books_publishers_link)\
.join(db.Books).filter(calibre_db.common_filters())\
.group_by(text('books_publishers_link.publisher'))\
.order_by(db.Publishers.sort)\
.limit(config.config_books_per_page).offset(off) .limit(config.config_books_per_page).offset(off)
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(db.session.query(db.Publishers).all())) len(calibre_db.session.query(db.Publishers).all()))
return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_publisher', pagination=pagination) return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_publisher', pagination=pagination)
@@ -188,21 +256,51 @@ def feed_publisherindex():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_publisher(book_id): def feed_publisher(book_id):
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books,
db.Books.publishers.any(db.Publishers.id == book_id), db.Books.publishers.any(db.Publishers.id == book_id),
[db.Books.timestamp.desc()]) [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@opds.route("/opds/category") @opds.route("/opds/category")
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_categoryindex(): def feed_categoryindex():
off = request.args.get("offset") or 0 shift = 0
entries = db.session.query(db.Tags).join(db.books_tags_link).join(db.Books).filter(common_filters())\ off = int(request.args.get("offset") or 0)
.group_by(text('books_tags_link.tag')).order_by(db.Tags.name).offset(off).limit(config.config_books_per_page) entries = calibre_db.session.query(func.upper(func.substr(db.Tags.name, 1, 1)).label('id'))\
.join(db.books_tags_link).join(db.Books).filter(calibre_db.common_filters())\
.group_by(func.upper(func.substr(db.Tags.name, 1, 1))).all()
elements = []
if off == 0:
elements.append({'id': "00", 'name':_("All")})
shift = 1
for entry in entries[
off + shift - 1:
int(off + int(config.config_books_per_page) - shift)]:
elements.append({'id': entry.id, 'name': entry.id})
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(db.session.query(db.Tags).all())) len(entries) + 1)
return render_xml_template('feed.xml',
letterelements=elements,
folder='opds.feed_letter_category',
pagination=pagination)
@opds.route("/opds/category/letter/<book_id>")
@requires_basic_auth_if_no_ano
def feed_letter_category(book_id):
off = request.args.get("offset") or 0
letter = true() if book_id == "00" else func.upper(db.Tags.name).startswith(book_id)
entries = calibre_db.session.query(db.Tags)\
.join(db.books_tags_link)\
.join(db.Books)\
.filter(calibre_db.common_filters()).filter(letter)\
.group_by(text('books_tags_link.tag'))\
.order_by(db.Tags.name)
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
entries.count())
entries = entries.offset(off).limit(config.config_books_per_page).all()
return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_category', pagination=pagination) return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_category', pagination=pagination)
@@ -210,21 +308,50 @@ def feed_categoryindex():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_category(book_id): def feed_category(book_id):
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books,
db.Books.tags.any(db.Tags.id == book_id), db.Books.tags.any(db.Tags.id == book_id),
[db.Books.timestamp.desc()]) [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@opds.route("/opds/series") @opds.route("/opds/series")
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_seriesindex(): def feed_seriesindex():
off = request.args.get("offset") or 0 shift = 0
entries = db.session.query(db.Series).join(db.books_series_link).join(db.Books).filter(common_filters())\ off = int(request.args.get("offset") or 0)
.group_by(text('books_series_link.series')).order_by(db.Series.sort).offset(off).all() entries = calibre_db.session.query(func.upper(func.substr(db.Series.sort, 1, 1)).label('id'))\
.join(db.books_series_link).join(db.Books).filter(calibre_db.common_filters())\
.group_by(func.upper(func.substr(db.Series.sort, 1, 1))).all()
elements = []
if off == 0:
elements.append({'id': "00", 'name':_("All")})
shift = 1
for entry in entries[
off + shift - 1:
int(off + int(config.config_books_per_page) - shift)]:
elements.append({'id': entry.id, 'name': entry.id})
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(db.session.query(db.Series).all())) len(entries) + 1)
return render_xml_template('feed.xml',
letterelements=elements,
folder='opds.feed_letter_series',
pagination=pagination)
@opds.route("/opds/series/letter/<book_id>")
@requires_basic_auth_if_no_ano
def feed_letter_series(book_id):
off = request.args.get("offset") or 0
letter = true() if book_id == "00" else func.upper(db.Series.sort).startswith(book_id)
entries = calibre_db.session.query(db.Series)\
.join(db.books_series_link)\
.join(db.Books)\
.filter(calibre_db.common_filters()).filter(letter)\
.group_by(text('books_series_link.series'))\
.order_by(db.Series.sort)
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
entries.count())
entries = entries.offset(off).limit(config.config_books_per_page).all()
return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_series', pagination=pagination) return render_xml_template('feed.xml', listelements=entries, folder='opds.feed_series', pagination=pagination)
@@ -232,10 +359,10 @@ def feed_seriesindex():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_series(book_id): def feed_series(book_id):
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books,
db.Books.series.any(db.Series.id == book_id), db.Books.series.any(db.Series.id == book_id),
[db.Books.series_index]) [db.Books.series_index])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@@ -243,16 +370,19 @@ def feed_series(book_id):
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_ratingindex(): def feed_ratingindex():
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries = db.session.query(db.Ratings, func.count('books_ratings_link.book').label('count'), entries = calibre_db.session.query(db.Ratings, func.count('books_ratings_link.book').label('count'),
(db.Ratings.rating / 2).label('name')) \ (db.Ratings.rating / 2).label('name')) \
.join(db.books_ratings_link).join(db.Books).filter(common_filters()) \ .join(db.books_ratings_link)\
.group_by(text('books_ratings_link.rating')).order_by(db.Ratings.rating).all() .join(db.Books)\
.filter(calibre_db.common_filters()) \
.group_by(text('books_ratings_link.rating'))\
.order_by(db.Ratings.rating).all()
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(entries)) len(entries))
element = list() element = list()
for entry in entries: for entry in entries:
element.append(FeedObject(entry[0].id, "{} Stars".format(entry.name))) element.append(FeedObject(entry[0].id, _("{} Stars").format(entry.name)))
return render_xml_template('feed.xml', listelements=element, folder='opds.feed_ratings', pagination=pagination) return render_xml_template('feed.xml', listelements=element, folder='opds.feed_ratings', pagination=pagination)
@@ -260,10 +390,10 @@ def feed_ratingindex():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_ratings(book_id): def feed_ratings(book_id):
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books,
db.Books.ratings.any(db.Ratings.id == book_id), db.Books.ratings.any(db.Ratings.id == book_id),
[db.Books.timestamp.desc()]) [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@@ -271,8 +401,10 @@ def feed_ratings(book_id):
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_formatindex(): def feed_formatindex():
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries = db.session.query(db.Data).join(db.Books).filter(common_filters()) \ entries = calibre_db.session.query(db.Data).join(db.Books)\
.group_by(db.Data.format).order_by(db.Data.format).all() .filter(calibre_db.common_filters()) \
.group_by(db.Data.format)\
.order_by(db.Data.format).all()
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(entries)) len(entries))
@@ -286,10 +418,10 @@ def feed_formatindex():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_format(book_id): def feed_format(book_id):
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books,
db.Books.data.any(db.Data.format == book_id.upper()), db.Books.data.any(db.Data.format == book_id.upper()),
[db.Books.timestamp.desc()]) [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@@ -299,13 +431,13 @@ def feed_format(book_id):
def feed_languagesindex(): def feed_languagesindex():
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
if current_user.filter_language() == u"all": if current_user.filter_language() == u"all":
languages = speaking_language() languages = calibre_db.speaking_language()
else: else:
try: try:
cur_l = LC.parse(current_user.filter_language()) cur_l = LC.parse(current_user.filter_language())
except UnknownLocaleError: except UnknownLocaleError:
cur_l = None cur_l = None
languages = db.session.query(db.Languages).filter( languages = calibre_db.session.query(db.Languages).filter(
db.Languages.lang_code == current_user.filter_language()).all() db.Languages.lang_code == current_user.filter_language()).all()
if cur_l: if cur_l:
languages[0].name = cur_l.get_language_name(get_locale()) languages[0].name = cur_l.get_language_name(get_locale())
@@ -320,10 +452,10 @@ def feed_languagesindex():
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def feed_languages(book_id): def feed_languages(book_id):
off = request.args.get("offset") or 0 off = request.args.get("offset") or 0
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), entries, __, pagination = calibre_db.fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1), 0,
db.Books, db.Books,
db.Books.languages.any(db.Languages.id == book_id), db.Books.languages.any(db.Languages.id == book_id),
[db.Books.timestamp.desc()]) [db.Books.timestamp.desc()])
return render_xml_template('feed.xml', entries=entries, pagination=pagination) return render_xml_template('feed.xml', entries=entries, pagination=pagination)
@@ -356,7 +488,7 @@ def feed_shelf(book_id):
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == book_id).order_by( books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == book_id).order_by(
ub.BookShelf.order.asc()).all() ub.BookShelf.order.asc()).all()
for book in books_in_shelf: for book in books_in_shelf:
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first() cur_book = calibre_db.get_book(book.book_id)
result.append(cur_book) result.append(cur_book)
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
len(result)) len(result))
@@ -365,16 +497,25 @@ def feed_shelf(book_id):
@opds.route("/opds/download/<book_id>/<book_format>/") @opds.route("/opds/download/<book_id>/<book_format>/")
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
@download_required
def opds_download_link(book_id, book_format): def opds_download_link(book_id, book_format):
return get_download_link(book_id, book_format.lower()) # I gave up with this: With enabled ldap login, the user doesn't get logged in, therefore it's always guest
# workaround, loading the user from the request and checking it's download rights here
# in case of anonymous browsing user is None
user = load_user_from_request(request) or current_user
if not user.role_download():
return abort(403)
if "Kobo" in request.headers.get('User-Agent'):
client = "kobo"
else:
client = ""
return get_download_link(book_id, book_format.lower(), client)
@opds.route("/ajax/book/<string:uuid>/<library>") @opds.route("/ajax/book/<string:uuid>/<library>")
@opds.route("/ajax/book/<string:uuid>", defaults={'library': ""}) @opds.route("/ajax/book/<string:uuid>", defaults={'library': ""})
@requires_basic_auth_if_no_ano @requires_basic_auth_if_no_ano
def get_metadata_calibre_companion(uuid, library): def get_metadata_calibre_companion(uuid, library):
entry = db.session.query(db.Books).filter(db.Books.uuid.like("%" + uuid + "%")).first() entry = calibre_db.session.query(db.Books).filter(db.Books.uuid.like("%" + uuid + "%")).first()
if entry is not None: if entry is not None:
js = render_template('json.txt', entry=entry) js = render_template('json.txt', entry=entry)
response = make_response(js) response = make_response(js)
@@ -386,8 +527,7 @@ def get_metadata_calibre_companion(uuid, library):
def feed_search(term): def feed_search(term):
if term: if term:
term = term.strip().lower() entries, __, ___ = calibre_db.get_search_results(term)
entries = get_search_results(term)
entriescount = len(entries) if len(entries) > 0 else 1 entriescount = len(entries) if len(entries) > 0 else 1
pagination = Pagination(1, entriescount, entriescount) pagination = Pagination(1, entriescount, entriescount)
return render_xml_template('feed.xml', searchterm=term, entries=entries, pagination=pagination) return render_xml_template('feed.xml', searchterm=term, entries=entries, pagination=pagination)
@@ -397,10 +537,18 @@ def feed_search(term):
def check_auth(username, password): def check_auth(username, password):
if sys.version_info.major == 3: if sys.version_info.major == 3:
username = username.encode('windows-1252') try:
user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == username = username.encode('windows-1252')
except UnicodeEncodeError:
username = username.encode('utf-8')
user = ub.session.query(ub.User).filter(func.lower(ub.User.name) ==
username.decode('utf-8').lower()).first() username.decode('utf-8').lower()).first()
return bool(user and check_password_hash(str(user.password), password)) if bool(user and check_password_hash(str(user.password), password)):
return True
else:
ip_Address = request.headers.get('X-Forwarded-For', request.remote_addr)
log.warning('OPDS Login failed for user "%s" IP-address: %s', username.decode('utf-8'), ip_Address)
return False
def authenticate(): def authenticate():
+138
View File
@@ -0,0 +1,138 @@
# -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
# Copyright (C) 2018-2019 OzzieIsaacs, cervinko, jkrehm, bodybybuddha, ok11,
# andy29485, idalin, Kyosfonica, wuqi, Kennyl, lemmsh,
# falgh1, grunjol, csitko, ytils, xybydy, trasba, vrabe,
# ruben-herold, marblepebble, JackED42, SiphonSquirrel,
# apetresc, nanu-c, mutschler
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
from datetime import datetime
from flask import Blueprint, request, make_response, abort, url_for, flash, redirect
from flask_login import login_required, current_user, login_user
from flask_babel import gettext as _
from sqlalchemy.sql.expression import true
from . import config, logger, ub
from .render_template import render_title_template
try:
from functools import wraps
except ImportError:
pass # We're not using Python 3
remotelogin = Blueprint('remotelogin', __name__)
log = logger.create()
def remote_login_required(f):
@wraps(f)
def inner(*args, **kwargs):
if config.config_remote_login:
return f(*args, **kwargs)
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
data = {'status': 'error', 'message': 'Forbidden'}
response = make_response(json.dumps(data, ensure_ascii=False))
response.headers["Content-Type"] = "application/json; charset=utf-8"
return response, 403
abort(403)
return inner
@remotelogin.route('/remote/login')
@remote_login_required
def remote_login():
auth_token = ub.RemoteAuthToken()
ub.session.add(auth_token)
ub.session_commit()
verify_url = url_for('remotelogin.verify_token', token=auth_token.auth_token, _external=true)
log.debug(u"Remot Login request with token: %s", auth_token.auth_token)
return render_title_template('remote_login.html', title=_(u"Login"), token=auth_token.auth_token,
verify_url=verify_url, page="remotelogin")
@remotelogin.route('/verify/<token>')
@remote_login_required
@login_required
def verify_token(token):
auth_token = ub.session.query(ub.RemoteAuthToken).filter(ub.RemoteAuthToken.auth_token == token).first()
# Token not found
if auth_token is None:
flash(_(u"Token not found"), category="error")
log.error(u"Remote Login token not found")
return redirect(url_for('web.index'))
# Token expired
elif datetime.now() > auth_token.expiration:
ub.session.delete(auth_token)
ub.session_commit()
flash(_(u"Token has expired"), category="error")
log.error(u"Remote Login token expired")
return redirect(url_for('web.index'))
# Update token with user information
auth_token.user_id = current_user.id
auth_token.verified = True
ub.session_commit()
flash(_(u"Success! Please return to your device"), category="success")
log.debug(u"Remote Login token for userid %s verified", auth_token.user_id)
return redirect(url_for('web.index'))
@remotelogin.route('/ajax/verify_token', methods=['POST'])
@remote_login_required
def token_verified():
token = request.form['token']
auth_token = ub.session.query(ub.RemoteAuthToken).filter(ub.RemoteAuthToken.auth_token == token).first()
data = {}
# Token not found
if auth_token is None:
data['status'] = 'error'
data['message'] = _(u"Token not found")
# Token expired
elif datetime.now() > auth_token.expiration:
ub.session.delete(auth_token)
ub.session_commit()
data['status'] = 'error'
data['message'] = _(u"Token has expired")
elif not auth_token.verified:
data['status'] = 'not_verified'
else:
user = ub.session.query(ub.User).filter(ub.User.id == auth_token.user_id).first()
login_user(user)
ub.session.delete(auth_token)
ub.session_commit("User {} logged in via remotelogin, token deleted".format(user.name))
data['status'] = 'success'
log.debug(u"Remote Login for userid %s succeded", user.id)
flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.name), category="success")
response = make_response(json.dumps(data, ensure_ascii=False))
response.headers["Content-Type"] = "application/json; charset=utf-8"
return response
+122
View File
@@ -0,0 +1,122 @@
# -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
# Copyright (C) 2018-2020 OzzieIsaacs
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from flask import render_template
from flask_babel import gettext as _
from flask import g
from werkzeug.local import LocalProxy
from flask_login import current_user
from . import config, constants, ub, logger, db, calibre_db
from .ub import User
log = logger.create()
def get_sidebar_config(kwargs=None):
kwargs = kwargs or []
if 'content' in kwargs:
content = kwargs['content']
content = isinstance(content, (User, LocalProxy)) and not content.role_anonymous()
else:
content = 'conf' in kwargs
sidebar = list()
sidebar.append({"glyph": "glyphicon-book", "text": _('Books'), "link": 'web.index', "id": "new",
"visibility": constants.SIDEBAR_RECENT, 'public': True, "page": "root",
"show_text": _('Show recent books'), "config_show":False})
sidebar.append({"glyph": "glyphicon-fire", "text": _('Hot Books'), "link": 'web.books_list', "id": "hot",
"visibility": constants.SIDEBAR_HOT, 'public': True, "page": "hot",
"show_text": _('Show Hot Books'), "config_show": True})
if current_user.role_admin():
sidebar.append({"glyph": "glyphicon-download", "text": _('Downloaded Books'), "link": 'web.download_list',
"id": "download", "visibility": constants.SIDEBAR_DOWNLOAD, 'public': (not g.user.is_anonymous),
"page": "download", "show_text": _('Show Downloaded Books'),
"config_show": content})
else:
sidebar.append({"glyph": "glyphicon-download", "text": _('Downloaded Books'), "link": 'web.books_list',
"id": "download", "visibility": constants.SIDEBAR_DOWNLOAD, 'public': (not g.user.is_anonymous),
"page": "download", "show_text": _('Show Downloaded Books'),
"config_show": content})
sidebar.append(
{"glyph": "glyphicon-star", "text": _('Top Rated Books'), "link": 'web.books_list', "id": "rated",
"visibility": constants.SIDEBAR_BEST_RATED, 'public': True, "page": "rated",
"show_text": _('Show Top Rated Books'), "config_show": True})
sidebar.append({"glyph": "glyphicon-eye-open", "text": _('Read Books'), "link": 'web.books_list', "id": "read",
"visibility": constants.SIDEBAR_READ_AND_UNREAD, 'public': (not g.user.is_anonymous),
"page": "read", "show_text": _('Show read and unread'), "config_show": content})
sidebar.append(
{"glyph": "glyphicon-eye-close", "text": _('Unread Books'), "link": 'web.books_list', "id": "unread",
"visibility": constants.SIDEBAR_READ_AND_UNREAD, 'public': (not g.user.is_anonymous), "page": "unread",
"show_text": _('Show unread'), "config_show": False})
sidebar.append({"glyph": "glyphicon-random", "text": _('Discover'), "link": 'web.books_list', "id": "rand",
"visibility": constants.SIDEBAR_RANDOM, 'public': True, "page": "discover",
"show_text": _('Show Random Books'), "config_show": True})
sidebar.append({"glyph": "glyphicon-inbox", "text": _('Categories'), "link": 'web.category_list', "id": "cat",
"visibility": constants.SIDEBAR_CATEGORY, 'public': True, "page": "category",
"show_text": _('Show category selection'), "config_show": True})
sidebar.append({"glyph": "glyphicon-bookmark", "text": _('Series'), "link": 'web.series_list', "id": "serie",
"visibility": constants.SIDEBAR_SERIES, 'public': True, "page": "series",
"show_text": _('Show series selection'), "config_show": True})
sidebar.append({"glyph": "glyphicon-user", "text": _('Authors'), "link": 'web.author_list', "id": "author",
"visibility": constants.SIDEBAR_AUTHOR, 'public': True, "page": "author",
"show_text": _('Show author selection'), "config_show": True})
sidebar.append(
{"glyph": "glyphicon-text-size", "text": _('Publishers'), "link": 'web.publisher_list', "id": "publisher",
"visibility": constants.SIDEBAR_PUBLISHER, 'public': True, "page": "publisher",
"show_text": _('Show publisher selection'), "config_show":True})
sidebar.append({"glyph": "glyphicon-flag", "text": _('Languages'), "link": 'web.language_overview', "id": "lang",
"visibility": constants.SIDEBAR_LANGUAGE, 'public': (g.user.filter_language() == 'all'),
"page": "language",
"show_text": _('Show language selection'), "config_show": True})
sidebar.append({"glyph": "glyphicon-star-empty", "text": _('Ratings'), "link": 'web.ratings_list', "id": "rate",
"visibility": constants.SIDEBAR_RATING, 'public': True,
"page": "rating", "show_text": _('Show ratings selection'), "config_show": True})
sidebar.append({"glyph": "glyphicon-file", "text": _('File formats'), "link": 'web.formats_list', "id": "format",
"visibility": constants.SIDEBAR_FORMAT, 'public': True,
"page": "format", "show_text": _('Show file formats selection'), "config_show": True})
sidebar.append(
{"glyph": "glyphicon-trash", "text": _('Archived Books'), "link": 'web.books_list', "id": "archived",
"visibility": constants.SIDEBAR_ARCHIVED, 'public': (not g.user.is_anonymous), "page": "archived",
"show_text": _('Show archived books'), "config_show": content})
sidebar.append(
{"glyph": "glyphicon-th-list", "text": _('Books List'), "link": 'web.books_table', "id": "list",
"visibility": constants.SIDEBAR_LIST, 'public': (not g.user.is_anonymous), "page": "list",
"show_text": _('Show Books List'), "config_show": content})
return sidebar
def get_readbooks_ids():
if not config.config_read_column:
readBooks = ub.session.query(ub.ReadBook).filter(ub.ReadBook.user_id == int(current_user.id))\
.filter(ub.ReadBook.read_status == ub.ReadBook.STATUS_FINISHED).all()
return frozenset([x.book_id for x in readBooks])
else:
try:
readBooks = calibre_db.session.query(db.cc_classes[config.config_read_column])\
.filter(db.cc_classes[config.config_read_column].value == True).all()
return frozenset([x.book for x in readBooks])
except (KeyError, AttributeError):
log.error("Custom Column No.%d is not existing in calibre database", config.config_read_column)
return []
# Returns the template for rendering and includes the instance name
def render_title_template(*args, **kwargs):
sidebar = get_sidebar_config(kwargs)
return render_template(instance=config.config_calibre_web_title, sidebar=sidebar,
accept=constants.EXTENSIONS_UPLOAD, read_book_ids=get_readbooks_ids(),
*args, **kwargs)
+1
View File
@@ -77,6 +77,7 @@ class ReverseProxied(object):
servr = environ.get('HTTP_X_FORWARDED_HOST', '') servr = environ.get('HTTP_X_FORWARDED_HOST', '')
if servr: if servr:
environ['HTTP_HOST'] = servr environ['HTTP_HOST'] = servr
self.proxied = True
return self.app(environ, start_response) return self.app(environ, start_response)
@property @property
+82 -9
View File
@@ -22,11 +22,14 @@ import os
import errno import errno
import signal import signal
import socket import socket
import subprocess # nosec
try: try:
from gevent.pywsgi import WSGIServer from gevent.pywsgi import WSGIServer
from gevent.pool import Pool from gevent.pool import Pool
from gevent import __version__ as _version from gevent import __version__ as _version
from greenlet import GreenletExit
import ssl
VERSION = 'Gevent ' + _version VERSION = 'Gevent ' + _version
_GEVENT = True _GEVENT = True
except ImportError: except ImportError:
@@ -72,7 +75,11 @@ class WebServer(object):
if config.config_access_log: if config.config_access_log:
log_name = "gevent.access" if _GEVENT else "tornado.access" log_name = "gevent.access" if _GEVENT else "tornado.access"
formatter = logger.ACCESS_FORMATTER_GEVENT if _GEVENT else logger.ACCESS_FORMATTER_TORNADO formatter = logger.ACCESS_FORMATTER_GEVENT if _GEVENT else logger.ACCESS_FORMATTER_TORNADO
self.access_logger = logger.create_access_log(config.config_access_logfile, log_name, formatter) self.access_logger, logfile = logger.create_access_log(config.config_access_logfile, log_name, formatter)
if logfile != config.config_access_logfile:
log.warning("Accesslog path %s not valid, falling back to default", config.config_access_logfile)
config.config_access_logfile = logfile
config.save()
else: else:
if not _GEVENT: if not _GEVENT:
logger.get('tornado.access').disabled = True logger.get('tornado.access').disabled = True
@@ -130,6 +137,64 @@ class WebServer(object):
return sock, _readable_listen_address(*address) return sock, _readable_listen_address(*address)
@staticmethod
def _get_args_for_reloading():
"""Determine how the script was executed, and return the args needed
to execute it again in a new process.
Code from https://github.com/pyload/pyload. Author GammaC0de, voulter
"""
rv = [sys.executable]
py_script = sys.argv[0]
args = sys.argv[1:]
# Need to look at main module to determine how it was executed.
__main__ = sys.modules["__main__"]
# The value of __package__ indicates how Python was called. It may
# not exist if a setuptools script is installed as an egg. It may be
# set incorrectly for entry points created with pip on Windows.
if getattr(__main__, "__package__", None) is None or (
os.name == "nt"
and __main__.__package__ == ""
and not os.path.exists(py_script)
and os.path.exists("{}.exe".format(py_script))
):
# Executed a file, like "python app.py".
py_script = os.path.abspath(py_script)
if os.name == "nt":
# Windows entry points have ".exe" extension and should be
# called directly.
if not os.path.exists(py_script) and os.path.exists("{}.exe".format(py_script)):
py_script += ".exe"
if (
os.path.splitext(sys.executable)[1] == ".exe"
and os.path.splitext(py_script)[1] == ".exe"
):
rv.pop(0)
rv.append(py_script)
else:
# Executed a module, like "python -m module".
if sys.argv[0] == "-m":
args = sys.argv
else:
if os.path.isfile(py_script):
# Rewritten by Python from "-m script" to "/path/to/script.py".
py_module = __main__.__package__
name = os.path.splitext(os.path.basename(py_script))[0]
if name != "__main__":
py_module += ".{}".format(name)
else:
# Incorrectly rewritten by pydevd debugger from "-m script" to "script".
py_module = py_script
rv.extend(("-m", py_module.lstrip(".")))
rv.extend(args)
return rv
def _start_gevent(self): def _start_gevent(self):
ssl_args = self.ssl_args or {} ssl_args = self.ssl_args or {}
@@ -139,6 +204,16 @@ class WebServer(object):
output = _readable_listen_address(self.listen_address, self.listen_port) output = _readable_listen_address(self.listen_address, self.listen_port)
log.info('Starting Gevent server on %s', output) log.info('Starting Gevent server on %s', output)
self.wsgiserver = WSGIServer(sock, self.app, log=self.access_logger, spawn=Pool(), **ssl_args) self.wsgiserver = WSGIServer(sock, self.app, log=self.access_logger, spawn=Pool(), **ssl_args)
if ssl_args:
wrap_socket = self.wsgiserver.wrap_socket
def my_wrap_socket(*args, **kwargs):
try:
return wrap_socket(*args, **kwargs)
except (ssl.SSLError, OSError) as ex:
log.warning('Gevent SSL Error: %s', ex)
raise GreenletExit
self.wsgiserver.wrap_socket = my_wrap_socket
self.wsgiserver.serve_forever() self.wsgiserver.serve_forever()
finally: finally:
if self.unix_socket_file: if self.unix_socket_file:
@@ -176,21 +251,19 @@ class WebServer(object):
finally: finally:
self.wsgiserver = None self.wsgiserver = None
# prevent irritating log of pending tasks message from asyncio
logger.get('asyncio').setLevel(logger.logging.CRITICAL)
if not self.restart: if not self.restart:
log.info("Performing shutdown of Calibre-Web") log.info("Performing shutdown of Calibre-Web")
# prevent irritiating log of pending tasks message from asyncio
logger.get('asyncio').setLevel(logger.logging.CRITICAL)
return True return True
log.info("Performing restart of Calibre-Web") log.info("Performing restart of Calibre-Web")
arguments = list(sys.argv) args = self._get_args_for_reloading()
arguments.insert(0, sys.executable) subprocess.call(args, close_fds=True) # nosec
if os.name == 'nt':
arguments = ["\"%s\"" % a for a in arguments]
os.execv(sys.executable, arguments)
return True return True
def _killServer(self, ignored_signum, ignored_frame): def _killServer(self, __, ___):
self.stop() self.stop()
def stop(self, restart=False): def stop(self, restart=False):
+20 -7
View File
@@ -22,12 +22,16 @@ from base64 import b64decode, b64encode
from jsonschema import validate, exceptions, __version__ from jsonschema import validate, exceptions, __version__
from datetime import datetime from datetime import datetime
try: try:
# pylint: disable=unused-import
from urllib import unquote from urllib import unquote
except ImportError: except ImportError:
from urllib.parse import unquote from urllib.parse import unquote
from flask import json from flask import json
from .. import logger as log from .. import logger
log = logger.create()
def b64encode_json(json_data): def b64encode_json(json_data):
@@ -45,7 +49,8 @@ def to_epoch_timestamp(datetime_object):
def get_datetime_from_json(json_object, field_name): def get_datetime_from_json(json_object, field_name):
try: try:
return datetime.utcfromtimestamp(json_object[field_name]) return datetime.utcfromtimestamp(json_object[field_name])
except KeyError: except (KeyError, OSError, OverflowError):
# OSError is thrown on Windows if timestamp is <1970 or >2038
return datetime.min return datetime.min
@@ -60,7 +65,7 @@ class SyncToken:
books_last_modified: Datetime representing the last modified book that the device knows about. books_last_modified: Datetime representing the last modified book that the device knows about.
""" """
SYNC_TOKEN_HEADER = "x-kobo-synctoken" SYNC_TOKEN_HEADER = "x-kobo-synctoken" # nosec
VERSION = "1-1-0" VERSION = "1-1-0"
LAST_MODIFIED_ADDED_VERSION = "1-1-0" LAST_MODIFIED_ADDED_VERSION = "1-1-0"
MIN_VERSION = "1-0-0" MIN_VERSION = "1-0-0"
@@ -81,6 +86,7 @@ class SyncToken:
"archive_last_modified": {"type": "string"}, "archive_last_modified": {"type": "string"},
"reading_state_last_modified": {"type": "string"}, "reading_state_last_modified": {"type": "string"},
"tags_last_modified": {"type": "string"}, "tags_last_modified": {"type": "string"},
"books_last_id": {"type": "integer", "optional": True}
}, },
} }
@@ -92,18 +98,20 @@ class SyncToken:
archive_last_modified=datetime.min, archive_last_modified=datetime.min,
reading_state_last_modified=datetime.min, reading_state_last_modified=datetime.min,
tags_last_modified=datetime.min, tags_last_modified=datetime.min,
): books_last_id=-1
): # nosec
self.raw_kobo_store_token = raw_kobo_store_token self.raw_kobo_store_token = raw_kobo_store_token
self.books_last_created = books_last_created self.books_last_created = books_last_created
self.books_last_modified = books_last_modified self.books_last_modified = books_last_modified
self.archive_last_modified = archive_last_modified self.archive_last_modified = archive_last_modified
self.reading_state_last_modified = reading_state_last_modified self.reading_state_last_modified = reading_state_last_modified
self.tags_last_modified = tags_last_modified self.tags_last_modified = tags_last_modified
self.books_last_id = books_last_id
@staticmethod @staticmethod
def from_headers(headers): def from_headers(headers):
sync_token_header = headers.get(SyncToken.SYNC_TOKEN_HEADER, "") sync_token_header = headers.get(SyncToken.SYNC_TOKEN_HEADER, "")
if sync_token_header == "": if sync_token_header == "": # nosec
return SyncToken() return SyncToken()
# On the first sync from a Kobo device, we may receive the SyncToken # On the first sync from a Kobo device, we may receive the SyncToken
@@ -133,9 +141,12 @@ class SyncToken:
archive_last_modified = get_datetime_from_json(data_json, "archive_last_modified") archive_last_modified = get_datetime_from_json(data_json, "archive_last_modified")
reading_state_last_modified = get_datetime_from_json(data_json, "reading_state_last_modified") reading_state_last_modified = get_datetime_from_json(data_json, "reading_state_last_modified")
tags_last_modified = get_datetime_from_json(data_json, "tags_last_modified") tags_last_modified = get_datetime_from_json(data_json, "tags_last_modified")
books_last_id = data_json["books_last_id"]
except TypeError: except TypeError:
log.error("SyncToken timestamps don't parse to a datetime.") log.error("SyncToken timestamps don't parse to a datetime.")
return SyncToken(raw_kobo_store_token=raw_kobo_store_token) return SyncToken(raw_kobo_store_token=raw_kobo_store_token)
except KeyError:
books_last_id = -1
return SyncToken( return SyncToken(
raw_kobo_store_token=raw_kobo_store_token, raw_kobo_store_token=raw_kobo_store_token,
@@ -143,7 +154,8 @@ class SyncToken:
books_last_modified=books_last_modified, books_last_modified=books_last_modified,
archive_last_modified=archive_last_modified, archive_last_modified=archive_last_modified,
reading_state_last_modified=reading_state_last_modified, reading_state_last_modified=reading_state_last_modified,
tags_last_modified=tags_last_modified tags_last_modified=tags_last_modified,
books_last_id=books_last_id
) )
def set_kobo_store_header(self, store_headers): def set_kobo_store_header(self, store_headers):
@@ -166,7 +178,8 @@ class SyncToken:
"books_last_created": to_epoch_timestamp(self.books_last_created), "books_last_created": to_epoch_timestamp(self.books_last_created),
"archive_last_modified": to_epoch_timestamp(self.archive_last_modified), "archive_last_modified": to_epoch_timestamp(self.archive_last_modified),
"reading_state_last_modified": to_epoch_timestamp(self.reading_state_last_modified), "reading_state_last_modified": to_epoch_timestamp(self.reading_state_last_modified),
"tags_last_modified": to_epoch_timestamp(self.tags_last_modified) "tags_last_modified": to_epoch_timestamp(self.tags_last_modified),
"books_last_id":self.books_last_id
}, },
} }
return b64encode_json(token) return b64encode_json(token)
+6
View File
@@ -45,3 +45,9 @@ except ImportError as err:
log.debug("Cannot import SyncToken, syncing books with Kobo Devices will not work: %s", err) log.debug("Cannot import SyncToken, syncing books with Kobo Devices will not work: %s", err)
kobo = None kobo = None
SyncToken = None SyncToken = None
try:
from . import gmail
except ImportError as err:
log.debug("Cannot import gmail, sending books via Gmail Oauth2 Verification will not work: %s", err)
gmail = None
+83
View File
@@ -0,0 +1,83 @@
from __future__ import print_function
import os.path
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from googleapiclient.discovery import build
from google.oauth2.credentials import Credentials
from datetime import datetime
import base64
from flask_babel import gettext as _
from ..constants import BASE_DIR
from .. import logger
log = logger.create()
SCOPES = ['openid', 'https://www.googleapis.com/auth/gmail.send', 'https://www.googleapis.com/auth/userinfo.email']
def setup_gmail(token):
# If there are no (valid) credentials available, let the user log in.
creds = None
if "token" in token:
creds = Credentials(
token=token['token'],
refresh_token=token['refresh_token'],
token_uri=token['token_uri'],
client_id=token['client_id'],
client_secret=token['client_secret'],
scopes=token['scopes'],
)
creds.expiry = datetime.fromisoformat(token['expiry'])
if not creds or not creds.valid:
# don't forget to dump one more time after the refresh
# also, some file-locking routines wouldn't be needless
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
cred_file = os.path.join(BASE_DIR, 'gmail.json')
if not os.path.exists(cred_file):
raise Exception(_("Found no valid gmail.json file with OAuth information"))
flow = InstalledAppFlow.from_client_secrets_file(
os.path.join(BASE_DIR, 'gmail.json'), SCOPES)
creds = flow.run_local_server(port=0)
user_info = get_user_info(creds)
return {
'token': creds.token,
'refresh_token': creds.refresh_token,
'token_uri': creds.token_uri,
'client_id': creds.client_id,
'client_secret': creds.client_secret,
'scopes': creds.scopes,
'expiry': creds.expiry.isoformat(),
'email': user_info
}
return {}
def get_user_info(credentials):
user_info_service = build(serviceName='oauth2', version='v2',credentials=credentials)
user_info = user_info_service.userinfo().get().execute()
return user_info.get('email', "")
def send_messsage(token, msg):
log.debug("Start sending email via Gmail")
creds = Credentials(
token=token['token'],
refresh_token=token['refresh_token'],
token_uri=token['token_uri'],
client_id=token['client_id'],
client_secret=token['client_secret'],
scopes=token['scopes'],
)
creds.expiry = datetime.fromisoformat(token['expiry'])
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
service = build('gmail', 'v1', credentials=creds)
message_as_bytes = msg.as_bytes() # the message should converted from string to bytes.
message_as_base64 = base64.urlsafe_b64encode(message_as_bytes) # encode in base64 (printable letters coding)
raw = message_as_base64.decode() # convert to something JSON serializable
body = {'raw': raw}
(service.users().messages().send(userId='me', body=body).execute())
log.debug("Email send successfully via Gmail")
+11 -4
View File
@@ -20,7 +20,10 @@ from __future__ import division, print_function, unicode_literals
import time import time
from functools import reduce from functools import reduce
from goodreads.client import GoodreadsClient try:
from goodreads.client import GoodreadsClient
except ImportError:
from betterreads.client import GoodreadsClient
try: import Levenshtein try: import Levenshtein
except ImportError: Levenshtein = False except ImportError: Levenshtein = False
@@ -69,7 +72,7 @@ def get_author_info(author_name):
author_info = _client.find_author(author_name=author_name) author_info = _client.find_author(author_name=author_name)
except Exception as ex: except Exception as ex:
# Skip goodreads, if site is down/inaccessible # Skip goodreads, if site is down/inaccessible
log.warning('Goodreads website is down/inaccessible? %s', ex) log.warning('Goodreads website is down/inaccessible? %s', ex.__str__())
return return
if author_info: if author_info:
@@ -95,8 +98,12 @@ def get_other_books(author_info, library_books=None):
for book in author_info.books: for book in author_info.books:
if book.isbn in identifiers: if book.isbn in identifiers:
continue continue
if book.gid["#text"] in identifiers: if isinstance(book.gid, int):
continue if book.gid in identifiers:
continue
else:
if book.gid["#text"] in identifiers:
continue
if Levenshtein and library_titles: if Levenshtein and library_titles:
goodreads_title = book._book_dict['title_without_series'] goodreads_title = book._book_dict['title_without_series']
+24 -8
View File
@@ -20,7 +20,7 @@ from __future__ import division, print_function, unicode_literals
import base64 import base64
from flask_simpleldap import LDAP, LDAPException from flask_simpleldap import LDAP, LDAPException
from flask_simpleldap import ldap as pyLDAP
from .. import constants, logger from .. import constants, logger
try: try:
@@ -38,6 +38,7 @@ def init_app(app, config):
app.config['LDAP_HOST'] = config.config_ldap_provider_url app.config['LDAP_HOST'] = config.config_ldap_provider_url
app.config['LDAP_PORT'] = config.config_ldap_port app.config['LDAP_PORT'] = config.config_ldap_port
app.config['LDAP_CUSTOM_OPTIONS'] = {pyLDAP.OPT_REFERRALS: 0}
if config.config_ldap_encryption == 2: if config.config_ldap_encryption == 2:
app.config['LDAP_SCHEMA'] = 'ldaps' app.config['LDAP_SCHEMA'] = 'ldaps'
else: else:
@@ -54,8 +55,14 @@ def init_app(app, config):
app.config['LDAP_USERNAME'] = "" app.config['LDAP_USERNAME'] = ""
app.config['LDAP_PASSWORD'] = base64.b64decode("") app.config['LDAP_PASSWORD'] = base64.b64decode("")
if bool(config.config_ldap_cert_path): if bool(config.config_ldap_cert_path):
app.config['LDAP_REQUIRE_CERT'] = True app.config['LDAP_CUSTOM_OPTIONS'].update({
app.config['LDAP_CERT_PATH'] = config.config_ldap_cert_path pyLDAP.OPT_X_TLS_REQUIRE_CERT: pyLDAP.OPT_X_TLS_DEMAND,
pyLDAP.OPT_X_TLS_CACERTFILE: config.config_ldap_cacert_path,
pyLDAP.OPT_X_TLS_CERTFILE: config.config_ldap_cert_path,
pyLDAP.OPT_X_TLS_KEYFILE: config.config_ldap_key_path,
pyLDAP.OPT_X_TLS_NEWCTX: 0
})
app.config['LDAP_BASE_DN'] = config.config_ldap_dn app.config['LDAP_BASE_DN'] = config.config_ldap_dn
app.config['LDAP_USER_OBJECT_FILTER'] = config.config_ldap_user_object app.config['LDAP_USER_OBJECT_FILTER'] = config.config_ldap_user_object
@@ -64,13 +71,22 @@ def init_app(app, config):
app.config['LDAP_OPENLDAP'] = bool(config.config_ldap_openldap) app.config['LDAP_OPENLDAP'] = bool(config.config_ldap_openldap)
app.config['LDAP_GROUP_OBJECT_FILTER'] = config.config_ldap_group_object_filter app.config['LDAP_GROUP_OBJECT_FILTER'] = config.config_ldap_group_object_filter
app.config['LDAP_GROUP_MEMBERS_FIELD'] = config.config_ldap_group_members_field app.config['LDAP_GROUP_MEMBERS_FIELD'] = config.config_ldap_group_members_field
# app.config['LDAP_CUSTOM_OPTIONS'] = {'OPT_NETWORK_TIMEOUT': 10}
_ldap.init_app(app) try:
_ldap.init_app(app)
except ValueError:
if bool(config.config_ldap_cert_path):
app.config['LDAP_CUSTOM_OPTIONS'].pop(pyLDAP.OPT_X_TLS_NEWCTX)
try:
_ldap.init_app(app)
except RuntimeError as e:
log.error(e)
except RuntimeError as e:
log.error(e)
def get_object_details(user=None, group=None, query_filter=None, dn_only=False): def get_object_details(user=None,query_filter=None):
return _ldap.get_object_details(user, group, query_filter, dn_only) return _ldap.get_object_details(user, query_filter=query_filter)
def bind(): def bind():
@@ -101,7 +117,7 @@ def bind_user(username, password):
return None, error return None, error
except LDAPException as ex: except LDAPException as ex:
if ex.message == 'Invalid credentials': if ex.message == 'Invalid credentials':
error = ("LDAP admin login failed") error = "LDAP admin login failed"
return None, error return None, error
if ex.message == "Can't contact LDAP server": if ex.message == "Can't contact LDAP server":
# log.warning('LDAP Server down: %s', ex) # log.warning('LDAP Server down: %s', ex)
+220
View File
@@ -0,0 +1,220 @@
from __future__ import division, print_function, unicode_literals
import threading
import abc
import uuid
import time
try:
import queue
except ImportError:
import Queue as queue
from datetime import datetime
from collections import namedtuple
from cps import logger
log = logger.create()
# task 'status' consts
STAT_WAITING = 0
STAT_FAIL = 1
STAT_STARTED = 2
STAT_FINISH_SUCCESS = 3
# Only retain this many tasks in dequeued list
TASK_CLEANUP_TRIGGER = 20
QueuedTask = namedtuple('QueuedTask', 'num, user, added, task')
def _get_main_thread():
for t in threading.enumerate():
if t.__class__.__name__ == '_MainThread':
return t
raise Exception("main thread not found?!")
class ImprovedQueue(queue.Queue):
def to_list(self):
"""
Returns a copy of all items in the queue without removing them.
"""
with self.mutex:
return list(self.queue)
# Class for all worker tasks in the background
class WorkerThread(threading.Thread):
_instance = None
@classmethod
def getInstance(cls):
if cls._instance is None:
cls._instance = WorkerThread()
return cls._instance
def __init__(self):
threading.Thread.__init__(self)
self.dequeued = list()
self.doLock = threading.Lock()
self.queue = ImprovedQueue()
self.num = 0
self.start()
@classmethod
def add(cls, user, task):
ins = cls.getInstance()
ins.num += 1
log.debug("Add Task for user: {}: {}".format(user, task))
ins.queue.put(QueuedTask(
num=ins.num,
user=user,
added=datetime.now(),
task=task,
))
@property
def tasks(self):
with self.doLock:
tasks = self.queue.to_list() + self.dequeued
return sorted(tasks, key=lambda x: x.num)
def cleanup_tasks(self):
with self.doLock:
dead = []
alive = []
for x in self.dequeued:
(dead if x.task.dead else alive).append(x)
# if the ones that we need to keep are within the trigger, do nothing else
delta = len(self.dequeued) - len(dead)
if delta > TASK_CLEANUP_TRIGGER:
ret = alive
else:
# otherwise, lop off the oldest dead tasks until we hit the target trigger
ret = sorted(dead, key=lambda x: x.task.end_time)[-TASK_CLEANUP_TRIGGER:] + alive
self.dequeued = sorted(ret, key=lambda x: x.num)
# Main thread loop starting the different tasks
def run(self):
main_thread = _get_main_thread()
while main_thread.is_alive():
try:
# this blocks until something is available. This can cause issues when the main thread dies - this
# thread will remain alive. We implement a timeout to unblock every second which allows us to check if
# the main thread is still alive.
# We don't use a daemon here because we don't want the tasks to just be abruptly halted, leading to
# possible file / database corruption
item = self.queue.get(timeout=1)
except queue.Empty:
time.sleep(1)
continue
with self.doLock:
# add to list so that in-progress tasks show up
self.dequeued.append(item)
# once we hit our trigger, start cleaning up dead tasks
if len(self.dequeued) > TASK_CLEANUP_TRIGGER:
self.cleanup_tasks()
# sometimes tasks (like Upload) don't actually have work to do and are created as already finished
if item.task.stat is STAT_WAITING:
# CalibreTask.start() should wrap all exceptions in it's own error handling
item.task.start(self)
self.queue.task_done()
class CalibreTask:
__metaclass__ = abc.ABCMeta
def __init__(self, message):
self._progress = 0
self.stat = STAT_WAITING
self.error = None
self.start_time = None
self.end_time = None
self.message = message
self.id = uuid.uuid4()
@abc.abstractmethod
def run(self, worker_thread):
"""Provides the caller some human-readable name for this class"""
raise NotImplementedError
@abc.abstractmethod
def name(self):
"""Provides the caller some human-readable name for this class"""
raise NotImplementedError
def start(self, *args):
self.start_time = datetime.now()
self.stat = STAT_STARTED
# catch any unhandled exceptions in a task and automatically fail it
try:
self.run(*args)
except Exception as ex:
self._handleError(str(ex))
log.debug_or_exception(ex)
self.end_time = datetime.now()
@property
def stat(self):
return self._stat
@stat.setter
def stat(self, x):
self._stat = x
@property
def progress(self):
return self._progress
@progress.setter
def progress(self, x):
if not 0 <= x <= 1:
raise ValueError("Task progress should within [0, 1] range")
self._progress = x
@property
def error(self):
return self._error
@error.setter
def error(self, x):
self._error = x
@property
def runtime(self):
return (self.end_time or datetime.now()) - self.start_time
@property
def dead(self):
"""Determines whether or not this task can be garbage collected
We have a separate dictating this because there may be certain tasks that want to override this
"""
# By default, we're good to clean a task if it's "Done"
return self.stat in (STAT_FINISH_SUCCESS, STAT_FAIL)
@progress.setter
def progress(self, x):
# todo: throw error if outside of [0,1]
self._progress = x
def _handleError(self, error_message):
self.stat = STAT_FAIL
self.progress = 1
self.error = error_message
def _handleSuccess(self):
self.stat = STAT_FINISH_SUCCESS
self.progress = 1
+203 -136
View File
@@ -22,15 +22,17 @@
from __future__ import division, print_function, unicode_literals from __future__ import division, print_function, unicode_literals
from datetime import datetime from datetime import datetime
import sys
from flask import Blueprint, request, flash, redirect, url_for from flask import Blueprint, request, flash, redirect, url_for
from flask_babel import gettext as _ from flask_babel import gettext as _
from flask_login import login_required, current_user from flask_login import login_required, current_user
from sqlalchemy.sql.expression import func from sqlalchemy.sql.expression import func, true
from sqlalchemy.exc import OperationalError, InvalidRequestError
from . import logger, ub, searched_ids, db from . import logger, ub, calibre_db, db
from .web import render_title_template from .render_template import render_title_template
from .helper import common_filters from .usermanagement import login_required_if_no_ano
shelf = Blueprint('shelf', __name__) shelf = Blueprint('shelf', __name__)
@@ -92,9 +94,19 @@ def add_to_shelf(shelf_id, book_id):
shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book_id, order=maxOrder + 1)) shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book_id, order=maxOrder + 1))
shelf.last_modified = datetime.utcnow() shelf.last_modified = datetime.utcnow()
ub.session.merge(shelf) try:
ub.session.commit() ub.session.merge(shelf)
ub.session.commit()
except (OperationalError, InvalidRequestError):
ub.session.rollback()
log.error("Settings DB is not Writeable")
flash(_(u"Settings DB is not Writeable"), category="error")
if "HTTP_REFERER" in request.environ:
return redirect(request.environ["HTTP_REFERER"])
else:
return redirect(url_for('web.index'))
if not xhr: if not xhr:
log.debug("Book has been added to shelf: {}".format(shelf.name))
flash(_(u"Book has been added to shelf: %(sname)s", sname=shelf.name), category="success") flash(_(u"Book has been added to shelf: %(sname)s", sname=shelf.name), category="success")
if "HTTP_REFERER" in request.environ: if "HTTP_REFERER" in request.environ:
return redirect(request.environ["HTTP_REFERER"]) return redirect(request.environ["HTTP_REFERER"])
@@ -113,41 +125,44 @@ def search_to_shelf(shelf_id):
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
if not check_shelf_edit_permissions(shelf): if not check_shelf_edit_permissions(shelf):
log.warning("You are not allowed to add a book to the the shelf: {}".format(shelf.name))
flash(_(u"You are not allowed to add a book to the the shelf: %(name)s", name=shelf.name), category="error") flash(_(u"You are not allowed to add a book to the the shelf: %(name)s", name=shelf.name), category="error")
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
if current_user.id in searched_ids and searched_ids[current_user.id]: if current_user.id in ub.searched_ids and ub.searched_ids[current_user.id]:
books_for_shelf = list() books_for_shelf = list()
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).all() books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).all()
if books_in_shelf: if books_in_shelf:
book_ids = list() book_ids = list()
for book_id in books_in_shelf: for book_id in books_in_shelf:
book_ids.append(book_id.book_id) book_ids.append(book_id.book_id)
for searchid in searched_ids[current_user.id]: for searchid in ub.searched_ids[current_user.id]:
if searchid not in book_ids: if searchid not in book_ids:
books_for_shelf.append(searchid) books_for_shelf.append(searchid)
else: else:
books_for_shelf = searched_ids[current_user.id] books_for_shelf = ub.searched_ids[current_user.id]
if not books_for_shelf: if not books_for_shelf:
log.error("Books are already part of %s", shelf) log.error("Books are already part of {}".format(shelf.name))
flash(_(u"Books are already part of the shelf: %(name)s", name=shelf.name), category="error") flash(_(u"Books are already part of the shelf: %(name)s", name=shelf.name), category="error")
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
maxOrder = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.BookShelf.shelf == shelf_id).first() maxOrder = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.BookShelf.shelf == shelf_id).first()[0] or 0
if maxOrder[0] is None:
maxOrder = 0
else:
maxOrder = maxOrder[0]
for book in books_for_shelf: for book in books_for_shelf:
maxOrder = maxOrder + 1 maxOrder += 1
shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book, order=maxOrder)) shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book, order=maxOrder))
shelf.last_modified = datetime.utcnow() shelf.last_modified = datetime.utcnow()
ub.session.merge(shelf) try:
ub.session.commit() ub.session.merge(shelf)
flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success") ub.session.commit()
flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success")
except (OperationalError, InvalidRequestError):
ub.session.rollback()
log.error("Settings DB is not Writeable")
flash(_("Settings DB is not Writeable"), category="error")
else: else:
log.error("Could not add books to shelf: {}".format(shelf.name))
flash(_(u"Could not add books to shelf: %(sname)s", sname=shelf.name), category="error") flash(_(u"Could not add books to shelf: %(sname)s", sname=shelf.name), category="error")
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
@@ -158,7 +173,7 @@ def remove_from_shelf(shelf_id, book_id):
xhr = request.headers.get('X-Requested-With') == 'XMLHttpRequest' xhr = request.headers.get('X-Requested-With') == 'XMLHttpRequest'
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
if shelf is None: if shelf is None:
log.error("Invalid shelf specified: %s", shelf_id) log.error("Invalid shelf specified: {}".format(shelf_id))
if not xhr: if not xhr:
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
return "Invalid shelf specified", 400 return "Invalid shelf specified", 400
@@ -181,10 +196,18 @@ def remove_from_shelf(shelf_id, book_id):
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
return "Book already removed from shelf", 410 return "Book already removed from shelf", 410
ub.session.delete(book_shelf) try:
shelf.last_modified = datetime.utcnow() ub.session.delete(book_shelf)
ub.session.commit() shelf.last_modified = datetime.utcnow()
ub.session.commit()
except (OperationalError, InvalidRequestError):
ub.session.rollback()
log.error("Settings DB is not Writeable")
flash(_("Settings DB is not Writeable"), category="error")
if "HTTP_REFERER" in request.environ:
return redirect(request.environ["HTTP_REFERER"])
else:
return redirect(url_for('web.index'))
if not xhr: if not xhr:
flash(_(u"Book has been removed from shelf: %(sname)s", sname=shelf.name), category="success") flash(_(u"Book has been removed from shelf: %(sname)s", sname=shelf.name), category="success")
if "HTTP_REFERER" in request.environ: if "HTTP_REFERER" in request.environ:
@@ -194,6 +217,7 @@ def remove_from_shelf(shelf_id, book_id):
return "", 204 return "", 204
else: else:
if not xhr: if not xhr:
log.warning("You are not allowed to remove a book from shelf: {}".format(shelf.name))
flash(_(u"Sorry you are not allowed to remove a book from this shelf: %(sname)s", sname=shelf.name), flash(_(u"Sorry you are not allowed to remove a book from this shelf: %(sname)s", sname=shelf.name),
category="error") category="error")
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
@@ -204,88 +228,79 @@ def remove_from_shelf(shelf_id, book_id):
@login_required @login_required
def create_shelf(): def create_shelf():
shelf = ub.Shelf() shelf = ub.Shelf()
if request.method == "POST": return create_edit_shelf(shelf, title=_(u"Create a Shelf"), page="shelfcreate")
to_save = request.form.to_dict()
if "is_public" in to_save:
shelf.is_public = 1
shelf.name = to_save["title"]
shelf.user_id = int(current_user.id)
is_shelf_name_unique = False
if shelf.is_public == 1:
is_shelf_name_unique = ub.session.query(ub.Shelf) \
.filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 1)) \
.first() is None
if not is_shelf_name_unique:
flash(_(u"A public shelf with the name '%(title)s' already exists.", title=to_save["title"]),
category="error")
else:
is_shelf_name_unique = ub.session.query(ub.Shelf) \
.filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 0) &
(ub.Shelf.user_id == int(current_user.id)))\
.first() is None
if not is_shelf_name_unique:
flash(_(u"A private shelf with the name '%(title)s' already exists.", title=to_save["title"]),
category="error")
if is_shelf_name_unique:
try:
ub.session.add(shelf)
ub.session.commit()
flash(_(u"Shelf %(title)s created", title=to_save["title"]), category="success")
return redirect(url_for('shelf.show_shelf', shelf_id=shelf.id))
except Exception:
flash(_(u"There was an error"), category="error")
return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"Create a Shelf"), page="shelfcreate")
else:
return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"Create a Shelf"), page="shelfcreate")
@shelf.route("/shelf/edit/<int:shelf_id>", methods=["GET", "POST"]) @shelf.route("/shelf/edit/<int:shelf_id>", methods=["GET", "POST"])
@login_required @login_required
def edit_shelf(shelf_id): def edit_shelf(shelf_id):
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
return create_edit_shelf(shelf, title=_(u"Edit a shelf"), page="shelfedit", shelf_id=shelf_id)
# if shelf ID is set, we are editing a shelf
def create_edit_shelf(shelf, title, page, shelf_id=False):
if request.method == "POST": if request.method == "POST":
to_save = request.form.to_dict() to_save = request.form.to_dict()
if "is_public" in to_save:
is_shelf_name_unique = False shelf.is_public = 1
if shelf.is_public == 1:
is_shelf_name_unique = ub.session.query(ub.Shelf) \
.filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 1)) \
.filter(ub.Shelf.id != shelf_id) \
.first() is None
if not is_shelf_name_unique:
flash(_(u"A public shelf with the name '%(title)s' already exists.", title=to_save["title"]),
category="error")
else: else:
is_shelf_name_unique = ub.session.query(ub.Shelf) \ shelf.is_public = 0
.filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 0) & if check_shelf_is_unique(shelf, to_save, shelf_id):
(ub.Shelf.user_id == int(current_user.id)))\
.filter(ub.Shelf.id != shelf_id)\
.first() is None
if not is_shelf_name_unique:
flash(_(u"A private shelf with the name '%(title)s' already exists.", title=to_save["title"]),
category="error")
if is_shelf_name_unique:
shelf.name = to_save["title"] shelf.name = to_save["title"]
shelf.last_modified = datetime.utcnow() # shelf.last_modified = datetime.utcnow()
if "is_public" in to_save: if not shelf_id:
shelf.is_public = 1 shelf.user_id = int(current_user.id)
ub.session.add(shelf)
shelf_action = "created"
flash_text = _(u"Shelf %(title)s created", title=to_save["title"])
else: else:
shelf.is_public = 0 shelf_action = "changed"
flash_text = _(u"Shelf %(title)s changed", title=to_save["title"])
try: try:
ub.session.commit() ub.session.commit()
flash(_(u"Shelf %(title)s changed", title=to_save["title"]), category="success") log.info(u"Shelf {} {}".format(to_save["title"], shelf_action))
except Exception: flash(flash_text, category="success")
return redirect(url_for('shelf.show_shelf', shelf_id=shelf.id))
except (OperationalError, InvalidRequestError) as ex:
ub.session.rollback()
log.debug_or_exception(ex)
log.error("Settings DB is not Writeable")
flash(_("Settings DB is not Writeable"), category="error")
except Exception as ex:
ub.session.rollback()
log.debug_or_exception(ex)
flash(_(u"There was an error"), category="error") flash(_(u"There was an error"), category="error")
return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"Edit a shelf"), page="shelfedit") return render_title_template('shelf_edit.html', shelf=shelf, title=title, page=page)
def check_shelf_is_unique(shelf, to_save, shelf_id=False):
if shelf_id:
ident = ub.Shelf.id != shelf_id
else: else:
return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"Edit a shelf"), page="shelfedit") ident = true()
if shelf.is_public == 1:
is_shelf_name_unique = ub.session.query(ub.Shelf) \
.filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 1)) \
.filter(ident) \
.first() is None
if not is_shelf_name_unique:
log.error("A public shelf with the name '{}' already exists.".format(to_save["title"]))
flash(_(u"A public shelf with the name '%(title)s' already exists.", title=to_save["title"]),
category="error")
else:
is_shelf_name_unique = ub.session.query(ub.Shelf) \
.filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 0) &
(ub.Shelf.user_id == int(current_user.id))) \
.filter(ident) \
.first() is None
if not is_shelf_name_unique:
log.error("A private shelf with the name '{}' already exists.".format(to_save["title"]))
flash(_(u"A private shelf with the name '%(title)s' already exists.", title=to_save["title"]),
category="error")
return is_shelf_name_unique
def delete_shelf_helper(cur_shelf): def delete_shelf_helper(cur_shelf):
@@ -295,45 +310,34 @@ def delete_shelf_helper(cur_shelf):
ub.session.delete(cur_shelf) ub.session.delete(cur_shelf)
ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).delete() ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).delete()
ub.session.add(ub.ShelfArchive(uuid=cur_shelf.uuid, user_id=cur_shelf.user_id)) ub.session.add(ub.ShelfArchive(uuid=cur_shelf.uuid, user_id=cur_shelf.user_id))
ub.session.commit() ub.session_commit("successfully deleted Shelf {}".format(cur_shelf.name))
log.info("successfully deleted %s", cur_shelf)
@shelf.route("/shelf/delete/<int:shelf_id>") @shelf.route("/shelf/delete/<int:shelf_id>")
@login_required @login_required
def delete_shelf(shelf_id): def delete_shelf(shelf_id):
cur_shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() cur_shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
delete_shelf_helper(cur_shelf) try:
delete_shelf_helper(cur_shelf)
except InvalidRequestError:
ub.session.rollback()
log.error("Settings DB is not Writeable")
flash(_("Settings DB is not Writeable"), category="error")
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
@shelf.route("/shelf/<int:shelf_id>", defaults={'shelf_type': 1}) @shelf.route("/simpleshelf/<int:shelf_id>")
@shelf.route("/shelf/<int:shelf_id>/<int:shelf_type>") @login_required_if_no_ano
def show_shelf(shelf_type, shelf_id): def show_simpleshelf(shelf_id):
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() return render_show_shelf(2, shelf_id, 1, None)
result = list()
# user is allowed to access shelf
if shelf and check_shelf_view_permissions(shelf):
page = "shelf.html" if shelf_type == 1 else 'shelfdown.html'
books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id)\ @shelf.route("/shelf/<int:shelf_id>", defaults={"sort_param": "order", 'page': 1})
.order_by(ub.BookShelf.order.asc()).all() @shelf.route("/shelf/<int:shelf_id>/<sort_param>", defaults={'page': 1})
for book in books_in_shelf: @shelf.route("/shelf/<int:shelf_id>/<sort_param>/<int:page>")
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).filter(common_filters()).first() @login_required_if_no_ano
if cur_book: def show_shelf(shelf_id, sort_param, page):
result.append(cur_book) return render_show_shelf(1, shelf_id, page, sort_param)
else:
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
if not cur_book:
log.info('Not existing book %s in %s deleted', book.book_id, shelf)
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book.book_id).delete()
ub.session.commit()
return render_title_template(page, entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name),
shelf=shelf, page="shelf")
else:
flash(_(u"Error opening shelf. Shelf does not exist or is not accessible"), category="error")
return redirect(url_for("web.index"))
@shelf.route("/shelf/order/<int:shelf_id>", methods=["GET", "POST"]) @shelf.route("/shelf/order/<int:shelf_id>", methods=["GET", "POST"])
@@ -348,27 +352,90 @@ def order_shelf(shelf_id):
setattr(book, 'order', to_save[str(book.book_id)]) setattr(book, 'order', to_save[str(book.book_id)])
counter += 1 counter += 1
# if order diffrent from before -> shelf.last_modified = datetime.utcnow() # if order diffrent from before -> shelf.last_modified = datetime.utcnow()
ub.session.commit() try:
ub.session.commit()
except (OperationalError, InvalidRequestError):
ub.session.rollback()
log.error("Settings DB is not Writeable")
flash(_("Settings DB is not Writeable"), category="error")
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
result = list() result = list()
if shelf and check_shelf_view_permissions(shelf): if shelf and check_shelf_view_permissions(shelf):
books_in_shelf2 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id) \ result = calibre_db.session.query(db.Books)\
.order_by(ub.BookShelf.order.asc()).all() .join(ub.BookShelf,ub.BookShelf.book_id == db.Books.id , isouter=True) \
for book in books_in_shelf2: .add_columns(calibre_db.common_filters().label("visible")) \
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).filter(common_filters()).first() .filter(ub.BookShelf.shelf == shelf_id).order_by(ub.BookShelf.order.asc()).all()
if cur_book:
result.append({'title': cur_book.title,
'id': cur_book.id,
'author': cur_book.authors,
'series': cur_book.series,
'series_index': cur_book.series_index})
else:
cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
result.append({'title': _('Hidden Book'),
'id': cur_book.id,
'author': [],
'series': []})
return render_title_template('shelf_order.html', entries=result, return render_title_template('shelf_order.html', entries=result,
title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name), title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name),
shelf=shelf, page="shelforder") shelf=shelf, page="shelforder")
def change_shelf_order(shelf_id, order):
result = calibre_db.session.query(db.Books).join(ub.BookShelf,ub.BookShelf.book_id == db.Books.id)\
.filter(ub.BookShelf.shelf == shelf_id).order_by(*order).all()
for index, entry in enumerate(result):
book = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id) \
.filter(ub.BookShelf.book_id == entry.id).first()
book.order = index
ub.session_commit("Shelf-id:{} - Order changed".format(shelf_id))
def render_show_shelf(shelf_type, shelf_id, page_no, sort_param):
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()
# check user is allowed to access shelf
if shelf and check_shelf_view_permissions(shelf):
if shelf_type == 1:
# order = [ub.BookShelf.order.asc()]
if sort_param == 'pubnew':
change_shelf_order(shelf_id, [db.Books.pubdate.desc()])
if sort_param == 'pubold':
change_shelf_order(shelf_id, [db.Books.pubdate])
if sort_param == 'abc':
change_shelf_order(shelf_id, [db.Books.sort])
if sort_param == 'zyx':
change_shelf_order(shelf_id, [db.Books.sort.desc()])
if sort_param == 'new':
change_shelf_order(shelf_id, [db.Books.timestamp.desc()])
if sort_param == 'old':
change_shelf_order(shelf_id, [db.Books.timestamp])
if sort_param == 'authaz':
change_shelf_order(shelf_id, [db.Books.author_sort.asc()])
if sort_param == 'authza':
change_shelf_order(shelf_id, [db.Books.author_sort.desc()])
page = "shelf.html"
pagesize = 0
else:
pagesize = sys.maxsize
page = 'shelfdown.html'
result, __, pagination = calibre_db.fill_indexpage(page_no, pagesize,
db.Books,
ub.BookShelf.shelf == shelf_id,
[ub.BookShelf.order.asc()],
ub.BookShelf,ub.BookShelf.book_id == db.Books.id)
# delete chelf entries where book is not existent anymore, can happen if book is deleted outside calibre-web
wrong_entries = calibre_db.session.query(ub.BookShelf)\
.join(db.Books, ub.BookShelf.book_id == db.Books.id, isouter=True)\
.filter(db.Books.id == None).all()
for entry in wrong_entries:
log.info('Not existing book {} in {} deleted'.format(entry.book_id, shelf))
try:
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == entry.book_id).delete()
ub.session.commit()
except (OperationalError, InvalidRequestError):
ub.session.rollback()
log.error("Settings DB is not Writeable")
flash(_("Settings DB is not Writeable"), category="error")
return render_title_template(page,
entries=result,
pagination=pagination,
title=_(u"Shelf: '%(name)s'", name=shelf.name),
shelf=shelf,
page="shelf")
else:
flash(_(u"Error opening shelf. Shelf does not exist or is not accessible"), category="error")
return redirect(url_for("web.index"))
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+24
View File
@@ -0,0 +1,24 @@
body.serieslist.grid-view div.container-fluid > div > div.col-sm-10::before {
display: none;
}
.cover .badge {
position: absolute;
top: 0;
left: 0;
color: #fff;
background-color: #cc7b19;
border-radius: 0;
padding: 0 8px;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
line-height: 24px;
}
.cover {
box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}
.cover .read {
padding: 0 0;
line-height: 15px;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+25 -6
View File
@@ -33,7 +33,6 @@ body {
position: relative; position: relative;
cursor: pointer; cursor: pointer;
padding: 4px; padding: 4px;
transition: all 0.2s ease; transition: all 0.2s ease;
} }
@@ -45,7 +44,7 @@ body {
#sidebar a.active, #sidebar a.active,
#sidebar a.active img + span { #sidebar a.active img + span {
background-color: #45B29D; background-color: #45b29d;
} }
#sidebar li img { #sidebar li img {
@@ -85,21 +84,30 @@ body {
#progress .bar-load, #progress .bar-load,
#progress .bar-read { #progress .bar-read {
display: flex; display: flex;
align-items: flex-end;
justify-content: flex-end;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0;
bottom: 0; bottom: 0;
transition: width 150ms ease-in-out; transition: width 150ms ease-in-out;
} }
#progress .from-left {
left: 0;
align-items: flex-end;
justify-content: flex-end;
}
#progress .from-right {
right: 0;
align-items: flex-start;
justify-content: flex-start;
}
#progress .bar-load { #progress .bar-load {
color: #000; color: #000;
background-color: #ccc; background-color: #ccc;
} }
#progress .bar-read { #progress .bar-read {
color: #fff; color: #fff;
background-color: #45b29d; background-color: #45b29d;
} }
@@ -219,3 +227,14 @@ th {
.dark-theme .overlay { .dark-theme .overlay {
background-color: rgba(0, 0, 0, 0.8); background-color: rgba(0, 0, 0, 0.8);
} }
/* Hide scrollbar for Chrome, Safari and Opera */
.disabled-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.disabled-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"
fill="rgba(255,255,255,1)"><path d="M8 12a1 1 0 0 1-.707-.293l-5-5a1 1 0 0 1 1.414-1.414L8
9.586l4.293-4.293a1 1 0 0 1 1.414 1.414l-5 5A1 1 0 0 1 8 12z"></path></svg>

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

@@ -0,0 +1,4 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M8 12a1 1 0 0 1-.707-.293l-5-5a1 1 0 0 1 1.414-1.414L8 9.586l4.293-4.293a1 1 0 0 1 1.414 1.414l-5 5A1 1 0 0 1 8 12z"></path></svg>

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

@@ -0,0 +1,5 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"
fill="rgba(255,255,255,1)"><path d="M13 11a1 1 0 0 1-.707-.293L8 6.414l-4.293 4.293a1 1 0 0 1-1.414-1.414l5-5a1 1 0 0 1 1.414 0l5 5A1 1 0 0 1 13 11z"></path></svg>

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

@@ -0,0 +1,4 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M13 11a1 1 0 0 1-.707-.293L8 6.414l-4.293 4.293a1 1 0 0 1-1.414-1.414l5-5a1 1 0 0 1 1.414 0l5 5A1 1 0 0 1 13 11z"></path></svg>

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"
fill="rgba(255,255,255,1)" style="animation:spinLoadingIcon 1s steps(12,end)
infinite"><style>@keyframes
spinLoadingIcon{to{transform:rotate(360deg)}}</style><path
d="M7 3V1s0-1 1-1 1 1 1 1v2s0 1-1 1-1-1-1-1z"/><path d="M4.63
4.1l-1-1.73S3.13 1.5 4 1c.87-.5 1.37.37 1.37.37l1 1.73s.5.87-.37
1.37c-.87.57-1.37-.37-1.37-.37z" fill-opacity=".93"/><path
d="M3.1 6.37l-1.73-1S.5 4.87 1 4c.5-.87 1.37-.37 1.37-.37l1.73 1s.87.5.37
1.37c-.5.87-1.37.37-1.37.37z" fill-opacity=".86"/><path d="M3
9H1S0 9 0 8s1-1 1-1h2s1 0 1 1-1 1-1 1z" fill-opacity=".79"/><path d="M4.1 11.37l-1.73 1S1.5 12.87 1
12c-.5-.87.37-1.37.37-1.37l1.73-1s.87-.5 1.37.37c.5.87-.37 1.37-.37 1.37z"
fill-opacity=".72"/><path d="M3.63 13.56l1-1.73s.5-.87
1.37-.37c.87.5.37 1.37.37 1.37l-1 1.73s-.5.87-1.37.37c-.87-.5-.37-1.37-.37-1.37z"
fill-opacity=".65"/><path d="M7 15v-2s0-1 1-1 1 1 1 1v2s0 1-1
1-1-1-1-1z" fill-opacity=".58"/><path d="M10.63
14.56l-1-1.73s-.5-.87.37-1.37c.87-.5 1.37.37 1.37.37l1 1.73s.5.87-.37
1.37c-.87.5-1.37-.37-1.37-.37z" fill-opacity=".51"/><path
d="M13.56 12.37l-1.73-1s-.87-.5-.37-1.37c.5-.87 1.37-.37 1.37-.37l1.73 1s.87.5.37
1.37c-.5.87-1.37.37-1.37.37z" fill-opacity=".44"/><path d="M15
9h-2s-1 0-1-1 1-1 1-1h2s1 0 1 1-1 1-1 1z" fill-opacity=".37"/><path d="M14.56 5.37l-1.73
1s-.87.5-1.37-.37c-.5-.87.37-1.37.37-1.37l1.73-1s.87-.5 1.37.37c.5.87-.37 1.37-.37
1.37z" fill-opacity=".3"/><path d="M9.64 3.1l.98-1.66s.5-.874
1.37-.37c.87.5.37 1.37.37 1.37l-1 1.73s-.5.87-1.37.37c-.87-.5-.37-1.37-.37-1.37z"
fill-opacity=".23"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" style="animation:spinLoadingIcon 1s steps(12,end) infinite"><style>@keyframes spinLoadingIcon{to{transform:rotate(360deg)}}</style><path d="M7 3V1s0-1 1-1 1 1 1 1v2s0 1-1 1-1-1-1-1z"/><path d="M4.63 4.1l-1-1.73S3.13 1.5 4 1c.87-.5 1.37.37 1.37.37l1 1.73s.5.87-.37 1.37c-.87.57-1.37-.37-1.37-.37z" fill-opacity=".93"/><path d="M3.1 6.37l-1.73-1S.5 4.87 1 4c.5-.87 1.37-.37 1.37-.37l1.73 1s.87.5.37 1.37c-.5.87-1.37.37-1.37.37z" fill-opacity=".86"/><path d="M3 9H1S0 9 0 8s1-1 1-1h2s1 0 1 1-1 1-1 1z" fill-opacity=".79"/><path d="M4.1 11.37l-1.73 1S1.5 12.87 1 12c-.5-.87.37-1.37.37-1.37l1.73-1s.87-.5 1.37.37c.5.87-.37 1.37-.37 1.37z" fill-opacity=".72"/><path d="M3.63 13.56l1-1.73s.5-.87 1.37-.37c.87.5.37 1.37.37 1.37l-1 1.73s-.5.87-1.37.37c-.87-.5-.37-1.37-.37-1.37z" fill-opacity=".65"/><path d="M7 15v-2s0-1 1-1 1 1 1 1v2s0 1-1 1-1-1-1-1z" fill-opacity=".58"/><path d="M10.63 14.56l-1-1.73s-.5-.87.37-1.37c.87-.5 1.37.37 1.37.37l1 1.73s.5.87-.37 1.37c-.87.5-1.37-.37-1.37-.37z" fill-opacity=".51"/><path d="M13.56 12.37l-1.73-1s-.87-.5-.37-1.37c.5-.87 1.37-.37 1.37-.37l1.73 1s.87.5.37 1.37c-.5.87-1.37.37-1.37.37z" fill-opacity=".44"/><path d="M15 9h-2s-1 0-1-1 1-1 1-1h2s1 0 1 1-1 1-1 1z" fill-opacity=".37"/><path d="M14.56 5.37l-1.73 1s-.87.5-1.37-.37c-.5-.87.37-1.37.37-1.37l1.73-1s.87-.5 1.37.37c.5.87-.37 1.37-.37 1.37z" fill-opacity=".3"/><path d="M9.64 3.1l.98-1.66s.5-.874 1.37-.37c.87.5.37 1.37.37 1.37l-1 1.73s-.5.87-1.37.37c-.87-.5-.37-1.37-.37-1.37z" fill-opacity=".23"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

@@ -0,0 +1,16 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16
16"
fill="rgba(255,255,255,1)">
<path
d="M8 16a8 8 0 1 1 8-8 8.009 8.009 0 0 1-8 8zM8 2a6 6 0 1 0 6 6 6.006 6.006 0 0 0-6-6z">
</path>
<path
d="M8 7a1 1 0 0 0-1 1v3a1 1 0 0 0 2 0V8a1 1 0 0 0-1-1z">
</path>
<circle
cx="8" cy="5" r="1.188">
</circle>
</svg>

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

@@ -0,0 +1,15 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16
16">
<path
d="M8 16a8 8 0 1 1 8-8 8.009 8.009 0 0 1-8 8zM8 2a6 6 0 1 0 6 6 6.006 6.006 0 0 0-6-6z">
</path>
<path
d="M8 7a1 1 0 0 0-1 1v3a1 1 0 0 0 2 0V8a1 1 0 0 0-1-1z">
</path>
<circle
cx="8" cy="5" r="1.188">
</circle>
</svg>

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 933 B

@@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="rgba(255,255,255,1)"><path d="M13 13c-.3 0-.5-.1-.7-.3L8 8.4l-4.3 4.3c-.9.9-2.3-.5-1.4-1.4l5-5c.4-.4 1-.4 1.4 0l5 5c.6.6.2 1.7-.7 1.7zm0-11H3C1.7 2 1.7 4 3 4h10c1.3 0 1.3-2 0-2z"/></svg>

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13 13c-.3 0-.5-.1-.7-.3L8 8.4l-4.3 4.3c-.9.9-2.3-.5-1.4-1.4l5-5c.4-.4 1-.4 1.4 0l5 5c.6.6.2 1.7-.7 1.7zm0-11H3C1.7 2 1.7 4 3 4h10c1.3 0 1.3-2 0-2z"/></svg>

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

@@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"
fill="rgba(255,255,255,1)"><path d="M15 3.7V13c0 1.5-1.53 3-3 3H7.13c-.72 0-1.63-.5-2.13-1l-5-5s.84-1 .87-1c.13-.1.33-.2.53-.2.1 0 .3.1.4.2L4 10.6V2.7c0-.6.4-1 1-1s1 .4 1 1v4.6h1V1c0-.6.4-1 1-1s1 .4 1 1v6.3h1V1.7c0-.6.4-1 1-1s1 .4 1 1v5.7h1V3.7c0-.6.4-1 1-1s1 .4 1 1z"/></svg>

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M15 3.7V13c0 1.5-1.53 3-3 3H7.13c-.72 0-1.63-.5-2.13-1l-5-5s.84-1 .87-1c.13-.1.33-.2.53-.2.1 0 .3.1.4.2L4 10.6V2.7c0-.6.4-1 1-1s1 .4 1 1v4.6h1V1c0-.6.4-1 1-1s1 .4 1 1v6.3h1V1.7c0-.6.4-1 1-1s1 .4 1 1v5.7h1V3.7c0-.6.4-1 1-1s1 .4 1 1z"/></svg>

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

@@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="rgba(255,255,255,1)"><path d="M8 10c-.3 0-.5-.1-.7-.3l-5-5c-.9-.9.5-2.3 1.4-1.4L8 7.6l4.3-4.3c.9-.9 2.3.5 1.4 1.4l-5 5c-.2.2-.4.3-.7.3zm5 2H3c-1.3 0-1.3 2 0 2h10c1.3 0 1.3-2 0-2z"/></svg>

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M8 10c-.3 0-.5-.1-.7-.3l-5-5c-.9-.9.5-2.3 1.4-1.4L8 7.6l4.3-4.3c.9-.9 2.3.5 1.4 1.4l-5 5c-.2.2-.4.3-.7.3zm5 2H3c-1.3 0-1.3 2 0 2h10c1.3 0 1.3-2 0-2z"/></svg>

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

@@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"
fill="rgba(255,255,255,1)"><path d="M1 1a1 1 0 011 1v2.4A7 7 0 118 15a7 7 0 01-4.9-2 1 1 0 011.4-1.5 5 5 0 10-1-5.5H6a1 1 0 010 2H1a1 1 0 01-1-1V2a1 1 0 011-1z"/></svg>

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M1 1a1 1 0 011 1v2.4A7 7 0 118 15a7 7 0 01-4.9-2 1 1 0 011.4-1.5 5 5 0 10-1-5.5H6a1 1 0 010 2H1a1 1 0 01-1-1V2a1 1 0 011-1z"/></svg>

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 731 B

@@ -0,0 +1,5 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"
fill="rgba(255,255,255,1)"><path d="M15 1a1 1 0 0 0-1 1v2.418A6.995 6.995 0 1 0 8 15a6.954 6.954 0 0 0 4.95-2.05 1 1 0 0 0-1.414-1.414A5.019 5.019 0 1 1 12.549 6H10a1 1 0 0 0 0 2h5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1z"></path></svg>

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

@@ -0,0 +1,4 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M15 1a1 1 0 0 0-1 1v2.418A6.995 6.995 0 1 0 8 15a6.954 6.954 0 0 0 4.95-2.05 1 1 0 0 0-1.414-1.414A5.019 5.019 0 1 1 12.549 6H10a1 1 0 0 0 0 2h5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1z"></path></svg>

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

@@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"
fill="rgba(255,255,255,1)"><path d="M0 4h1.5c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5H0zM9.5 4c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5h-3c-1 0-1.5-.5-1.5-1.5v-5C5 4.5 5.5 4 6.5 4zM16 4h-1.5c-1 0-1.5.5-1.5 1.5v5c0 1 .5 1.5 1.5 1.5H16z"/></svg>

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M0 4h1.5c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5H0zM9.5 4c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5h-3c-1 0-1.5-.5-1.5-1.5v-5C5 4.5 5.5 4 6.5 4zM16 4h-1.5c-1 0-1.5.5-1.5 1.5v5c0 1 .5 1.5 1.5 1.5H16z"/></svg>

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

@@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"
fill="rgba(255,255,255,1)"><path d="M9.5 4c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5h-3c-1 0-1.5-.5-1.5-1.5v-5C5 4.5 5.5 4 6.5 4zM11 0v.5c0 1-.5 1.5-1.5 1.5h-3C5.5 2 5 1.5 5 .5V0h6zM11 16v-.5c0-1-.5-1.5-1.5-1.5h-3c-1 0-1.5.5-1.5 1.5v.5h6z"/></svg>

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"><path d="M9.5 4c1 0 1.5.5 1.5 1.5v5c0 1-.5 1.5-1.5 1.5h-3c-1 0-1.5-.5-1.5-1.5v-5C5 4.5 5.5 4 6.5 4zM11 0v.5c0 1-.5 1.5-1.5 1.5h-3C5.5 2 5 1.5 5 .5V0h6zM11 16v-.5c0-1-.5-1.5-1.5-1.5h-3c-1 0-1.5.5-1.5 1.5v.5h6z"/></svg>

After

Width:  |  Height:  |  Size: 280 B

Some files were not shown because too many files have changed in this diff Show More