|
|
@ -1,28 +1,38 @@
|
|
|
|
#!/bin/bash
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
#TODO: Figure out how to prevent pandoc from exporting the YAML header of the .md files (probably set up a temp dir).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BASE_PATH="/home/aadhavan/Programming/Bash/sitegen"
|
|
|
|
BASE_PATH="/home/aadhavan/Programming/Bash/sitegen"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_for_dirs() {
|
|
|
|
check_for_dirs() {
|
|
|
|
if [ ! -d "${BASE_PATH}/source" ]; then
|
|
|
|
if [ ! -d "${BASE_PATH}/source" ]; then
|
|
|
|
echo "'source' folder does not exist."
|
|
|
|
echo "ERROR: 'source' folder does not exist. Your content is sourced from this folder."
|
|
|
|
exit
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -d "${BASE_PATH}/output" ]; then
|
|
|
|
if [ ! -d "${BASE_PATH}/output" ]; then
|
|
|
|
echo "'output' folder does not exist."
|
|
|
|
mkdir "${BASE_PATH}/output"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ -d "${BASE_PATH}/temp" ]; then
|
|
|
|
|
|
|
|
echo "ERROR: You have an existing 'temp' folder. Please delete this folder, and run the script again."
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "${BASE_PATH}/header.html" ]; then
|
|
|
|
|
|
|
|
echo "ERROR: You do not have a header.html file. This file is used as a global header. Please create this file, and run the script again."
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "${BASE_PATH}/footer.html" ]; then
|
|
|
|
|
|
|
|
echo "ERROR: You do not have a footer.html file. This file is used as a global footer. Please create this file, and run the script again."
|
|
|
|
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Check if temp dir exists, if it does, throw an error and exit.
|
|
|
|
|
|
|
|
# Check if header and footer.html exist.
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup_temp_dir() {
|
|
|
|
setup_temp_dir() {
|
|
|
|
# Check if 'temp' already exists
|
|
|
|
# Check if 'temp' already exists
|
|
|
|
mkdir $BASE_PATH/temp
|
|
|
|
mkdir "${BASE_PATH}/temp"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setup_output_dir() {
|
|
|
|
setup_output_dir() {
|
|
|
@ -97,8 +107,14 @@ md_to_html() {
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clean_up() {
|
|
|
|
|
|
|
|
rm -r ${BASE_PATH}/temp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_for_dirs
|
|
|
|
check_for_dirs
|
|
|
|
setup_temp_dir
|
|
|
|
setup_temp_dir
|
|
|
|
setup_output_dir
|
|
|
|
setup_output_dir
|
|
|
|
del_files_in_output
|
|
|
|
del_files_in_output
|
|
|
|
md_to_html
|
|
|
|
md_to_html
|
|
|
|
|
|
|
|
clean_up
|
|
|
|