Date:   Saturday January 4, 2003 @ 0:39
Author: matt

Update of /home/cvs/AxKit-XSP-Wiki/webstuff
In directory ted.sergeant.org:/home/matt/Perl/AxKit-XSP-Wiki/webstuff

Modified Files:
        view wiki.xsl 
Log Message:
Lots of cleanup and added stuff
Log:
PR:

Index: view
===================================================================
RCS file: /home/cvs/AxKit-XSP-Wiki/webstuff/view,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -u -r1.3 -r1.4
--- view        2002/06/21 15:42:06     1.3
+++ view        2003/01/04 00:39:08     1.4
@@ -2,61 +2,74 @@
 <xspwiki xmlns:wiki="http://axkit.org/NS/xsp/wiki/1";
       xmlns:xsp="http://apache.org/xsp/core/v1";
 >
-    <!-- This file contains information about where to find the
-         wiki DB's, and also anything web specific, before
-         passing it all to the Wiki function (which returns XML) -->
     <xsp:logic>
       my $path_info = $r->path_info;
       
-      my $dbroot = '/tmp';
+      my $dbroot = $r->dir_config('WikiDBRoot') || die "No DB root specified!";
+      my $default_db = $r->dir_config( 'WikiDB' ) || 'AxKit';
+      my $default_page = $r->dir_config( 'DefaultPage' ) || 'DefaultPage';
+      my $uri = $r->uri;
       
-      my ($db, $page) = ('AxKit', 'DefaultPage');
+      my ($db, $page) = AxKit::XSP::Wiki::extract_page_info($path_info);
       
-      if ($path_info) {
-        ($db, $page) = ($path_info =~
-            m|^/([A-Z][A-Za-z0-9]+)/([A-Z][A-Za-z0-9:_]+)$|g);
        if (!$db) {
-          die "Invalid path_info: $path_info";
+        $r->header_out(Location => "$uri/$default_db/$default_page");
+       return 302;
        }
-       
        if (!$page) {
-         die "Invalid path_info: $path_info";
-       }
-       
-       if ($page !~ /^[A-Z][A-Za-z0-9:_]+$/) {
-         die "Invalid page name: $page";
-       }
-      }
-      else {
-        $r->header_out(Location => "view/$db/$page");
+        $r->header_out(Location => "$uri/$db/$default_page");
        return 302;
       }
       
-      my $action = $cgi->param('action');
-      $action ||= 'view';
+      my $action = $cgi->param('action') || 'view';
+      $action = 'preview' if $cgi->param('preview');
+      my $id = $cgi->param('id');
+      if ($id !~ /^\d*$/) {
+        die "Invalid id format";
+      }
       
       if ($action eq 'save') {
+        my $ip = $r->get_remote_host();
         AxKit::XSP::Wiki::save_page(
-                                   $dbroot, $db, $page,
-                                   $cgi->param('text'),
-                                   $cgi->param('texttype'),
+          $dbroot, $db, $page, $cgi->param('text'), $cgi->param('texttype'), $ip,
                                    );
-        $r->header_out(Location => "./$page");
+        $r->header_out(Location => "$uri/$db/$page");
        return 302;
       }
-      
-      my $title = join(' ', split(/(?=[A-Z])/, $page));
-      
+      elsif ($action eq 'restore') {
+        my $ip = $r->get_remote_host();
+        AxKit::XSP::Wiki::restore_page(
+          $dbroot, $db, $page, $ip, $id,
+        );
+        $r->header_out(Location => "$uri/$db/$page");
+        return 302;
+      }
+      elsif ($action eq 'preview') {
       <xsp:content>
-        <title><xsp:expr>$title</xsp:expr></title>
        <page><xsp:expr>$page</xsp:expr></page>
+        <db><xsp:expr>$db</xsp:expr></db>
+        <wiki:preview-page>
+          <wiki:dbpath><xsp:expr>$dbroot</xsp:expr></wiki:dbpath>
+          <wiki:db><xsp:expr>$db</xsp:expr></wiki:db>
+          <wiki:page><xsp:expr>$page</xsp:expr></wiki:page>
+          <wiki:text><xsp:expr>$cgi->param('text')</xsp:expr></wiki:text>
+          <wiki:texttype><xsp:expr>$cgi->param('texttype')</xsp:expr></wiki:texttype>
+        </wiki:preview-page>
+       </xsp:content>
+      }
+      else {
+      <xsp:content>
+       <page><xsp:expr>$page</xsp:expr></page>
+        <db><xsp:expr>$db</xsp:expr></db>
         <wiki:display-page>
           <wiki:dbpath><xsp:expr>$dbroot</xsp:expr></wiki:dbpath>
           <wiki:db><xsp:expr>$db</xsp:expr></wiki:db>
          <wiki:page><xsp:expr>$page</xsp:expr></wiki:page>
           <wiki:action><xsp:expr>$action</xsp:expr></wiki:action>
+          <wiki:id><xsp:expr>$id</xsp:expr></wiki:id>
         </wiki:display-page>
       </xsp:content>
+      }
       
     </xsp:logic>
 </xspwiki>
Index: wiki.xsl
===================================================================
RCS file: /home/cvs/AxKit-XSP-Wiki/webstuff/wiki.xsl,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -u -r1.4 -r1.5
--- wiki.xsl    2002/12/29 17:46:32     1.4
+++ wiki.xsl    2003/01/04 00:39:08     1.5
@@ -51,7 +51,7 @@
        <xsl:choose>
          <xsl:when test="$action='view'">
            <div class="line">&#160;</div>
-           <a href="./{/xspwiki/page}?action=edit">Edit This Page</a> / <a 
href="./{/xspwiki/page}?action=history">Show Page History</a>
+           <a href="../../../edit/{/xspwiki/db}/{/xspwiki/page}?action=edit">Edit 
+This Page</a> / <a href="./{/xspwiki/page}?action=history">Show Page History</a>
          </xsl:when>
          <xsl:when test="$action='edit'">
            <div class="line">&#160;</div>
@@ -144,6 +144,10 @@
 
 <xsl:template match="history/entry/bytes">
   <td><xsl:apply-templates/></td>
+</xsl:template>
+
+<xsl:template match="newpage">
+  <i>This page has not yet been created</i>
 </xsl:template>
 
 <!-- useful for testing - commented out for live

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to