doclist altered to use URL rewriting scheme rather than extension-less filenames

Was convenient for development, but I would prefer to stay conventional.
master
Mike Gerwitz 2013-06-06 14:44:39 -04:00
parent 962e7bf63e
commit 050071eb32
1 changed files with 6 additions and 15 deletions

View File

@ -1,7 +1,6 @@
#!/bin/bash
#
# Copies a html file without its sorting prefix and extension, placing it in its
# own directory and naming it as an index file if necessary
# Copies a html file without its sorting prefix
#
# Copyright (C) 2013 Mike Gerwitz
#
@ -22,8 +21,7 @@
sstrip()
{
base="$( basename "$1" )"
a="${base#??-}"
echo "${1%/*}/${a%.*}"
echo "${1%/*}/${base#??-}"
}
[ -n "$2" ] || {
@ -31,15 +29,8 @@ sstrip()
exit 64
}
# ensure that parent directory exists
mkdir -p "${dest%/*}"
dest="$( sstrip "$2" )"
# if there is a src directory matching the stripped src name, then we shall
# place the destination file in a subdirectory of that name; this both solves
# the problem of naming conflicts and maintains the illusion of url rewriting
# using only the filesystem
[ -d "$( sstrip "$1" )" ] \
&& dest="$dest/index.html"
dir="${dest%/*}"
( test -d "$dir" || mkdir -p "$dir" ) \
&& cp -v "$1" "$dest"
cp -v "$1" "$dest"