]> git.plutz.net Git - busy/blobdiff - Wiki.page
modified to use acl engine
[busy] / Wiki.page
index 490966367705b8b8d744062aa4e6aa007612c0a3..8df11d605ff55eab5b5379139bef3214cdf41c62 100755 (executable)
--- a/Wiki.page
+++ b/Wiki.page
@@ -6,6 +6,8 @@ rev="$(egrep -o '(^|&)(r=)[0-9]{10}(&|$)' <<<"${QUERY_STRING}" |tr -d '&r=')"
 search="$(egrep -o '(^|&)(s=).+(&|$)' <<<"${QUERY_STRING}" |sed -r 's:^&?s=::;s:\+: :g;s:%:\\x:g')"
 search="$(echo -e "${search}" |sed 's:\t: :g;s:\r::g;s:\\:\\\\:g' |head -n1)"
 
+[ -z "$ACL_WIKIEDIT" ] && ACL_WIKIEDIT=false
+
 [ -n "$rev" ] && rev=".$rev"
 if [ -n "$search" ]; then
   info=''
@@ -21,10 +23,10 @@ else
   lock="$(cut -d: -f1 "$lock")"
 fi
 
-if [ -n "$edit" -a -r "Wiki/$edit" ]; then
+if [ -n "$edit" -a -r "Wiki/${edit}${rev}" ]; then
   title="$(egrep -x 'title=.+' "Wiki/$edit.meta" |cut -d= -f2- || echo '(Untitled)')"
   cat <<WikiEND
-    <form class="edit" action="write/scriptedit.cgi?i=$edit" method="post" accept-charset="UTF-8">
+    <form class="edit" action="write/wikiedit.cgi?i=$edit" method="post" accept-charset="UTF-8">
       <div id="LEFT">
        Editing <b>$title</b><br>
         <input type="submit" value="Submit">
@@ -34,7 +36,7 @@ if [ -n "$edit" -a -r "Wiki/$edit" ]; then
       <div id="MAIN">
        <div class="wiki">
           <h1>$title</h1>
-          <textarea name="page" rows=30 cols=40>$(cat "Wiki/$edit")</textarea>
+          <textarea name="page" rows=30 cols=40>$(cat "Wiki/${edit}${rev}")</textarea>
         </div>
       </div>
     </form>
@@ -67,8 +69,9 @@ elif [ -n "$info" -a -r "Wiki/${info}${rev}" ]; then
        rno=$(($rno+1))
         done) <a class='rev' href='?p=Wiki&amp;i=$info'>Latest</a><br>
       <hr>
-      $($LOGIN && [ -z "$rev" ] && if [ -z "$lock" ]; then
-         echo "<a class='function' href='write/lock.cgi?p=Wiki&amp;e=$info'>edit this page</a>"
+      $($LOGIN && if [ -z "$lock" ]; then
+          [ -z "$rev" ] && echo "<a class='function' href='write/lock.cgi?p=Wiki&amp;e=$info'>edit this page</a>"
+         [ -n "$rev" ] && echo "Click <a class='function' href='write/lock.cgi?p=Wiki&amp;e=${info}&amp;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='write/lock.cgi?p=Wiki&amp;e=$info'>edit anyway</a>"
         fi
@@ -126,7 +129,7 @@ elif [ -z "$info" ]; then
       <hr>
 WikiEND
   if [ -n "$search" ]; then
-    echo "<h1>Search results for: $search</h1>"
+    echo "<h1>Wiki search results for: $search</h1>"
     for each in $(grep -ile "$search" Wiki/<0000000000-9999999999>_<000-999>); do
       echo "<div class='search'><a href='?p=Wiki&amp;i=${each:t}'><h2>$(grep '^title=' "$each.meta" |cut -d= -f2-)</h2></a>"
       grep -C1 -ie "$search" "$each" |sed "s:$search:<b>&</b>:g;s:$:<br>:g"
@@ -162,12 +165,12 @@ WikiEND
         <a name="$info" href="/?p=Wiki&amp;i=$info"><h1>$title</h1></a>
         $description<br><br>
         <a class="function" href="/?p=Wiki&amp;i=$info">View</a> 
-        $($LOGIN && echo "<a class='function' href='#' onclick=\"javascript:show_screen('change_$info');hide_screen('display_$info');\">Change Info</a>")
+        $($ACL_WIKIEDIT && echo "<a class='function' href='#' onclick=\"javascript:show_screen('change_$info');hide_screen('display_$info');\">Change Info</a>")
       </div>
 WikiEND
-    $LOGIN && cat <<WikiEND
+    $ACL_WIKIEDIT && cat <<WikiEND
       <div id="change_$info" style="display: none;">
-        <form action="/write/wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
+        <form action="/write/$($LOGIN && echo user_)wikimeta.cgi?i=$info" method="post" accept-charset="UTF-8">
          <b>Title:</b> <input type="text" name="title" value="$title"><br>
          <b>Description:</b><br>
          <textarea name="desc" rows="6" style="width:100%;">$description</textarea><br>