From d832dace648047cdeee32f295b7f1c799d0b5b50 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 2 Apr 2015 21:27:55 -0700 Subject: Add Islands for backlinkless files --- trunk/backlink.sh | 17 ++++++++++++++--- trunk/common-titles.sh | 7 ++++--- trunk/first-lines.sh | 5 +++-- trunk/island.head | 9 +++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 trunk/island.head (limited to 'trunk') 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 @@ searchQuery="$1"; # .html file to backlink outFile="$2"; # .back file to create headerFile="$3"; # header information file -shift 3; +islandHead="$4"; +shift 4; glob="$@"; # where to search for backlinks +islandLink="island" +[[ ! -f ${islandLink}.txt ]] && cat "$islandHead" > ${islandLink}.txt; + # Find backlinkers echo -n "Back-linking \"$searchQuery\"" cat "$headerFile" > "$outFile"; -grep -ql "$searchQuery" $glob >> "$outFile"; +if ! grep -ql "$searchQuery" $glob >> "$outFile"; then + echo "[_island_](${islandLink}.htm)." >> "$outFile"; + title=`grep '^title:' "${searchQuery%.html}.txt" | cut -d' ' -f2-`; + echo "- [$title]($searchQuery)" >> "${islandLink}.txt" +fi # Change title of $outFile inText="`basename $searchQuery .html`.txt"; @@ -18,8 +26,11 @@ title=`grep '^title:' "$inText" | cut -d' ' -f2-`; sed -i "s/_TITLE_/$title/" "$outFile"; echo -n "." +# Change *.txt to *.html +sed -i 's/^\(.*\)\.txt/\1.html/g' "$outFile"; + # Link to backlinks -for file in `grep '.html' "$outFile"`; do +for file in `grep '.html$' "$outFile"`; do fText="`basename $file .html`.txt"; title=`grep '^title:' $fText | cut -d' ' -f2-`; sed -i "s/^$file$/- [$title](&)/" "$outFile"; diff --git a/trunk/common-titles.sh b/trunk/common-titles.sh index 9bc0de8..df6158d 100644 --- a/trunk/common-titles.sh +++ b/trunk/common-titles.sh @@ -5,17 +5,18 @@ header="$2"; shift 2; glob="$@"; -echo -n "Compiling ${outFile}..."; +echo -n "Compiling ${outFile}"; cat "$header" > $outFile; for file in $glob; do # Copy title to $outFile & link title="$(grep '^title:' "$file" | cut -d' ' -f2- | sed 's/"//g')"; if (( $RANDOM % 13 == 0 )); then - echo -n "| "; + echo -n "| " >> "$outFile"; else - echo -n " "; + echo -n " " >> "$outFile"; fi echo "[$title](${file%.*}.html)" >> "$outFile"; + echo -n "."; done echo "Done."; diff --git a/trunk/first-lines.sh b/trunk/first-lines.sh index 37b7291..fb06026 100644 --- a/trunk/first-lines.sh +++ b/trunk/first-lines.sh @@ -17,11 +17,12 @@ firstLineOf() { # $1 = file echo "$try" } -echo -n "Compiling ${outFile}..." +echo -n "Compiling ${outFile}" cat "$header" > $outFile for file in $glob; do # Copy first line to $outFile & link - echo "[$(firstLineOf "$file")](${file%.*}.html)" >> $outFile + echo "[$(firstLineOf "$file")](${file%.*}.html)" >> $outFile; + echo -n "."; done echo "Done." diff --git a/trunk/island.head b/trunk/island.head new file mode 100644 index 0000000..1a9b454 --- /dev/null +++ b/trunk/island.head @@ -0,0 +1,9 @@ +--- +title: Islands +genre: list + +project: + title: About autocento + class: meta +... + -- cgit 1.4.1-21-gabe81