Skip to content

Commit 8e6496f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into hardcover
2 parents e77dadd + 19960a9 commit 8e6496f

File tree

5 files changed

+160
-12
lines changed

5 files changed

+160
-12
lines changed

.github/workflows/dockerhub-build-push-on-push.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
name: Build & Push - Dev
2-
# Automatically builds and pushes a multi-platform dev image based on commits involving key files
2+
# Automatically builds and pushes a multi-platform dev image based on commits involving key files in any branch
33

44
on:
55
push:
6+
branches:
7+
- '**' # Runs on pushes to any branch
68
paths:
79
- 'empty_library/**'
810
- 'root/**'
911
- 'scripts/**'
1012
- '**/Dockerfile'
13+
create:
14+
branches:
15+
- '**' # Runs when a new branch is created
1116

1217
jobs:
1318
build:
1419
runs-on: ubuntu-latest
20+
if: github.event.ref_type == 'branch' || github.event_name == 'push' # Ensures it runs for branch creation & push events
1521

1622
steps:
17-
- uses: actions/checkout@v4
23+
- name: Checkout correct branch
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.ref }}
27+
28+
- name: Determine Docker Image Tag
29+
id: tag
30+
run: |
31+
if [[ "${{ github.ref_name }}" == "main" ]]; then
32+
echo "IMAGE_TAG=dev" >> $GITHUB_ENV
33+
else
34+
echo "IMAGE_TAG=dev-${{ github.ref_name }}" >> $GITHUB_ENV
35+
fi
1836
1937
- name: DockerHub Login
2038
uses: docker/login-action@v3
@@ -31,15 +49,15 @@ jobs:
3149
- name: Build and push Docker image
3250
uses: docker/build-push-action@v6
3351
with:
34-
provenance: false # Disable provenance metadata to fix BuildKit issues
52+
provenance: false # Disable provenance metadata to fix BuildKit issues
3553
context: .
3654
file: ./Dockerfile
3755
push: true
3856
build-args: |
3957
BUILD_DATE=${{ github.event.repository.updated_at }}
40-
VERSION=${{ vars.CURRENT_DEV_VERSION }}-DEV_BUILD-${{ vars.CURRENT_DEV_BUILD_NUM }}
58+
VERSION=${{ vars.CURRENT_DEV_VERSION }}-DEV_BUILD-${{ env.IMAGE_TAG }}-${{ vars.CURRENT_DEV_BUILD_NUM }}
4159
tags: |
42-
${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated:dev
60+
${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated:dev-${{ env.IMAGE_TAG }}
4361
4462
platforms: linux/amd64,linux/arm64
4563

root/app/calibre-web/cps/cwa_functions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ def refresh_library(app):
9797
current_app.config["library_refresh_messages"] = []
9898

9999
if return_code == 2:
100-
message = "Library Refresh - The book ingest service is already running, please wait until it has finished before trying again."
100+
message = "Library Refresh 🔄 The book ingest service is already running ✋ Please wait until it has finished before trying again"
101101
elif return_code == 0:
102-
message = "Library Refresh - Library refreshed & ingest process complete."
102+
message = "Library Refresh 🔄 Library refreshed & ingest process complete! ✅"
103103
else:
104-
message = "Library Refresh - An unexpected error occurred, check the logs."
104+
message = "Library Refresh 🔄 An unexpected error occurred, check the logs"
105105

106106
# Display message to user in Web UI
107107
current_app.config["library_refresh_messages"].append(message)
108108
# Print result to docker log
109-
print(message.replace('Library Refresh -', '[library-refresh]'), flush=True)
109+
print(message.replace('Library Refresh 🔄', '[library-refresh]'), flush=True)
110110

111111
@csrf.exempt
112112
@library_refresh.route("/cwa-library-refresh", methods=["GET", "POST"])
@@ -121,7 +121,7 @@ def cwa_library_refresh():
121121
library_refresh_thread = Thread(target=refresh_library, args=(app,))
122122
library_refresh_thread.start()
123123

124-
return jsonify({"message": "Library Refresh: Checking for any books that may have been missed, please wait..."}), 200
124+
return jsonify({"message": "Library Refresh 🔄 Checking for any books that may have been missed, please wait..."}), 200
125125

126126
@csrf.exempt
127127
@library_refresh.route("/cwa-library-refresh/messages", methods=["GET"])

root/app/calibre-web/cps/editbooks.py

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,76 @@ def table_get_custom_enum(c_id):
214214
@edit_required
215215
def edit_list_book(param):
216216
vals = request.form.to_dict()
217+
return edit_book_param(param, vals)
218+
219+
@editbook.route("/ajax/editselectedbooks", methods=['POST'])
220+
@login_required_if_no_ano
221+
@edit_required
222+
def edit_selected_books():
223+
d = request.get_json()
224+
selections = d.get('selections')
225+
title = d.get('title')
226+
title_sort = d.get('title_sort')
227+
author_sort = d.get('author_sort')
228+
authors = d.get('authors')
229+
categories = d.get('categories')
230+
series = d.get('series')
231+
languages = d.get('languages')
232+
publishers = d.get('publishers')
233+
comments = d.get('comments')
234+
checkA = d.get('checkA')
235+
236+
if len(selections) != 0:
237+
for book_id in selections:
238+
vals = {
239+
"pk": book_id,
240+
"value": None,
241+
"checkA": checkA,
242+
}
243+
if title:
244+
vals['value'] = title
245+
edit_book_param('title', vals)
246+
if title_sort:
247+
vals['value'] = title_sort
248+
edit_book_param('sort', vals)
249+
if author_sort:
250+
vals['value'] = author_sort
251+
edit_book_param('author_sort', vals)
252+
if authors:
253+
vals['value'] = authors
254+
edit_book_param('authors', vals)
255+
if categories:
256+
vals['value'] = categories
257+
edit_book_param('tags', vals)
258+
if series:
259+
vals['value'] = series
260+
edit_book_param('series', vals)
261+
if languages:
262+
vals['value'] = languages
263+
edit_book_param('languages', vals)
264+
if publishers:
265+
vals['value'] = publishers
266+
edit_book_param('publishers', vals)
267+
if comments:
268+
vals['value'] = comments
269+
edit_book_param('comments', vals)
270+
return json.dumps({'success': True})
271+
return ""
272+
273+
# Separated from /editbooks so that /editselectedbooks can also use this
274+
#
275+
# param: the property of the book to be changed
276+
# vals - JSON Object:
277+
# {
278+
# 'pk': "the book id",
279+
# 'value': "changes value of param to what's passed here"
280+
# 'checkA': "Optional. Used to check if autosort author is enabled. Assumed as true if not passed"
281+
# 'checkT': "Optional. Used to check if autotitle author is enabled. Assumed as true if not passed"
282+
# }
283+
#
284+
@login_required_if_no_ano
285+
@edit_required
286+
def edit_book_param(param, vals):
217287
book = calibre_db.get_book(vals['pk'])
218288
sort_param = ""
219289
ret = ""
@@ -353,6 +423,66 @@ def simulate_merge_list_book():
353423
return ""
354424

355425

426+
@editbook.route("/ajax/displayselectedbooks", methods=['POST'])
427+
@user_login_required
428+
@edit_required
429+
def display_selected_books():
430+
vals = request.get_json().get('selections')
431+
books = []
432+
if vals:
433+
for book_id in vals:
434+
books.append(calibre_db.get_book(book_id).title)
435+
return json.dumps({'books': books})
436+
return ""
437+
438+
@editbook.route("/ajax/archiveselectedbooks", methods=['POST'])
439+
@login_required_if_no_ano
440+
@edit_required
441+
def archive_selected_books():
442+
vals = request.get_json().get('selections')
443+
state = request.get_json().get('archive')
444+
if vals:
445+
for book_id in vals:
446+
is_archived = change_archived_books(book_id, state,
447+
message="Book {} archive bit set to: {}".format(book_id, state))
448+
if is_archived:
449+
kobo_sync_status.remove_synced_book(book_id)
450+
return json.dumps({'success': True})
451+
return ""
452+
453+
@editbook.route("/ajax/deleteselectedbooks", methods=['POST'])
454+
@user_login_required
455+
@edit_required
456+
def delete_selected_books():
457+
vals = request.get_json().get('selections')
458+
if vals:
459+
for book_id in vals:
460+
delete_book_from_table(book_id, "", True)
461+
return json.dumps({'success': True})
462+
return ""
463+
464+
@editbook.route("/ajax/readselectedbooks", methods=['POST'])
465+
@user_login_required
466+
@edit_required
467+
def read_selected_books():
468+
vals = request.get_json().get('selections')
469+
markAsRead = request.get_json().get('markAsRead')
470+
if vals:
471+
try:
472+
for book_id in vals:
473+
ret = helper.edit_book_read_status(book_id, markAsRead)
474+
475+
except (OperationalError, IntegrityError, StaleDataError) as e:
476+
calibre_db.session.rollback()
477+
log.error_or_exception("Database error: {}".format(e))
478+
ret = Response(json.dumps({'success': False,
479+
'msg': 'Database error: {}'.format(e.orig if hasattr(e, "orig") else e)}),
480+
mimetype='application/json')
481+
482+
return json.dumps({'success': True})
483+
return ""
484+
485+
356486
@editbook.route("/ajax/mergebooks", methods=['POST'])
357487
@user_login_required
358488
@edit_required

root/app/calibre-web/cps/render_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def cwa_update_notification() -> None:
147147

148148
update_available, current_version, tag_name = cwa_update_available()
149149
if update_available:
150-
message = f"⚡🚨 CWA UPDATE AVAILABLE! 🚨⚡ Current - {current_version} | Newest - {tag_name} | To update, just re-pull the image! This message will only display once per day"
150+
message = f"⚡🚨 CWA UPDATE AVAILABLE! 🚨⚡ Current - {current_version} | Newest - {tag_name} | To update, just re-pull the image! This message will only display once per day |"
151151
flash(_(message), category="cwa_update")
152152
print(f"[cwa-update-notification-service] {message}", flush=True)
153153

root/app/calibre-web/cps/templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
{%if message[0] == "cwa_update" %}
203203
<div class="row-fluid text-center">
204204
<div id="flash_info" class="alert alert-info alert-cwa">
205-
{{ message[1] }}
205+
{{ message[1] }} <a href="https://github.com/crocodilestick/Calibre-Web-Automated/releases">See Changelog</a>
206206
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
207207
<span aria-hidden="true">&times;</span>
208208
</button>

0 commit comments

Comments
 (0)