]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Render.pm
* Add --render mode, which can be used to preview an edit at the command
[ikiwiki.git] / IkiWiki / Render.pm
index c16877b3deb9117573962d7a061843ecf26e5067..48a25bef7a6fe417a2aa49498dbc010fcd1fefbb 100644 (file)
@@ -374,4 +374,29 @@ FILE:              foreach my $file (@files) {
        }
 } #}}}
 
+sub commandline_render () { #{{{
+       loadplugins();
+       checkconfig();
+       lockwiki();
+       loadindex();
+       unlockwiki();
+
+       my $srcfile=possibly_foolish_untaint($config{render});
+       my $file=$srcfile;
+       $file=~s/\Q$config{srcdir}\E\/?//;
+
+       my $type=pagetype($file);
+       die "ikiwiki: cannot render $srcfile\n" unless defined $type;
+       my $content=readfile($srcfile);
+       my $page=pagename($file);
+       $pagesources{$page}=$file;
+       $content=filter($page, $content);
+       $content=preprocess($page, $page, $content);
+       $content=linkify($page, $page, $content);
+       $content=htmlize($page, $type, $content);
+
+       print genpage($page, $content, mtime($srcfile));
+       exit 0;
+} #}}}
+
 1