diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-09-21 21:34:29 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-09-21 21:34:29 +0000 |
commit | c35444826ca47123697a8f2512866f4f99964cc4 (patch) | |
tree | b29bf3982c043867389e5ba4a4ee62789c93f4b2 /IkiWiki | |
parent | 63f09c7cef0eb10d8051a92ff626bf1b5f29b9b0 (diff) |
* Add --render mode, which can be used to preview an edit at the command
line by test rendering a single page.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Render.pm | 25 | ||||
-rw-r--r-- | IkiWiki/Setup/Standard.pm | 7 |
2 files changed, 30 insertions, 2 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index c16877b3d..48a25bef7 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -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 diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm index b7583097d..7512c2587 100644 --- a/IkiWiki/Setup/Standard.pm +++ b/IkiWiki/Setup/Standard.pm @@ -34,7 +34,7 @@ sub setup_standard { $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$setup{exclude}/; } - if (! $config{refresh} || $config{wrappers}) { + if (! $config{render} && (! $config{refresh} || $config{wrappers})) { debug("generating wrappers.."); my @wrappers=@{$setup{wrappers}}; delete $setup{wrappers}; @@ -66,7 +66,10 @@ sub setup_standard { } } - if (! $config{refresh}) { + if ($config{render}) { + commandline_render(); + } + elsif (! $config{refresh}) { $config{rebuild}=1; debug("rebuilding wiki.."); } |