* Add --render mode, which can be used to preview an edit at the command

line by test rendering a single page.
master
joey 2006-09-21 21:34:29 +00:00
parent 63f09c7cef
commit c35444826c
5 changed files with 48 additions and 4 deletions

View 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

View File

@ -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..");
}

4
debian/changelog vendored
View File

@ -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

View File

@ -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.

View File

@ -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();