diff build.sh @ 11:9dca7035ab93

Generate index page for slides
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Fri, 31 Jan 2014 23:26:36 +0900
parents 455db4624bce
children daf59131cdb8
line wrap: on
line diff
--- a/build.sh	Fri Jan 31 22:58:46 2014 +0900
+++ b/build.sh	Fri Jan 31 23:26:36 2014 +0900
@@ -31,8 +31,12 @@
     ${build_command} build $1 -o `dirname $1` ${build_template_option}
 }
 
+find_sources() {
+    find "$(dirname $0)/${slide_root_dirname}" -name "${build_target_filename}"
+}
+
 build_slides() {
-    target_list=`find "$(dirname $0)/${slide_root_dirname}" -name "${build_target_filename}"`
+    target_list=`find_sources`
     for target in ${target_list}; do
         if need_build $target; then
             build $target
@@ -40,8 +44,23 @@
     done
 }
 
+build_index() {
+    rm -f ${index_source_name}
+    touch ${index_source_name}
+
+    slide_list=`find_sources`
+    for slide in ${slide_list}; do
+        title=`head -5 $slide | grep "title[ ]*:" | sed -e 's/^title[ ]*:[ ]*//'`
+        date=`basename $(dirname $slide)`
+        echo "* ${date} : [$title]($(slide_name_from_full_path $slide))" >> ${index_source_name}
+    done
+
+    kramdown ${index_source_name} --template "$(dirname $0)/${index_template_file}" > ${index_file_name}
+}
+
 
 # main
 
 command_check
 build_slides
+build_index