shellcheck fixes
This commit is contained in:
parent
452ef31545
commit
1efc9068a9
46
sw
46
sw
|
@ -8,18 +8,18 @@ sw_filter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sw_main() {
|
sw_main() {
|
||||||
$MDHANDLER $1
|
$MDHANDLER "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
sw_menu() {
|
sw_menu() {
|
||||||
echo "<ul>"
|
echo "<ul>"
|
||||||
[ -z "`echo $1 | grep index.md`" ] && echo "<li><a href=\"index.html\">.</a></li>"
|
[ -z "$(echo $1 | grep index.md)" ] && echo "<li><a href=\"index.html\">.</a></li>"
|
||||||
[ "`dirname $1`" != "." ] && echo "<li><a href=\"../index.html\">..</a></li>"
|
[ "$(dirname $1)" != "." ] && echo "<li><a href=\"../index.html\">..</a></li>"
|
||||||
FILES=`ls \`dirname $1\` | sed -e 's,.md$,.html,g'`
|
FILES=$(ls $(dirname $1) | sed -e 's,.md$,.html,g')
|
||||||
for i in $FILES ; do
|
for i in $FILES ; do
|
||||||
sw_filter $i && continue
|
sw_filter "$i" && continue
|
||||||
NAME=`echo $i | sed -e 's/\..*$//' -e 's/_/ /g'`
|
NAME=$(echo "$i" | sed -e 's/\..*$//' -e 's/_/ /g')
|
||||||
[ -z "`echo $i | grep '\..*$'`" ] && i="$i/index.html"
|
[ -z "$(echo $i | grep '\..*$')" ] && i="$i/index.html"
|
||||||
echo "<li><a href=\"$i\">$NAME</a></li>"
|
echo "<li><a href=\"$i\">$NAME</a></li>"
|
||||||
done
|
done
|
||||||
echo "</ul>"
|
echo "</ul>"
|
||||||
|
@ -42,17 +42,17 @@ _header_
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1 class="headerTitle">
|
<h1 class="headerTitle">
|
||||||
<a href="`echo $1 | sed -e 's,[^/]*/,../,g' -e 's,[^/]*.md$,index.html,g'`">${TITLE}</a> <span class="headerSubtitle">${SUBTITLE}</span>
|
<a href="$(echo $1 | sed -e 's,[^/]*/,../,g' -e 's,[^/]*.md$,index.html,g')">${TITLE}</a> <span class="headerSubtitle">${SUBTITLE}</span>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
_header_
|
_header_
|
||||||
# Menu
|
# Menu
|
||||||
echo "<div id=\"side-bar\">"
|
echo "<div id=\"side-bar\">"
|
||||||
sw_menu $1
|
sw_menu "$1"
|
||||||
echo "</div>"
|
echo "</div>"
|
||||||
# Body
|
# Body
|
||||||
echo "<div id=\"main\">"
|
echo "<div id=\"main\">"
|
||||||
sw_main $1
|
sw_main "$1"
|
||||||
echo "</div>"
|
echo "</div>"
|
||||||
# Footer
|
# Footer
|
||||||
cat << _footer_
|
cat << _footer_
|
||||||
|
@ -65,16 +65,16 @@ _footer_
|
||||||
}
|
}
|
||||||
|
|
||||||
sw_style() {
|
sw_style() {
|
||||||
if [ -f $CDIR/$STYLE ]; then
|
if [ -f "$CDIR/$STYLE" ]; then
|
||||||
echo '<style type="text/css">'
|
echo '<style type="text/css">'
|
||||||
cat $CDIR/$STYLE
|
cat "$CDIR/$STYLE"
|
||||||
echo '</style>'
|
echo '</style>'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set input dir
|
# Set input dir
|
||||||
IDIR="`echo $1 | sed -e 's,/*$,,'`"
|
IDIR="$(echo $1 | sed -e 's,/*$,,')"
|
||||||
if [ -z "$IDIR" ] || [ ! -d $IDIR ]; then
|
if [ -z "$IDIR" ] || [ ! -d "$IDIR" ]; then
|
||||||
echo "Usage: sw [dir]"
|
echo "Usage: sw [dir]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -88,19 +88,19 @@ fi
|
||||||
|
|
||||||
# Setup output dir structure
|
# Setup output dir structure
|
||||||
CDIR=$PWD
|
CDIR=$PWD
|
||||||
ODIR="$CDIR/`basename $IDIR`.static"
|
ODIR="$CDIR/$(basename $IDIR).static"
|
||||||
rm -rf $ODIR
|
rm -rf "$ODIR"
|
||||||
mkdir -p $ODIR
|
mkdir -p "$ODIR"
|
||||||
cp -rf $IDIR/* $ODIR
|
cp -rf $IDIR/* "$ODIR"
|
||||||
rm -f `find $ODIR -type f -iname '*.md'`
|
rm -f $(find "$ODIR" -type f -iname '*.md') #TODO: can't find do that?
|
||||||
|
|
||||||
# Parse files
|
# Parse files
|
||||||
cd $IDIR
|
cd "$IDIR" || exit 1
|
||||||
FILES=`find . -iname '*.md' | sed -e 's,^\./,,'`
|
FILES=$(find . -iname '*.md' | sed -e 's,^\./,,')
|
||||||
for a in $FILES; do
|
for a in $FILES; do
|
||||||
b="$ODIR/`echo $a | sed -e 's,.md$,.html,g'`"
|
b="$ODIR/$(echo $a | sed -e 's,.md$,.html,g')"
|
||||||
echo "* $a"
|
echo "* $a"
|
||||||
sw_page $a > $b;
|
sw_page "$a" > "$b"
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue