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 | |
parent | 63f09c7cef0eb10d8051a92ff626bf1b5f29b9b0 (diff) |
* Add --render mode, which can be used to preview an edit at the command
line by test rendering a single page.
-rw-r--r-- | IkiWiki/Render.pm | 25 | ||||
-rw-r--r-- | IkiWiki/Setup/Standard.pm | 7 | ||||
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | doc/usage.mdwn | 9 | ||||
-rwxr-xr-x | ikiwiki.pl | 7 |
5 files changed, 48 insertions, 4 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.."); } diff --git a/debian/changelog b/debian/changelog index c2a80fa24..8e4a2fddc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -53,8 +53,10 @@ ikiwiki (1.27) UNRELEASED; urgency=low * Patch from James Westby to make the location of the estseek.cgi script configurable. * Add typography (SmartyPants) plugin by Recai. + * Add --render mode, which can be used to preview an edit at the command + line by test rendering a single page. - -- Joey Hess <joeyh@debian.org> Thu, 21 Sep 2006 16:27:44 -0400 + -- Joey Hess <joeyh@debian.org> Thu, 21 Sep 2006 17:31:25 -0400 ikiwiki (1.26) unstable; urgency=low diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 0c7e7d036..aa352736c 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -75,6 +75,15 @@ These options control the mode that ikiwiki is operating in. along with this one. --rebuild will also force feeds to be polled even if they were polled recently. +* --render file + + Renders a single file, outputting the resulting html. Does not save state, + so this cannot be used for building whole wikis, but it is useful for + previewing an edited file at the command line. Generally used in conjunction + with --setup to load in a wiki's setup: + + ikiwiki --setup ~/ikiwiki.setup --render foo.mdwn + * --version Print ikiwiki version number. diff --git a/ikiwiki.pl b/ikiwiki.pl index aa0fd136a..b4cf0e64a 100755 --- a/ikiwiki.pl +++ b/ikiwiki.pl @@ -26,6 +26,7 @@ sub getconfig () { #{{{ "syslog!" => \$config{syslog}, "rebuild!" => \$config{rebuild}, "refresh!" => \$config{refresh}, + "render=s" => \$config{render}, "wrappers!" => \$config{wrappers}, "getctime" => \$config{getctime}, "wrappermode=i" => \$config{wrappermode}, @@ -76,7 +77,7 @@ sub getconfig () { #{{{ }, ) || usage(); - if (! $config{setup}) { + if (! $config{setup} && ! $config{render}) { loadplugins(); usage() unless @ARGV == 2; $config{srcdir} = possibly_foolish_untaint(shift @ARGV); @@ -114,6 +115,10 @@ sub main () { #{{{ require IkiWiki::Wrapper; gen_wrapper(); } + elsif ($config{render}) { + require IkiWiki::Render; + commandline_render(); + } else { lockwiki(); loadindex(); |