diff options
author | Case Duckworth | 2015-04-02 21:27:55 -0700 |
---|---|---|
committer | Case Duckworth | 2015-04-02 21:27:55 -0700 |
commit | d832dace648047cdeee32f295b7f1c799d0b5b50 (patch) | |
tree | 34f7efb6e713eef3522053a8ee2aded46ad1e33d /trunk | |
parent | Fix #15: add compile support for indeces (diff) | |
download | autocento-d832dace648047cdeee32f295b7f1c799d0b5b50.tar.gz autocento-d832dace648047cdeee32f295b7f1c799d0b5b50.zip |
Add Islands for backlinkless files
Diffstat (limited to 'trunk')
-rw-r--r-- | trunk/backlink.sh | 17 | ||||
-rw-r--r-- | trunk/common-titles.sh | 7 | ||||
-rw-r--r-- | trunk/first-lines.sh | 5 | ||||
-rw-r--r-- | trunk/island.head | 9 |
4 files changed, 30 insertions, 8 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 @@ | |||
4 | searchQuery="$1"; # .html file to backlink | 4 | searchQuery="$1"; # .html file to backlink |
5 | outFile="$2"; # .back file to create | 5 | outFile="$2"; # .back file to create |
6 | headerFile="$3"; # header information file | 6 | headerFile="$3"; # header information file |
7 | shift 3; | 7 | islandHead="$4"; |
8 | shift 4; | ||
8 | glob="$@"; # where to search for backlinks | 9 | glob="$@"; # where to search for backlinks |
9 | 10 | ||
11 | islandLink="island" | ||
12 | [[ ! -f ${islandLink}.txt ]] && cat "$islandHead" > ${islandLink}.txt; | ||
13 | |||
10 | # Find backlinkers | 14 | # Find backlinkers |
11 | echo -n "Back-linking \"$searchQuery\"" | 15 | echo -n "Back-linking \"$searchQuery\"" |
12 | cat "$headerFile" > "$outFile"; | 16 | cat "$headerFile" > "$outFile"; |
13 | grep -ql "$searchQuery" $glob >> "$outFile"; | 17 | if ! 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" | ||
21 | fi | ||
14 | 22 | ||
15 | # Change title of $outFile | 23 | # Change title of $outFile |
16 | inText="`basename $searchQuery .html`.txt"; | 24 | inText="`basename $searchQuery .html`.txt"; |
@@ -18,8 +26,11 @@ title=`grep '^title:' "$inText" | cut -d' ' -f2-`; | |||
18 | sed -i "s/_TITLE_/$title/" "$outFile"; | 26 | sed -i "s/_TITLE_/$title/" "$outFile"; |
19 | echo -n "." | 27 | echo -n "." |
20 | 28 | ||
29 | # Change *.txt to *.html | ||
30 | sed -i 's/^\(.*\)\.txt/\1.html/g' "$outFile"; | ||
31 | |||
21 | # Link to backlinks | 32 | # Link to backlinks |
22 | for file in `grep '.html' "$outFile"`; do | 33 | for 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"; |
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"; | |||
5 | shift 2; | 5 | shift 2; |
6 | glob="$@"; | 6 | glob="$@"; |
7 | 7 | ||
8 | echo -n "Compiling ${outFile}..."; | 8 | echo -n "Compiling ${outFile}"; |
9 | cat "$header" > $outFile; | 9 | cat "$header" > $outFile; |
10 | 10 | ||
11 | for file in $glob; do | 11 | for file in $glob; do |
12 | # Copy title to $outFile & link | 12 | # Copy title to $outFile & link |
13 | title="$(grep '^title:' "$file" | cut -d' ' -f2- | sed 's/"//g')"; | 13 | title="$(grep '^title:' "$file" | cut -d' ' -f2- | sed 's/"//g')"; |
14 | if (( $RANDOM % 13 == 0 )); then | 14 | if (( $RANDOM % 13 == 0 )); then |
15 | echo -n "| "; | 15 | echo -n "| " >> "$outFile"; |
16 | else | 16 | else |
17 | echo -n " "; | 17 | echo -n " " >> "$outFile"; |
18 | fi | 18 | fi |
19 | echo "[$title](${file%.*}.html)" >> "$outFile"; | 19 | echo "[$title](${file%.*}.html)" >> "$outFile"; |
20 | echo -n "."; | ||
20 | done | 21 | done |
21 | echo "Done."; | 22 | 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 | |||
17 | echo "$try" | 17 | echo "$try" |
18 | } | 18 | } |
19 | 19 | ||
20 | echo -n "Compiling ${outFile}..." | 20 | echo -n "Compiling ${outFile}" |
21 | cat "$header" > $outFile | 21 | cat "$header" > $outFile |
22 | 22 | ||
23 | for file in $glob; do | 23 | for file in $glob; do |
24 | # Copy first line to $outFile & link | 24 | # Copy first line to $outFile & link |
25 | echo "[$(firstLineOf "$file")](${file%.*}.html)" >> $outFile | 25 | echo "[$(firstLineOf "$file")](${file%.*}.html)" >> $outFile; |
26 | echo -n "."; | ||
26 | done | 27 | done |
27 | echo "Done." | 28 | 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 @@ | |||
1 | --- | ||
2 | title: Islands | ||
3 | genre: list | ||
4 | |||
5 | project: | ||
6 | title: About autocento | ||
7 | class: meta | ||
8 | ... | ||
9 | |||