Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to script to generate all image sizes
- Loading branch information
Showing
3 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
#!/bin/bash | ||
set -e | ||
cd /static | ||
rm -rf * | ||
mkdir content | ||
cp -R $GHOST_HOME/current/content/images content/ | ||
|
||
echo "Running gssg..." | ||
gssg --domain "http://127.0.0.1" --dest . --url "https://$GHOST_DOMAIN" | ||
|
||
echo "Download all sizes of images" | ||
cd /static/content/images | ||
sizes=( "w600" "w1000" "w2000" ) | ||
|
||
function getImage() { | ||
file=$1 | ||
for size in "${sizes[@]}"; do | ||
targetFile="/static/content/images/size/$size/$file" | ||
path=$(dirname $targetFile) | ||
mkdir -p $path | ||
if [ ! -f $targetFile ]; then | ||
echo "Getting: $targetFile" | ||
curl -f --silent -o $targetFile http://127.0.0.1/content/images/size/$size/$file | ||
else | ||
echo "Skipping: $targetFile" | ||
fi | ||
done | ||
} | ||
|
||
echo "Downloading images that have already been sized" | ||
cd /static/content/images | ||
for file in $(find size -type f -o -name "*.png"); do | ||
source=$(echo $file | sed 's,^[^/]*/,,' | sed 's,^[^/]*/,,') | ||
getImage $source | ||
done | ||
|
||
echo "Downloading images that have not already been sized" | ||
for file in $(find . -path ./size -prune -type f -o -name "*.png"); do | ||
source=$(echo $file | sed 's,^[^/]*/,,') | ||
getImage $source | ||
done | ||
|
||
echo "Static content generated!" | ||
echo "Uploading to gcs..." | ||
gsutil -m rsync -R . gs://$GHOST_DOMAIN | ||
cd /static | ||
gsutil -m rsync -d -c -R . gs://$GHOST_DOMAIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters