Skip to content

Commit

Permalink
Make light theme default theme on epub reader
Browse files Browse the repository at this point in the history
Fix csp Header for reader and google drive (#3108)
Testrun
  • Loading branch information
OzzieIsaacs committed Jul 25, 2024
1 parent a0728b0 commit f8adcbb
Show file tree
Hide file tree
Showing 4 changed files with 654 additions and 427 deletions.
4 changes: 2 additions & 2 deletions cps/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ def rename_author_path(first_author, old_author_dir, renamed_author, calibre_pat
except OSError as ex:
log.error("Rename author from: %s to %s: %s", old_author_path, new_author_path, ex)
log.debug(ex, exc_info=True)
return _("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s",
src=old_author_path, dest=new_author_path, error=str(ex))
raise Exception(_("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s",
src=old_author_path, dest=new_author_path, error=str(ex)))
return new_authordir

# Moves files in file storage during author/title rename, or from temp dir to file storage
Expand Down
2 changes: 1 addition & 1 deletion cps/static/js/reading/epub.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ var reader;
}

// Default settings load
const theme = localStorage.getItem("calibre.reader.theme") ?? Object.keys(themes)[0];
const theme = localStorage.getItem("calibre.reader.theme") ?? "lightTheme";
selectTheme(theme);
})();
18 changes: 9 additions & 9 deletions cps/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@
def add_security_headers(resp):
default_src = ([host.strip() for host in config.config_trustedhosts.split(',') if host] +
["'self'", "'unsafe-inline'", "'unsafe-eval'"])
csp = "default-src " + ' '.join(default_src) + "; "
csp += "font-src 'self' data:"
csp = "default-src " + ' '.join(default_src)
if request.endpoint == "web.read_book" and config.config_use_google_drive:
csp +=" blob: "
csp += "; font-src 'self' data:"
if request.endpoint == "web.read_book":
csp += " blob:"
csp += " blob: "
csp += "; img-src 'self'"
if request.path.startswith("/author/") and config.config_use_goodreads:
csp += " images.gr-assets.com i.gr-assets.com s.gr-assets.com"
csp += " data:"
if request.endpoint == "edit-book.show_edit_book" or config.config_use_google_drive:
csp += " *;"
elif request.endpoint == "web.read_book":
csp += " blob:; style-src-elem 'self' blob: 'unsafe-inline';"
else:
csp += ";"
csp += " object-src 'none';"
csp += " *"
if request.endpoint == "web.read_book":
csp += " blob: ; style-src-elem 'self' blob: 'unsafe-inline'"
csp += "; object-src 'none';"
resp.headers['Content-Security-Policy'] = csp
resp.headers['X-Content-Type-Options'] = 'nosniff'
resp.headers['X-Frame-Options'] = 'SAMEORIGIN'
Expand Down
Loading

0 comments on commit f8adcbb

Please sign in to comment.