about summary refs log tree commit diff stats
path: root/trunk/backlink.sh
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/backlink.sh')
-rw-r--r--trunk/backlink.sh17
1 files changed, 14 insertions, 3 deletions
diff --git a/trunk/backlink.sh b/trunk/backlink.sh index 7d143a8..15bb11e 100644 --- a/trunk/backlink.sh +++ b/trunk/backlink.sh
@@ -4,13 +4,21 @@
4searchQuery="$1"; # .html file to backlink 4searchQuery="$1"; # .html file to backlink
5outFile="$2"; # .back file to create 5outFile="$2"; # .back file to create
6headerFile="$3"; # header information file 6headerFile="$3"; # header information file
7shift 3; 7islandHead="$4";
8shift 4;
8glob="$@"; # where to search for backlinks 9glob="$@"; # where to search for backlinks
9 10
11islandLink="island"
12[[ ! -f ${islandLink}.txt ]] && cat "$islandHead" > ${islandLink}.txt;
13
10# Find backlinkers 14# Find backlinkers
11echo -n "Back-linking \"$searchQuery\"" 15echo -n "Back-linking \"$searchQuery\""
12cat "$headerFile" > "$outFile"; 16cat "$headerFile" > "$outFile";
13grep -ql "$searchQuery" $glob >> "$outFile"; 17if ! grep -ql "$searchQuery" $glob >> "$outFile"; then
18 echo "[_island_](${islandLink}.htm)." >> "$outFile";
19 title=`grep '^title:' "${searchQuery%.html}.txt" | cut -d' ' -f2-`;
20 echo "- [$title]($searchQuery)" >> "${islandLink}.txt"
21fi
14 22
15# Change title of $outFile 23# Change title of $outFile
16inText="`basename $searchQuery .html`.txt"; 24inText="`basename $searchQuery .html`.txt";
@@ -18,8 +26,11 @@ title=`grep '^title:' "$inText" | cut -d' ' -f2-`;
18sed -i "s/_TITLE_/$title/" "$outFile"; 26sed -i "s/_TITLE_/$title/" "$outFile";
19echo -n "." 27echo -n "."
20 28
29# Change *.txt to *.html
30sed -i 's/^\(.*\)\.txt/\1.html/g' "$outFile";
31
21# Link to backlinks 32# Link to backlinks
22for file in `grep '.html' "$outFile"`; do 33for file in `grep '.html$' "$outFile"`; do
23 fText="`basename $file .html`.txt"; 34 fText="`basename $file .html`.txt";
24 title=`grep '^title:' $fText | cut -d' ' -f2-`; 35 title=`grep '^title:' $fText | cut -d' ' -f2-`;
25 sed -i "s/^$file$/- [$title](&)/" "$outFile"; 36 sed -i "s/^$file$/- [$title](&)/" "$outFile";