about summary refs log tree commit diff stats
path: root/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'trunk')
-rw-r--r--trunk/common-titles.head17
-rw-r--r--trunk/common-titles.sh21
-rw-r--r--trunk/first-lines.head17
-rw-r--r--trunk/first-lines.sh32
4 files changed, 76 insertions, 11 deletions
diff --git a/trunk/common-titles.head b/trunk/common-titles.head new file mode 100644 index 0000000..705647d --- /dev/null +++ b/trunk/common-titles.head
@@ -0,0 +1,17 @@
1---
2title: Autocento of the breakfast table
3id: common-titles
4subtitle: index of common titles
5genre: prose
6
7project:
8 title: About Autocento
9 class: meta
10 next:
11 - title: Index of first lines
12 link: first-lines
13 prev:
14 - title: About _Autocento_
15 link: about
16...
17
diff --git a/trunk/common-titles.sh b/trunk/common-titles.sh new file mode 100644 index 0000000..9bc0de8 --- /dev/null +++ b/trunk/common-titles.sh
@@ -0,0 +1,21 @@
1#!/bin/bash
2
3outFile="$1";
4header="$2";
5shift 2;
6glob="$@";
7
8echo -n "Compiling ${outFile}...";
9cat "$header" > $outFile;
10
11for file in $glob; do
12 # Copy title to $outFile & link
13 title="$(grep '^title:' "$file" | cut -d' ' -f2- | sed 's/"//g')";
14 if (( $RANDOM % 13 == 0 )); then
15 echo -n "| ";
16 else
17 echo -n " ";
18 fi
19 echo "[$title](${file%.*}.html)" >> "$outFile";
20done
21echo "Done.";
diff --git a/trunk/first-lines.head b/trunk/first-lines.head new file mode 100644 index 0000000..f73b410 --- /dev/null +++ b/trunk/first-lines.head
@@ -0,0 +1,17 @@
1---
2title: Autocento of the breakfast table
3id: first-lines
4subtitle: index of first lines
5genre: prose
6
7project:
8 title: About Autocento
9 class: meta
10 next:
11 - title: About _Autocento_
12 link: about
13 prev:
14 - title: Index of common titles
15 link: common-titles
16...
17
diff --git a/trunk/first-lines.sh b/trunk/first-lines.sh index 50b0e0c..37b7291 100644 --- a/trunk/first-lines.sh +++ b/trunk/first-lines.sh
@@ -1,17 +1,27 @@
1#!/bin/bash 1#!/bin/bash
2 2
3outFile=src/first-lines.txt 3outFile="$1";
4header="$2";
5shift 2;
6glob="$@";
4 7
5echo "" > $outFile 8firstLineOf() { # $1 = file
9 endOfYaml=$(sed -n '/^\.\.\.$/=' "$1")
10 tryLineNumber=$((endOfYaml + 1))
11 try=""
12 while [[ -z $try ]]; do
13 try=$(head -n $tryLineNumber "$1" | tail -n 1 |\
14 sed -e 's/^[|>] //' -e 's/[][]//g' -e 's/^#.*//' -e 's/^--.*//')
15 (( tryLineNumber += 1 ))
16 done
17 echo "$try"
18}
6 19
7for file in src/*.txt; do 20echo -n "Compiling ${outFile}..."
8 echo -n "Getting first line of $file .. " 21cat "$header" > $outFile
9 endOfYAML=$(sed -n '/^\.\.\.$/=' "$file")
10 firstLineNumber=$((endOfYAML + 2))
11 22
12 echo "$file: " >> $outFile 23for file in $glob; do
13 echo " $(head -n $firstLineNumber "$file" | tail -n 1)" >> $outFile 24 # Copy first line to $outFile & link
14 25 echo "[$(firstLineOf "$file")](${file%.*}.html)" >> $outFile
15 unset endOfYAML firstLineNumber
16 echo "Done."
17done 26done
27echo "Done."