-
Notifications
You must be signed in to change notification settings - Fork 0
/
steilerPhoto
executable file
·87 lines (76 loc) · 2.68 KB
/
steilerPhoto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
ROOT_DIR=/home/FrankSteiler/steilerPhoto/
PROD_CONF="--config=_config.yml"
DEV_CONF="--config=_config.yml,_dev_config.yml"
main () {
CONF="$DEV_CONF"
if [ "$2" = "prod" ] || [ "$2" = "p" ] ; then
CONF="$PROD_CONF"
fi
if [ "$1" = "build" ] || [ "$1" = "b" ]; then
(cd $ROOT_DIR && bundle exec jekyll build $CONF)
elif [ "$1" = "serve" ] || [ "$1" = "s" ] ; then
(cd $ROOT_DIR && bundle exec jekyll serve $CONF)
elif [ "$1" = "deploy" ] || [ "$1" = "d" ] ; then
if [ "$2" = "prod" ] || [ "$2" = "p" ] ; then
(cd $ROOT_DIR ; rm -r _site ; bundle exec jekyll build $PROD_CONF && bundle exec jekyll deploy $PROD_CONF)
else
(cd $ROOT_DIR ; rm -r _site ; bundle exec jekyll build $PROD_CONF && bundle exec jekyll deploy $DEV_CONF)
fi
elif [ "$1" = "create" ] || [ "$1" = "c" ] ; then
create_post
exit 0
else
help
exit 0
fi
}
create_post () {
echo "Creating new blog post skeleton for steilerPhoto blog!"
echo
echo "Please input your blog post's title:"
read title
FILENAME="$(date +%Y-%m-%d)-$(echo -n "${title}" | sed -e 's/[^[:alnum:]]/_/g' | tr -s '_' | tr A-Z a-z)"
echo "Using the following file/path name:"
read -e -i "$FILENAME" -p "Please adjust if necessary: " FILENAME
IMAGE_PATH="_images/$FILENAME"
POST_PATH="_posts/${FILENAME}.md"
(
cd $ROOT_DIR
mkdir $IMAGE_PATH && echo "Created '$IMAGE_PATH' in '$(pwd)'"
> $POST_PATH
echo "---" >> $POST_PATH
echo "title: \"${title}\"" >> $POST_PATH
echo "layout: posts" >> $POST_PATH
echo "---" >> $POST_PATH
echo >> $POST_PATH
echo "Put your excerpt here" >> $POST_PATH
echo >> $POST_PATH
echo "<!--more-->" >> $POST_PATH
echo >> $POST_PATH
echo "Put the rest of your article here" >> $POST_PATH
echo "Created '$POST_PATH' in '$(pwd)'"
)
echo
echo "All prepared! Put your images into '$IMAGE_PATH' using 'XX-Your_Image_Title.jpg' and modify your blog post in '$POST_PATH'"
}
help () {
echo "Simple script to manipulate steilerPhoto blog"
echo
echo "Usage:"
echo " $0 build"
echo " $0 b Build the site"
echo
echo " $0 server"
echo " $0 s Server the site"
echo
echo " $0 deploy"
echo " $0 d Deploy the site (This always deploys a production render of the page into the dev or prod environment)"
echo
echo " $0 create"
echo " $0 c Create a new post"
echo
echo " If the second argument is 'prod' or 'p' the production configuration will be used"
}
main $@
exit -1