mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 02:46:46 -04:00
Add --last-push-hash option to deploy-ebook-to-www script to decide whether to rebuild the cover images/actual ebook
This commit is contained in:
parent
27f7ce9334
commit
73297adbf7
1 changed files with 61 additions and 31 deletions
|
@ -6,12 +6,14 @@ DESCRIPTION
|
|||
Deploy a Standard Ebook source repository to the web.
|
||||
|
||||
USAGE
|
||||
deploy-ebook-to-www [-v,--verbose] [-g,--group GROUP] [--webroot WEBROOT] [--weburl WEBURL] [--no-images] DIRECTORY [DIRECTORY...]
|
||||
deploy-ebook-to-www [-v,--verbose] [-g,--group GROUP] [--webroot WEBROOT] [--weburl WEBURL] [--no-images] [-l,--last-push-hash HASH] DIRECTORY [DIRECTORY...]
|
||||
DIRECTORY is a bare source repository.
|
||||
GROUP is a groupname. Defaults to "se".
|
||||
WEBROOT is the path to your webroot. Defaults to "/standardebooks.org".
|
||||
WEBURL is the URL the website is served on. Defaults to "https://standardebooks.org".
|
||||
|
||||
With --last-push-hash, check the repo head against HASH to see if the cover image or ebook source changed, which will determine if cover thumbnails get re-generated or the ebook gets re-built.
|
||||
|
||||
With --no-images, do not create cover thumbnails or hero images for the web.
|
||||
EOF
|
||||
exit
|
||||
|
@ -22,9 +24,11 @@ require(){ command -v "$1" > /dev/null 2>&1 || { suggestion=""; if [ -n "$2" ];
|
|||
|
||||
verbose="false"
|
||||
images="true"
|
||||
build="true"
|
||||
group="se"
|
||||
webRoot="/standardebooks.org/web"
|
||||
webUrl="https://standardebooks.org"
|
||||
lastPushHash=""
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
usage
|
||||
|
@ -53,6 +57,11 @@ while [ $# -gt 0 ]; do
|
|||
webUrl="$2"
|
||||
shift 2
|
||||
;;
|
||||
-l|--last-push-hash)
|
||||
[ -n "$2" ] || die "Last commit hash can’t be empty."
|
||||
lastPushHash="$2"
|
||||
shift 2
|
||||
;;
|
||||
--no-images)
|
||||
images="false"
|
||||
shift 1
|
||||
|
@ -124,6 +133,25 @@ do
|
|||
continue
|
||||
fi
|
||||
|
||||
if [ "${lastPushHash}" != "" ]; then
|
||||
# We were passed the hash of the last push before this one.
|
||||
# Check to see if the cover image changed, to decide if we want to rebuild the cover image thumbnail/hero
|
||||
diff=$(git diff "${lastPushHash}" HEAD)
|
||||
|
||||
if [[ "${diff}" =~ diff\ --git\ a/images/cover.jpg ]] || [[ "${diff}" =~ diff\ --git\ a/images/cover.svg ]]; then
|
||||
images="true"
|
||||
else
|
||||
images="false"
|
||||
fi
|
||||
|
||||
# Check to see if the actual ebook changed, to decide if we want to build
|
||||
if [[ "${diff}" =~ diff\ --git\ a/src/ ]]; then
|
||||
build="true"
|
||||
else
|
||||
build="false"
|
||||
fi
|
||||
fi
|
||||
|
||||
webDir=$(git show HEAD:src/epub/content.opf | grep --only-matching --extended-regexp "<dc:identifier id=\"uid\">url:https://standardebooks.org/ebooks/[^<]+<\/dc:identifier>" | sed --regexp-extended "s/<[^>]+?>//g" | sed --regexp-extended "s/^url:https:\/\/standardebooks.org\/ebooks\/?//")
|
||||
|
||||
if [ "${webDir}" = "" ]; then
|
||||
|
@ -183,6 +211,7 @@ do
|
|||
popd > /dev/null || die "Couldn't pop directory."
|
||||
fi
|
||||
|
||||
if [ "${build}" = "true" ]; then
|
||||
if [ "${verbose}" = "true" ]; then
|
||||
printf "Building ebook ... "
|
||||
fi
|
||||
|
@ -214,6 +243,7 @@ do
|
|||
|
||||
# Move contents of the work dir over
|
||||
mv "${workDir}"/* "${webDir}/"
|
||||
fi
|
||||
|
||||
if [ "${images}" = "true" ]; then
|
||||
# Move the cover images over
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue