about summary refs log tree commit diff stats
path: root/scripts
diff options
context:
space:
mode:
authorCase Duckworth2015-04-14 18:09:55 -0700
committerCase Duckworth2015-04-14 18:09:55 -0700
commit08fd8e95dccb91d0495a50d1009f85cb80cfad65 (patch)
tree9accf8a6e9b1f836e3c7c7b5437d11351545a07e /scripts
parentChange file hierarchy and rewrite makefile (diff)
downloadautocento-08fd8e95dccb91d0495a50d1009f85cb80cfad65.tar.gz
autocento-08fd8e95dccb91d0495a50d1009f85cb80cfad65.zip
First compile in v1.0.0 v1.0.0
Diffstat (limited to 'scripts')
-rw-r--r--scripts/addhead.sh4
-rw-r--r--scripts/compile.sh18
-rw-r--r--scripts/randomize.js11
3 files changed, 18 insertions, 15 deletions
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 @@
1#!/bin/bash
2# addhead.sh <file> <header>
3
4
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
31 *.back) # backlinks: compile.sh a.back a.txt #{{{ 31 *.back) # backlinks: compile.sh a.back a.txt #{{{
32 found=( $(backLinksOf "$(basename ${FILE%.*}).html" ${1%/*}/*.${1##*.}) ); 32 found=( $(backLinksOf "$(basename ${FILE%.*}).html" ${1%/*}/*.${1##*.}) );
33 if [[ $? -ne 0 ]]; then 33 if [[ $? -ne 0 ]]; then
34 echo "__ISLAND__"; exit; 34 echo "[_island._](../islands.html) <!--__ISLAND__-->"; exit;
35 fi 35 fi
36 for f in "${found[@]}"; do 36 for f in "${found[@]}"; do
37 echo -n "- [$(getMeta title "$f")](../$(basename ${f%.*}).html)"; 37 echo -n "- [$(getMeta title "$f")](../$(basename ${f%.*}).html)";
@@ -45,40 +45,40 @@ case "$FILE" in
45 echo "- [$(getMeta title "$f")]($(basename ${f%.*}).html)"; 45 echo "- [$(getMeta title "$f")]($(basename ${f%.*}).html)";
46 done 46 done
47 ;; #}}} 47 ;; #}}}
48 *hapax*) # hapax: compile.sh hapax.txt *.hapax #{{{ 48 *hapax*) # hapax: compile.sh hapax.txt *.hapax #{{{
49 for word in $(sort $FILE); do 49 for word in $(sort $FILE); do
50 f=$(grep -liwq "^$word$" "$@"); 50 f=$(grep -liwq "^$word$" "$@");
51 grep -qv "^[^0-9A-Za-z]" <<< $word && \ 51 grep -qv "^[^0-9A-Za-z]" <<< $word && \
52 echo "[$word]($(basename ${f%.*}).html)"; 52 echo "[$word]($(basename ${f%.*}).html)";
53 done 53 done
54 ;; #}}} 54 ;; #}}}
55 *first-*) # first-lines: compile.sh first-lines.txt *.txt #{{{ 55 *first-*) # first-lines: compile.sh first-lines.txt *.txt #{{{
56 for f in "$@"; do 56 for f in "$@"; do
57 echo "[$(firstLineOf "$f")]($(basename ${f%.*}).html)"; 57 echo "[$(firstLineOf "$f")]($(basename ${f%.*}).html)";
58 done 58 done
59 ;; #}}} 59 ;; #}}}
60 *common-*) # common-titles: compile.sh common-titles.txt *.txt #{{{ 60 *common-*) # common-titles: compile.sh common-titles.txt *.txt #{{{
61 for f in "$@"; do 61 for f in "$@"; do
62 echo "[$(getMeta title "$f")]($(basename ${f%.*}).html)"; 62 echo "[$(getMeta title "$f")]($(basename ${f%.*}).html)";
63 done 63 done
64 ;; #}}} 64 ;; #}}}
65 *toc*) # table of contents: compile.sh toc.txt *.txt #{{{ 65 *toc*) # table of contents: compile.sh toc.txt *.txt #{{{
66 for f in "$@"; do 66 for f in "$@"; do
67 echo "#. [$(getMeta toc "$f")]($(basename ${f%.*}).html)" >> $FILE; 67 echo "#. [$(getMeta toc "$f")]($(basename ${f%.*}).html)" >> $FILE;
68 done 68 done
69 ;; #}}} 69 ;; #}}}
70 *random*) # randomize.js: compile.sh randomize.js *.html #{{{ 70 *random*) # randomize.js: compile.sh randomize.js *.html #{{{
71 rlist=$(echo "$@" | sed -e 's/\(\S\+.html\) \?/"\1",/g' \ 71 rlist=$(echo "$@" | sed -e 's/\(\S\+.html\) \?/"\1",/g' \
72 -e 's/^\(.*\),$/var files=[\1]/') 72 -e 's/^\(.*\),$/var files=[\1]/')
73 sed -i "s/var files=.*/$rlist/" $FILE; 73 sed -i "s/var files=.*/$rlist/" $FILE;
74 ;; #}}} 74 ;; #}}}
75 --fix-head) # fix backlink head: compile.sh --fix-head a.back a.txt #{{{ 75 --fix-head) # fix backlink head: compile.sh --fix-head a.back a.txt #{{{
76 title="$(getMeta title "$2")"; 76 title="$(getMeta toc "$2")";
77 id="$(getMeta id "$2")"; 77 id="$(getMeta id "$2")";
78 sed -i "s/__TITLE__/$title/" "$1"; 78 sed -i "s/__TITLE__/$title/" "$1";
79 sed -i "s/__ID__/$id/" "$1"; 79 sed -i "s/__ID__/$id/" "$1";
80 ;; #}}} 80 ;; #}}}
81 *) # bad argument {{{ 81 *) # bad argument {{{
82 echo "Bad argument"; 82 echo "Bad argument";
83 exit 1; 83 exit 1;
84 ;; #}}} 84 ;; #}}}
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() {
12 var index = Math.floor(Math.random() * files.length); 12 var index = Math.floor(Math.random() * files.length);
13 13
14 var url = window.location.pathname; 14 var url = window.location.pathname;
15 var current = "../" + url.substring(url.lastIndexOf('/')+1);
15 var current = url.substring(url.lastIndexOf('/')+1); 16 var current = url.substring(url.lastIndexOf('/')+1);
16 17
17 if (current != files[index]) { 18 if (current != files[index]) {
18 randomlink.setAttribute("href", files[index]); 19 var blre = /backlinks/
19 randomlink.setAttribute("title", "To random article"); 20 if (!blre.test(url)) {
21 randomlink.setAttribute("href", files[index]);
22 randomlink.setAttribute("title", "To random article");
23 } else {
24 randomlink.setAttribute("href", '../' + files[index]);
25 randomlink.setAttribute("title", "To random article");
26 }
20 } else { 27 } else {
21 _randomize() 28 _randomize()
22 } 29 }