Support for sub-pages, and metadata powered markdown files.

This commit is contained in:
Marco Cawthorne 2023-11-09 17:09:13 -08:00
parent eff7646d6b
commit c15e6400df
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 87 additions and 10 deletions

View File

@ -26,7 +26,15 @@ pagedump()
# always check for markdown first
if [ -f "$1.md" ]
then
# always check for markdown first
if [ -f "$1.yaml" ]
then
pandoc -t markdown --metadata-file "$1.yaml" --template "$1.md" | pandoc -t html
else
pandoc -t html -f markdown "$1.md"
fi
return
fi
fi
@ -166,7 +174,7 @@ make_news_header()
echo "</table>" >> "$2"
}
# arguments: site, page side, page, title
# arguments: site, page side, page, title, sub-page
site_button()
{
if [ "$2" = "news" ]
@ -179,7 +187,13 @@ site_button()
BTN_NAME="$3"
BTN_PAGE="$3"
fi
if [ "$5" = "" ]
then
BTN_OUT="_pb_$BTN_NAME"
else
BTN_OUT="_pb_$5_$BTN_NAME"
fi
if [ -f "$BTN_SEARCHPATH/$BTN_NAME.gif" ]
then
@ -202,7 +216,12 @@ site_button()
return
fi
echo "<a href=\"$BTN_PAGE.html\">&#8226; $4</a><br>"
if [ "$5" = "" ]
then
echo "<a href=\"$BTN_PAGE.html\"> $4</a><br>"
else
echo "<a href=\"$5_$BTN_PAGE.html\">&#8226; $4</a><br>"
fi
}
# arguments: site-name (folder inside ./sites)
@ -235,7 +254,7 @@ site_process()
# enumerate and list the right-aligned pages
if [ -d "./sites/$1/pages_right" ]
then
find ./sites/$1/pages_right -name title | sort | while read LINE
find ./sites/$1/pages_right -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@ -247,14 +266,22 @@ site_process()
fi
site_button "$1" "pages_right" "$ID_NAME" "$TITLE" >> "$TMP_PAGES_R"
#echo "<a href=\"$ID_NAME.html\">&#8226; $TITLE</a><br>" >> "$TMP_PAGES_R"
# a page may have sub-pages
find "./sites/$1/pages_right/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
do
SUBDIR=$(dirname "$SUBLINE")
SUBID_NAME=$(basename "$SUBDIR")
SUBTITLE=$(cat "$SUBDIR/title")
site_button "$1" "pages_right/$ID_NAME" "$SUBID_NAME" "$SUBTITLE" "$ID_NAME" >> "$TMP_PAGES_L"
done
done
fi
# enumerate and list the left-aligned pages
if [ -d "./sites/$1/pages_left" ]
then
find ./sites/$1/pages_left -name title | sort | while read LINE
find ./sites/$1/pages_left -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@ -266,7 +293,15 @@ site_process()
fi
site_button "$1" "pages_left" "$ID_NAME" "$TITLE" >> "$TMP_PAGES_L"
#echo "<a href=\"$ID_NAME.html\">&#8226; $TITLE</a><br>" >> "$TMP_PAGES_L"
# a page may have sub-pages
find "./sites/$1/pages_left/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
do
SUBDIR=$(dirname "$SUBLINE")
SUBID_NAME=$(basename "$SUBDIR")
SUBTITLE=$(cat "$SUBDIR/title")
site_button "$1" "pages_left/$ID_NAME" "$SUBID_NAME" "$SUBTITLE" "$ID_NAME" >> "$TMP_PAGES_L"
done
done
fi
@ -292,7 +327,7 @@ site_process()
# build right-aligned pages
if [ -d "./sites/$1/pages_right" ]
then
find ./sites/$1/pages_right -name title | sort | while read LINE
find ./sites/$1/pages_right -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@ -303,13 +338,27 @@ site_process()
html_start "$OUTFILE" "$TITLE" "$1"
pagedump "$DIR/content" >> "$OUTFILE"
html_end "$OUTFILE" "$1"
# handle sub-pages
find "./sites/$1/pages_right/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
do
SUBDIR=$(dirname "$SUBLINE")
SUBID_NAME=$(basename "$SUBDIR")
SUBTITLE=$(cat "$SUBDIR/title")
SUBOUTFILE="./out/$1/${ID_NAME}_${SUBID_NAME}.html"
# generate the individual news page
html_start "$SUBOUTFILE" "$TITLE - $SUBTITLE" "$1"
pagedump "$SUBDIR/content" >> "$SUBOUTFILE"
html_end "$SUBOUTFILE" "$1"
done
done
fi
# Build left-aligned pages
if [ -d "./sites/$1/pages_left" ]
then
find ./sites/$1/pages_left -name title | sort | while read LINE
find ./sites/$1/pages_left -maxdepth 2 -name title | sort | while read LINE
do
DIR=$(dirname "$LINE")
ID_NAME=$(basename "$DIR")
@ -320,6 +369,20 @@ site_process()
html_start "$OUTFILE" "$TITLE" "$1"
pagedump "$DIR/content" >> "$OUTFILE"
html_end "$OUTFILE" "$1"
# handle sub-pages
find "./sites/$1/pages_left/$ID_NAME/" -mindepth 2 -maxdepth 2 -name title | sort | while read SUBLINE
do
SUBDIR=$(dirname "$SUBLINE")
SUBID_NAME=$(basename "$SUBDIR")
SUBTITLE=$(cat "$SUBDIR/title")
SUBOUTFILE="./out/$1/${ID_NAME}_${SUBID_NAME}.html"
# generate the individual news page
html_start "$SUBOUTFILE" "$TITLE - $SUBTITLE" "$1"
pagedump "$SUBDIR/content" >> "$SUBOUTFILE"
html_end "$SUBOUTFILE" "$1"
done
done
fi

View File

@ -51,6 +51,20 @@ file inside your page directory. Name it the same thing as your page.
Same can be done for the 'News' button, just name it 'news' and place it
inside the `./sites/???/news/` directory with the file format of your choosing.
# Sub-pages
Pages can have sub-pages. Simply have another page-styled directory within
a page directory. For example, `./sites/???/pages_left/games/files/` containing both
a `title` and a `content.md` file.
# Metadata within pages
You can use metadata within Markdown pages. If your `content.md` has a `content.yaml` file
alongside it, it will be used within the page accordingly. Please see this page for detailed
information:
https://pandoc.org/MANUAL.html#extension-yaml_metadata_block
# LICENSE
Licensed under the ISC license. Everything in here was written by