]> sipb.mit.edu Git - ikiwiki.git/commitdiff
dd page preview
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 16 Mar 2006 21:39:45 +0000 (21:39 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 16 Mar 2006 21:39:45 +0000 (21:39 +0000)
ikiwiki
templates/editpage.tmpl

diff --git a/ikiwiki b/ikiwiki
index bda2d0401376f9cb7ee6ea0cd1f71d2192249d3c..0463ba15db48d442e94ca972b1d5838a2cab896b 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -247,10 +247,10 @@ sub htmllink { #{{{
 
 sub linkify ($$) { #{{{
        my $content=shift;
-       my $file=shift;
+       my $page=shift;
 
        $content =~ s{(\\?)$config{wiki_link_regexp}}{
-               $1 ? "[[$2]]" : htmllink(pagename($file), $2)
+               $1 ? "[[$2]]" : htmllink($page, $2)
        }eg;
        
        return $content;
@@ -372,7 +372,7 @@ sub check_overwrite ($$) { #{{{
                        ", before, so not rendering from $src");
        }
 } #}}}
-               
+
 sub render ($) { #{{{
        my $file=shift;
        
@@ -383,7 +383,7 @@ sub render ($) { #{{{
                
                $links{$page}=[findlinks($content, $page)];
                
-               $content=linkify($content, $file);
+               $content=linkify($content, $page);
                $content=htmlize($type, $content);
                $content=finalize($content, $page);
                
@@ -1031,7 +1031,17 @@ sub cgi_editpage ($$) { #{{{
                print $q->redirect("$config{url}/".htmlpage($page));
                return;
        }
-       if (! $form->submitted || ! $form->validate) {
+       elsif ($form->submitted eq "Preview") {
+               $form->tmpl_param("page_preview",
+                       htmlize($config{default_pageext},
+                               linkify($form->field('content'), $page)));
+       }
+       else {
+               $form->tmpl_param("page_preview", "");
+       }
+       
+       if (! $form->submitted || $form->submitted eq "Preview" || 
+           ! $form->validate) {
                if ($form->field("do") eq "create") {
                        if (exists $pagesources{lc($page)}) {
                                # hmm, someone else made the page in the
@@ -1083,7 +1093,7 @@ sub cgi_editpage ($$) { #{{{
                
                $form->tmpl_param("can_commit", $config{svn});
                $form->tmpl_param("indexlink", indexlink());
-               print $form->render(submit => ["Save Page", "Cancel"]);
+               print $form->render(submit => ["Save Page", "Preview", "Cancel"]);
        }
        else {
                # save page
index 8b755749f26e4e617a91f52f88a2ecc8db76e515..c23630dfa6216a5e9226a3e95c131296aeb6a8a8 100644 (file)
@@ -17,5 +17,9 @@ Optional comment about this change:</br>
 </TMPL_IF>
 <TMPL_VAR FORM-SUBMIT>
 <TMPL_VAR FORM-END>
+<TMPL_IF NAME="PAGE_PREVIEW">
+<hr>
+<TMPL_VAR PAGE_PREVIEW>
+</TMPL_IF>
 </body>
 </html>