support, to edit pages etc without a web server.
rebuild => 0,
refresh => 0,
getctime => 0,
+ w3mmode => 0,
wrapper => undef,
wrappermode => undef,
svnrepo => undef,
plugin => [qw{mdwn inline htmlscrubber}],
timeformat => '%c',
} #}}}
-
+
sub checkconfig () { #{{{
+ if ($config{w3mmode}) {
+ eval q{use Cwd q{abs_path}};
+ $config{srcdir}=possibly_foolish_untaint(abs_path($config{srcdir}));
+ $config{destdir}=possibly_foolish_untaint(abs_path($config{destdir}));
+ $config{cgiurl}="file:///\$LIB/ikiwiki-w3m.cgi/".$config{cgiurl}
+ unless $config{cgiurl} =~ m!file:///!;
+ $config{url}="file://".$config{destdir};
+ }
+
if ($config{cgi} && ! length $config{url}) {
error("Must specify url to wiki with --url when using --cgi\n");
}
package IkiWiki;
+sub redirect ($$) { #{{{
+ my $q=shift;
+ my $url=shift;
+ if (! $config{w3mmode}) {
+ print $q->redirect($url);
+ }
+ else {
+ print "Content-type: text/plain\n";
+ print "W3m-control: GOTO $url\n\n";
+ }
+} #}}}
+
sub page_locked ($$;$) { #{{{
my $page=shift;
my $session=shift;
$session->param("name", $form->field("name"));
if (defined $form->field("do") &&
$form->field("do") ne 'signin') {
- print $q->redirect(cgiurl(
+ redirect($q, cgiurl(
do => $form->field("do"),
page => $form->field("page"),
title => $form->field("title"),
));
}
else {
- print $q->redirect($config{url});
+ redirect($q, $config{url});
}
}
elsif ($form->submitted eq 'Register') {
if ($form->submitted eq 'Logout') {
$session->delete();
- print $q->redirect($config{url});
+ redirect($q, $config{url});
return;
}
elsif ($form->submitted eq 'Cancel') {
- print $q->redirect($config{url});
+ redirect($q, $config{url});
return;
}
elsif ($form->submitted eq "Save Preferences" && $form->validate) {
}
if ($form->submitted eq "Cancel") {
- print $q->redirect("$config{url}/".htmlpage($page));
+ redirect($q, "$config{url}/".htmlpage($page));
return;
}
elsif ($form->submitted eq "Preview") {
if (! @page_locs) {
# hmm, someone else made the page in the
# meantime?
- print $q->redirect("$config{url}/".htmlpage($page));
+ redirect($q, "$config{url}/".htmlpage($page));
return;
}
# The trailing question mark tries to avoid broken
# caches and get the most recent version of the page.
- print $q->redirect("$config{url}/".htmlpage($page)."?updated");
+ redirect($q, "$config{url}/".htmlpage($page)."?updated");
}
} #}}}
install -d $(PREFIX)/sbin
install ikiwiki-mass-rebuild $(PREFIX)/sbin
+
+ install -d $(PREFIX)/lib/w3m/cgi-bin
+ install ikiwiki-w3m.cgi $(PREFIX)/lib/w3m/cgi-bin
}
}
* Patch from Recai to fix utf8 issues in git backend.
* Add wikitext markup plugin, which supports ".wiki" pages written in the
original wiki syntax, CamelCase links and all.
+ * Support a w3mmode, which lets w3m run ikiwiki using its local CGI
+ support, to edit pages etc without a web server.
-- Joey Hess <joeyh@debian.org> Fri, 7 Jul 2006 14:11:50 -0400
After rather a lot of fiddling, we think that ikiwiki correctly and fully
supports utf8 everywhere.
-* [[serverless]] mode
+* [[w3mmode]]
Can be set up so that w3m can be used to browse a wiki and edit pages
without using a web server.
*one
*one
-hi, mom!
-
----
[[haiku hint="sandbox play"]]
+++ /dev/null
-It's possible to use all of ikiwiki's web features (page editing, etc) in
-the `w3m` web browser without using a web server. `w3m` supports local CGI
-scripts, and ikiwiki can be set up to run that way.
and $EDITOR. Browse around a wiki, select pages to edit and get dropped
right into the editor and have the page committed to svn automatically.
+[[todo/done]]
+
Less grandiosely, a simple command line util to add a new page would be
useful, especially if it made it easy to add blog entries to the wiki. I
have a special purpose version of this in my [blog
script](http://kitenet.net/~joey/code/bin.html).
-
-----
-
-w3m's cgi mode requires that cgis be in /usr/lib/w3m/cgi-bin/, and the url
-for it can be $LIB/script. This presents a problem, since a regular user
-can't add an ikiwiki wrapper to there (nor should they). But,
-/usr/lib/w3m/cgi-bin/ikiwiki could be a meta-wrapper, that is passed the
-path to the real wrapper in PATH_INFO, validates it, and runs the real
-wrapper. So:
-
-<a href="file:///$LIB/ikiwiki.cgi/home/joey/.ikiwiki/wrappers/ikiwiki.cgi">
-
-Validation is important, because we don't want just any html document
-including an evil w3m cgi that gets unintentionally run. The validation I'm
-thinking of is that the ikiwiki meta-wrapper only runs wrappers in
-$HOME/.ikiwiki/wrappers/, which the user presumably controls.
Be vebose about what is being done.
+* --w3mmode, --no-w3mmode
+
+ Enable [[w3mmode]], which allows w3m to use ikiwiki as a local CGI script,
+ without a web server.
+
* --getctime
Pull last changed time for each new page out of the revision control
--- /dev/null
+It's possible to use all of ikiwiki's web features (page editing, etc) in
+the `w3m` web browser without using a web server. `w3m` supports local CGI
+scripts, and ikiwiki can be set up to run that way. This requires some
+special configuration:
+
+ * `w3mmode` must be enabled
+ * A CGI wrapper must be created, in ~/.ikiwiki/wrappers/
+ * `cgiurl` should be set to just the base of the filename of the CGI
+ wrapper.
+
+This [[ikiwiki.setup]] is an example of setting up a wiki using w3mmode.
--- /dev/null
+#!/usr/bin/perl
+# Configuration file for ikiwiki (w3m mode).
+# Passing this to ikiwiki --setup will make ikiwiki generate wrappers and
+# build the wiki.
+#
+# Remember to re-run ikiwiki --setup any time you edit this file.
+
+use IkiWiki::Setup::Standard {
+ wikiname => "ikiwiki",
+ #adminuser => ["yourname", ],
+ #adminemail => 'me@myhost',
+
+ # Be sure to customise these..
+ srcdir => "doc",
+ destdir => "html",
+
+ # Enable w3m mode.
+ w3mmode => 1,
+
+ cgiurl => 'ikiwiki.cgi',
+ #templatedir => "/usr/share/ikiwiki/templates",
+
+ rcs => "",
+
+ # Subversion stuff.
+ #rcs => "svn",
+ #historyurl => "http://svn.myhost/trunk/[[file]]",
+ #diffurl => "http://svn.someurl/trunk/[[file]]?root=wiki&r1=[[r1]]&r2=[[r2]]",
+ #svnrepo => "/svn/wiki",
+ #svnpath => "trunk",
+
+ # Git stuff.
+ #rcs => "git",
+ #historyurl => "http://git.host/gitweb.cgi?p=wiki.git;a=history;f=[[file]]",
+ #diffurl => "http://git.host/gitweb.cgi?p=wiki.git;a=blobdiff;h=[[sha1_to]];hp=[[sha1_from]];hb=[[sha1_parent]];f=[[file]]",
+
+ wrappers => [
+ {
+ # The cgi wrapper.
+ cgi => 1,
+ wrapper => "$ENV{HOME}/.ikiwiki/wrappers/ikiwiki.cgi",
+ wrappermode => "0755",
+ },
+ #{
+ # # The svn post-commit wrapper.
+ # # Note that this will overwrite any existing
+ # # post-commit hook script, which may not be
+ # # what you want.
+ # wrapper => "/svn/wikirepo/hooks/post-commit",
+ # wrappermode => "04755",
+ # # Enable mail notifications of commits.
+ # notify => 1,
+ #},
+ #{
+ # # The git post-update wrapper.
+ # # Note that this will overwrite any existing
+ # # post-update hook script, which may not be
+ # # what you want.
+ # wrapper => "/git/wikirepo/.git/hooks/post-update",
+ # wrappermode => "04755",
+ # # Enable mail notifications of commits.
+ # notify => 1,
+ #},
+ ],
+
+ # Can anonymous web users edit pages?
+ anonok => 1,
+ # Generate rss feeds for pages?
+ rss => 1,
+ # Urls to ping with XML-RPC when rss feeds are updated
+ #pingurl => [qw{http://rpc.technorati.com/rpc/ping}],
+ # Include discussion links on all pages?
+ discussion => 1,
+ # Time format (for strftime)
+ #timeformat => '%c',
+
+ # To add plugins, list them here.
+ #add_plugins => [qw{pagecount brokenlinks search smiley wikitext}],
+ # If you want to disable any of the default plugins, list them here.
+ #disable_plugins => [qw{inline htmlscrubber}],
+}
"rss!" => \$config{rss},
"cgi!" => \$config{cgi},
"discussion!" => \$config{discussion},
+ "w3mmode!" => \$config{w3mmode},
"notify!" => \$config{notify},
"url=s" => \$config{url},
"cgiurl=s" => \$config{cgiurl},
--- /dev/null
+#!/usr/bin/perl
+# ikiwiki w3m cgi meta-wrapper
+if (! exists $ENV{PATH_INFO} || ! length $ENV{PATH_INFO}) {
+ die "PATH_INFO should be set";
+}
+my $path=$ENV{PATH_INFO};
+$path=~s!/!!g;
+$path="$ENV{HOME}/.ikiwiki/wrappers/$path";
+if (! -x $path) {
+ print "Content-type: text/html\n\n";
+ print "Cannot find ikiwiki wrapper: $path\n";
+ exit 1;
+}
+exec $path;
+die "$path: exec error: $!";