3 # Pull in global dependencies.
7 title_file="$metadata_dir"/title
8 redo-ifchange "$title_file"
9 template_file="${metadata_dir}"/index.tmpl
10 redo-ifchange "$template_file"
13 title=$(read_and_escape_file "$title_file" | head -1 | prep_sed)
15 # Generate link list entries.
16 tmp_snippets_dir=.tmp_index_snippets
17 mkdir -p "$tmp_snippets_dir"
18 for file in ./*.rst ./*.md; do
19 if [ -e "$file" ]; then
20 uuid_file="${metadata_dir}/${file%.*}.uuid"
21 redo-ifchange "$uuid_file"
22 published=`stat -c%y "${uuid_file}"`
23 published_unix=$(date -u "+%s%N" -d "${published}")
24 snippet_file="${metadata_dir}/${file%.*}.index_snippet"
25 redo-ifchange "$snippet_file"
26 ln -s "$srcdir/$snippet_file" "./${tmp_snippets_dir}/${published_unix}"
31 for file in ./${tmp_snippets_dir}/*; do
32 if [ -e "$file" ]; then
33 touch ./${tmp_snippets_dir}/list
34 cat "$file" ./${tmp_snippets_dir}/list > ./${tmp_snippets_dir}/tmp
35 mv ./${tmp_snippets_dir}/tmp ./${tmp_snippets_dir}/list
38 if [ -e "./${tmp_snippets_dir}/list" ]; then
39 list=$(cat ./${tmp_snippets_dir}/list | prep_sed)
41 rm -rf "${tmp_snippets_dir}"
43 # Put data into template.
44 template=$(cat "$template_file")
45 printf "%s" "$template" | \
46 sed 's/%TITLE%/'"$title"'/g' | \
47 sed 's/%LIST%/'"$list"'/g' | \