Introduction
Introduction Statistics Contact Development Disclaimer Help
cleanup code a bit - static-site-scripts - static site generator shellscripts
git clone git://git.codemadness.org/static-site-scripts
Log
Files
Refs
README
LICENSE
---
commit 0da97548a31e9d61b1ff571ac5ada8ba0e4aff57
parent 7545fb3e22b322e60b84d22f2f1f44ceb26f9667
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 16 Dec 2013 20:54:55 +0100
cleanup code a bit
Signed-off-by: Hiltjo Posthuma <[email protected]>
Diffstat:
M generate.sh | 40 ++++++++++++++++++-----------…
1 file changed, 23 insertions(+), 17 deletions(-)
---
diff --git a/generate.sh b/generate.sh
@@ -36,20 +36,28 @@ loadconfig() {
fi
# load config: config is loaded here to be able to override above vari…
# (sfeedpath, sfeedfile, etc).
- if [ -r "$config" ]; then
- . "$config"
+ if [ -r "${config}" ]; then
+ . "${config}"
else
echo "$0 [configfile]" >&2
echo "" >&2
- echo "Configuration file \"$config\" does not exist or is not …
+ echo "Error: configuration file \"${config}\" does not exist o…
exit 1
fi
}
+# Default config options.
+markdown="smu" # default markdown processor.
+
# Read config file.
loadconfig "$1"
config="$1"
+if [ ! -d "${pagesdir}" ]; then
+ echo "Error: pages directory \"${pagesdir}\" not found." >&2
+ exit 1
+fi
+
# Try to make output dir.
mkdir -p "${outputdir}"
@@ -64,15 +72,16 @@ find "${pagesdir}" -name "*.sh" | while read -r page; do
done | sort -rn | while read -r ts meta; do # process in order of time descend…
pagename=$(basename "${meta}" ".sh")
page_metadata "${meta}"
- urlfull="${sitefullurl}/${url}"
- #url="${siterelurl}/${url}"
- if [ -f "${pagesdir}/${pagename}.html" ]; then
- filename="${pagesdir}/${pagename}.html"
- content=$(cat "${filename}")
- elif [ -f "${pagesdir}/${pagename}.md" ]; then
- # TODO: test markdown
- filename="${pagesdir}/${pagename}.md"
- content=$("${markdown}" "${filename}")
+ urlfull="${siteurlfull}/${url}"
+ filename=""
+ if [ "$content" = "" ]; then # content not set: try data from file.
+ if [ -f "${pagesdir}/${pagename}.html" ]; then
+ filename="${pagesdir}/${pagename}.html"
+ content=$(cat "${filename}")
+ elif [ -f "${pagesdir}/${pagename}.md" ]; then
+ filename="${pagesdir}/${pagename}.md"
+ content=$("${markdown}" "${filename}")
+ fi
fi
. "${layoutdir}/page/page.sh" > "${outputdir}/${pagename}.html"
. "${layoutdir}/index/indexitem.sh" >> "${outputdir}/index.html"
@@ -100,7 +109,7 @@ content=$(cat "${outputdir}/atom.xml")
cd "${outputdir}"
# Sitemap: urllist.txt
-find ./ -type f -name "*.html" | sort | sed 's@^./\(.*\)$@'${sitefullurl}'/\1@…
+find ./ -type f -name "*.html" | sort | sed 's@^./\(.*\)$@'${siteurlfull}'/\1@…
# Sitemap: sitemap.xml
(cat <<!
@@ -108,12 +117,9 @@ find ./ -type f -name "*.html" | sort | sed 's@^./\(.*\)$@…
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
!
-find ./ -type f -name "*.html" | sort | sed 's@^./\(.*\)$@<url><loc>'${siteful…
+find ./ -type f -name "*.html" | sort | sed 's@^./\(.*\)$@<url><loc>'${siteurl…
cat <<!
</urlset>
!
) > "sitemap.xml"
-
-# Restore current dir.
-cd "${basedir}"
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.