add_comment(){
info="$1"
- cat <<WikiEND
- <a id='comment_button' class='function' href='#'
- onclick='javascript:show_screen("comment");hide_screen("comment_button");'>Comment / Ask</a>
- <div id="comment" style="display: none;">
- <form action="/?action=wikimeta&i=$info" method="post" accept-charset="UTF-8">
- <b>Comment:</b><br>
- <textarea name="comm" rows="6" style="width:99%;"></textarea><br>
- <input type="submit" value="Submit">
- <a class="function" href="#" onclick="javascript:hide_screen('comment');show_screen('comment_button');">Cancel</a>
- </form>
- </div>
-WikiEND
+ cat <<-WikiEND
+ <a id='comment_button' class='function' href='#'
+ onclick='javascript:show_screen("comment");hide_screen("comment_button");'>Comment / Ask</a>
+ <div id="comment" style="display: none;">
+ <form action="./?action=wikimeta&i=$info" method="post" accept-charset="UTF-8">
+ <b>Comment:</b><br>
+ <textarea name="comm" rows="6" style="width:99%;"></textarea><br>
+ <input type="submit" value="Submit">
+ <a class="function" href="#" onclick="javascript:hide_screen('comment');show_screen('comment_button');">Cancel</a>
+ </form>
+ </div>
+ WikiEND
}
+wikitext="$(_wiki Wiki/"${info}${rev}")"
+wikitoc="$(echo -E "$wikitext" \
+ | sed -rn '/<h[0-9]>.+<\/h[0-9]>/s;^.*<h([0-9])><a name="(.+)">(.+)</a></h[0-9]>.*$;<a class="i\1" href="#\2">\3</a><br>;p'
+ )"
+
cat <<WikiEND
<div id="LEFT">
- <form method="GET" action="/${SCRIPTNAME}" accept-charset="utf-8">
+ <form method="GET" action="./" accept-charset="utf-8">
<input type="hidden" name="p" value="Wiki">
<input type="text" name="s" placeholder="Search"><br>
<input type="submit" value="Search Wiki">
done) <a class='rev' href='?p=Wiki&i=$info'>Latest</a><br>
<hr>
$($LOGIN && if [ -z "$lock" ]; then
- [ -z "$rev" ] && echo "<a class='function' href='/?action=lock&p=Wiki&e=$info'>edit this page</a>"
- [ -n "$rev" ] && echo "Click <a class='function' href='/?action=lock&p=Wiki&e=${info}&r=${rev:s/.//}'>edit</a> to derive a new page revision from this one."
+ [ -z "$rev" ] && echo "<a class='function' href='./?action=lock&p=Wiki&e=$info'>edit this page</a>"
+ [ -n "$rev" ] && echo "Click <a class='function' href='./?action=lock&p=Wiki&e=${info}&r=${rev:s/.//}'>edit</a> to derive a new page revision from this one."
else
- echo "<b>This page is currently being edited by $lock</b><a class='function' href='/?action=lock&p=Wiki&e=$info'>edit anyway</a>"
+ echo "<b>This page is currently being edited by $lock</b><a class='function' href='./?action=lock&p=Wiki&e=$info'>edit anyway</a>"
fi
$LOGIN && echo '<hr>')
<h1>Table of Content</h1>
<div class="toc">
- $(cat Wiki/"${info}${rev}" |while read line; do
- if (egrep -q '^ *###' <<<"$line"); then
- echo "<a class='i2' href='#$(sed 's,^ *### *,,;' <<<"$line")'>$(sed 's,^ *###,,' <<<"$line")</a><br>"
- elif (egrep -q '^ *##' <<<"$line"); then
- echo "<a class='i1' href='#$(sed 's,^ *## *,,;' <<<"$line")'>$(sed 's,^ *##,,' <<<"$line")</a><br>"
- elif (egrep -q '^ *#' <<<"$line"); then
- echo "<a class='i0' href='#$(sed 's,^ *# *,,;' <<<"$line")'>$(sed 's,^ *#,,' <<<"$line")</a><br>"
- fi
- done)
+ ${wikitoc}
</div>
<hr>
</div>
<div id="MAIN">
<div class="wiki"><div class="wikitext">
<h1 class="wikihead">$title</h1>
- $(_wiki Wiki/"${info}${rev}")
+ ${wikitext}
</div></div>
</div>