From 56378a14e2c41902d8d97bf51d26446e42a83ab3 Mon Sep 17 00:00:00 2001 From: joey Date: Wed, 5 Jul 2006 18:20:25 +0000 Subject: [PATCH 01/16] Encode:: cleanup from Recai --- IkiWiki/CGI.pm | 12 ++++++------ IkiWiki/Render.pm | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 424ce2c78..3b4228b75 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -316,7 +316,7 @@ sub cgi_editpage ($$) { #{{{ # This untaint is safe because titlepage removes any problimatic # characters. - my ($page)=Encode::decode_utf8($form->param('page')); + my ($page)=decode_utf8($form->param('page')); $page=titlepage(possibly_foolish_untaint(lc($page))); if (! defined $page || ! length $page || $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) { @@ -363,8 +363,8 @@ sub cgi_editpage ($$) { #{{{ require IkiWiki::Render; # Apparently FormBuilder doesn't not treat input as # utf-8, so decode from it. - my $content = Encode::decode_utf8($form->field('editcontent')); - my $comments = Encode::decode_utf8($form->field('comments')); + my $content=decode_utf8($form->field('editcontent')); + my $comments=decode_utf8($form->field('comments')); $form->field(name => "editcontent", value => $content, force => 1); $form->field(name => "comments", @@ -452,7 +452,7 @@ sub cgi_editpage ($$) { #{{{ page_locked($page, $session); # Decode utf-8 since FormBuilder does not - my $content=Encode::decode_utf8($form->field('editcontent')); + my $content=decode_utf8($form->field('editcontent')); $content=~s/\r\n/\n/g; $content=~s/\r/\n/g; @@ -468,7 +468,7 @@ sub cgi_editpage ($$) { #{{{ } if (defined $form->field('comments') && length $form->field('comments')) { - $message.=": ".Encode::decode_utf8($form->field('comments')); + $message.=": ".decode_utf8($form->field('comments')); } if ($config{rcs}) { @@ -487,7 +487,7 @@ sub cgi_editpage ($$) { #{{{ force => 1); $form->tmpl_param("page_conflict", 1); $form->field("editcontent", value => $conflict, force => 1); - $form->field(name => "comments", value => Encode::decode_utf8($form->field('comments')), force => 1); + $form->field(name => "comments", value => decode_utf8($form->field('comments')), force => 1); $form->field("do", "edit)"); $form->tmpl_param("page_select", 0); $form->field(name => "page", type => 'hidden'); diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index ab43717c6..6d5ea9ee5 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -222,7 +222,7 @@ sub displaytime ($) { #{{{ eval q{use POSIX}; # strftime doesn't know about encodings, so make sure # its output is properly treated as utf8 - return Encode::decode_utf8(POSIX::strftime( + return decode_utf8(POSIX::strftime( $config{timeformat}, localtime($time))); } #}}} @@ -310,7 +310,7 @@ sub refresh () { #{{{ find({ no_chdir => 1, wanted => sub { - $_ = Encode::decode_utf8($_); + $_=decode_utf8($_); if (/$config{wiki_file_prune_regexp}/) { $File::Find::prune=1; } @@ -330,7 +330,7 @@ sub refresh () { #{{{ find({ no_chdir => 1, wanted => sub { - $_ = Encode::decode_utf8($_); + $_=decode_utf8($_); if (/$config{wiki_file_prune_regexp}/) { $File::Find::prune=1; } -- 2.39.5 From 89697f2c7a9cebc9e0c33ca1d056388b9e827eb8 Mon Sep 17 00:00:00 2001 From: joey Date: Wed, 5 Jul 2006 20:54:10 +0000 Subject: [PATCH 02/16] * Patch from Recai to fix utf8 issues in git backend. --- IkiWiki/Rcs/git.pm | 4 +++- debian/changelog | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm index 636eb57f5..6cbcfd14e 100644 --- a/IkiWiki/Rcs/git.pm +++ b/IkiWiki/Rcs/git.pm @@ -3,6 +3,8 @@ use warnings; use strict; use IkiWiki; +use Encode; +use open qw{:utf8 :std}; package IkiWiki; @@ -228,7 +230,7 @@ sub _parse_diff_tree (@) { #{{{ } if (length $file) { push @{ $ci{'details'} }, { - 'file' => $file, + 'file' => decode_utf8($file), 'sha1_from' => $sha1_from, 'sha1_to' => $sha1_to, }; diff --git a/debian/changelog b/debian/changelog index 4d1cea8a9..6b7c1a679 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,8 +3,9 @@ ikiwiki (1.9) UNRELEASED; urgency=low * Improve display of parentlinks and page title of toplevel index page. * Patch from Faidon to use svn --limit when possible for recentchanges, speeds up recentchanges a lot for wikis with more history. + * Patch from Recai to fix utf8 issues in git backend. - -- Joey Hess Wed, 5 Jul 2006 13:33:59 -0400 + -- Joey Hess Wed, 5 Jul 2006 16:53:34 -0400 ikiwiki (1.8) unstable; urgency=low -- 2.39.5 From 723ebda4760d7e6bb848f1b1d39706f441d3f209 Mon Sep 17 00:00:00 2001 From: joey Date: Thu, 6 Jul 2006 19:50:32 +0000 Subject: [PATCH 03/16] some stylesheet improvements for the table, also add a bit more border between items to avoid them running together in some cases --- basewiki/style.css | 18 ++++++++++++++++-- templates/recentchanges.tmpl | 18 ++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/basewiki/style.css b/basewiki/style.css index c7988b7b7..74186ab3b 100644 --- a/basewiki/style.css +++ b/basewiki/style.css @@ -31,12 +31,26 @@ } /* Stuff for the RecentChanges table. */ -.changeheader { +tr.changeheader { background: #eee; color: black !important; } -.changetime { +tr.changeinfo { + background: #eee; + color: black !important; +} +th.changeheader { + padding: 1px .3em; +} +td.changeinfo { + padding: 1px .3em; +} +td.changetime { white-space: nowrap; + padding: 1px .3em; +} +td.changelog { + font-style: italic; } /* Used for adding a blog page. */ diff --git a/templates/recentchanges.tmpl b/templates/recentchanges.tmpl index fe01822da..250e5de51 100644 --- a/templates/recentchanges.tmpl +++ b/templates/recentchanges.tmpl @@ -22,18 +22,18 @@ - - - + + + - - + + - - + - -- 2.39.5 From 0f22d66c965d7f2a3e4698de7ddf992efebf6c42 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 7 Jul 2006 18:28:27 +0000 Subject: [PATCH 04/16] * Add wikitext markup plugin, which supports ".wiki" pages written in the original wiki syntax, CamelCase links and all. --- IkiWiki/Plugin/wikitext.pm | 30 ++++++++++++++++++++++++++++++ debian/changelog | 4 +++- doc/features.mdwn | 5 +++-- doc/ikiwiki.setup | 2 +- doc/install.mdwn | 3 ++- doc/plugins/wikitext.mdwn | 21 +++++++++++++++++++++ 6 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 IkiWiki/Plugin/wikitext.pm create mode 100644 doc/plugins/wikitext.mdwn diff --git a/IkiWiki/Plugin/wikitext.pm b/IkiWiki/Plugin/wikitext.pm new file mode 100644 index 000000000..310b86724 --- /dev/null +++ b/IkiWiki/Plugin/wikitext.pm @@ -0,0 +1,30 @@ +#!/usr/bin/perl +# WikiText markup +package IkiWiki::Plugin::wikitext; + +use warnings; +use strict; +use Text::WikiFormat; + +sub import { #{{{ + IkiWiki::hook(type => "filter", id => "wiki", call => \&filter); + IkiWiki::hook(type => "htmlize", id => "wiki", call => \&htmlize); +} # }}} + +sub filter (@) { #{{{ + my %params=@_; + + # Make CamelCase links work by promoting them to fullfledged + # WikiLinks. This regexp is based on the one in Text::WikiFormat. + $params{content}=~s#(?=])\b((?:[A-Z][a-z0-9]\w*){2,})#[[$1]]#g; + + return $params{content}; +} #}}} + +sub htmlize ($) { #{{{ + my $content = shift; + + return Text::WikiFormat::format($content, undef, { implicit_links => 0 }); +} # }}} + +1 diff --git a/debian/changelog b/debian/changelog index 6b7c1a679..3cea775be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,10 @@ ikiwiki (1.9) UNRELEASED; urgency=low * Patch from Faidon to use svn --limit when possible for recentchanges, speeds up recentchanges a lot for wikis with more history. * 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. - -- Joey Hess Wed, 5 Jul 2006 16:53:34 -0400 + -- Joey Hess Fri, 7 Jul 2006 14:11:50 -0400 ikiwiki (1.8) unstable; urgency=low diff --git a/doc/features.mdwn b/doc/features.mdwn index c22d2be91..5152beffd 100644 --- a/doc/features.mdwn +++ b/doc/features.mdwn @@ -23,11 +23,12 @@ Some of ikiwiki's features: page with a filename ending in ".mdwn" is converted from markdown to html by ikiwiki. Markdown understands text formatted as it would be in an email, and is quite smart about converting it to html. The only additional markup - provided by ikiwiki aside from regular markdown is the [[WikiLink]] and + provided by ikiwiki on top of regular markdown is the [[WikiLink]] and [[PreprocessorDirective]] If you prefer to use some other markup language, ikiwiki allows others to - be added by [[plugins]]. + easily be added by [[plugins]]. For example it also supports traditional + [[plugins/WikiText]] formatted pages. * support for other file types diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index 9713d553b..8bc0e3336 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -71,7 +71,7 @@ use IkiWiki::Setup::Standard { #timeformat => '%c', # To add plugins, list them here. - #add_plugins => [qw{pagecount brokenlinks search smiley}], + #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}], } diff --git a/doc/install.mdwn b/doc/install.mdwn index f65e1a227..d23c88e41 100644 --- a/doc/install.mdwn +++ b/doc/install.mdwn @@ -6,7 +6,8 @@ perl modules if available: `CGI::Session` `CGI::FormBuilder` (version `Date::Parse` (libtimedate-perl), `HTML::Scrubber`, `RPC::XML`, `XML::Simple` -If you want to install from the tarball, you should make sure that the required perl modules are installed, then run: +If you want to install from the tarball, you should make sure that the +required perl modules are installed, then run: perl Makefile.PL make diff --git a/doc/plugins/wikitext.mdwn b/doc/plugins/wikitext.mdwn new file mode 100644 index 000000000..5c5383fc5 --- /dev/null +++ b/doc/plugins/wikitext.mdwn @@ -0,0 +1,21 @@ +This plugin allows ikiwiki to process pages written in the original wiki +text format. To use it, you need to have the Text::WikiFormat perl module +installed, enable the plugin, then files with the extention `.wiki` will be +processed as wiki text. + +Wiki formatting is very simple. An item wrapped in three single quotes is +strong. An item wrapped in two single quotes is emphasized. Any word with +multiple CapitalLetters (e. g., StudlyCaps) will become a link (standard +[[WikiLinks|WikiLink]] work too). Four or more +hyphen characters at the start of a line create a horizontal line. +Newlines turn into the appropriate tags. Headers are matching equals signs +around the header text -- the more signs, the lesser the header. + +Lists are indented text, by one tab or four spaces. In unordered lists, +where each item has its own bullet point, each item needs a leading +asterisk and space. Ordered lists consist of items marked with combination +of one or more alphanumeric characters followed by a period and an optional +space. Any indented text without either marking is code, handled literally. +You can nest lists. + +This plugin is included in ikiwiki, but is not enabled by default. -- 2.39.5 From 42ffdb661c4a070cd0291bc27b4609f51c3777a2 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 7 Jul 2006 18:33:40 +0000 Subject: [PATCH 05/16] html too --- doc/features.mdwn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/features.mdwn b/doc/features.mdwn index 5152beffd..9e9e9195d 100644 --- a/doc/features.mdwn +++ b/doc/features.mdwn @@ -28,7 +28,8 @@ Some of ikiwiki's features: If you prefer to use some other markup language, ikiwiki allows others to easily be added by [[plugins]]. For example it also supports traditional - [[plugins/WikiText]] formatted pages. + [[plugins/WikiText]] formatted pages or pages written as pure + [[plugins/HTML]]. * support for other file types -- 2.39.5 From 1cd1f073fff6be0300dec80cf1571ca247ce24ab Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 7 Jul 2006 19:38:35 +0000 Subject: [PATCH 06/16] web commit from 127.0.0.1 --- doc/features.mdwn | 10 ++++++++-- doc/sandbox.mdwn | 4 +++- doc/serverless.mdwn | 3 +++ doc/todo/terminalclient.mdwn | 20 +++++++++++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 doc/serverless.mdwn diff --git a/doc/features.mdwn b/doc/features.mdwn index 9e9e9195d..1406f5a1b 100644 --- a/doc/features.mdwn +++ b/doc/features.mdwn @@ -38,9 +38,10 @@ Some of ikiwiki's features: unchanged by ikiwiki as it builds your wiki. So you can check in an image, program, or other special file and link to it from your wiki pages. -* [[SubPage]]s +* [[SubPages|SubPage]] - Arbitrarily deep hierarchies of pages with fairly simple and useful [[SubPage/LinkingRules]] + Arbitrarily deep hierarchies of pages with fairly simple and useful + [[SubPage/LinkingRules]] * [[blogging|blog]] @@ -135,6 +136,11 @@ Some of ikiwiki's features: After rather a lot of fiddling, we think that ikiwiki correctly and fully supports utf8 everywhere. +* [[serverless]] mode + + Can be set up so that w3m can be used to browse a wiki and edit pages + without using a web server. + ---- It also has some [[TODO]] items and [[Bugs]]. diff --git a/doc/sandbox.mdwn b/doc/sandbox.mdwn index 6bd9fa072..538d03403 100644 --- a/doc/sandbox.mdwn +++ b/doc/sandbox.mdwn @@ -48,6 +48,8 @@ Bulleted list *one *one +hi, mom! + ---- [[haiku hint="sandbox play"]] @@ -67,4 +69,4 @@ Bulleted list This sandbox is also a [[blog]]! -[[inline pages="sandbox/*" rootpage="sandbox" show="5"]] \ No newline at end of file +[[inline pages="sandbox/*" rootpage="sandbox" show="5"]] diff --git a/doc/serverless.mdwn b/doc/serverless.mdwn new file mode 100644 index 000000000..2cbf6e2f7 --- /dev/null +++ b/doc/serverless.mdwn @@ -0,0 +1,3 @@ +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. diff --git a/doc/todo/terminalclient.mdwn b/doc/todo/terminalclient.mdwn index 1a3908305..8c802888b 100644 --- a/doc/todo/terminalclient.mdwn +++ b/doc/todo/terminalclient.mdwn @@ -3,4 +3,22 @@ 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. 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). +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: + + + +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. -- 2.39.5 From 1bdfa4d8b54763eee1c266e3516bb50dd864cedc Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 7 Jul 2006 21:00:48 +0000 Subject: [PATCH 07/16] * Support a w3mmode, which lets w3m run ikiwiki using its local CGI support, to edit pages etc without a web server. --- IkiWiki.pm | 12 +++++- IkiWiki/CGI.pm | 26 ++++++++---- Makefile.PL | 3 ++ debian/changelog | 2 + doc/features.mdwn | 2 +- doc/sandbox.mdwn | 2 - doc/serverless.mdwn | 3 -- doc/todo/terminalclient.mdwn | 18 +------- doc/usage.mdwn | 5 +++ doc/w3mmode.mdwn | 11 +++++ doc/w3mmode/ikiwiki.setup | 81 ++++++++++++++++++++++++++++++++++++ ikiwiki | 1 + ikiwiki-w3m.cgi | 15 +++++++ 13 files changed, 151 insertions(+), 30 deletions(-) delete mode 100644 doc/serverless.mdwn create mode 100644 doc/w3mmode.mdwn create mode 100644 doc/w3mmode/ikiwiki.setup create mode 100755 ikiwiki-w3m.cgi diff --git a/IkiWiki.pm b/IkiWiki.pm index d8b272125..4964f97a1 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -34,6 +34,7 @@ sub defaultconfig () { #{{{ rebuild => 0, refresh => 0, getctime => 0, + w3mmode => 0, wrapper => undef, wrappermode => undef, svnrepo => undef, @@ -49,8 +50,17 @@ sub defaultconfig () { #{{{ 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"); } diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 3b4228b75..671f0b924 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -9,6 +9,18 @@ use Encode; 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; @@ -158,7 +170,7 @@ sub cgi_signin ($$) { #{{{ $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"), @@ -167,7 +179,7 @@ sub cgi_signin ($$) { #{{{ )); } else { - print $q->redirect($config{url}); + redirect($q, $config{url}); } } elsif ($form->submitted eq 'Register') { @@ -272,11 +284,11 @@ sub cgi_prefs ($$) { #{{{ 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) { @@ -356,7 +368,7 @@ sub cgi_editpage ($$) { #{{{ } if ($form->submitted eq "Cancel") { - print $q->redirect("$config{url}/".htmlpage($page)); + redirect($q, "$config{url}/".htmlpage($page)); return; } elsif ($form->submitted eq "Preview") { @@ -419,7 +431,7 @@ sub cgi_editpage ($$) { #{{{ 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; } @@ -504,7 +516,7 @@ sub cgi_editpage ($$) { #{{{ # 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"); } } #}}} diff --git a/Makefile.PL b/Makefile.PL index 89a8f3232..59c5d86ba 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -39,6 +39,9 @@ extra_install: 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 } } diff --git a/debian/changelog b/debian/changelog index 3cea775be..359ea1c13 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ ikiwiki (1.9) UNRELEASED; urgency=low * 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 Fri, 7 Jul 2006 14:11:50 -0400 diff --git a/doc/features.mdwn b/doc/features.mdwn index 1406f5a1b..1b09a3274 100644 --- a/doc/features.mdwn +++ b/doc/features.mdwn @@ -136,7 +136,7 @@ Some of ikiwiki's features: 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. diff --git a/doc/sandbox.mdwn b/doc/sandbox.mdwn index 538d03403..a536303d2 100644 --- a/doc/sandbox.mdwn +++ b/doc/sandbox.mdwn @@ -48,8 +48,6 @@ Bulleted list *one *one -hi, mom! - ---- [[haiku hint="sandbox play"]] diff --git a/doc/serverless.mdwn b/doc/serverless.mdwn deleted file mode 100644 index 2cbf6e2f7..000000000 --- a/doc/serverless.mdwn +++ /dev/null @@ -1,3 +0,0 @@ -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. diff --git a/doc/todo/terminalclient.mdwn b/doc/todo/terminalclient.mdwn index 8c802888b..b420a3d17 100644 --- a/doc/todo/terminalclient.mdwn +++ b/doc/todo/terminalclient.mdwn @@ -2,23 +2,9 @@ Hack together a local ikiwiki w/o a web server using w3m's cgi-less mode 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: - - - -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. diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 7bc9e5314..8404d15da 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -200,6 +200,11 @@ These options configure the wiki. 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 diff --git a/doc/w3mmode.mdwn b/doc/w3mmode.mdwn new file mode 100644 index 000000000..3afee5c9b --- /dev/null +++ b/doc/w3mmode.mdwn @@ -0,0 +1,11 @@ +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. diff --git a/doc/w3mmode/ikiwiki.setup b/doc/w3mmode/ikiwiki.setup new file mode 100644 index 000000000..ed65e0f91 --- /dev/null +++ b/doc/w3mmode/ikiwiki.setup @@ -0,0 +1,81 @@ +#!/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}], +} diff --git a/ikiwiki b/ikiwiki index 099a821b7..cdb2042e1 100755 --- a/ikiwiki +++ b/ikiwiki @@ -29,6 +29,7 @@ sub getconfig () { #{{{ "rss!" => \$config{rss}, "cgi!" => \$config{cgi}, "discussion!" => \$config{discussion}, + "w3mmode!" => \$config{w3mmode}, "notify!" => \$config{notify}, "url=s" => \$config{url}, "cgiurl=s" => \$config{cgiurl}, diff --git a/ikiwiki-w3m.cgi b/ikiwiki-w3m.cgi new file mode 100755 index 000000000..fd0b0d677 --- /dev/null +++ b/ikiwiki-w3m.cgi @@ -0,0 +1,15 @@ +#!/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: $!"; -- 2.39.5 From dfcd4c299a2a36cacb1de29c67559ac3869e90c8 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 7 Jul 2006 21:03:26 +0000 Subject: [PATCH 08/16] simplify --- doc/w3mmode/ikiwiki.setup | 49 --------------------------------------- 1 file changed, 49 deletions(-) diff --git a/doc/w3mmode/ikiwiki.setup b/doc/w3mmode/ikiwiki.setup index ed65e0f91..bda511747 100644 --- a/doc/w3mmode/ikiwiki.setup +++ b/doc/w3mmode/ikiwiki.setup @@ -7,8 +7,6 @@ use IkiWiki::Setup::Standard { wikiname => "ikiwiki", - #adminuser => ["yourname", ], - #adminemail => 'me@myhost', # Be sure to customise these.. srcdir => "doc", @@ -16,24 +14,9 @@ use IkiWiki::Setup::Standard { # 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. @@ -41,41 +24,9 @@ use IkiWiki::Setup::Standard { 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}], } -- 2.39.5 From 50c21744cac9842b75bfafd776b3dc4c38370b03 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 10 Jul 2006 21:13:41 +0000 Subject: [PATCH 09/16] * Display CGI processing errors if present. --- IkiWiki/CGI.pm | 8 +++++++- debian/changelog | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 671f0b924..53e151dc2 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -534,7 +534,13 @@ sub cgi () { #{{{ my $do=$q->param('do'); if (! defined $do || ! length $do) { - error("\"do\" parameter missing"); + my $error = $q->cgi_error; + if ($error) { + error("Request not processed: $error"); + } + else { + error("\"do\" parameter missing"); + } } # Things that do not need a session. diff --git a/debian/changelog b/debian/changelog index 359ea1c13..b2f037e2f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,8 +8,9 @@ ikiwiki (1.9) UNRELEASED; urgency=low 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. + * Display CGI processing errors if present. - -- Joey Hess Fri, 7 Jul 2006 14:11:50 -0400 + -- Joey Hess Mon, 10 Jul 2006 17:12:57 -0400 ikiwiki (1.8) unstable; urgency=low -- 2.39.5 From f389b08a0c8952494ff95f70c26783d3c3584cf9 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 11 Jul 2006 20:18:11 +0000 Subject: [PATCH 10/16] * Fix from Faidon for a XML parser issue that breaks utf-8 for RecentChanges. Avoid using XML::SAX::PurePerl, which is buggy in this area, and also way slow. --- IkiWiki/Rcs/svn.pm | 7 +++++++ debian/changelog | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/IkiWiki/Rcs/svn.pm b/IkiWiki/Rcs/svn.pm index 71517f215..560eb38a3 100644 --- a/IkiWiki/Rcs/svn.pm +++ b/IkiWiki/Rcs/svn.pm @@ -104,8 +104,15 @@ sub rcs_recentchanges ($) { #{{{ eval q{use CGI 'escapeHTML'}; eval q{use Date::Parse}; eval q{use Time::Duration}; + eval q{use XML::SAX}; eval q{use XML::Simple}; + # avoid using XML::SAX::PurePerl, it's buggy with UTF-8 data + my @parsers = map { ${$_}{Name} } @{XML::SAX->parsers()}; + do { + $XML::Simple::PREFERRED_PARSER = pop @parsers; + } until $XML::Simple::PREFERRED_PARSER ne 'XML::SAX::PurePerl'; + # --limit is only supported on Subversion 1.2.0+ my $svn_version=`svn --version -q`; my $svn_limit=''; diff --git a/debian/changelog b/debian/changelog index b2f037e2f..5c77798bd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,8 +9,11 @@ ikiwiki (1.9) UNRELEASED; urgency=low * Support a w3mmode, which lets w3m run ikiwiki using its local CGI support, to edit pages etc without a web server. * Display CGI processing errors if present. + * Fix from Faidon for a XML parser issue that breaks utf-8 for + RecentChanges. Avoid using XML::SAX::PurePerl, which is buggy in this + area, and also way slow. - -- Joey Hess Mon, 10 Jul 2006 17:12:57 -0400 + -- Joey Hess Tue, 11 Jul 2006 14:37:30 -0400 ikiwiki (1.8) unstable; urgency=low -- 2.39.5 From 40057f507dc4efc9073f1e34b1e1047573d66609 Mon Sep 17 00:00:00 2001 From: www-data Date: Tue, 11 Jul 2006 20:30:05 +0000 Subject: [PATCH 11/16] web commit by joey --- doc/index.mdwn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/index.mdwn b/doc/index.mdwn index 3191d1c24..23e60c00b 100644 --- a/doc/index.mdwn +++ b/doc/index.mdwn @@ -12,6 +12,8 @@ Instead it can use [[Subversion]] (or [[Git]]). * [[Security]] lists potential security problems. ikiwiki is still being developed, and is being written with security as a priority, so don't expect things to stay in this list for long. +* Developers, please document any ikiwiki patches you have in the [[PatchQueue]]. + All wikis are supposed to have a [[SandBox]], so this one does too. ikiwiki is developed by [[Joey]] and is [[FreeSoftware]]. -- 2.39.5 From 20da61215f7da9ac5c62aa5a1e707291fe14c0d5 Mon Sep 17 00:00:00 2001 From: www-data Date: Tue, 11 Jul 2006 20:32:33 +0000 Subject: [PATCH 12/16] web commit by joey --- doc/patchqueue.mdwn | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 doc/patchqueue.mdwn diff --git a/doc/patchqueue.mdwn b/doc/patchqueue.mdwn new file mode 100644 index 000000000..840a7950f --- /dev/null +++ b/doc/patchqueue.mdwn @@ -0,0 +1,4 @@ +Since we have enough people working on ikiwiki to be dangerous, or at least to duplicate work without coordination, and since Joey is still the only one committing directly to the tree, here's a queue of suggested patches. Feel free to either copy the patch inline, or link to one elsewhere (or nag Joey to open up anonymous svn access to this wiki). + +[[inline pages="patchqueue/* !patchqueue/done !link(patchqueue/done) !*/Discussion" rootpage="patchqueue" show="30"]] + -- 2.39.5 From d390421c8c5b933f68616d53474209960b726116 Mon Sep 17 00:00:00 2001 From: www-data Date: Tue, 11 Jul 2006 20:32:59 +0000 Subject: [PATCH 13/16] web commit by joey --- doc/patchqueue.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/patchqueue.mdwn b/doc/patchqueue.mdwn index 840a7950f..0c90aeea8 100644 --- a/doc/patchqueue.mdwn +++ b/doc/patchqueue.mdwn @@ -1,4 +1,4 @@ -Since we have enough people working on ikiwiki to be dangerous, or at least to duplicate work without coordination, and since Joey is still the only one committing directly to the tree, here's a queue of suggested patches. Feel free to either copy the patch inline, or link to one elsewhere (or nag Joey to open up anonymous svn access to this wiki). +Since we have enough people working on ikiwiki to be dangerous, or at least to duplicate work without coordination, and since Joey is still the only one committing directly to the tree, here's a queue of suggested patches. Feel free to either copy the patch inline, or link to one elsewhere (or nag Joey to open up anonymous svn access to this wiki so you can check in the patches directly). [[inline pages="patchqueue/* !patchqueue/done !link(patchqueue/done) !*/Discussion" rootpage="patchqueue" show="30"]] -- 2.39.5 From 8423016f5ac62d6229219a1bc0b485fec52048d1 Mon Sep 17 00:00:00 2001 From: www-data Date: Tue, 11 Jul 2006 20:36:31 +0000 Subject: [PATCH 14/16] web commit by joey --- ...ect_a_page_type_on_new_file_creations.mdwn | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn diff --git a/doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn b/doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn new file mode 100644 index 000000000..90ec73c17 --- /dev/null +++ b/doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn @@ -0,0 +1,127 @@ +From [[Recai]]. + +Note that this isn't safe since it needs to check file types from the CGI +against the list of allowed file types. Also, renaming a page won't work so +at least the first cut needs to be changed to only allow changing file type +when crating a new page. -- [[Joey]] + +diff -rup ikiwiki.orig/IkiWiki/CGI.pm ikiwiki/IkiWiki/CGI.pm +--- ikiwiki.orig/IkiWiki/CGI.pm 2006-07-08 02:33:07.000000000 +0300 ++++ ikiwiki/IkiWiki/CGI.pm 2006-07-08 18:27:24.000000000 +0300 +@@ -310,7 +310,7 @@ sub cgi_editpage ($$) { #{{{ + + eval q{use CGI::FormBuilder}; + my $form = CGI::FormBuilder->new( +- fields => [qw(do rcsinfo subpage from page editcontent comments)], ++ fields => [qw(do rcsinfo subpage from page type editcontent comments)], + header => 1, + charset => "utf-8", + method => 'POST', +@@ -337,12 +337,21 @@ sub cgi_editpage ($$) { #{{{ + $page=lc($page); + + my $file; +- if (exists $pagesources{lc($page)}) { +- $file=$pagesources{lc($page)}; ++ my $type; ++ if (exists $pagesources{$page}) { ++ $file=$pagesources{$page}; ++ $type=pagetype($file); + } + else { +- $file=$page.".".$config{default_pageext}; ++ $type=$form->param('type'); ++ if (defined $type && length $type) { ++ $type=possibly_foolish_untaint($type); ++ } else { ++ $type=$config{default_pageext}; ++ } ++ $file=$page.".".$type; + } ++ + my $newfile=0; + if (! -e "$config{srcdir}/$file") { + $newfile=1; +@@ -353,6 +362,7 @@ sub cgi_editpage ($$) { #{{{ + $form->field(name => "rcsinfo", type => 'hidden'); + $form->field(name => "subpage", type => 'hidden'); + $form->field(name => "page", value => "$page", force => 1); ++ $form->field(name => "type", value => "$type", force => 1, type => 'hidden'); + $form->field(name => "comments", type => "text", size => 80); + $form->field(name => "editcontent", type => "textarea", rows => 20, + cols => 80); +@@ -382,8 +392,7 @@ sub cgi_editpage ($$) { #{{{ + $form->field(name => "comments", + value => $comments, force => 1); + $form->tmpl_param("page_preview", +- htmlize(pagetype($file), +- linkify($page, $page, $content))); ++ htmlize($type, linkify($page, $page, $content))); + } + else { + $form->tmpl_param("page_preview", ""); +@@ -395,6 +404,8 @@ sub cgi_editpage ($$) { #{{{ + if ($form->field("do") eq "create") { + my @page_locs; + my $best_loc; ++ my @page_types; ++ my $best_type; + my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/; + if (! defined $from || ! length $from || + $from ne $form->param('from') || +@@ -435,9 +446,24 @@ sub cgi_editpage ($$) { #{{{ + return; + } + ++ if (exists $hooks{htmlize}) { ++ @page_types=keys %{$hooks{htmlize}}; ++ } ++ else { ++ @page_types=($type); ++ } ++ ++ # favor the type of originated page ++ $best_type=pagetype($pagesources{$from}); ++ if (! defined $best_type || ! length $best_type) { ++ $best_type=$type; ++ } ++ + $form->tmpl_param("page_select", 1); + $form->field(name => "page", type => 'select', + options => \@page_locs, value => $best_loc); ++ $form->field(name => "type", type => 'select', ++ options => \@page_types, value => $best_type); + $form->title("creating ".pagetitle($page)); + } + elsif ($form->field("do") eq "edit") { +@@ -454,6 +480,7 @@ sub cgi_editpage ($$) { #{{{ + } + $form->tmpl_param("page_select", 0); + $form->field(name => "page", type => 'hidden'); ++ $form->field(name => "type", type => 'hidden'); + $form->title("editing ".pagetitle($page)); + } + +@@ -503,6 +530,7 @@ sub cgi_editpage ($$) { #{{{ + $form->field("do", "edit)"); + $form->tmpl_param("page_select", 0); + $form->field(name => "page", type => 'hidden'); ++ $form->field(name => "type", type => 'hidden'); + $form->title("editing $page"); + print $form->render(submit => \@buttons); + return; +diff -rup ikiwiki.orig/templates/editpage.tmpl ikiwiki/templates/editpage.tmpl +--- ikiwiki.orig/templates/editpage.tmpl 2006-07-03 03:13:46.000000000 +0300 ++++ ikiwiki/templates/editpage.tmpl 2006-07-08 18:04:48.000000000 +0300 +@@ -28,9 +28,11 @@ confict and commit again to save your ch + + + Page location: ++Page type: + +
+ ++ +
+
+ -- 2.39.5 From fcffc462befef45aebdec1111a3287b9fcf6c9a5 Mon Sep 17 00:00:00 2001 From: www-data Date: Tue, 11 Jul 2006 20:40:22 +0000 Subject: [PATCH 15/16] web commit by joey --- doc/patchqueue/l10n.mdwn | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 doc/patchqueue/l10n.mdwn diff --git a/doc/patchqueue/l10n.mdwn b/doc/patchqueue/l10n.mdwn new file mode 100644 index 000000000..84bc18fdb --- /dev/null +++ b/doc/patchqueue/l10n.mdwn @@ -0,0 +1,97 @@ +From [[Recai]]: +> Here is my initial work on ikiwiki l10n infrastructure (I'm sending it +> before finalizing, there may be errors). + +I've revised the patches (tested OK): + +- $config{lang} patch: + + http://people.debian.org/~roktas/patches/ikiwiki/ikiwiki-lang.diff + + + Support for CGI::FormBuilder. + + Modify Makefile.PL for l10n. + +- l10n infrastructure from Koha project. (This patch must be applied with + '-p1', also, it needs a 'chmod +x l10n/*.pl' after patching.) + + + Leave templates dir untouched, use a temporary translations directory + instead. + + Fix Makefile (it failed to update templates). + + http://people.debian.org/~roktas/patches/ikiwiki/ikiwiki-l10n.diff + +However... + +> There are two places in IkiWiki, subject to localization: HTML::Template + +Unfortunately this is not correct. There a few (?) exceptional places, for +example button texts in CGI.pm: + + my @buttons=("Save Page", "Preview", "Cancel"); + +> fine. Also a final note, I haven't examined the quality of generated +> templates yet. + +Looks like, tmpl_process3 cannot preserve line breaks in template files. +For example, it processed the following template: + + Someone[1], possibly you, requested that you be emailed the password for +user + on [2]. + + The password is: + + -- + ikiwiki + + [1] The user requesting the password was at IP address + [2] Located at + +as (in Turkish): + +Birisi[1], ki muhtemelen bu sizsiniz, [2] üzerindeki + kullanıcısına ait parolanın epostalanması isteğinde +bulundu. Parola: -- ikiwiki [1] Parolayı isteyen +kullanıcının ait IP adresi: [2] + +---- + +> Unfortunately this is not correct. There a few (?) exceptional places, for +> example button texts in CGI.pm: +> +> my @buttons=("Save Page", "Preview", "Cancel"); + +Hmm, I've thought on this issue. Using Locale::gettext seems to be the +natural solution. But this would need to create another po file and also, +ikiwiki would depend another Perl module. Kinda overkill... + +I have another idea... What about to create another (flat) template file +for this sort of strings? Something like strings.tmpl with the content: + + Save Page, Preview, Cancel + +or we could categorize these strings in some variables (',' is the +delimiter for this code snippet): + + + Save Page, Preview, Cancel + + +and then (preferably in a separate wrapper function in CGI.pm): + + my $template=template("strings.tmpl"); + $template->param("BUTTONS", 1); + my @buttons=split(/\s*,\s*/, $template->output); + +You get the idea... I've tried this method. All in one po file, kind of +ugly, but it _really_ works. + +> > fine. Also a final note, I haven't examined the quality of generated +> > templates yet. +> +> Looks like, tmpl_process3 cannot preserve line breaks in template files. +> For example, it processed the following template: + +This could be easily worked around in tmpl_process3, but I wouldn't like to +maintain a separate utility. -- 2.39.5 From eecc8af979c860eb6c3a37ce9cc98f06c307835f Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 11 Jul 2006 20:41:30 +0000 Subject: [PATCH 16/16] foo --- ...ect_a_page_type_on_new_file_creations.mdwn | 244 +++++++++--------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn b/doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn index 90ec73c17..d1c865598 100644 --- a/doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn +++ b/doc/patchqueue/allow_to_select_a_page_type_on_new_file_creations.mdwn @@ -1,127 +1,127 @@ From [[Recai]]. - + Note that this isn't safe since it needs to check file types from the CGI against the list of allowed file types. Also, renaming a page won't work so at least the first cut needs to be changed to only allow changing file type when crating a new page. -- [[Joey]] - -diff -rup ikiwiki.orig/IkiWiki/CGI.pm ikiwiki/IkiWiki/CGI.pm ---- ikiwiki.orig/IkiWiki/CGI.pm 2006-07-08 02:33:07.000000000 +0300 -+++ ikiwiki/IkiWiki/CGI.pm 2006-07-08 18:27:24.000000000 +0300 -@@ -310,7 +310,7 @@ sub cgi_editpage ($$) { #{{{ - - eval q{use CGI::FormBuilder}; - my $form = CGI::FormBuilder->new( -- fields => [qw(do rcsinfo subpage from page editcontent comments)], -+ fields => [qw(do rcsinfo subpage from page type editcontent comments)], - header => 1, - charset => "utf-8", - method => 'POST', -@@ -337,12 +337,21 @@ sub cgi_editpage ($$) { #{{{ - $page=lc($page); - - my $file; -- if (exists $pagesources{lc($page)}) { -- $file=$pagesources{lc($page)}; -+ my $type; -+ if (exists $pagesources{$page}) { -+ $file=$pagesources{$page}; -+ $type=pagetype($file); - } - else { -- $file=$page.".".$config{default_pageext}; -+ $type=$form->param('type'); -+ if (defined $type && length $type) { -+ $type=possibly_foolish_untaint($type); -+ } else { -+ $type=$config{default_pageext}; -+ } -+ $file=$page.".".$type; - } -+ - my $newfile=0; - if (! -e "$config{srcdir}/$file") { - $newfile=1; -@@ -353,6 +362,7 @@ sub cgi_editpage ($$) { #{{{ - $form->field(name => "rcsinfo", type => 'hidden'); - $form->field(name => "subpage", type => 'hidden'); - $form->field(name => "page", value => "$page", force => 1); -+ $form->field(name => "type", value => "$type", force => 1, type => 'hidden'); - $form->field(name => "comments", type => "text", size => 80); - $form->field(name => "editcontent", type => "textarea", rows => 20, - cols => 80); -@@ -382,8 +392,7 @@ sub cgi_editpage ($$) { #{{{ - $form->field(name => "comments", - value => $comments, force => 1); - $form->tmpl_param("page_preview", -- htmlize(pagetype($file), -- linkify($page, $page, $content))); -+ htmlize($type, linkify($page, $page, $content))); - } - else { - $form->tmpl_param("page_preview", ""); -@@ -395,6 +404,8 @@ sub cgi_editpage ($$) { #{{{ - if ($form->field("do") eq "create") { - my @page_locs; - my $best_loc; -+ my @page_types; -+ my $best_type; - my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/; - if (! defined $from || ! length $from || - $from ne $form->param('from') || -@@ -435,9 +446,24 @@ sub cgi_editpage ($$) { #{{{ - return; - } - -+ if (exists $hooks{htmlize}) { -+ @page_types=keys %{$hooks{htmlize}}; -+ } -+ else { -+ @page_types=($type); -+ } -+ -+ # favor the type of originated page -+ $best_type=pagetype($pagesources{$from}); -+ if (! defined $best_type || ! length $best_type) { -+ $best_type=$type; -+ } -+ - $form->tmpl_param("page_select", 1); - $form->field(name => "page", type => 'select', - options => \@page_locs, value => $best_loc); -+ $form->field(name => "type", type => 'select', -+ options => \@page_types, value => $best_type); - $form->title("creating ".pagetitle($page)); - } - elsif ($form->field("do") eq "edit") { -@@ -454,6 +480,7 @@ sub cgi_editpage ($$) { #{{{ - } - $form->tmpl_param("page_select", 0); - $form->field(name => "page", type => 'hidden'); -+ $form->field(name => "type", type => 'hidden'); - $form->title("editing ".pagetitle($page)); - } - -@@ -503,6 +530,7 @@ sub cgi_editpage ($$) { #{{{ - $form->field("do", "edit)"); - $form->tmpl_param("page_select", 0); - $form->field(name => "page", type => 'hidden'); -+ $form->field(name => "type", type => 'hidden'); - $form->title("editing $page"); - print $form->render(submit => \@buttons); - return; -diff -rup ikiwiki.orig/templates/editpage.tmpl ikiwiki/templates/editpage.tmpl ---- ikiwiki.orig/templates/editpage.tmpl 2006-07-03 03:13:46.000000000 +0300 -+++ ikiwiki/templates/editpage.tmpl 2006-07-08 18:04:48.000000000 +0300 -@@ -28,9 +28,11 @@ confict and commit again to save your ch - - - Page location: -+Page type: - -
- -+ -
-
- + + diff -rup ikiwiki.orig/IkiWiki/CGI.pm ikiwiki/IkiWiki/CGI.pm + --- ikiwiki.orig/IkiWiki/CGI.pm 2006-07-08 02:33:07.000000000 +0300 + +++ ikiwiki/IkiWiki/CGI.pm 2006-07-08 18:27:24.000000000 +0300 + @@ -310,7 +310,7 @@ sub cgi_editpage ($$) { #{{{ + + eval q{use CGI::FormBuilder}; + my $form = CGI::FormBuilder->new( + - fields => [qw(do rcsinfo subpage from page editcontent comments)], + + fields => [qw(do rcsinfo subpage from page type editcontent comments)], + header => 1, + charset => "utf-8", + method => 'POST', + @@ -337,12 +337,21 @@ sub cgi_editpage ($$) { #{{{ + $page=lc($page); + + my $file; + - if (exists $pagesources{lc($page)}) { + - $file=$pagesources{lc($page)}; + + my $type; + + if (exists $pagesources{$page}) { + + $file=$pagesources{$page}; + + $type=pagetype($file); + } + else { + - $file=$page.".".$config{default_pageext}; + + $type=$form->param('type'); + + if (defined $type && length $type) { + + $type=possibly_foolish_untaint($type); + + } else { + + $type=$config{default_pageext}; + + } + + $file=$page.".".$type; + } + + + my $newfile=0; + if (! -e "$config{srcdir}/$file") { + $newfile=1; + @@ -353,6 +362,7 @@ sub cgi_editpage ($$) { #{{{ + $form->field(name => "rcsinfo", type => 'hidden'); + $form->field(name => "subpage", type => 'hidden'); + $form->field(name => "page", value => "$page", force => 1); + + $form->field(name => "type", value => "$type", force => 1, type => 'hidden'); + $form->field(name => "comments", type => "text", size => 80); + $form->field(name => "editcontent", type => "textarea", rows => 20, + cols => 80); + @@ -382,8 +392,7 @@ sub cgi_editpage ($$) { #{{{ + $form->field(name => "comments", + value => $comments, force => 1); + $form->tmpl_param("page_preview", + - htmlize(pagetype($file), + - linkify($page, $page, $content))); + + htmlize($type, linkify($page, $page, $content))); + } + else { + $form->tmpl_param("page_preview", ""); + @@ -395,6 +404,8 @@ sub cgi_editpage ($$) { #{{{ + if ($form->field("do") eq "create") { + my @page_locs; + my $best_loc; + + my @page_types; + + my $best_type; + my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/; + if (! defined $from || ! length $from || + $from ne $form->param('from') || + @@ -435,9 +446,24 @@ sub cgi_editpage ($$) { #{{{ + return; + } + + + if (exists $hooks{htmlize}) { + + @page_types=keys %{$hooks{htmlize}}; + + } + + else { + + @page_types=($type); + + } + + + + # favor the type of originated page + + $best_type=pagetype($pagesources{$from}); + + if (! defined $best_type || ! length $best_type) { + + $best_type=$type; + + } + + + $form->tmpl_param("page_select", 1); + $form->field(name => "page", type => 'select', + options => \@page_locs, value => $best_loc); + + $form->field(name => "type", type => 'select', + + options => \@page_types, value => $best_type); + $form->title("creating ".pagetitle($page)); + } + elsif ($form->field("do") eq "edit") { + @@ -454,6 +480,7 @@ sub cgi_editpage ($$) { #{{{ + } + $form->tmpl_param("page_select", 0); + $form->field(name => "page", type => 'hidden'); + + $form->field(name => "type", type => 'hidden'); + $form->title("editing ".pagetitle($page)); + } + + @@ -503,6 +530,7 @@ sub cgi_editpage ($$) { #{{{ + $form->field("do", "edit)"); + $form->tmpl_param("page_select", 0); + $form->field(name => "page", type => 'hidden'); + + $form->field(name => "type", type => 'hidden'); + $form->title("editing $page"); + print $form->render(submit => \@buttons); + return; + diff -rup ikiwiki.orig/templates/editpage.tmpl ikiwiki/templates/editpage.tmpl + --- ikiwiki.orig/templates/editpage.tmpl 2006-07-03 03:13:46.000000000 +0300 + +++ ikiwiki/templates/editpage.tmpl 2006-07-08 18:04:48.000000000 +0300 + @@ -28,9 +28,11 @@ confict and commit again to save your ch + + + Page location: + +Page type: + +
+ + + +
+
+ -- 2.39.5
usertimechangesusertimechanges
+ "> @@ -45,17 +45,15 @@
- +
-