summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2013-07-14 10:47:47 (GMT)
committer Jaromil <jaromil@dyne.org>2013-07-14 10:47:47 (GMT)
commit20d220c5c6b742f9a60ebffd30ba36d665dea137 (patch)
tree935c13e532d34daaab07a7454f3906283565222f
parent5ddb43db1b561ee0f558023c40905b1b3544e312 (diff)
new renderer supports markdown files
-rwxr-xr-xrender74
1 files changed, 46 insertions, 28 deletions
diff --git a/render b/render
index 9454a8c..3bfd783 100755
--- a/render
+++ b/render
@@ -64,7 +64,7 @@ render_html() {
dst="pub/${1}"
- print -n "rendering $dst... "
+ act -n "rendering html: $dst... "
# TODO: check duplicates
# establish if we are rendering a section
@@ -85,8 +85,40 @@ render_html() {
print "done."
}
+render_markdown() {
+ src=`find views -type f -name "${1}.md"`
+
+ { test -r "${src}" } || {
+ print "${1} section not found";
+ return 1 }
+
+
+ dst="pub/${1%.*}"
+
+ act -n "rendering markdown: $dst... "
+ # TODO: check duplicates
+
+ # establish if we are rendering a section
+ if [[ ${sections[(i)$1]} -le ${#sections} ]]; then
+ sec=${1}
+ else
+ sec=`dirname $src`
+ sec=${sec[(ws:/:)2]}
+ fi
+ render_header > $dst
+
+ echo "<article>" >> $dst
+ cat ${src} | markdown >> $dst
+ echo "</article>" >> $dst
+
+ cat tmpl/footer.html >> $dst
+ print "done."
+
+
+}
+
read_meta() {
tmp=`awk '
@@ -195,25 +227,9 @@ ${nav_icon}&nbsp;&nbsp;${BRAND}
<ul class="nav">
EOF
-
-# # other sections
-# for sec in ${sections}; do
-# ssec=`basename $sec`
-# icon=""; nav_icon="&nbsp;"
-# nav_active=""
-# read_meta views/$ssec.html
-# { test "$icon" = "" } || {
-# nav_icon="<i class=\"icon-${icon}\"></i>" }
-# { test "$ssec" = "$active" } && {
-# nav_active=" class=\"active\"" }
-# cat <<EOF
-# <li${nav_active}><a href="${ssec}">${nav_icon}&nbsp;${ssec//_/ }</a></li>
-# EOF
-# done
-
unset active
- # complete navbar with static entries if present
+ # use the plain html navbar in tmpl/
{ test -r tmpl/navbar.html } && { cat tmpl/navbar.html }
cat <<EOF
@@ -229,19 +245,21 @@ EOF
render_html index
-act "${#sections} sections configured"
-
-if [ ${#sections} = 0 ]; then
- act "No sections configured"
-else
- for s in ${sections}; do
- render_section ${s}
- done
-fi
+# render all HTML views
+htmls=(`find views -type f -name '*.html'`)
+for h in $htmls; do
+ render_html `basename ${h%.*}`
+done
+# render all markdown views
+mds=(`find views -type f -name '*.md'`)
+for m in $mds; do
+ render_markdown `basename ${m%.*}`
+done
for m in `find views -mindepth 1 -type d `; do
+ act -n "publishing $m... "
rsync -r $m pub/
- notice "$m published"
+ print done
done
act "Website refreshed."