diff --git a/.gitignore b/.gitignore index 817c5458..8c911510 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ www/manual/* config/apache/htpasswd-standardebooks.org config/php/fpm/standardebooks.org-secrets.ini www/bulk-downloads/*/ +.venv diff --git a/README.md b/README.md index 8f3ac87c..c29e9233 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ PHP 8+ is required. ```shell # Install Apache, PHP, PHP-FPM, and various other dependencies. -sudo apt install -y git composer php-fpm php-cli php-gd php-xml php-apcu php-mbstring php-intl php-curl php-zip php-mysql apache2 apache2-utils libfcgi0ldbl task-spooler ipv6calc mariadb-server attr libapache2-mod-xsendfile libimage-exiftool-perl +sudo apt install -y git composer php-fpm php-cli php-gd php-xml php-apcu php-mbstring php-intl php-curl php-zip php-mysql apache2 apache2-utils libfcgi0ldbl task-spooler ipv6calc mariadb-server attr libapache2-mod-xsendfile libimage-exiftool-perl librsvg2-bin task-spooler attr # Create the site root and logs root and clone this repo into it. sudo mkdir /standardebooks.org/ @@ -19,6 +19,12 @@ git clone https://github.com/standardebooks/web/ cd /standardebooks.org/web/ composer install +# Install the SE toolset as a library in `.venv` so we can use it in some scripts. +python3 -m venv .venv +source .venv/bin/activate +pip3 install standardebooks +deactivate + # Add standardebooks.test to your hosts file. echo -e "127.0.0.1\tstandardebooks.test" | sudo tee -a /etc/hosts @@ -43,33 +49,28 @@ sudo systemctl restart "php*-fpm.service" # Link MariaDB configuration. sudo ln -s /standardebooks.org/web/config/mariadb/99-se.cnf /etc/mysql/mariadb.conf.d/ +sudo systemctl restart mariadb.service # Create and populate the SE database. mariadb < /standardebooks.org/web/config/sql/se.sql mariadb < /standardebooks.org/web/config/sql/users.sql mariadb se < /standardebooks.org/web/config/sql/se/*.sql + +# Create users and groups. +sudo useradd se +sudo groupadd committers +sudo groupadd se-secrets +sudo usermod --append --groups committers,se-secrets se +sudo usermod --append --groups se-secrets www-data ``` If everything went well you should now be able to open your web browser and visit `https://standardebooks.test`. However, you won’t see any ebooks if you visit `https://standardebooks.test/ebooks`. To install some ebooks, first you have to clone their source from GitHub, then deploy them to your local website using the `./scripts/deploy-ebook-to-www` script: ```shell -# First, install the SE toolset, which will make the `se build` command-line executable available to the `deploy-ebook-to-www` script: -# https://standardebooks.org/tools - -# Install the SE toolset as a library so we can use it in some automated scripts. -pip install standardebooks - -# The `se` command must be in your $PATH, but installing it via `pip` might not do that automatically. -# If `which se` doesn't say anything, then either add the `pip` installation of the `se` executable to your $PATH manually, -# or install it again using `pipx`; this will create a duplicate installation, -# but it will also install it in your $PATH for you: -pipx install standardebooks - -# Once the toolset is installed and in your $PATH, clone a book and deploy it to your local SE site: mkdir /standardebooks.org/ebooks/ cd /standardebooks.org/ebooks/ git clone --bare https://github.com/standardebooks/david-lindsay_a-voyage-to-arcturus -/standardebooks.org/web/scripts/deploy-ebook-to-www david-lindsay_a-voyage-to-arcturus.git +/standardebooks.org/web/scripts/deploy-ebook-to-www /standardebooks.org/ebooks/david-lindsay_a-voyage-to-arcturus.git ``` If everything went well, `https://standardebooks.test/ebooks` will show the one ebook you deployed. @@ -126,7 +127,7 @@ This repository includes [PHPStan](https://github.com/phpstan/phpstan) to static To run PHPStan, execute: ```shell -$> /vendor/bin/phpstan analyse -c /config/phpstan/phpstan.neon +/vendor/phpstan/phpstan/phpstan analyze --configuration=/config/phpstan/phpstan.neon ``` If run successfully, it should output `[OK] No errors`. @@ -139,7 +140,7 @@ Before submitting design contributions, please discuss them with the Standard Eb ### Main website -- Creating a favicon +- Creating a favicon. - Creating a search bar for the SE Manual of Style. diff --git a/scripts/deploy-ebook-to-www b/scripts/deploy-ebook-to-www index e942b47e..5c0e751b 100755 --- a/scripts/deploy-ebook-to-www +++ b/scripts/deploy-ebook-to-www @@ -149,6 +149,10 @@ if ! [ -f "${scriptsDir}"/generate-bulk-downloads ]; then die "\"${scriptsDir}\"/generate-bulk-downloads\" is not a file or could not be found." fi +if ! [ -f "${scriptsDir}/../.venv/bin/activate" ]; then + die "\"${scriptsDir}\"/../.venv/bin/activate\" is not a file or could not be found. Make sure you have installed the \`standardebooks\` package into a Python virtual environment." +fi + mkdir -p "${webRoot}"/images/covers/ for dir in "$@" @@ -232,8 +236,8 @@ do # Build the hero image for individual ebook pages. # Resize and crop the image to 2156 width, 720 height, and starting at the coords 0,1078. - convert -resize "1318" -crop "1318x439+0+659" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB -interlace JPEG "${imgWorkDir}/${urlSafeIdentifier}.jpg" "${imgWorkDir}/${urlSafeIdentifier}-hero.jpg" - convert -resize "2636" -crop "2636x860+0+1318" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB -interlace JPEG "${imgWorkDir}/${urlSafeIdentifier}.jpg" "${imgWorkDir}/${urlSafeIdentifier}-hero@2x.jpg" + convert -resize "1318" -crop "1318x439+0+659" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB "${imgWorkDir}/${urlSafeIdentifier}.jpg" "${imgWorkDir}/${urlSafeIdentifier}-hero.jpg" + convert -resize "2636" -crop "2636x860+0+1318" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB "${imgWorkDir}/${urlSafeIdentifier}.jpg" "${imgWorkDir}/${urlSafeIdentifier}-hero@2x.jpg" "${scriptsDir}"/cavif --quiet --quality 50 "${imgWorkDir}/${urlSafeIdentifier}-hero.jpg" -o "${imgWorkDir}/${urlSafeIdentifier}-hero.avif" "${scriptsDir}"/cavif --quiet --quality 50 "${imgWorkDir}/${urlSafeIdentifier}-hero@2x.jpg" -o "${imgWorkDir}/${urlSafeIdentifier}-hero@2x.avif" @@ -250,8 +254,8 @@ do # So, we use `rsvg-convert` to write a png, then `convert` to convert and compress to jpg. rsvg-convert --width 242 --keep-aspect-ratio --output "${imgWorkDir}/${urlSafeIdentifier}.png" "${imgWorkDir}/${urlSafeIdentifier}.svg" rsvg-convert --width 484 --keep-aspect-ratio --output "${imgWorkDir}/${urlSafeIdentifier}@2x.png" "${imgWorkDir}/${urlSafeIdentifier}.svg" - convert -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB -interlace JPEG "${imgWorkDir}/${urlSafeIdentifier}.png" "${imgWorkDir}/${urlSafeIdentifier}-cover.jpg" - convert -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB -interlace JPEG "${imgWorkDir}/${urlSafeIdentifier}@2x.png" "${imgWorkDir}/${urlSafeIdentifier}-cover@2x.jpg" + convert -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB "${imgWorkDir}/${urlSafeIdentifier}.png" "${imgWorkDir}/${urlSafeIdentifier}-cover.jpg" + convert -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB "${imgWorkDir}/${urlSafeIdentifier}@2x.png" "${imgWorkDir}/${urlSafeIdentifier}-cover@2x.jpg" "${scriptsDir}"/cavif --quiet --quality 50 "${imgWorkDir}/${urlSafeIdentifier}-cover.jpg" -o "${imgWorkDir}/${urlSafeIdentifier}-cover.avif" "${scriptsDir}"/cavif --quiet --quality 50 "${imgWorkDir}/${urlSafeIdentifier}-cover@2x.jpg" -o "${imgWorkDir}/${urlSafeIdentifier}-cover@2x.avif" @@ -292,8 +296,8 @@ do fi # Build distributable covers. - convert -resize "1400" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB -interlace JPEG "${workDir}/src/epub/images/cover.svg" ""${workDir}"/downloads/cover.jpg" - convert -resize "350" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB -interlace JPEG "${workDir}/src/epub/images/cover.svg" ""${workDir}"/downloads/cover-thumbnail.jpg" + convert -resize "1400" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB "${workDir}/src/epub/images/cover.svg" ""${workDir}"/downloads/cover.jpg" + convert -resize "350" -sampling-factor 4:2:0 -strip -quality 80 -colorspace RGB "${workDir}/src/epub/images/cover.svg" ""${workDir}"/downloads/cover-thumbnail.jpg" if [ "${verbose}" = "true" ]; then printf "Done.\n" @@ -370,7 +374,9 @@ do sed --in-place --regexp-extended "s|\s*\-epub\-[^;]+?;||g" "${workDir}"/src/epub/css/*.css # Add a chapter navigation footer to each page. + source "${scriptsDir}/../.venv/bin/activate" "${scriptsDir}"/inject-chapter-navigation-footer "${workDir}" "${bookUrl}" + deactivate # Adjust sponsored links in the colophon. sed --in-place 's|