Skip to content

Commit 73eecc1

Browse files
MAJOR REFACTOR
- The CWA repo now contains all of the core required files it needs & no longer directly uses the latest Calibre-Web releases & linuxserver/docker-calibre-web repo to build it's images - This change should hopefully make contributing to the project much more intuitive for those interested as well making CWA easier to develop for in general Bugfixes: - Fixed typo in amazonjp.py preventing it from working
1 parent bc068ec commit 73eecc1

913 files changed

Lines changed: 310022 additions & 146 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ docker-compose.yml
44
.github
55
.gitignore
66
.github/workflows
7+
.gitattributes
78
build.sh
89
README.md
910
LICENSE
1011
Dockerfile
1112
.dockerignore
12-
build
13+
build.sh
1314
.history
14-
Dockerfile_calibre_not_included
15+
docker-compose.yml.dev
16+
changelogs
17+
cwa-wiki
18+
wiki_images

Dockerfile

Lines changed: 49 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,18 @@ SHELL ["/bin/bash", "-c"]
2626
ARG BUILD_DATE
2727
ARG VERSION
2828
ARG CALIBREWEB_RELEASE=0.6.24
29-
ARG LSCW_RELEASE=0.6.24-ls304
3029
ARG CALIBRE_RELEASE=8.4.0
3130
ARG KEPUBIFY_RELEASE=v4.0.4
3231
LABEL build_version="Version:- ${VERSION}"
3332
LABEL build_date="${BUILD_DATE}"
34-
LABEL CW-Stock-version="${CALIBREWEB_RELEASE}"
35-
LABEL LSCW_Image_Release="${LSCW_RELEASE}"
33+
LABEL CW-base-version="${CALIBREWEB_RELEASE}"
3634
LABEL maintainer="CrocodileStick"
3735

3836
# Copy local files into the container
3937
COPY --chown=abc:abc . /app/calibre-web-automated/
40-
# STEP 1 - Install stock Calibre-Web
38+
# STEP 1 - Install Required Packages
4139
RUN \
42-
# STEP 1.1 - Installs required build & runtime packages
40+
# STEP 1.1 - Install required apt packages
4341
echo "**** install build packages ****" && \
4442
apt-get update && \
4543
apt-get install -y --no-install-recommends \
@@ -56,68 +54,34 @@ RUN \
5654
libsasl2-2 \
5755
libxi6 \
5856
libxslt1.1 \
57+
xdg-utils \
58+
inotify-tools \
59+
python3 \
60+
python3-pip \
61+
nano \
62+
sqlite3 \
63+
zip \
5964
python3-venv && \
60-
echo "**** install calibre-web ****" && \
61-
# STEP 1.2 - Check that $CALIBREWEB_RELEASE ARG is not none and if it is, sets the variables value to the most recent tag name
62-
if [ -z ${CALIBREWEB_RELEASE+x} ]; then \
63-
CALIBREWEB_RELEASE=$(curl -sX GET "https://api.github.com/repos/janeczku/calibre-web/releases/latest" \
64-
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
65-
fi && \
66-
# STEP 1.3 - Downloads the tarball of the release stored in $CALIBREWEB_RELEASE from CW's GitHub Repo, saving it into /tmp
67-
curl -o \
68-
/tmp/calibre-web.tar.gz -L \
69-
https://github.com/janeczku/calibre-web/archive/${CALIBREWEB_RELEASE}.tar.gz && \
70-
# STEP 1.4 - Makes /app/calibre-web to extract the downloaded files from the repo to, -p to ignore potential errors that could arise if the folder already existed
71-
mkdir -p \
72-
/app/calibre-web && \
73-
# STEP 1.5 - Extracts the contents of the tar.gz file downloaded from the repo to the /app/calibre-web dir previously created
74-
tar xf \
75-
/tmp/calibre-web.tar.gz -C \
76-
/app/calibre-web --strip-components=1 && \
77-
# STEP 1.6 - Sets up a python virtual environment and installs pip and wheel packages
78-
cd /app/calibre-web && \
65+
# STEP 1.2 - Set up a python virtual environment and install pip and wheel packages
66+
cd /app/calibre-web-automated && \
7967
python3 -m venv /lsiopy && \
8068
pip install -U --no-cache-dir \
8169
pip \
8270
wheel && \
83-
# STEP 1.7 - Installing the required python packages listed in 'requirements.txt' and 'optional-requirements.txt'
71+
# STEP 1.3 - Installing the required python packages listed in 'requirements.txt' and 'optional-requirements.txt'
8472
# HOWEVER, they are not pulled from PyPi directly, they are pulled from linuxserver's Ubuntu Wheel Index
8573
# This is essentially a repository of precompiled some of the most popular packages with C/C++ source code
8674
# This provides the install maximum compatibility with multiple different architectures including: x86_64, armv71 and aarch64
8775
# You can read more about python wheels here: https://realpython.com/python-wheels/
8876
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ -r \
89-
requirements.txt -r \
90-
optional-requirements.txt && \
91-
# STEP 1.8 - Installs kepubify
92-
echo "**** install kepubify ****" && \
93-
if [[ $KEPUBIFY_RELEASE == 'newest' ]]; then \
94-
KEPUBIFY_RELEASE=$(curl -sX GET "https://api.github.com/repos/pgaskin/kepubify/releases/latest" \
95-
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
96-
fi && \
97-
if [ "$(uname -m)" == "x86_64" ]; then \
98-
curl -o \
99-
/usr/bin/kepubify -L \
100-
https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-64bit; \
101-
elif [ "$(uname -m)" == "aarch64" ]; then \
102-
curl -o \
103-
/usr/bin/kepubify -L \
104-
https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-arm64; \
105-
fi && \
106-
# STEP 2 - Install Calibre-Web Automated
107-
echo "~~~~ CWA Install - installing additional required packages ~~~~" && \
108-
# STEP 2.1 - Install additional required packages
109-
apt-get update && \
110-
apt-get install -y --no-install-recommends \
111-
xdg-utils \
112-
inotify-tools \
113-
python3 \
114-
python3-pip \
115-
nano \
116-
sqlite3 \
117-
zip && \
118-
# STEP 2.2 - Install additional required python packages
119-
pip install -r /app/calibre-web-automated/requirements.txt && \
120-
# STEP 2.2.1 - Create koplugin.zip from KOReader plugin folder
77+
requirements.txt -r && \
78+
# STEP 2 - Move contents of /app/calibre-web-automated/root to / and delete the /app/calibre-web-automated/root directory
79+
cp -R /app/calibre-web-automated/root/* / && \
80+
rm -R /app/calibre-web-automated/root/ && \
81+
# STEP 3 - Run CWA install script to make required dirs, set script permissions and add aliases for CLI commands ect.
82+
chmod +x /app/calibre-web-automated/scripts/setup-cwa.sh && \
83+
/app/calibre-web-automated/scripts/setup-cwa.sh && \
84+
# STEP 4 - Create koplugin.zip from KOReader plugin folder
12185
echo "~~~~ Creating koplugin.zip from KOReader plugin folder... ~~~~" && \
12286
if [ -d "/app/calibre-web-automated/koreader/plugins/cwasync.koplugin" ]; then \
12387
cd /app/calibre-web-automated/koreader/plugins && \
@@ -135,48 +99,31 @@ RUN \
13599
else \
136100
echo "Warning: cwasync.koplugin folder not found, skipping zip creation"; \
137101
fi && \
138-
# STEP 2.3 - Get required 'root' dir from the linuxserver/docker-calibre-web repo
139-
echo "~~~~ Getting required files from linuxserver/docker-calibre-web... ~~~~" && \
140-
# STEP 2.4.1 - Check the most recent release of linuxserver/docker-calibre-web and store it's tag in LSCW_RELEASE if one was not specified as an ARG
141-
if [[ $LSCW_RELEASE == 'newest' ]]; then \
142-
LSCW_RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/docker-calibre-web/releases/latest" \
143-
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
144-
fi && \
145-
# STEP 2.4.2 - Download the most recent LSCW release to /tmp
146-
curl -o \
147-
/tmp/lscw.tar.gz -L \
148-
https://github.com/linuxserver/docker-calibre-web/archive/refs/tags/${LSCW_RELEASE}.tar.gz && \
149-
# STEP 2.4.3 - Makes /app/calibre-web to extract the downloaded files from the repo to, -p to ignore potential errors that could arise if the folder already existed
150-
mkdir -p \
151-
/tmp/lscw && \
152-
# STEP 2.4.4 - Extract contents of lscw.tat.gz to /tmp/lscw
153-
tar xf \
154-
/tmp/lscw.tar.gz -C \
155-
/tmp/lscw --strip-components=1 && \
156-
# STEP 2.4.5 - Move contents of 'root' dirs to root dir
157-
cp -R /tmp/lscw/root/* / && \
158-
cp -R /app/calibre-web-automated/root/* / && \
159-
# STEP 2.4.6 - Move koplugin.zip to static directory
102+
# STEP 4.1 - Move koplugin.zip to static directory
160103
if [ -f "/app/calibre-web-automated/koreader/plugins/koplugin.zip" ]; then \
161-
mkdir -p /app/calibre-web/cps/static && \
104+
mkdir -p /app/calibre-web-automated/cps/static && \
162105
cp /app/calibre-web-automated/koreader/plugins/koplugin.zip /app/calibre-web/cps/static/ && \
163106
echo "Moved koplugin.zip to static directory"; \
164107
else \
165108
echo "Warning: koplugin.zip not found, skipping move to static directory"; \
166109
fi && \
167-
# STEP 2.4.7 - Remove the temp files
168-
rm -R /app/calibre-web-automated/root/ && \
169-
rm -R /tmp/lscw/root/ && \
170-
# STEP 2.5 - ADD files referencing the versions of the installed main packages
171-
# CALIBRE_RELEASE is placed in root by universal calibre below and containers the calibre version being used
172-
echo "$VERSION" >| /app/CWA_RELEASE && \
173-
echo "$LSCW_RELEASE" >| /app/LSCW_RELEASE && \
174-
echo "$KEPUBIFY_RELEASE" >| /app/KEPUBIFY_RELEASE && \
175-
# STEP 2.6 - Run CWA install script to make required dirs, set script permissions and add aliases for CLI commands ect.
176-
chmod +x /app/calibre-web-automated/scripts/setup-cwa.sh && \
177-
/app/calibre-web-automated/scripts/setup-cwa.sh && \
178-
# STEP 3 - Install Universal Calibre
179-
# STEP 3.1 - Install additional required packages
110+
# STEP 5 - Installs kepubify
111+
echo "**** install kepubify ****" && \
112+
if [[ $KEPUBIFY_RELEASE == 'newest' ]]; then \
113+
KEPUBIFY_RELEASE=$(curl -sX GET "https://api.github.com/repos/pgaskin/kepubify/releases/latest" \
114+
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
115+
fi && \
116+
if [ "$(uname -m)" == "x86_64" ]; then \
117+
curl -o \
118+
/usr/bin/kepubify -L \
119+
https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-64bit; \
120+
elif [ "$(uname -m)" == "aarch64" ]; then \
121+
curl -o \
122+
/usr/bin/kepubify -L \
123+
https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-arm64; \
124+
fi && \
125+
# STEP 6 - Install Calibre
126+
# STEP 6.1 - Install additional required packages
180127
apt-get update && \
181128
apt-get install -y --no-install-recommends \
182129
libxtst6 \
@@ -192,10 +139,10 @@ RUN \
192139
libglx-mesa0 \
193140
xz-utils \
194141
binutils && \
195-
# STEP 3.2 - Make the /app/calibre directory for the installed files
142+
# STEP 6.2 - Make the /app/calibre directory for the installed files
196143
mkdir -p \
197144
/app/calibre && \
198-
# STEP 3.3 - Download the desired version of Calibre, determined by the CALIBRE_RELEASE variable and the architecture of the build environment
145+
# STEP 6.3 - Download the desired version of Calibre, determined by the CALIBRE_RELEASE variable and the architecture of the build environment
199146
if [ "$(uname -m)" == "x86_64" ]; then \
200147
curl -o \
201148
/calibre.txz -L \
@@ -205,16 +152,18 @@ RUN \
205152
/calibre.txz -L \
206153
"https://download.calibre-ebook.com/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE}-arm64.txz"; \
207154
fi && \
208-
# STEP 3.4 - Extract the downloaded file to /app/calibre
155+
# STEP 6.4 - Extract the downloaded file to /app/calibre
209156
tar xf \
210157
/calibre.txz -C \
211158
/app/calibre && \
212-
# STEP 3.4.1 - Remove the ABI tag from the extracted libQt6* files to allow them to be used on older kernels
159+
# STEP 6.4.1 - Remove the ABI tag from the extracted libQt6* files to allow them to be used on older kernels
213160
strip --remove-section=.note.ABI-tag /app/calibre/lib/libQt6* && \
214-
# STEP 3.5 - Delete the extracted calibre.txz to save space in final image
161+
# STEP 6.5 - Delete the extracted calibre.txz to save space in final image
215162
rm /calibre.txz && \
216-
# STEP 3.6 - Store the CALIBRE_RELEASE in the root of the image in CALIBRE_RELEASE
217-
echo $CALIBRE_RELEASE > /CALIBRE_RELEASE
163+
# STEP 7 - ADD files referencing the versions of the installed main packages
164+
echo "$VERSION" >| /app/CWA_RELEASE && \
165+
echo "$KEPUBIFY_RELEASE" >| /app/KEPUBIFY_RELEASE && \
166+
echo "$CALIBRE_RELEASE" > /CALIBRE_RELEASE
218167

219168
# Removes packages that are no longer required, also emptying dirs used to build the image that are no longer needed
220169
RUN \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ And that's you off to the races! 🥳 HOWEVER to avoid potential problems and en
280280
- **New Users** - Use any empty folder (if you run into any issues, make sure the ownership of said folder isn't `root:root` in your main os)
281281
- **Existing/ CW Users** - If there are multiple libraries in the mounted directory, CWA will automatically find and mount the largest one - check the logs for more details on which `metadata.db` was utilised
282282
<!-- - `/books` _(Optional)_ Utilise if you have a separate collection of book files somewhere and want to be able to access within the container. For the majority of users, this is not required and mounting`/calibre-library' is sufficient -->
283-
- `/app/calibre-web/gmail.json` _(Optional)_ - This is used to setup Calibre-Web and/or CWA with your gmail account for sending books via email. Follow the guide [here](https://github.com/janeczku/calibre-web/wiki/Setup-Mailserver#gmail) if this is something you're interested in but be warned it can be a very fiddly process, I would personally recommend a simple SMTP Server
283+
- `/app/calibre-web-automated/gmail.json` _(Optional)_ - This is used to setup Calibre-Web and/or CWA with your gmail account for sending books via email. Follow the guide [here](https://github.com/janeczku/calibre-web/wiki/Setup-Mailserver#gmail) if this is something you're interested in but be warned it can be a very fiddly process, I would personally recommend a simple SMTP Server
284284

285285
And just like that, Calibre-Web Automated should be up and running! **HOWEVER** to avoid potential problems and ensure maximum functionality,we recommend carrying out these [Post-Install Tasks Here](#post-install-tasks).
286286

changelogs/V3.1.0_changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Contributed by [netvyper](https://github.com/netvyper), you can now select multi
134134
- Auto-Send-to-Kindle 🛫⚙️
135135
- User setting to pick preferred accent colour of the Web UI 🎨
136136

137-
# Affliated Projects 👬
137+
# Affiliateddd Projects
138138

139139
- In the spirit of community, I also wanted to give a shout out to some really great affiliate projects made by members of our community!
140140
- As well as being featured here in the release, affiliated projects will now also be prominently feature on the CWA GitHub page to drive as much traffic & enthusiasm to them as possible

cps/MyLoginManager.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
4+
# Copyright (C) 2018-2019 OzzieIsaacs, cervinko, jkrehm, bodybybuddha, ok11,
5+
# andy29485, idalin, Kyosfonica, wuqi, Kennyl, lemmsh,
6+
# falgh1, grunjol, csitko, ytils, xybydy, trasba, vrabe,
7+
# ruben-herold, marblepebble, JackED42, SiphonSquirrel,
8+
# apetresc, nanu-c, mutschler, GammaC0de, vuolter
9+
#
10+
# This program is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation, either version 3 of the License, or
13+
# (at your option) any later version.
14+
#
15+
# This program is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
#
20+
# You should have received a copy of the GNU General Public License
21+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
23+
from .cw_login import LoginManager
24+
from flask import session
25+
26+
27+
class MyLoginManager(LoginManager):
28+
def _session_protection_failed(self):
29+
sess = session._get_current_object()
30+
ident = self._session_identifier_generator()
31+
if(sess and not (len(sess) == 1
32+
and sess.get('csrf_token', None))) and ident != sess.get('_id', None):
33+
return super(). _session_protection_failed()
34+
return False
35+
36+
37+

0 commit comments

Comments
 (0)