From 08fd8e95dccb91d0495a50d1009f85cb80cfad65 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 14 Apr 2015 18:09:55 -0700 Subject: First compile in v1.0.0 --- scripts/addhead.sh | 4 ---- scripts/compile.sh | 18 +++++++++--------- scripts/randomize.js | 11 +++++++++-- 3 files changed, 18 insertions(+), 15 deletions(-) delete mode 100644 scripts/addhead.sh (limited to 'scripts') diff --git a/scripts/addhead.sh b/scripts/addhead.sh deleted file mode 100644 index 73e1dcf..0000000 --- a/scripts/addhead.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# addhead.sh
- - diff --git a/scripts/compile.sh b/scripts/compile.sh index 5478410..ba89f5a 100644 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -31,7 +31,7 @@ case "$FILE" in *.back) # backlinks: compile.sh a.back a.txt #{{{ found=( $(backLinksOf "$(basename ${FILE%.*}).html" ${1%/*}/*.${1##*.}) ); if [[ $? -ne 0 ]]; then - echo "__ISLAND__"; exit; + echo "[_island._](../islands.html) "; exit; fi for f in "${found[@]}"; do echo -n "- [$(getMeta title "$f")](../$(basename ${f%.*}).html)"; @@ -45,40 +45,40 @@ case "$FILE" in echo "- [$(getMeta title "$f")]($(basename ${f%.*}).html)"; done ;; #}}} - *hapax*) # hapax: compile.sh hapax.txt *.hapax #{{{ + *hapax*) # hapax: compile.sh hapax.txt *.hapax #{{{ for word in $(sort $FILE); do f=$(grep -liwq "^$word$" "$@"); grep -qv "^[^0-9A-Za-z]" <<< $word && \ echo "[$word]($(basename ${f%.*}).html)"; done ;; #}}} - *first-*) # first-lines: compile.sh first-lines.txt *.txt #{{{ + *first-*) # first-lines: compile.sh first-lines.txt *.txt #{{{ for f in "$@"; do echo "[$(firstLineOf "$f")]($(basename ${f%.*}).html)"; done ;; #}}} - *common-*) # common-titles: compile.sh common-titles.txt *.txt #{{{ + *common-*) # common-titles: compile.sh common-titles.txt *.txt #{{{ for f in "$@"; do echo "[$(getMeta title "$f")]($(basename ${f%.*}).html)"; done ;; #}}} - *toc*) # table of contents: compile.sh toc.txt *.txt #{{{ + *toc*) # table of contents: compile.sh toc.txt *.txt #{{{ for f in "$@"; do echo "#. [$(getMeta toc "$f")]($(basename ${f%.*}).html)" >> $FILE; done ;; #}}} - *random*) # randomize.js: compile.sh randomize.js *.html #{{{ + *random*) # randomize.js: compile.sh randomize.js *.html #{{{ rlist=$(echo "$@" | sed -e 's/\(\S\+.html\) \?/"\1",/g' \ -e 's/^\(.*\),$/var files=[\1]/') sed -i "s/var files=.*/$rlist/" $FILE; ;; #}}} - --fix-head) # fix backlink head: compile.sh --fix-head a.back a.txt #{{{ - title="$(getMeta title "$2")"; + --fix-head) # fix backlink head: compile.sh --fix-head a.back a.txt #{{{ + title="$(getMeta toc "$2")"; id="$(getMeta id "$2")"; sed -i "s/__TITLE__/$title/" "$1"; sed -i "s/__ID__/$id/" "$1"; ;; #}}} - *) # bad argument {{{ + *) # bad argument {{{ echo "Bad argument"; exit 1; ;; #}}} diff --git a/scripts/randomize.js b/scripts/randomize.js index b225b2f..0ad9bf9 100644 --- a/scripts/randomize.js +++ b/scripts/randomize.js @@ -12,11 +12,18 @@ function _randomize() { var index = Math.floor(Math.random() * files.length); var url = window.location.pathname; + var current = "../" + url.substring(url.lastIndexOf('/')+1); var current = url.substring(url.lastIndexOf('/')+1); if (current != files[index]) { - randomlink.setAttribute("href", files[index]); - randomlink.setAttribute("title", "To random article"); + var blre = /backlinks/ + if (!blre.test(url)) { + randomlink.setAttribute("href", files[index]); + randomlink.setAttribute("title", "To random article"); + } else { + randomlink.setAttribute("href", '../' + files[index]); + randomlink.setAttribute("title", "To random article"); + } } else { _randomize() } -- cgit 1.4.1-21-gabe81