paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 749b21e6c4854c9a6787ee5d65ca5915ac934d5c
parent 6c6da8652c4255c65801973b1c43b179e0e67233
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Thu, 28 Mar 2019 00:31:04 -0400

Make createpages.sh build files in sub-directories

Improve createpages.sh with the ability to create pages which exist in
sub-directories. Previously, it could only ever build pages in the root
of the pages/ directory. To facilitate website growth and better
organization, sub-directories will need to exist and createpages.sh will
have to build pages and place them in the appropriate directory of the
output.

Diffstat:
Mcreatepages.sh | 47++++++++++++++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/createpages.sh b/createpages.sh @@ -14,26 +14,44 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. -numpages=0 htmldir="public/html" - echo "Building $@..." for page in $@; do - if [[ "$page" != "" ]]; then - pagename=$(basename $page | cut -f 1 -d '.') - echo "=====Creating $pagename.html=====" + pagename=$(basename $page | cut -f 1 -d '.') + filepath=$(dirname $page) + checkpage=$(echo $filepath | cut -f 1 -d '/') + + # Stripts "pages" from the file path so files are saved in the root of + # $htmldir + if [[ "$filepath" == "pages" ]]; then + savepath="." + elif [[ "$checkpage" == "pages" ]]; then + savepath=$(echo ${filepath#$checkpage/}) + fi + + if [[ ! -d "$htmldir/$savepath" ]]; then + mkdir -p $htmldir/$savepath + mkdir -p build/$savepath + fi + + if [[ "$page" != "" && ! -d $page ]]; then + uppername=${pagename^} + echo "=====Creating $htmldir/$savepath/$pagename.html=====" + echo " Compiling page content..." - markdown pages/$pagename.md > build/$pagename-content.html + markdown $filepath/$pagename.md > build/$savepath/$pagename-content.html + echo " Constructing full page..." - > $htmldir/$pagename.html - cat build/header.html >> $htmldir/$pagename.html - cat build/$pagename-content.html >> $htmldir/$pagename.html - cat build/footer.html >> $htmldir/$pagename.html - uppername=${pagename^} - sed -i "s/<title>.*<\/title>/<title>paritybit.ca – $uppername<\/title>/" $htmldir/$pagename.html - ((numpages++)) - echo -e "=====Created $pagename.html=====\n" + > $htmldir/$savepath/$pagename.html + cat build/header.html >> $htmldir/$savepath/$pagename.html + cat build/$savepath/$pagename-content.html >> $htmldir/$savepath/$pagename.html + cat build/footer.html >> $htmldir/$savepath/$pagename.html + + sed -i "s/<title>.*<\/title>/<title>paritybit.ca – $uppername<\/title>/" \ + $htmldir/$savepath/$pagename.html + + echo -e "=====Created $htmldir/$savepath/$pagename.html=====\n" fi done @@ -44,4 +62,3 @@ if [[ $1 == '-i' ]]; then curl --data "input=`cat build/roll.css`" https://cssminifier.com/raw > \ public/css/roll.min.css fi -echo "Done"