Last active
May 16, 2016 13:49
-
-
Save mrcotter/dbf6813fcdad4a34a2aa3fd69322a7ee to your computer and use it in GitHub Desktop.
Bash script that fixing errors and missing files when using Buster to generate static site for Ghost, generating sitemap as well
This file contains hidden or 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
#!/bin/bash | |
# remove previously generated site | |
echo -e "\033[0;32mRemove previousely generated site...\033[0m" | |
if [ -e ./static ]; then | |
cp static/README.md . | |
rm -rfv static/* | |
fi | |
# generate static site | |
echo -e "\033[0;32mGenerate your static site...\033[0m" | |
buster generate --domain=http://127.0.0.1:2368 | |
# Copy sitemap files | |
echo -e "\033[0;32mCopy sitemap files...\033[0m" | |
wget --convert-links --page-requisites --no-parent --directory-prefix static --no-host-directories --restrict-file-name=unix http://127.0.0.1:2368/sitemap.xsl | |
wget --convert-links --page-requisites --no-parent --directory-prefix static --no-host-directories --restrict-file-name=unix http://127.0.0.1:2368/sitemap.xml | |
wget --convert-links --page-requisites --no-parent --directory-prefix static --no-host-directories --restrict-file-name=unix http://localhost:2368/sitemap-pages.xml | |
wget --convert-links --page-requisites --no-parent --directory-prefix static --no-host-directories --restrict-file-name=unix http://localhost:2368/sitemap-posts.xml | |
wget --convert-links --page-requisites --no-parent --directory-prefix static --no-host-directories --restrict-file-name=unix http://localhost:2368/sitemap-authors.xml | |
wget --convert-links --page-requisites --no-parent --directory-prefix static --no-host-directories --restrict-file-name=unix http://localhost:2368/sitemap-tags.xml | |
# fix domain and other issues | |
echo -e "\033[0;32mPatching domain and other issues...\033[0m" | |
find static -name "*.html" -type f -exec sed -i 's|u=http://localhost:2368|u=https://www.your_site.com|g' '{}' \; | |
find static -name "*.html" -type f -exec sed -i 's|url=http://localhost:2368|url=https://www.your_site.com|g' '{}' \; | |
find static -name "*.html" -type f -exec sed -i 's|href="http://localhost:2368|href="https://www.your_site.com|g' '{}' \; | |
find static -name "*.html" -type f -exec sed -i 's|src="http://localhost:2368|src="https://www.your_site.com|g' '{}' \; | |
find static -name "*.html" -type f -exec sed -i 's|link>http://localhost:2368|link>https://www.your_site.com|g' '{}' \; | |
find static -name "*.html" -type f -exec sed -i 's|http://localhost:2368|https://www.your_site.com|g' '{}' \; | |
find static -name "*.html" -type f -exec sed -i 's|index.html#shareModal|#shareModal|g' '{}' \; | |
find static -name "*.html" -type f -exec sed -i 's|href="index.html#!|href="#!|g' '{}' \; | |
find static -name "*.xsl" -type f -exec sed -i 's|http://localhost:2368|https://www.your_site.com|g' '{}' \; | |
find static -name "*.xml" -type f -exec sed -i 's|href="//localhost:2368|href="https://www.your_site.com|g' '{}' \; | |
find static -name "*.xml" -type f -exec sed -i 's|loc>http://localhost:2368|loc>https://www.your_site.com|g' '{}' \; | |
# fix missing files | |
mv README.md static/ | |
cp -rv "/Path/to/missing/folder" "Path/to/destination/folder/in/static" | |
echo -e "\033[0;32mCommit and Sync to Git...\033[0m" | |
cd static | |
# Add changes to git | |
git add -A | |
# Commit changes | |
msg="rebuilding site `date`" | |
git commit -m "$msg" | |
# Push source and build repos | |
git push origin master | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment