aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/archive2
-rwxr-xr-xbin/assemble2
-rwxr-xr-xbin/compile-book58
-rwxr-xr-xbin/compile-notes35
4 files changed, 95 insertions, 2 deletions
diff --git a/bin/archive b/bin/archive
index 8949268..ef77b9d 100755
--- a/bin/archive
+++ b/bin/archive
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
# Archiver
#
diff --git a/bin/assemble b/bin/assemble
index 3b5b287..04ae785 100755
--- a/bin/assemble
+++ b/bin/assemble
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
# Assembler
#
diff --git a/bin/compile-book b/bin/compile-book
new file mode 100755
index 0000000..42f7f67
--- /dev/null
+++ b/bin/compile-book
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+#
+# Book compiler
+#
+
+# Parameters
+BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`"
+DIRNAME="`dirname $0`"
+BASEDIR="$DIRNAME/.."
+OUTPUT="${1:-book}"
+REVISION="$2"
+DATE="$3"
+
+# Remove any dangling output files
+rm -f $OUTPUT.md $OUTPUT.Rmd
+
+# Bookup config
+cat _bookup.yml >> $OUTPUT.md ; echo "" >> $OUTPUT.md
+
+# Bibliography
+cat _biblio.yml >> $OUTPUT.md ; echo "" >> $OUTPUT.md
+
+# YAML headers
+for file in $BASEDIR/structure/00*.yml; do
+ cat $file >> $OUTPUT.md
+ echo "---" >> $OUTPUT.md
+done
+
+# Markdown headers
+for file in $BASEDIR/structure/00*.md; do
+ cat $file >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+done
+
+# Sections
+find content/sections -type f | grep '\.md$' | sort | while read file; do
+ cat $file >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+ cat $BASEDIR/templates/references.md >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+done
+
+# Footers
+for file in $BASEDIR/structure/99*.md; do
+ cat $file >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+done
+
+# Revision information
+sed -i -e "s|%%revision%%|$REVISION|g" -e "s|%%date%%|$DATE|g" $OUTPUT.md
+
+# Post-processing
+if [ -e "snippets/terminology.sed" ]; then
+ sed -i -f snippets/terminology.sed $OUTPUT.md
+fi
+
+# Symlink as a Bookdown source
+ln -sf $OUTPUT.md $OUTPUT.Rmd
diff --git a/bin/compile-notes b/bin/compile-notes
new file mode 100755
index 0000000..1e55dcc
--- /dev/null
+++ b/bin/compile-notes
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+#
+# Book compiler
+#
+
+# Parameters
+BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`"
+DIRNAME="`dirname $0`"
+BASEDIR="$DIRNAME/.."
+OUTPUT="${1:-notes}"
+REVISION="$2"
+DATE="$3"
+
+# Remove any dangling output files
+rm -f $OUTPUT.md
+
+# Content
+find content/notes -type f | grep '\.md$' | sort | while read file; do
+ cat $file >> $OUTPUT.md
+ echo "" >> $OUTPUT.md
+done
+
+# Bibliography section
+echo "# Bibliografia" >> $OUTPUT.md
+
+# Revision information
+sed -i -e "s|%%revision%%|$REVISION|g" -e "s|%%date%%|$REVISION|g" $OUTPUT.md
+
+# Post-processing
+if [ -e "snippets/terminology.sed" ]; then
+ sed -i -f snippets/terminology.sed $OUTPUT.md
+fi
+
+# Symlink as a Bookdown source
+ln -s $OUTPUT.md notes.Rmd