aboutsummaryrefslogtreecommitdiff
path: root/md
diff options
context:
space:
mode:
authorthinkpadmaster <a.scerba02@gmail.com>2023-07-20 20:46:25 -0500
committerAlex Scerba <alex@scerba.org>2024-10-29 13:19:56 -0400
commit7d27031ee8c45f88bf56b1cbc082db58b40a9a1c (patch)
treefcbbe7b8189e75b7f3b51d529d2d3c67ee2f6422 /md
parent8a825553449e6d48b89f864c261fccc97ac39962 (diff)
Finalize deployment script
Diffstat (limited to 'md')
-rwxr-xr-xmd/postDeploy.sh47
1 files changed, 37 insertions, 10 deletions
diff --git a/md/postDeploy.sh b/md/postDeploy.sh
index 3fb1412..1eae836 100755
--- a/md/postDeploy.sh
+++ b/md/postDeploy.sh
@@ -3,22 +3,49 @@
# Usage: ./postDeploy.sh title_of_post.md type
# type can be 'blog' or 'projects' in my case
-readonly POSTS_DIR="../html/$2"
-readonly POST_TEMP="POST_TEMPLATE.tmpl.html"
+if [ -z $3 ]
+then
+ base_dir="/home/ascerba/go/alexscerba.com"
+else
+ base_dir="$3"
+fi
+
+readonly posts_dir="$base_dir/html/$2"
+readonly post_temp="$base_dir/md/POST_TEMPLATE.tmpl.html"
post=$(basename "$1" .md)
-echo "converting $post to HTML"
-echo "Outputting at '$POSTS_DIR/$post.tmpl.html'"
+echo "converting $1 to HTML"
+echo "Outputting at '$posts_dir/$post.tmpl.html'"
# pandoc for md to html
-pandoc -f markdown-auto_identifiers -t html --template=$POST_TEMP --wrap=none -o "$POSTS_DIR/$post.tmpl.html" "$post".md
+pandoc -f markdown-auto_identifiers -t html --template=$post_temp --wrap=none -o "$posts_dir/$post.tmpl.html" "$1"
# # adds in filename to path no longer needed
-# sed -i "s/posts\//posts\/$post/" "$POSTS_DIR/$post.tmpl.html"
+sed -i "s;src=\";src=\"/static/media/$post/;" "$posts_dir/$post.tmpl.html"
+
+# Pull images from <p> tags
+sed -i "s;<p><img;<img;" "$posts_dir/$post.tmpl.html"
+sed -i "s;/></p>;/>;" "$posts_dir/$post.tmpl.html"
# makes http & https links have target _blank and rel noopener noreferrer
-perl -i -0pe 's/(<\W*a\W*[^>]*href=)(["'"'"']http[s]?:\/\/[^"'"'"'>]*["'"'"'])([^>]*>)/$1$2 target="_blank" rel="noopener noreferrer"$3/g' "$POSTS_DIR/$post.tmpl.html"
+perl -i -0pe 's/(<\W*a\W*[^>]*href=)(["'"'"']http[s]?:\/\/[^"'"'"'>]*["'"'"'])([^>]*>)/$1$2 target="_blank" rel="noopener noreferrer"$3/g' "$posts_dir/$post.tmpl.html"
+
+
+echo "Converting and deploying images:"
+mkdir "$base_dir/static/media/$post"
+media_dir="$base_dir/static/media/$post"
+for image in $(ls "$base_dir/md/staged/images")
+do
+ echo "Converting $image and deploying at $media_dir/$image"
+ convert $base_dir/md/staged/images/$image -resize 1280x1280\> $media_dir/$image
+done
+for media in $(ls "$base_dir/md/staged/media")
+do
+ echo "Copying $media to $media_dir/$media"
+ cp $base_dir/md/staged/media/$media $media_dir/$media
+done
-echo "moving $1 to 'deployed' folder"
-mkdir -p "deployed/$post"
-mv $1 "deployed/$post/$1" \ No newline at end of file
+echo "Moving to 'deployed' folder"
+mv -vT "$base_dir/md/staged" "$base_dir/md/deployed/$post"
+mkdir "$base_dir/md/staged"
+echo "Post deploy complete!" \ No newline at end of file