]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Add --render mode, which can be used to preview an edit at the command
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 21 Sep 2006 21:34:29 +0000 (21:34 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 21 Sep 2006 21:34:29 +0000 (21:34 +0000)
  line by test rendering a single page.

IkiWiki/Render.pm
IkiWiki/Setup/Standard.pm
debian/changelog
doc/usage.mdwn
ikiwiki.pl

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
index b7583097daf84851b0ebc43900ae941e79677695..7512c258758eb7e7a577d73e08b2679dc5a6e6b0 100644 (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..");
        }
index c2a80fa2428c8e0888768cd85b5196fbca1ab000..8e4a2fddca90f43a72de2764bb2a3e5e4e9bca86 100644 (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
 
index 0c7e7d036cb266c30374cb81a0c481b63b13a631..aa352736c44285acf70740d8df3d972c4ac07a27 100644 (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.
index aa0fd136a14c46ff9a2a961c16f8fc0840d37302..b4cf0e64a959e57e88b862a00f85c5625e4b24d9 100755 (executable)
@@ -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();