changeset 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
files .hgignore build.sh config/definition.sh template/index.html.erb
diffstat 4 files changed, 38 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Jan 31 22:58:46 2014 +0900
+++ b/.hgignore	Fri Jan 31 23:26:36 2014 +0900
@@ -1,5 +1,8 @@
 syntax: glob
 
+index.md
+index.html
+
 *.js
 *.css
 *.html
--- 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
--- a/config/definition.sh	Fri Jan 31 22:58:46 2014 +0900
+++ b/config/definition.sh	Fri Jan 31 23:26:36 2014 +0900
@@ -12,3 +12,8 @@
 build_command="slideshow"
 build_template_option="-t shower"
 build_target_filename=${slide_name}
+
+# index definitions
+index_source_name="index.md"
+index_file_name="index.html"
+index_template_file="template/index.html.erb"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/template/index.html.erb	Fri Jan 31 23:26:36 2014 +0900
@@ -0,0 +1,10 @@
+<html>
+  <head>
+    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+    <title> slides for seminar </title>
+  </head>
+
+  <body>
+    <%= @body %>
+  </body>
+</html>