mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Add --no-build and --no-recompose options to ebook deploy script
This commit is contained in:
parent
200ea5407a
commit
d3c1382490
1 changed files with 53 additions and 25 deletions
|
@ -6,17 +6,30 @@ DESCRIPTION
|
||||||
Deploy a Standard Ebook source repository to the web.
|
Deploy a Standard Ebook source repository to the web.
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
deploy-ebook-to-www [-v,--verbose] [-g,--group GROUP] [--webroot WEBROOT] [--weburl WEBURL] [--no-images] [--no-epubcheck] [-l,--last-push-hash HASH] DIRECTORY [DIRECTORY...]
|
deploy-ebook-to-www [-v,--verbose] [-g,--group GROUP] [--webroot WEBROOT] [--weburl WEBURL] [--no-images] [--no-build] [--no-epubcheck] [--no-recompose] [-l,--last-push-hash HASH] DIRECTORY [DIRECTORY...]
|
||||||
DIRECTORY is a bare source repository.
|
DIRECTORY is a bare source repository.
|
||||||
GROUP is a groupname. Defaults to "se".
|
GROUP is a groupname. Defaults to "se".
|
||||||
WEBROOT is the path to your webroot. Defaults to "/standardebooks.org".
|
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".
|
WEBURL is the URL the website is served on. Defaults to "https://standardebooks.org".
|
||||||
|
|
||||||
With --no-epubcheck, run 'build' instead of 'build --check'.
|
The deploy process does three things:
|
||||||
|
|
||||||
|
1. Build distributable ebook files using 'se build'.
|
||||||
|
|
||||||
|
2. Build single-page and toc-based web-readable versions using 'se recompose-epub'.
|
||||||
|
|
||||||
|
3. Generate various images and thumbnails for web use.
|
||||||
|
|
||||||
|
With --no-images, do not create cover thumbnails or hero images for the web.
|
||||||
|
|
||||||
|
With --no-build, do not run 'se build' or 'se recompose' to create distributable ebook files or web-readable versions.
|
||||||
|
|
||||||
|
With --no-epubcheck, run 'se build' instead of 'se build --check'.
|
||||||
|
|
||||||
|
With --no-recompose, do not run 'se recompose-epub' to generate single-page output.
|
||||||
|
|
||||||
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 --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
|
EOF
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
@ -32,6 +45,7 @@ webRoot="/standardebooks.org/web"
|
||||||
webUrl="https://standardebooks.org"
|
webUrl="https://standardebooks.org"
|
||||||
lastPushHash=""
|
lastPushHash=""
|
||||||
epubcheck="true"
|
epubcheck="true"
|
||||||
|
recompose="true"
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
usage
|
usage
|
||||||
|
@ -73,6 +87,14 @@ while [ $# -gt 0 ]; do
|
||||||
epubcheck="false"
|
epubcheck="false"
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
--no-recompose)
|
||||||
|
recompose="false"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--no-build)
|
||||||
|
build="false"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
*) break ;;
|
*) break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -145,12 +167,15 @@ do
|
||||||
# Check to see if the cover image changed, to decide if we want to rebuild the cover image thumbnail/hero
|
# 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)
|
diff=$(git diff "${lastPushHash}" HEAD)
|
||||||
|
|
||||||
|
if [ "${images}" = "true" ]; then
|
||||||
if [[ "${diff}" =~ diff\ --git\ a/images/cover.jpg ]] || [[ "${diff}" =~ diff\ --git\ a/images/cover.svg ]]; then
|
if [[ "${diff}" =~ diff\ --git\ a/images/cover.jpg ]] || [[ "${diff}" =~ diff\ --git\ a/images/cover.svg ]]; then
|
||||||
images="true"
|
images="true"
|
||||||
else
|
else
|
||||||
images="false"
|
images="false"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${build}" = "true" ]; then
|
||||||
# Check to see if the actual ebook changed, to decide if we want to build
|
# Check to see if the actual ebook changed, to decide if we want to build
|
||||||
if [[ "${diff}" =~ diff\ --git\ a/src/ ]]; then
|
if [[ "${diff}" =~ diff\ --git\ a/src/ ]]; then
|
||||||
build="true"
|
build="true"
|
||||||
|
@ -158,6 +183,7 @@ do
|
||||||
build="false"
|
build="false"
|
||||||
fi
|
fi
|
||||||
fi
|
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\/?//")
|
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\/?//")
|
||||||
|
|
||||||
|
@ -249,17 +275,11 @@ do
|
||||||
modifiedDate=$(TZ=UTC git log --date=iso-strict-local -1 --pretty=tformat:"%cd" --abbrev-commit | sed "s/+00:00/Z/")
|
modifiedDate=$(TZ=UTC git log --date=iso-strict-local -1 --pretty=tformat:"%cd" --abbrev-commit | sed "s/+00:00/Z/")
|
||||||
sed --in-place --regexp-extended "s/<meta property=\"dcterms:modified\">.+?<\/meta>/<meta property=\"dcterms:modified\">${modifiedDate}<\/meta>/" "${workDir}/src/epub/content.opf"
|
sed --in-place --regexp-extended "s/<meta property=\"dcterms:modified\">.+?<\/meta>/<meta property=\"dcterms:modified\">${modifiedDate}<\/meta>/" "${workDir}/src/epub/content.opf"
|
||||||
|
|
||||||
# Delete the contents of the old webdir
|
if [ "${recompose}" = "true" ]; then
|
||||||
rm --preserve-root --recursive --force "${webDir}"
|
|
||||||
|
|
||||||
# Re-create the webdir
|
|
||||||
mkdir -p "${webDir}"
|
|
||||||
|
|
||||||
# Recompose the epub into a single file, but put it outside of the epub src for now so we don't stomp on it with the following sections.
|
# Recompose the epub into a single file, but put it outside of the epub src for now so we don't stomp on it with the following sections.
|
||||||
# We do this first because the tweaks below shouldn't apply to the single-page file
|
# We do this first because the tweaks below shouldn't apply to the single-page file
|
||||||
cp "${webRoot}/www/css/web.css" "${workDir}"/src/epub/css/
|
se recompose-epub --xhtml --output "${workDir}"/single-page.xhtml --extra-css-file="${webRoot}/www/css/web.css" "${workDir}"
|
||||||
se recompose-epub --xhtml --output "${workDir}"/single-page.xhtml "${workDir}"
|
fi
|
||||||
rm "${workDir}"/src/epub/css/web.css
|
|
||||||
|
|
||||||
# Make some compatibilty adjustments for the individual XHTML files
|
# Make some compatibilty adjustments for the individual XHTML files
|
||||||
|
|
||||||
|
@ -281,8 +301,16 @@ do
|
||||||
|
|
||||||
# Done adding compatibility!
|
# Done adding compatibility!
|
||||||
|
|
||||||
|
if [ "${recompose}" = "true" ]; then
|
||||||
# Move the single-page file back into the /src/epub/text/ folder
|
# Move the single-page file back into the /src/epub/text/ folder
|
||||||
mv "${workDir}"/single-page.xhtml "${workDir}"/src/epub/text/single-page.xhtml
|
mv "${workDir}"/single-page.xhtml "${workDir}"/src/epub/text/single-page.xhtml
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Delete the contents of the old webdir
|
||||||
|
rm --preserve-root --recursive --force "${webDir}"
|
||||||
|
|
||||||
|
# Re-create the webdir
|
||||||
|
mkdir -p "${webDir}"
|
||||||
|
|
||||||
# Move contents of the work dir over
|
# Move contents of the work dir over
|
||||||
mv "${workDir}"/* "${webDir}/"
|
mv "${workDir}"/* "${webDir}/"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue