commit 9533dba5ef299146c3af0545796ee2ebc3860c67 parent e37d96f604ac96ef637c332a0c58a8e9a213eee2 Author: xfnw <xfnw@ttm.sh> Date: Thu, 29 Oct 2020 13:40:32 -0400 even more efficency improvements by removing like 4 sed invocations and echo instead of cat <<EOF Diffstat:
M | template/page.html | | | 4 | ++-- |
M | xfwc | | | 23 | +++++------------------ |
2 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/template/page.html b/template/page.html @@ -15,9 +15,9 @@ <center id='cnav'> <a href="1.html"><<</a> - <a href="PRE.html"><</a> + <a href="#PRE.html"><</a> <a href="RANDOM.html">?</a> - <a href="NEXT.html">></a> + <a href="#NEXT.html">></a> <a href="LAST.html">>></a> </center> diff --git a/xfwc b/xfwc @@ -13,7 +13,6 @@ cat <<EOF > feed.rss EOF -BOOPTMP=$(mktemp) TOTAL=$(ls src | wc -w) @@ -28,32 +27,20 @@ NEWF=$NUM.html TITLE=$(echo ${fn%????} | sed 's/_/ /g' | sed -e 's/[]$.*[\^]/\\&/g') echo "rendering $NEWF..." -cat <<EOF >> feed.rss +echo " <item> <title>$TITLE</title> <link>$ABSURL/$NEWF</link> <description>image #$NUM</description> </item> -EOF - -echo "<img class='comic' alt='$TITLE' title='$TITLE' src='src/$fn'/>" > $BOOPTMP -cp template/page.html $NEWF - -sed "/COMIC -->/r $BOOPTMP" template/page.html > $NEWF - -sed -i "s/XFSSTITLE/$TITLE/g" $NEWF - -sed -i "s/RANDOM/"$(( ( RANDOM % TOTAL ) + 1 ))"/" $NEWF - - -sed -i "s/LAST/$TOTAL/" $NEWF +" >> feed.rss +sed "s/<!-- COMIC -->/<img class='comic' alt='$TITLE' title='$TITLE' src='src\/$fn'\/>/; s/XFSSTITLE/$TITLE/g; s/RANDOM/"$(( ( RANDOM % TOTAL ) + 1 ))"/; s/LAST/$TOTAL/" template/page.html > $NEWF -[ "$NUM" = "1" ] || sed -i "s/PRE/"$(( NUM - 1 ))"/" $NEWF +[ "$NUM" = "1" ] || sed -i "s/#PRE/"$(( NUM - 1 ))"/" $NEWF -[ "$NUM" = "$TOTAL" ] || sed -i "s/NEXT/"$(( NUM + 1 ))"/" $NEWF +[ "$NUM" = "$TOTAL" ] || sed -i "s/#NEXT/"$(( NUM + 1 ))"/" $NEWF -sed -i 's/PRE/#/; s/NEXT/#/' $NEWF NUM=$(( NUM - 1 ))