about summary refs log tree commit diff stats
path: root/trunk/backlink.sh
diff options
context:
space:
mode:
authorCase Duckworth2015-04-01 23:16:18 -0700
committerCase Duckworth2015-04-01 23:20:18 -0700
commitd161be120c22faf222ec15ca618ee367e4d56575 (patch)
treeb945633e680e5682a967f63bad88a2b262b4d4c6 /trunk/backlink.sh
parentMerge branch 'gh-pages' of https://github.com/duckwork/autocento into gh-pages (diff)
downloadautocento-d161be120c22faf222ec15ca618ee367e4d56575.tar.gz
autocento-d161be120c22faf222ec15ca618ee367e4d56575.zip
Refactor makefile; Add hapax preprocessor
Diffstat (limited to 'trunk/backlink.sh')
-rw-r--r--trunk/backlink.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/trunk/backlink.sh b/trunk/backlink.sh new file mode 100644 index 0000000..7d143a8 --- /dev/null +++ b/trunk/backlink.sh
@@ -0,0 +1,29 @@
1#!/bin/bash
2
3# Command-line variables
4searchQuery="$1"; # .html file to backlink
5outFile="$2"; # .back file to create
6headerFile="$3"; # header information file
7shift 3;
8glob="$@"; # where to search for backlinks
9
10# Find backlinkers
11echo -n "Back-linking \"$searchQuery\""
12cat "$headerFile" > "$outFile";
13grep -ql "$searchQuery" $glob >> "$outFile";
14
15# Change title of $outFile
16inText="`basename $searchQuery .html`.txt";
17title=`grep '^title:' "$inText" | cut -d' ' -f2-`;
18sed -i "s/_TITLE_/$title/" "$outFile";
19echo -n "."
20
21# Link to backlinks
22for file in `grep '.html' "$outFile"`; do
23 fText="`basename $file .html`.txt";
24 title=`grep '^title:' $fText | cut -d' ' -f2-`;
25 sed -i "s/^$file$/- [$title](&)/" "$outFile";
26 echo -n "."
27done
28
29echo "Done."