diff options
Diffstat (limited to 'nav.sh')
-rwxr-xr-x | nav.sh | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -18,38 +18,38 @@ set -e # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -echo '<pre>' > $2 # starting <pre> tag -echo '<!--title: Sitemap — DistressNetwork°-->' >> $2 # util for plain.sh +echo '<pre>' > "$2" # starting <pre> tag +echo '<!--title: Sitemap — DistressNetwork°-->' >> "$2" # util for plain.sh # initial tree generation -tree -dfn --noreport -I 'css|error|favicon|fonts|js|media' $1 >> $2 +tree -dfn --noreport -I 'css|error|favicon|fonts|js|media' "$1" >> "$2" # remove leading path prefix -sed 's;/var/www/distress\.network;;g' -i'' $2 +sed 's;/var/www/distress\.network;;g' -i'' "$2" # link generation loop for each line -grep -n '─ ' $2 | \ +grep -n '─ ' "$2" | \ while IFS='' read -r data ; do - LINE=$(echo $data | cut -f 1 -d :) ; # extract line number - FULL=$(echo $data | cut -f 2- -d /) ; # extract output path - NAME=$(echo $FULL | grep -o '[^/]*$') ; # extract page name (last field of path) + LINE=$(echo "$data" | cut -f 1 -d :) ; # extract line number + FULL=$(echo "$data" | cut -f 2- -d /) ; # extract output path + NAME=$(echo "$FULL" | grep -o '[^/]*$') ; # extract page name (last field of path) # at the line number, replace path with link to page - sed "${LINE}s;─ .*;──<a href=\"/${FULL}\">${NAME}</a>;" -i'' $2 ; + sed "${LINE}s;─ .*;──<a href=\"/${FULL}\">${NAME}</a>;" -i'' "$2" ; done # replace starting blank line with root link -sed '3s;.*;<a href="/" aria-label="root">·</a>;' -i'' $2 +sed '3s;.*;<a href="/" aria-label="root">·</a>;' -i'' "$2" # hide tree characters for screen readers -sed 's;^\(.\+\)<a;<span aria-hidden="true">\1</span><a;1' -i'' $2 +sed 's;^\(.\+\)<a;<span aria-hidden="true">\1</span><a;1' -i'' "$2" -echo '</pre>' >> $2 # closing <pre> tag +echo '</pre>' >> "$2" # closing <pre> tag -cat $2 +cat "$2" |