From 46308ef825f568a8ca988436fa4022e3949ccabf Mon Sep 17 00:00:00 2001 From: www-data Date: Mon, 13 Mar 2006 01:07:50 +0000 Subject: [PATCH 01/16] web commit by webtest --- doc/index/discussion.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/index/discussion.mdwn b/doc/index/discussion.mdwn index 75afb2690..34d0cf048 100644 --- a/doc/index/discussion.mdwn +++ b/doc/index/discussion.mdwn @@ -1,4 +1,4 @@ -This [[subpage]] is a discussion page for ikiwiki. Feel free to discuss anything about the program here. +This [[SubPage]] is a discussion page for ikiwiki. Feel free to discuss anything about the program here. ---- -- 2.39.5 From 09902169560ec64800c5622d87fd2d85c246fc93 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 02:08:04 +0000 Subject: [PATCH 02/16] - add --exclude - move all the config vars into %config --- Makefile | 3 +- doc/todo.mdwn | 13 ++- doc/usage.mdwn | 7 +- ikiwiki | 259 +++++++++++++++++++++++++------------------------ 4 files changed, 154 insertions(+), 128 deletions(-) diff --git a/Makefile b/Makefile index 32c4feae1..94e66ce74 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ all: - ./ikiwiki doc templates html --wikiname="ikiwiki" --verbose --nosvn + ./ikiwiki doc templates html --wikiname="ikiwiki" --verbose \ + --nosvn --exclude=/discussion clean: rm -rf html diff --git a/doc/todo.mdwn b/doc/todo.mdwn index 4d82be982..98b98e3f2 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -21,7 +21,8 @@ is built. (As long as all changes to all pages is ok.) ## docs -Need to document all the command line switches in a man page and somehow on this wiki too. Can markdown generate a man page somehow? +Need to turn [[usage]] into a man page. +this wiki too. Can markdown generate a man page somehow? ## pluggable renderers @@ -61,4 +62,14 @@ and that includes the date. What syntax do other wikis use for this? I'm considering "[[ -- ]]" (with spaces removed) as it has a nice nmemonic. +## recentchanges links to commit diffs + +Would take a bit more viewcvs integration, let the be a "[diff]" link in +recentchanges that goes to the diff for any listed change. + +## recentchanges more than 100 + +Possibly add "next 100" link to it, but OTOH, you can just use svn log if +you need that data.. + ## [[Bugs]] diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 693c4659a..8f57a1593 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -66,6 +66,11 @@ Note that most options can be shortened to single letters, and boolean flags suc Specifies the url to link to for page history browsing. In the url, "[[]]" is replaced with the page to browse. It's common to use [[ViewCVS]] for this. +* --exclude regexp + + Specifies a rexexp of source files to exclude from processing. + May be specified multiple times to add to exclude list. + # AUTHOR -Joey Hess \ No newline at end of file +Joey Hess diff --git a/ikiwiki b/ikiwiki index 8e22ebfac..4246c7e78 100755 --- a/ikiwiki +++ b/ikiwiki @@ -13,28 +13,34 @@ BEGIN { } $ENV{PATH}="/usr/local/bin:/usr/bin:/bin"; -my ($srcdir, $templatedir, $destdir, %links, %oldlinks, %oldpagemtime, - %renderedfiles, %pagesources); -my $wiki_link_regexp=qr/\[\[([^\s]+)\]\]/; -my $wiki_file_regexp=qr/(^[-A-Za-z0-9_.:\/+]+$)/; -my $wiki_file_prune_regexp=qr!((^|/).svn/|\.\.|^\.|\/\.|\.html?$)!; -my $verbose=0; -my $wikiname="wiki"; -my $default_pagetype=".mdwn"; -my $cgi=0; -my $url=""; -my $cgiurl=""; -my $historyurl=""; -my $svn=1; -my $anonok=0; -my $rebuild=0; +my (%links, %oldlinks, %oldpagemtime, %renderedfiles, %pagesources); + +my %config=( + wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)}, + wiki_link_regexp => qr/\[\[([^\s]+)\]\]/, + wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/, + verbose => 0, + wikiname => "wiki", + default_pageext => ".mdwn", + cgi => 0, + url => "", + cgiurl => "", + historyurl => "", + svn => 1, + anonok => 0, + rebuild => 0, + wrapper => 0, + srcdir => undef, + destdir => undef, + templatedir => undef, +); sub usage { #{{{ die "usage: ikiwiki [options] source templates dest\n"; } #}}} sub error ($) { #{{{ - if ($cgi) { + if ($config{cgi}) { print "Content-type: text/html\n\n"; print misctemplate("Error", "

Error: @_

"); exit 1; @@ -45,11 +51,12 @@ sub error ($) { #{{{ } #}}} sub debug ($) { #{{{ - if (! $cgi) { - print "@_\n" if $verbose; + return unless $config{verbose}; + if (! $config{cgi}) { + print "@_\n"; } else { - print STDERR "@_\n" if $verbose; + print STDERR "@_\n"; } } #}}} @@ -139,7 +146,7 @@ sub findlinks ($) { #{{{ my $content=shift; my @links; - while ($content =~ /$wiki_link_regexp/g) { + while ($content =~ /$config{wiki_link_regexp}/g) { push @links, lc($1); } return @links; @@ -194,10 +201,10 @@ sub htmllink { #{{{ } if (! grep { $_ eq $bestlink } values %renderedfiles) { if (! $createsubpage) { - return "?$link" + return "?$link" } else { - return "?$link" + return "?$link" } } @@ -213,7 +220,7 @@ sub linkify ($$) { #{{{ my $content=shift; my $file=shift; - $content =~ s/$wiki_link_regexp/htmllink(pagename($file), $1)/eg; + $content =~ s/$config{wiki_link_regexp}/htmllink(pagename($file), $1)/eg; return $content; } #}}} @@ -271,12 +278,12 @@ sub parentlinks ($) { #{{{ } $path.="../"; } - unshift @ret, { url => $path , page => $wikiname }; + unshift @ret, { url => $path , page => $config{wikiname} }; return @ret; } #}}} sub indexlink () { #{{{ - return "$wikiname"; + return "$config{wikiname}"; } #}}} sub finalize ($$) { #{{{ @@ -287,24 +294,24 @@ sub finalize ($$) { #{{{ $title=~s/_/ /g; my $template=HTML::Template->new(blind_cache => 1, - filename => "$templatedir/page.tmpl"); + filename => "$config{templatedir}/page.tmpl"); - if (length $cgiurl) { - $template->param(editurl => "$cgiurl?do=edit&page=$page"); - if ($svn) { - $template->param(recentchangesurl => "$cgiurl?do=recentchanges"); + if (length $config{cgiurl}) { + $template->param(editurl => "$config{cgiurl}?do=edit&page=$page"); + if ($config{svn}) { + $template->param(recentchangesurl => "$config{cgiurl}?do=recentchanges"); } } - if (length $historyurl) { - my $u=$historyurl; + if (length $config{historyurl}) { + my $u=$config{historyurl}; $u=~s/\[\[\]\]/$pagesources{$page}/g; $template->param(historyurl => $u); } $template->param( title => $title, - wikiname => $wikiname, + wikiname => $config{wikiname}, parentlinks => [parentlinks($page)], content => $content, backlinks => [backlinks($page)], @@ -320,7 +327,7 @@ sub check_overwrite ($$) { #{{{ my $dest=shift; my $src=shift; - if (! exists $renderedfiles{$src} && -e $dest && ! $rebuild) { + if (! exists $renderedfiles{$src} && -e $dest && ! $config{rebuild}) { error("$dest exists and was rendered from ". join(" ",(grep { $renderedfiles{$_} eq $dest } keys %renderedfiles)). @@ -332,7 +339,7 @@ sub render ($) { #{{{ my $file=shift; my $type=pagetype($file); - my $content=readfile("$srcdir/$file"); + my $content=readfile("$config{srcdir}/$file"); if ($type ne 'unknown') { my $page=pagename($file); @@ -342,22 +349,22 @@ sub render ($) { #{{{ $content=htmlize($type, $content); $content=finalize($content, $page); - check_overwrite("$destdir/".htmlpage($page), $page); - writefile("$destdir/".htmlpage($page), $content); + check_overwrite("$config{destdir}/".htmlpage($page), $page); + writefile("$config{destdir}/".htmlpage($page), $content); $oldpagemtime{$page}=time; $renderedfiles{$page}=htmlpage($page); } else { $links{$file}=[]; - check_overwrite("$destdir/$file", $file); - writefile("$destdir/$file", $content); + check_overwrite("$config{destdir}/$file", $file); + writefile("$config{destdir}/$file", $content); $oldpagemtime{$file}=time; $renderedfiles{$file}=$file; } } #}}} sub loadindex () { #{{{ - open (IN, "$srcdir/.ikiwiki/index") || return; + open (IN, "$config{srcdir}/.ikiwiki/index") || return; while () { $_=possibly_foolish_untaint($_); chomp; @@ -373,10 +380,10 @@ sub loadindex () { #{{{ } #}}} sub saveindex () { #{{{ - if (! -d "$srcdir/.ikiwiki") { - mkdir("$srcdir/.ikiwiki"); + if (! -d "$config{srcdir}/.ikiwiki") { + mkdir("$config{srcdir}/.ikiwiki"); } - open (OUT, ">$srcdir/.ikiwiki/index") || error("cannot write to index: $!"); + open (OUT, ">$config{srcdir}/.ikiwiki/index") || error("cannot write to index: $!"); foreach my $page (keys %oldpagemtime) { print OUT "$oldpagemtime{$page} $pagesources{$page} $renderedfiles{$page} ". join(" ", @{$links{$page}})."\n" @@ -386,8 +393,8 @@ sub saveindex () { #{{{ } #}}} sub rcs_update () { #{{{ - if (-d "$srcdir/.svn") { - if (system("svn", "update", "--quiet", $srcdir) != 0) { + if (-d "$config{srcdir}/.svn") { + if (system("svn", "update", "--quiet", $config{srcdir}) != 0) { warn("svn update failed\n"); } } @@ -396,9 +403,10 @@ sub rcs_update () { #{{{ sub rcs_commit ($) { #{{{ my $message=shift; - if (-d "$srcdir/.svn") { + if (-d "$config{srcdir}/.svn") { if (system("svn", "commit", "--quiet", "-m", - possibly_foolish_untaint($message), $srcdir) != 0) { + possibly_foolish_untaint($message), + $config{srcdir}) != 0) { warn("svn commit failed\n"); } } @@ -407,14 +415,14 @@ sub rcs_commit ($) { #{{{ sub rcs_add ($) { #{{{ my $file=shift; - if (-d "$srcdir/.svn") { + if (-d "$config{srcdir}/.svn") { my $parent=dirname($file); - while (! -d "$srcdir/$parent/.svn") { + while (! -d "$config{srcdir}/$parent/.svn") { $file=$parent; $parent=dirname($file); } - if (system("svn", "add", "--quiet", "$srcdir/$file") != 0) { + if (system("svn", "add", "--quiet", "$config{srcdir}/$file") != 0) { warn("svn add failed\n"); } } @@ -427,8 +435,8 @@ sub rcs_recentchanges ($) { #{{{ eval q{use Date::Parse}; eval q{use Time::Duration}; - if (-d "$srcdir/.svn") { - my $info=`LANG=C svn info $srcdir`; + if (-d "$config{srcdir}/.svn") { + my $info=`LANG=C svn info $config{srcdir}`; my ($svn_url)=$info=~/^URL: (.*)$/m; # FIXME: currently assumes that the wiki is somewhere @@ -504,22 +512,22 @@ sub refresh () { #{{{ find({ no_chdir => 1, wanted => sub { - if (/$wiki_file_prune_regexp/) { + if (/$config{wiki_file_prune_regexp}/) { $File::Find::prune=1; } elsif (! -d $_) { - my ($f)=/$wiki_file_regexp/; # untaint + my ($f)=/$config{wiki_file_regexp}/; # untaint if (! defined $f) { warn("skipping bad filename $_\n"); } else { - $f=~s/^\Q$srcdir\E\/?//; + $f=~s/^\Q$config{srcdir}\E\/?//; push @files, $f; $exists{pagename($f)}=1; } } }, - }, $srcdir); + }, $config{srcdir}); my %rendered; @@ -539,7 +547,7 @@ sub refresh () { #{{{ if (! $exists{$page}) { debug("removing old page $page"); push @del, $renderedfiles{$page}; - prune($destdir."/".$renderedfiles{$page}); + prune($config{destdir}."/".$renderedfiles{$page}); delete $renderedfiles{$page}; $oldpagemtime{$page}=0; delete $pagesources{$page}; @@ -551,7 +559,7 @@ sub refresh () { #{{{ my $page=pagename($file); if (! exists $oldpagemtime{$page} || - mtime("$srcdir/$file") > $oldpagemtime{$page}) { + mtime("$config{srcdir}/$file") > $oldpagemtime{$page}) { debug("rendering changed file $file"); render($file); $rendered{$file}=1; @@ -622,26 +630,25 @@ FILE: foreach my $file (@files) { # Generates a C wrapper program for running ikiwiki in a specific way. # The wrapper may be safely made suid. -sub gen_wrapper ($$) { #{{{ - my ($svn, $rebuild)=@_; - +sub gen_wrapper () { #{{{ eval q{use Cwd 'abs_path'}; - $srcdir=abs_path($srcdir); - $destdir=abs_path($destdir); + $config{srcdir}=abs_path($config{srcdir}); + $config{destdir}=abs_path($config{destdir}); my $this=abs_path($0); if (! -x $this) { error("$this doesn't seem to be executable"); } - my @params=($srcdir, $templatedir, $destdir, "--wikiname=$wikiname"); - push @params, "--verbose" if $verbose; - push @params, "--rebuild" if $rebuild; - push @params, "--nosvn" if !$svn; - push @params, "--cgi" if $cgi; - push @params, "--url=$url" if $url; - push @params, "--cgiurl=$cgiurl" if $cgiurl; - push @params, "--historyurl=$historyurl" if $historyurl; - push @params, "--anonok" if $anonok; + my @params=($config{srcdir}, $config{templatedir}, $config{destdir}, + "--wikiname=$config{wikiname}"); + push @params, "--verbose" if $config{verbose}; + push @params, "--rebuild" if $config{rebuild}; + push @params, "--nosvn" if !$config{svn}; + push @params, "--cgi" if $config{cgi}; + push @params, "--url=$config{url}" if length $config{url}; + push @params, "--cgiurl=$config{cgiurl}" if length $config{cgiurl}; + push @params, "--historyurl=$config{historyurl}" if length $config{historyurl}; + push @params, "--anonok" if $config{anonok}; my $params=join(" ", map { "\'$_\'" } @params); my $call=''; foreach my $p ($this, $this, @params) { @@ -652,7 +659,7 @@ sub gen_wrapper ($$) { #{{{ my @envsave; push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE - HTTP_COOKIE} if $cgi; + HTTP_COOKIE} if $config{cgi}; my $envsave=""; foreach my $var (@envsave) { $envsave.=<<"EOF" @@ -706,12 +713,12 @@ sub misctemplate ($$) { #{{{ my $pagebody=shift; my $template=HTML::Template->new( - filename => "$templatedir/misc.tmpl" + filename => "$config{templatedir}/misc.tmpl" ); $template->param( title => $title, indexlink => indexlink(), - wikiname => $wikiname, + wikiname => $config{wikiname}, pagebody => $pagebody, ); return $template->output; @@ -721,12 +728,12 @@ sub cgi_recentchanges ($) { #{{{ my $q=shift; my $template=HTML::Template->new( - filename => "$templatedir/recentchanges.tmpl" + filename => "$config{templatedir}/recentchanges.tmpl" ); $template->param( title => "RecentChanges", indexlink => indexlink(), - wikiname => $wikiname, + wikiname => $config{wikiname}, changelog => [rcs_recentchanges(100)], ); print $q->header, $template->output; @@ -737,7 +744,7 @@ sub userinfo_get ($$) { #{{{ my $field=shift; eval q{use Storable}; - my $userdata=eval{ Storable::lock_retrieve("$srcdir/.ikiwiki/userdb") }; + my $userdata=eval{ Storable::lock_retrieve("$config{srcdir}/.ikiwiki/userdb") }; if (! defined $userdata || ! ref $userdata || ! exists $userdata->{$user} || ! ref $userdata->{$user}) { return ""; @@ -750,13 +757,13 @@ sub userinfo_set ($$) { #{{{ my $info=shift; eval q{use Storable}; - my $userdata=eval{ Storable::lock_retrieve("$srcdir/.ikiwiki/userdb") }; + my $userdata=eval{ Storable::lock_retrieve("$config{srcdir}/.ikiwiki/userdb") }; if (! defined $userdata || ! ref $userdata) { $userdata={}; } $userdata->{$user}=$info; my $oldmask=umask(077); - my $ret=Storable::lock_store($userdata, "$srcdir/.ikiwiki/userdb"); + my $ret=Storable::lock_store($userdata, "$config{srcdir}/.ikiwiki/userdb"); umask($oldmask); return $ret; } #}}} @@ -767,7 +774,7 @@ sub cgi_signin ($$) { #{{{ eval q{use CGI::FormBuilder}; my $form = CGI::FormBuilder->new( - title => "$wikiname signin", + title => "$config{wikiname} signin", fields => [qw(do page from name password confirm_password email)], header => 1, method => 'POST', @@ -782,7 +789,8 @@ sub cgi_signin ($$) { #{{{ params => $q, action => $q->request_uri, header => 0, - template => (-e "$templatedir/signin.tmpl" ? "$templatedir/signin.tmpl" : "") + template => (-e "$config{templatedir}/signin.tmpl" ? + "$config{templatedir}/signin.tmpl" : "") ); $form->field(name => "name", required => 0); @@ -861,12 +869,12 @@ sub cgi_signin ($$) { #{{{ if (defined $form->field("do") && $form->field("do") ne 'signin') { print $q->redirect( - "$cgiurl?do=".$form->field("do"). + "$config{cgiurl}?do=".$form->field("do"). "&page=".$form->field("page"). "&from=".$form->field("from"));; } else { - print $q->redirect($url); + print $q->redirect($config{url}); } } elsif ($form->submitted eq 'Register') { @@ -889,23 +897,22 @@ sub cgi_signin ($$) { #{{{ elsif ($form->submitted eq 'Mail Password') { my $user_name=$form->field("name"); my $template=HTML::Template->new( - filename => "$templatedir/passwordmail.tmpl" + filename => "$config{templatedir}/passwordmail.tmpl" ); $template->param( user_name => $user_name, user_password => userinfo_get($user_name, "password"), - wikiurl => $url, - wikiname => $wikiname, + wikiurl => $config{url}, + wikiname => $config{wikiname}, REMOTE_ADDR => $ENV{REMOTE_ADDR}, ); eval q{use Mail::Sendmail}; - my ($fromhost) = $cgiurl =~ m!/([^/]+)!; - print STDERR "$< $> >>> $cgiurl ".(getpwuid($>))[0]."@".$fromhost."\n"; + my ($fromhost) = $config{cgiurl} =~ m!/([^/]+)!; sendmail( To => userinfo_get($user_name, "email"), - From => "$wikiname admin <".(getpwuid($>))[0]."@".$fromhost.">", - Subject => "$wikiname information", + From => "$config{wikiname} admin <".(getpwuid($>))[0]."@".$fromhost.">", + Subject => "$config{wikiname} information", Message => $template->output, ) or error("Failed to send mail"); @@ -938,12 +945,12 @@ sub cgi_editpage ($$) { #{{{ params => $q, action => $q->request_uri, table => 0, - template => "$templatedir/editpage.tmpl" + template => "$config{templatedir}/editpage.tmpl" ); - my ($page)=$form->param('page')=~/$wiki_file_regexp/; + my ($page)=$form->param('page')=~/$config{wiki_file_regexp}/; if (! defined $page || ! length $page || $page ne $q->param('page') || - $page=~/$wiki_file_prune_regexp/ || $page=~/^\//) { + $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) { error("bad page name"); } $page=lc($page); @@ -956,7 +963,7 @@ sub cgi_editpage ($$) { #{{{ cols => 80); if ($form->submitted eq "Cancel") { - print $q->redirect("$url/".htmlpage($page)); + print $q->redirect("$config{url}/".htmlpage($page)); return; } if (! $form->submitted || ! $form->validate) { @@ -964,15 +971,15 @@ sub cgi_editpage ($$) { #{{{ if (exists $pagesources{lc($page)}) { # hmm, someone else made the page in the # meantime? - print $q->redirect("$url/".htmlpage($page)); + print $q->redirect("$config{url}/".htmlpage($page)); return; } my @page_locs; - my ($from)=$form->param('from')=~/$wiki_file_regexp/; + my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/; if (! defined $from || ! length $from || $from ne $form->param('from') || - $from=~/$wiki_file_prune_regexp/ || $from=~/^\//) { + $from=~/$config{wiki_file_prune_regexp}/ || $from=~/^\//) { @page_locs=$page; } else { @@ -994,7 +1001,7 @@ sub cgi_editpage ($$) { #{{{ elsif ($form->field("do") eq "edit") { my $content=""; if (exists $pagesources{lc($page)}) { - $content=readfile("$srcdir/$pagesources{lc($page)}"); + $content=readfile("$config{srcdir}/$pagesources{lc($page)}"); $content=~s/\n/\r\n/g; } $form->tmpl_param("page_select", 0); @@ -1004,13 +1011,13 @@ sub cgi_editpage ($$) { #{{{ $form->title("editing $page"); } - $form->tmpl_param("can_commit", $svn); + $form->tmpl_param("can_commit", $config{svn}); $form->tmpl_param("indexlink", indexlink()); print $form->render(submit => ["Save Page", "Cancel"]); } else { # save page - my $file=$page.$default_pagetype; + my $file=$page.$config{default_pageext}; my $newfile=1; if (exists $pagesources{lc($page)}) { $file=$pagesources{lc($page)}; @@ -1020,7 +1027,7 @@ sub cgi_editpage ($$) { #{{{ my $content=$form->field('content'); $content=~s/\r\n/\n/g; $content=~s/\r/\n/g; - writefile("$srcdir/$file", $content); + writefile("$config{srcdir}/$file", $content); my $message="web commit "; if ($session->param("name")) { @@ -1034,7 +1041,7 @@ sub cgi_editpage ($$) { #{{{ $message.=": ".$form->field('comments'); } - if ($svn) { + if ($config{svn}) { if ($newfile) { rcs_add($file); } @@ -1048,7 +1055,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("$url/".htmlpage($page)."?updated"); + print $q->redirect("$config{url}/".htmlpage($page)."?updated"); } } #}}} @@ -1073,11 +1080,11 @@ sub cgi () { #{{{ my $oldmask=umask(077); my $session = CGI::Session->new("driver:db_file", $q, - { FileName => "$srcdir/.ikiwiki/sessions.db" }); + { FileName => "$config{srcdir}/.ikiwiki/sessions.db" }); umask($oldmask); # Everything below this point needs the user to be signed in. - if ((! $anonok && ! defined $session->param("name") || + if ((! $config{anonok} && ! defined $session->param("name") || ! userinfo_get($session->param("name"), "regdate")) || $do eq 'signin') { cgi_signin($q, $session); @@ -1098,40 +1105,42 @@ sub cgi () { #{{{ } #}}} # main {{{ -my $wrapper=0; if (grep /^-/, @ARGV) { eval {use Getopt::Long}; GetOptions( - "wikiname=s" => \$wikiname, - "verbose|v" => \$verbose, - "rebuild!" => \$rebuild, - "wrapper!" => \$wrapper, - "svn!" => \$svn, - "anonok!" => \$anonok, - "cgi!" => \$cgi, - "url=s" => \$url, - "cgiurl=s" => \$cgiurl, - "historyurl=s" => \$historyurl, + "wikiname=s" => \$config{wikiname}, + "verbose|v!" => \$config{verbose}, + "rebuild!" => \$config{rebuild}, + "wrapper!" => \$config{wrapper}, + "svn!" => \$config{svn}, + "anonok!" => \$config{anonok}, + "cgi!" => \$config{cgi}, + "url=s" => \$config{url}, + "cgiurl=s" => \$config{cgiurl}, + "historyurl=s" => \$config{historyurl}, + "exclude=s@" => sub { + $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/; + }, ) || usage(); } usage() unless @ARGV == 3; -($srcdir) = possibly_foolish_untaint(shift); -($templatedir) = possibly_foolish_untaint(shift); -($destdir) = possibly_foolish_untaint(shift); +$config{srcdir} = possibly_foolish_untaint(shift); +$config{templatedir} = possibly_foolish_untaint(shift); +$config{destdir} = possibly_foolish_untaint(shift); -if ($cgi && ! length $url) { +if ($config{cgi} && ! length $config{url}) { error("Must specify url to wiki with --url when using --cgi"); } -gen_wrapper($svn, $rebuild) if $wrapper; +gen_wrapper() if $config{wrapper}; memoize('pagename'); memoize('bestlink'); -loadindex() unless $rebuild; -if ($cgi) { +loadindex() unless $config{rebuild}; +if ($config{cgi}) { cgi(); } else { - rcs_update() if $svn; + rcs_update() if $config{svn}; refresh(); saveindex(); } -- 2.39.5 From 710a8b2d8f5e014699c8c06caa5e3fe5ffd1e112 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 02:19:15 +0000 Subject: [PATCH 03/16] reorganized code --- ikiwiki | 78 +++++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/ikiwiki b/ikiwiki index 4246c7e78..729f8628b 100755 --- a/ikiwiki +++ b/ikiwiki @@ -1,4 +1,5 @@ #!/usr/bin/perl -T +$ENV{PATH}="/usr/local/bin:/usr/bin:/bin"; use warnings; use strict; @@ -6,16 +7,15 @@ use File::Find; use Memoize; use File::Spec; use HTML::Template; - +use Getopt::Long; BEGIN { $blosxom::version="is a proper perl module too much to ask?"; do "/usr/bin/markdown"; } -$ENV{PATH}="/usr/local/bin:/usr/bin:/bin"; my (%links, %oldlinks, %oldpagemtime, %renderedfiles, %pagesources); -my %config=( +my %config=( #{{{ wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)}, wiki_link_regexp => qr/\[\[([^\s]+)\]\]/, wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/, @@ -33,13 +33,37 @@ my %config=( srcdir => undef, destdir => undef, templatedir => undef, -); +); #}}} + +GetOptions( #{{{ + "wikiname=s" => \$config{wikiname}, + "verbose|v!" => \$config{verbose}, + "rebuild!" => \$config{rebuild}, + "wrapper!" => \$config{wrapper}, + "svn!" => \$config{svn}, + "anonok!" => \$config{anonok}, + "cgi!" => \$config{cgi}, + "url=s" => \$config{url}, + "cgiurl=s" => \$config{cgiurl}, + "historyurl=s" => \$config{historyurl}, + "exclude=s@" => sub { + $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/; + }, +) || usage(); + +usage() unless @ARGV == 3; +$config{srcdir} = possibly_foolish_untaint(shift); +$config{templatedir} = possibly_foolish_untaint(shift); +$config{destdir} = possibly_foolish_untaint(shift); +if ($config{cgi} && ! length $config{url}) { + error("Must specify url to wiki with --url when using --cgi"); +} #}}} sub usage { #{{{ die "usage: ikiwiki [options] source templates dest\n"; } #}}} -sub error ($) { #{{{ +sub error { #{{{ if ($config{cgi}) { print "Content-type: text/html\n\n"; print misctemplate("Error", "

Error: @_

"); @@ -66,7 +90,7 @@ sub mtime ($) { #{{{ return (stat($page))[9]; } #}}} -sub possibly_foolish_untaint ($) { #{{{ +sub possibly_foolish_untaint { #{{{ my $tainted=shift; my ($untainted)=$tainted=~/(.*)/; return $untainted; @@ -152,11 +176,12 @@ sub findlinks ($) { #{{{ return @links; } #}}} -# Given a page and the text of a link on the page, determine which existing -# page that link best points to. Prefers pages under a subdirectory with -# the same name as the source page, failing that goes down the directory tree -# to the base looking for matching pages. sub bestlink ($$) { #{{{ + # Given a page and the text of a link on the page, determine which + # existing page that link best points to. Prefers pages under a + # subdirectory with the same name as the source page, failing that + # goes down the directory tree to the base looking for matching + # pages. my $page=shift; my $link=lc(shift); @@ -321,9 +346,9 @@ sub finalize ($$) { #{{{ return $template->output; } #}}} -# Important security check. Make sure to call this before saving any files -# to the source directory. sub check_overwrite ($$) { #{{{ + # Important security check. Make sure to call this before saving + # any files to the source directory. my $dest=shift; my $src=shift; @@ -628,8 +653,6 @@ FILE: foreach my $file (@files) { } } #}}} -# Generates a C wrapper program for running ikiwiki in a specific way. -# The wrapper may be safely made suid. sub gen_wrapper () { #{{{ eval q{use Cwd 'abs_path'}; $config{srcdir}=abs_path($config{srcdir}); @@ -1105,33 +1128,6 @@ sub cgi () { #{{{ } #}}} # main {{{ -if (grep /^-/, @ARGV) { - eval {use Getopt::Long}; - GetOptions( - "wikiname=s" => \$config{wikiname}, - "verbose|v!" => \$config{verbose}, - "rebuild!" => \$config{rebuild}, - "wrapper!" => \$config{wrapper}, - "svn!" => \$config{svn}, - "anonok!" => \$config{anonok}, - "cgi!" => \$config{cgi}, - "url=s" => \$config{url}, - "cgiurl=s" => \$config{cgiurl}, - "historyurl=s" => \$config{historyurl}, - "exclude=s@" => sub { - $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/; - }, - ) || usage(); -} -usage() unless @ARGV == 3; -$config{srcdir} = possibly_foolish_untaint(shift); -$config{templatedir} = possibly_foolish_untaint(shift); -$config{destdir} = possibly_foolish_untaint(shift); - -if ($config{cgi} && ! length $config{url}) { - error("Must specify url to wiki with --url when using --cgi"); -} - gen_wrapper() if $config{wrapper}; memoize('pagename'); memoize('bestlink'); -- 2.39.5 From 1e5c7926cf8f54e25bb6c9c5f3b3be5e8667b47b Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 02:22:42 +0000 Subject: [PATCH 04/16] hide markdown goo away, it also speeds up the cgis a bit --- ikiwiki | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ikiwiki b/ikiwiki index 729f8628b..de71414ed 100755 --- a/ikiwiki +++ b/ikiwiki @@ -8,10 +8,6 @@ use Memoize; use File::Spec; use HTML::Template; use Getopt::Long; -BEGIN { - $blosxom::version="is a proper perl module too much to ask?"; - do "/usr/bin/markdown"; -} my (%links, %oldlinks, %oldpagemtime, %renderedfiles, %pagesources); @@ -254,6 +250,11 @@ sub htmlize ($$) { #{{{ my $type=shift; my $content=shift; + if (! $INC{"/usr/bin/markdown"}) { + $blosxom::version="is a proper perl module too much to ask?"; + do "/usr/bin/markdown"; + } + if ($type eq '.mdwn') { return Markdown::Markdown($content); } -- 2.39.5 From 15d316a812d89abf49be1641b4a611200c49c762 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 02:29:32 +0000 Subject: [PATCH 05/16] speed up cgis --- ikiwiki | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ikiwiki b/ikiwiki index de71414ed..361c75c07 100755 --- a/ikiwiki +++ b/ikiwiki @@ -3,7 +3,6 @@ $ENV{PATH}="/usr/local/bin:/usr/bin:/bin"; use warnings; use strict; -use File::Find; use Memoize; use File::Spec; use HTML::Template; @@ -251,7 +250,9 @@ sub htmlize ($$) { #{{{ my $content=shift; if (! $INC{"/usr/bin/markdown"}) { + no warnings 'once'; $blosxom::version="is a proper perl module too much to ask?"; + use warnings 'all'; do "/usr/bin/markdown"; } @@ -535,11 +536,15 @@ sub refresh () { #{{{ # Find existing pages. my %exists; my @files; + + eval q{use File::Find}; find({ no_chdir => 1, wanted => sub { if (/$config{wiki_file_prune_regexp}/) { + no warnings 'once'; $File::Find::prune=1; + use warnings "all"; } elsif (! -d $_) { my ($f)=/$config{wiki_file_regexp}/; # untaint -- 2.39.5 From 4796acdae76a294199e8d8152c3c9ed53db808a2 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 18:35:23 +0000 Subject: [PATCH 06/16] add --setup, --wrappermode allow filename param to --wrapper --- doc/bugs.mdwn | 6 ----- doc/setup.mdwn | 2 +- doc/todo.mdwn | 7 +++++- doc/usage.mdwn | 33 ++++++++++++++++++++----- ikiwiki | 66 +++++++++++++++++++++++++++++++++++++------------- ikiwiki.setup | 39 +++++++++++++++++++++++++++++ 6 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 ikiwiki.setup diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index 72719ba29..2c712de6d 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -27,9 +27,3 @@ markdown, but that will probably be a bear. I guess the question is how common "[[ ]]" is, and maybe we should just provide a way to escape a wikilink.. - -Fixed bugs: - -* RecentChanges is supposed to linkify WikiNames and it does, but only if - the user's page exists. It doesn't add a ?link to a noneistant page to - aid creating it. (Fixed. -- [[Joey]]) diff --git a/doc/setup.mdwn b/doc/setup.mdwn index acb401cfc..541131cf9 100644 --- a/doc/setup.mdwn +++ b/doc/setup.mdwn @@ -74,4 +74,4 @@ optional support for commits from the web. --historyurl='http://svn.host/trunk/[[]]?root=wiki' -11. Enjoy your new wiki! Add yourself to [[IkiWikiUsers]] \ No newline at end of file +11. Enjoy your new wiki! Add yourself to [[IkiWikiUsers]] diff --git a/doc/todo.mdwn b/doc/todo.mdwn index 98b98e3f2..23ade8cbd 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -15,7 +15,7 @@ is built. (As long as all changes to all pages is ok.) * Should support mail notification of new and changed pages. - Hmm, should be easy to implement this.. it runs as a svn post-cookit hook + Hmm, should be easy to implement this.. it runs as a svn post-coommit hook already, so just look at the userdb, svnlook at what's changed, and send mails to people who have subscribed. @@ -62,6 +62,11 @@ and that includes the date. What syntax do other wikis use for this? I'm considering "[[ -- ]]" (with spaces removed) as it has a nice nmemonic. +OTOH, adding additional syntax for this would be counter to one of the +design goals for ikiwiki: keeping as much markup as possible out of the +wiki and not adding nonstandard markup. And it's not significantly hard to +type "--[[Joey]]", and as to the date, we do have page history. + ## recentchanges links to commit diffs Would take a bit more viewcvs integration, let the be a "[diff]" link in diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 8f57a1593..8efb9a63d 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -6,13 +6,18 @@ ikiwiki - a wiki compiler ikiwiki [options] source templates destination +ikiwiki --setup configfile + # DESCRIPTION -`ikiwiki` is a wiki compiler. It builds static html pages for a wiki, from `source` in the [[MarkDown]] language, using the specified html `templates` and writes it out to `destination`. +`ikiwiki` is a wiki compiler. It builds static html pages for a wiki, from +`source` in the [[MarkDown]] language, using the specified html `templates` +and writes it out to `destination`. # OPTIONS -Note that most options can be shortened to single letters, and boolean flags such as --verbose can be negated with --no-verbose. +Note that most options can be shortened to single letters, and boolean +flags such as --verbose can be negated with --no-verbose. * --wikiname @@ -26,13 +31,22 @@ Note that most options can be shortened to single letters, and boolean flags suc Force a rebuild of all pages. -* --wrapper +* --wrapper [file] + + Generate a [[wrapper]] binary that is hardcoded to do action specified by + the other options, using the specified input files and `destination` + directory. The filename to use for the wrapper is optional. + + The wrapper is designed to be safely made suid and be run by untrusted + users, as a [[Subversion]] [[post-commit]] hook, or as a [[CGI]]. - Generate a [[wrapper]] binary that is hardcoded to do action specified by the other options, using the specified input files and `destination` directory. + Note that the generated wrapper will ignore all command line parameters + except for --params, which will make it print out the parameters it would + run ikiwiki with. - The wrapper is designed to be safely made suid and be run by untrusted users, as a [[Subversion]] [[post-commit]] hook, or as a [[CGI]]. +* --wrappermode mode - Note that the generated wrapper will ignore all command line parameters except for --params, which will make it print out the parameters it would run ikiwiki with. + Specify a mode to chmod the wrapper to after creating it. * --svn, --nosvn @@ -71,6 +85,13 @@ Note that most options can be shortened to single letters, and boolean flags suc Specifies a rexexp of source files to exclude from processing. May be specified multiple times to add to exclude list. +* --setup configfile + + In setup mode, ikiwiki reads the config file, which is really a perl + program that can call ikiwiki internal functions. Uses of this are + various; one is to automatically generate wrappers for a wiki based on + data in a config file. + # AUTHOR Joey Hess diff --git a/ikiwiki b/ikiwiki index 361c75c07..4e64e4031 100755 --- a/ikiwiki +++ b/ikiwiki @@ -18,23 +18,27 @@ my %config=( #{{{ wikiname => "wiki", default_pageext => ".mdwn", cgi => 0, - url => "", - cgiurl => "", - historyurl => "", svn => 1, + url => '', + cgiurl => '', + historyurl => '', anonok => 0, rebuild => 0, - wrapper => 0, + wrapper => undef, + wrappermode => undef, srcdir => undef, destdir => undef, templatedir => undef, + setup => undef, ); #}}} GetOptions( #{{{ + "setup=s" => \$config{setup}, "wikiname=s" => \$config{wikiname}, "verbose|v!" => \$config{verbose}, "rebuild!" => \$config{rebuild}, - "wrapper!" => \$config{wrapper}, + "wrapper=s" => sub { $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap" }, + "wrappermode=i" => \$config{wrappermode}, "svn!" => \$config{svn}, "anonok!" => \$config{anonok}, "cgi!" => \$config{cgi}, @@ -46,13 +50,16 @@ GetOptions( #{{{ }, ) || usage(); -usage() unless @ARGV == 3; -$config{srcdir} = possibly_foolish_untaint(shift); -$config{templatedir} = possibly_foolish_untaint(shift); -$config{destdir} = possibly_foolish_untaint(shift); -if ($config{cgi} && ! length $config{url}) { - error("Must specify url to wiki with --url when using --cgi"); -} #}}} +if (! $config{setup}) { + usage() unless @ARGV == 3; + $config{srcdir} = possibly_foolish_untaint(shift); + $config{templatedir} = possibly_foolish_untaint(shift); + $config{destdir} = possibly_foolish_untaint(shift); + if ($config{cgi} && ! length $config{url}) { + error("Must specify url to wiki with --url when using --cgi"); + } +} +#}}} sub usage { #{{{ die "usage: ikiwiki [options] source templates dest\n"; @@ -659,7 +666,8 @@ FILE: foreach my $file (@files) { } } #}}} -sub gen_wrapper () { #{{{ +sub gen_wrapper (@) { #{{{ + my %config=(@_); eval q{use Cwd 'abs_path'}; $config{srcdir}=abs_path($config{srcdir}); $config{destdir}=abs_path($config{destdir}); @@ -668,6 +676,10 @@ sub gen_wrapper () { #{{{ error("$this doesn't seem to be executable"); } + if ($config{setup}) { + error("cannot create a wrapper that uses a setup file"); + } + my @params=($config{srcdir}, $config{templatedir}, $config{destdir}, "--wikiname=$config{wikiname}"); push @params, "--verbose" if $config{verbose}; @@ -729,12 +741,15 @@ $envsave } EOF close OUT; - if (system("gcc", "ikiwiki-wrap.c", "-o", "ikiwiki-wrap") != 0) { + if (system("gcc", "ikiwiki-wrap.c", "-o", possibly_foolish_untaint($config{wrapper})) != 0) { error("failed to compile ikiwiki-wrap.c"); } unlink("ikiwiki-wrap.c"); - print "successfully generated ikiwiki-wrap\n"; - exit 0; + if (defined $config{wrappermode} && + ! chmod(oct($config{wrappermode}), possibly_foolish_untaint($config{wrapper}))) { + error("chmod $config{wrapper}: $!"); + } + print "successfully generated $config{wrapper}\n"; } #}}} sub misctemplate ($$) { #{{{ @@ -1133,8 +1148,25 @@ sub cgi () { #{{{ } } #}}} +sub setup () { # {{{ + my $setup=possibly_foolish_untaint($config{setup}); + open (IN, $setup) || error("read $setup: $!\n"); + local $/=undef; + my $code=; + ($code)=$code=~/(.*)/s; + close IN; + eval $code; + error($@) if $@; + print "ikiwiki setup complete\n"; + exit; +} #}}} + # main {{{ -gen_wrapper() if $config{wrapper}; +setup() if $config{setup}; +if ($config{wrapper}) { + gen_wrapper(%config); + exit; +} memoize('pagename'); memoize('bestlink'); loadindex() unless $config{rebuild}; diff --git a/ikiwiki.setup b/ikiwiki.setup new file mode 100644 index 000000000..44c4f3106 --- /dev/null +++ b/ikiwiki.setup @@ -0,0 +1,39 @@ +#!/usr/bin/perl +# Configuration file for ikiwiki. +# Passing this to ikiwiki --setup will make ikiwiki generate tw +# wrapper programs, one for cgi and one for a subversion post-commit hook. +# +# Remember to re-run ikiwiki --setup any time you edit this file. + +my %common=( + wikiname => "MyWiki", + + # Be sure to customise these.. + srcdir => "/path/to/source", + templatedir => "/path/to/templates", + destdir => "/var/www/wiki", + url => "http://myhost/wiki", + cgiurl => "http://myhost/ikiwiki.cgi", + historyurl => "$webdir/cgi-bin/viewcvs?[[]]" + + # Whether to integrate with svn. + svn => 1, + svnrepo => "/svn/wiki", + + # Can anonymous web users edit pages? + #anonok => 1, +); + +gen_wrapper( + %common, + cgi => 1, + wrapper => "$common{destdir}/ikiwiki.cgi", + wrappermode => 06755, +); +gen_wrapper( + %common, + # Note that this will overwrite any exsting post-commit hoo + # script, which may not be what you want. + wrapper => "$common{svnrepo}/hooks/post-commit", + wrappermode => 04755, +) if $common{$svn}; -- 2.39.5 From ac69a979059198a3716d1e177d177e978e1f1785 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 18:45:38 +0000 Subject: [PATCH 07/16] avoid linkifying escaped wikilinks --- doc/bugs.mdwn | 7 ------- doc/todo.mdwn | 6 +++--- doc/wikilink.mdwn | 9 ++++++--- ikiwiki | 6 ++++-- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index 2c712de6d..c9b175453 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -20,10 +20,3 @@ replaced with a link to the [[CGI]]? * [[ikiwiki]] should go to the same place as [[index]] (on this wiki). * There's no way to escape a [[WikiLink]] when discussing one on a wiki. -* Wikilinks are even expanded in the middle of [[MarkDown]] code blocks, - and probably shouldn't be (nor in blockquotes?) - - Hmm, the best way to fix this would be to add WikiLink support into - markdown, but that will probably be a bear. I guess the question is how - common "[[ ]]" is, and maybe we should just provide a way to escape a - wikilink.. diff --git a/doc/todo.mdwn b/doc/todo.mdwn index 23ade8cbd..d65991542 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -56,16 +56,16 @@ Make the html valid. Add css. ## sigs -Need a way to sign name in page that's easier to type than "-- [[ Joey ]]" +Need a way to sign name in page that's easier to type than "--\[[Joey]]" and that includes the date. -What syntax do other wikis use for this? I'm considering "[[ -- ]]" (with +What syntax do other wikis use for this? I'm considering "\[[--]]" (with spaces removed) as it has a nice nmemonic. OTOH, adding additional syntax for this would be counter to one of the design goals for ikiwiki: keeping as much markup as possible out of the wiki and not adding nonstandard markup. And it's not significantly hard to -type "--[[Joey]]", and as to the date, we do have page history. +type "--\[[Joey]]", and as to the date, we do have page history. ## recentchanges links to commit diffs diff --git a/doc/wikilink.mdwn b/doc/wikilink.mdwn index 03cb2b3c3..dab5d3ac4 100644 --- a/doc/wikilink.mdwn +++ b/doc/wikilink.mdwn @@ -1,6 +1,9 @@ WikiLinks provide easy linking between pages of the wiki. To create a -WikiLink, just put the name of the page to link to in double brackets. For -examples "[[ WikiLink ]]" (without the added whitespace). +[[WikiLink]], just put the name of the page to link to in double brackets. +For example "\[[WikiLink]]". + +If you ever need to write something like "\[[WikiLink]] without creating a +wikilink, just prefix it with a "\", like "\\\\[[WikiLink]]". Note that there are some special [[SubPage/LinkingRules]] that come into play when linking between [[SubPage]]s. @@ -8,4 +11,4 @@ play when linking between [[SubPage]]s. WikiLinks can be entered in any case you like, the page they link to is always lowercased. -Note that if the file linked to by a WikiLink looks like an image, it will be displayed inline on the page. \ No newline at end of file +Note that if the file linked to by a WikiLink looks like an image, it will be displayed inline on the page. diff --git a/ikiwiki b/ikiwiki index 4e64e4031..111ef54fc 100755 --- a/ikiwiki +++ b/ikiwiki @@ -172,7 +172,7 @@ sub findlinks ($) { #{{{ my $content=shift; my @links; - while ($content =~ /$config{wiki_link_regexp}/g) { + while ($content =~ /(? Date: Mon, 13 Mar 2006 19:10:29 +0000 Subject: [PATCH 08/16] add rebuild after calling setup, better format for setup files --- doc/usage.mdwn | 9 +++++++-- doc/wikilink.mdwn | 3 ++- ikiwiki | 11 ++++++++++- ikiwiki.setup | 22 +++++++++++++--------- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 8efb9a63d..0377014fd 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -89,8 +89,13 @@ flags such as --verbose can be negated with --no-verbose. In setup mode, ikiwiki reads the config file, which is really a perl program that can call ikiwiki internal functions. Uses of this are - various; one is to automatically generate wrappers for a wiki based on - data in a config file. + various; the normal one is to automatically generate wrappers for a + wiki based on data in a config file. + + Note that the wiki will be (re)built as part of the setup process to + ensure that any changes take effect. + + [[ikiwiki.setup]] is an example of such a config file. # AUTHOR diff --git a/doc/wikilink.mdwn b/doc/wikilink.mdwn index dab5d3ac4..ac0ec9d56 100644 --- a/doc/wikilink.mdwn +++ b/doc/wikilink.mdwn @@ -11,4 +11,5 @@ play when linking between [[SubPage]]s. WikiLinks can be entered in any case you like, the page they link to is always lowercased. -Note that if the file linked to by a WikiLink looks like an image, it will be displayed inline on the page. +Note that if the file linked to by a WikiLink looks like an image, it will +be displayed inline on the page. diff --git a/ikiwiki b/ikiwiki index 111ef54fc..ea3833a37 100755 --- a/ikiwiki +++ b/ikiwiki @@ -1152,6 +1152,7 @@ sub cgi () { #{{{ sub setup () { # {{{ my $setup=possibly_foolish_untaint($config{setup}); + delete $config{setup}; open (IN, $setup) || error("read $setup: $!\n"); local $/=undef; my $code=; @@ -1159,7 +1160,15 @@ sub setup () { # {{{ close IN; eval $code; error($@) if $@; - print "ikiwiki setup complete\n"; + print "$config{wikiname} setup complete, now forcing a rebuild.\n"; + $config{cgi}=0; + $config{rebuild}=1; + foreach my $c (keys %config) { + $config{$c}=possibly_foolish_untaint($config{$c}) + if defined $config{$c}; + } + refresh(); + saveindex(); exit; } #}}} diff --git a/ikiwiki.setup b/ikiwiki.setup index 44c4f3106..5a902a23c 100644 --- a/ikiwiki.setup +++ b/ikiwiki.setup @@ -5,7 +5,8 @@ # # Remember to re-run ikiwiki --setup any time you edit this file. -my %common=( +%config=(%config, + wikiname => "MyWiki", # Be sure to customise these.. @@ -14,7 +15,7 @@ my %common=( destdir => "/var/www/wiki", url => "http://myhost/wiki", cgiurl => "http://myhost/ikiwiki.cgi", - historyurl => "$webdir/cgi-bin/viewcvs?[[]]" + #historyurl => "http://svn.myhost/trunk/[[]]", # Whether to integrate with svn. svn => 1, @@ -22,18 +23,21 @@ my %common=( # Can anonymous web users edit pages? #anonok => 1, + ); -gen_wrapper( - %common, +gen_wrapper(%config, + cgi => 1, - wrapper => "$common{destdir}/ikiwiki.cgi", + wrapper => "$config{destdir}/ikiwiki.cgi", wrappermode => 06755, + ); -gen_wrapper( - %common, +gen_wrapper(%config, + # Note that this will overwrite any exsting post-commit hoo # script, which may not be what you want. - wrapper => "$common{svnrepo}/hooks/post-commit", + wrapper => "$config{svnrepo}/hooks/post-commit", wrappermode => 04755, -) if $common{$svn}; + +) if $config{$svn}; -- 2.39.5 From 2e1417eb08f18ffebcec76d994777d2413e0fcde Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 19:29:21 +0000 Subject: [PATCH 09/16] document setup files --- ikiwiki.setup => doc/ikiwiki.setup | 10 ++-- doc/post-commit.mdwn | 4 +- doc/setup.mdwn | 79 +++++++++++++++--------------- 3 files changed, 50 insertions(+), 43 deletions(-) rename ikiwiki.setup => doc/ikiwiki.setup (90%) diff --git a/ikiwiki.setup b/doc/ikiwiki.setup similarity index 90% rename from ikiwiki.setup rename to doc/ikiwiki.setup index 5a902a23c..9592d36f5 100644 --- a/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -13,6 +13,7 @@ srcdir => "/path/to/source", templatedir => "/path/to/templates", destdir => "/var/www/wiki", + url => "http://myhost/wiki", cgiurl => "http://myhost/ikiwiki.cgi", #historyurl => "http://svn.myhost/trunk/[[]]", @@ -20,7 +21,9 @@ # Whether to integrate with svn. svn => 1, svnrepo => "/svn/wiki", - + + # Whether to enable a cgi wrapper. + cgiwrapper => 0, # Can anonymous web users edit pages? #anonok => 1, @@ -32,7 +35,8 @@ gen_wrapper(%config, wrapper => "$config{destdir}/ikiwiki.cgi", wrappermode => 06755, -); +) if $config{cgiwrapper}; + gen_wrapper(%config, # Note that this will overwrite any exsting post-commit hoo @@ -40,4 +44,4 @@ gen_wrapper(%config, wrapper => "$config{svnrepo}/hooks/post-commit", wrappermode => 04755, -) if $config{$svn}; +) if $config{svn}; diff --git a/doc/post-commit.mdwn b/doc/post-commit.mdwn index 467fc6bd5..496c69075 100644 --- a/doc/post-commit.mdwn +++ b/doc/post-commit.mdwn @@ -1,7 +1,7 @@ A post-commit hook is run every time you commit a change to your subversion repository. To make the wiki be updated each time a commit is made, it can be run from (or as) a post-commit hook. The best way to run ikiwiki in a [[Subversion]] post-commit hook is using -a wrapper, which can be generated using `ikiwiki --wrapper`. +a [[wrapper, which can be generated using `ikiwiki --wrapper`. First, set up the subversion checkout that ikiwiki will update and compile into your wiki at each subversion commit. Run ikiwiki a few times by hand @@ -26,3 +26,5 @@ getting called by users who have write access to subversion, but not to your wiki checkout and html directory. If so, you can safely make ikiwiki-wrap suid to a user who can write there (*not* to root!). You might want to read [[Security]] first. + +[[setup]] explains setting this up in more detail. diff --git a/doc/setup.mdwn b/doc/setup.mdwn index 541131cf9..cc830c0b9 100644 --- a/doc/setup.mdwn +++ b/doc/setup.mdwn @@ -36,42 +36,43 @@ optional support for commits from the web. 6. Repeat steps 4 and 5 as desired, editing or adding pages and rebuilding the wiki. You can play around with other ikiwiki parameters such as - --wikiname too. Get conformatble with its command line. - -7. Set up a Subversion [[post-commit]] hook to automatically rebuild your - wiki when you commit to it. - - ikiwiki ~/wikiwc/ \ - /usr/lib/ikiwiki/templates ~/public_html/wiki/ \ - --url=http://host/~you/wiki/ --wrapper - mv ikiwiki-wrap /svn/wikirepo/hooks/post-commit - -8. Set up a [[CGI]] to allow editing the wiki from the web. - - ikiwiki ~/wikiwc/ \ - /usr/lib/ikiwiki/templates ~/public_html/wiki/ \ - --url=http://host/~you/wiki/ --wrapper --cgi - chmod 6755 ikiwiki-wrap - mv wrapper ~/public_html/wiki/ikiwki.cgi - - Note that this assumes that your web server will run CGI scripts from - your public_html directory. You might need to put it somewhere else - depending on your web server configuration. - -9. Add links to the CGI to all the pages in your wiki, and update your - post-commit hook to add such links when updating the wiki in the - future. Note the use of the [[WrapperParamsTrick]]. - - ikiwiki $(/svn/wikirepo/hooks/post-commit --params) \ - --cgiurl=http://host/~you/wiki/ikiwiki.cgi --wrapper - mv ikiwiki-wrap /svn/wikirepo/hooks/post-commit - ikiwiki $(/svn/wikirepo/hooks/post-commit --params) --rebuild - - Be sure to change the cgiurl to the actual url to the wiki.cgi you - installed in step 9. - -10. Add [[PageHistory]] links to the top of pages. This requires you to have setup [[ViewCVS]] or something similar to access your [[Subversion]] repository. The --historyurl parameter makes ikiwiki add the links, and in that url, "[[]]" is replaced with the name of the file to view. So repeat step 9 to rebuild the wiki post commit wrapper and wiki, adding a historyurl something like this one: - - --historyurl='http://svn.host/trunk/[[]]?root=wiki' - -11. Enjoy your new wiki! Add yourself to [[IkiWikiUsers]] + --wikiname too. Get confortable with its command line. + +7. By now you should be getting tired of typing in all the command line + options each time you change something in your wiki's setup. And it's + also getting old to have to manualy rebuild the wiki each time you + change a file. Time to introduce setup files. + + A sample setup file is [[ikiwiki.setup]]. Download it (or copy it from + `doc/ikiwiki.setup` in the ikiwiki sources), and edit it. + + Most of the options, like `wikiname` in the setup file are the same as + ikiwiki's command line options (documented in [[usage]]. `srcdir`, + `templatedir` and `destdir` are the three directories you specify when + running ikiwiki by hand. `svnrepo` is the path to your subversion + repository. Make sure that all of these are pointing to the right + directories, and read through and configure the rest of the file to your + liking. + + Note that the default file will enable a [[post-commit]] hook to + update the wiki, but has cgi support turned off. + + When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it will + generate the subversion [[post-commit]] hook and update your wiki. + +8. Set up [[CGI]] to allow editing the wiki from the web. + + Just edit ikiwiki.setup, change cgiwrapper to 1, and optioanlly anonok + to 1, run `ikiwiki --setup ikiwiki.setup`, and you're done! + +9. Add [[PageHistory]] links to the top of pages. This requires you to have + setup [[ViewCVS]] or something similar to access your [[Subversion]] + repository. The `historyurl` setting makes ikiwiki add the links, and + in that url, "[[]]" is replaced with the name of the file to view. So + edit ikiwiki.setup and set `historyurl` to something like this: + + `http://svn.host/trunk/[[]]?root=wiki` + + Then run `ikiwiki --setup ikiwiki.setup` again. + +10. Enjoy your new wiki! Add yourself to [[IkiWikiUsers]] -- 2.39.5 From 0f35669dd635f8018958ee99918e335283fd2399 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 19:31:05 +0000 Subject: [PATCH 10/16] foo --- doc/security.mdwn | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/security.mdwn b/doc/security.mdwn index e34dc5ed4..278bad024 100644 --- a/doc/security.mdwn +++ b/doc/security.mdwn @@ -63,6 +63,12 @@ If someone checks in a symlink to /etc/passwd, ikiwiki would publish that. To aoid this, ikiwiki will need to avoid reading files that are symlinks. TODO and note discussion of races above. +## setup files + +Setup files are not safe to keep in subversion with the rest of the wiki. +Just don't do it. [[ikiwiki.setup]] is *not* used as the setup file for +this wiki, BTW. + ---- # Hopefully non-holes -- 2.39.5 From 1c4d4e1e0474b6ffd3b8e0213d8a4804a3597e34 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 13 Mar 2006 19:53:13 +0000 Subject: [PATCH 11/16] improved setup file more --- doc/ikiwiki.setup | 42 ++++++++++++++++++------------------------ doc/setup.mdwn | 13 +++++++------ ikiwiki | 17 +++++++++++------ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index 9592d36f5..e8048c3b0 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -1,12 +1,11 @@ #!/usr/bin/perl # Configuration file for ikiwiki. -# Passing this to ikiwiki --setup will make ikiwiki generate tw +# Passing this to ikiwiki --setup will make ikiwiki generate two # wrapper programs, one for cgi and one for a subversion post-commit hook. # # Remember to re-run ikiwiki --setup any time you edit this file. -%config=(%config, - +%setup=( wikiname => "MyWiki", # Be sure to customise these.. @@ -22,26 +21,21 @@ svn => 1, svnrepo => "/svn/wiki", - # Whether to enable a cgi wrapper. - cgiwrapper => 0, - # Can anonymous web users edit pages? - #anonok => 1, - -); - -gen_wrapper(%config, + # The svn wrapper. + svnwrapper => { + # Note that this will overwrite any exsting post-commit hoo + # script, which may not be what you want. + wrapper => "$config{svnrepo}/hooks/post-commit", + wrappermode => 04755, + }, - cgi => 1, - wrapper => "$config{destdir}/ikiwiki.cgi", - wrappermode => 06755, - -) if $config{cgiwrapper}; - -gen_wrapper(%config, - - # Note that this will overwrite any exsting post-commit hoo - # script, which may not be what you want. - wrapper => "$config{svnrepo}/hooks/post-commit", - wrappermode => 04755, + # The cgi wrapper. + #cgiwrapper => { + # cgi => 1, + # wrapper => "/var/www/wiki/ikiwiki.cgi", + # wrappermode => 06755, + #}, -) if $config{svn}; + # Can anonymous web users edit pages? + #anonok => 1, +); diff --git a/doc/setup.mdwn b/doc/setup.mdwn index cc830c0b9..d72cac71a 100644 --- a/doc/setup.mdwn +++ b/doc/setup.mdwn @@ -54,16 +54,17 @@ optional support for commits from the web. directories, and read through and configure the rest of the file to your liking. - Note that the default file will enable a [[post-commit]] hook to - update the wiki, but has cgi support turned off. + Note that the default file has a block to configure a svnwraper. This + sets up a [[post-commit]] hook to update the wiki. - When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it will - generate the subversion [[post-commit]] hook and update your wiki. + When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it + will set everything up and update your wiki. 8. Set up [[CGI]] to allow editing the wiki from the web. - Just edit ikiwiki.setup, change cgiwrapper to 1, and optioanlly anonok - to 1, run `ikiwiki --setup ikiwiki.setup`, and you're done! + Just edit ikiwiki.setup, uncomment the block for the cgiwrapper, make + sure the filename for the cgi wrapper is ok, run + `ikiwiki --setup ikiwiki.setup`, and you're done! 9. Add [[PageHistory]] links to the top of pages. This requires you to have setup [[ViewCVS]] or something similar to access your [[Subversion]] diff --git a/ikiwiki b/ikiwiki index ea3833a37..add627739 100755 --- a/ikiwiki +++ b/ikiwiki @@ -1158,15 +1158,20 @@ sub setup () { # {{{ my $code=; ($code)=$code=~/(.*)/s; close IN; + + my (%setup); eval $code; error($@) if $@; - print "$config{wikiname} setup complete, now forcing a rebuild.\n"; - $config{cgi}=0; - $config{rebuild}=1; - foreach my $c (keys %config) { - $config{$c}=possibly_foolish_untaint($config{$c}) - if defined $config{$c}; + + gen_wrapper(%config, %setup, %{$setup{cgiwrapper}}) if $setup{cgiwrapper}; + gen_wrapper(%config, %setup, %{$setup{svnwrapper}}) if $setup{svnwrapper}; + + print "$setup{wikiname} setup complete, now forcing a rebuild\n"; + foreach my $c (keys %setup) { + $config{$c}=possibly_foolish_untaint($setup{$c}) + if defined $setup{$c} && ! ref $setup{$c}; } + $config{rebuild}=1; refresh(); saveindex(); exit; -- 2.39.5 From e2e1badeaec77ad6a606d7ba96c2f4be3201a4a2 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 14 Mar 2006 04:54:50 +0000 Subject: [PATCH 12/16] ugly fix for parentlink back to top of wiki --- ikiwiki | 1 + 1 file changed, 1 insertion(+) diff --git a/ikiwiki b/ikiwiki index add627739..f95ea0f09 100755 --- a/ikiwiki +++ b/ikiwiki @@ -314,6 +314,7 @@ sub parentlinks ($) { #{{{ } $path.="../"; } + $path=~s!../!!; unshift @ret, { url => $path , page => $config{wikiname} }; return @ret; } #}}} -- 2.39.5 From 7144eb3973ac73a5f79440f91a7c01665fb83aa4 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 14 Mar 2006 05:33:44 +0000 Subject: [PATCH 13/16] Some fixes to the parent links, I think the link to the index will be right in all cases now. --- doc/bugs.mdwn | 2 ++ doc/todo.mdwn | 9 +++++++++ ikiwiki | 5 ++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index c9b175453..3fbdadd45 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -20,3 +20,5 @@ replaced with a link to the [[CGI]]? * [[ikiwiki]] should go to the same place as [[index]] (on this wiki). * There's no way to escape a [[WikiLink]] when discussing one on a wiki. +* Seems to be losing track of just-created pages and not adding them to the + index. diff --git a/doc/todo.mdwn b/doc/todo.mdwn index d65991542..dd69e21fb 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -77,4 +77,13 @@ recentchanges that goes to the diff for any listed change. Possibly add "next 100" link to it, but OTOH, you can just use svn log if you need that data.. +## setup classes + +The setup files should "use WikiWiki::Setup" and the like at the top, and +indeed could just be one big use that passes all params to the module's +importer. The module then handles running ikiwiki functions. This would +allow for different types of setup files for more than just the one +hardcoded thing there is now, and would probably be good for upgrades, +incompatible changes, etc, too. + ## [[Bugs]] diff --git a/ikiwiki b/ikiwiki index f95ea0f09..7e140bbec 100755 --- a/ikiwiki +++ b/ikiwiki @@ -307,15 +307,14 @@ sub parentlinks ($) { #{{{ my $skip=1; foreach my $dir (reverse split("/", $page)) { if (! $skip) { + $path.="../"; unshift @ret, { url => "$path$dir.html", page => $dir }; } else { $skip=0; } - $path.="../"; } - $path=~s!../!!; - unshift @ret, { url => $path , page => $config{wikiname} }; + unshift @ret, { url => length $path ? $path : ".", page => $config{wikiname} }; return @ret; } #}}} -- 2.39.5 From c768f9a2e988a31f4e27923cc608edad0e19b7b4 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 14 Mar 2006 05:37:34 +0000 Subject: [PATCH 14/16] load/save index when rendering a page in cgi mode for svn-less wikis --- doc/bugs.mdwn | 2 -- ikiwiki | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index 3fbdadd45..c9b175453 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -20,5 +20,3 @@ replaced with a link to the [[CGI]]? * [[ikiwiki]] should go to the same place as [[index]] (on this wiki). * There's no way to escape a [[WikiLink]] when discussing one on a wiki. -* Seems to be losing track of just-created pages and not adding them to the - index. diff --git a/ikiwiki b/ikiwiki index 7e140bbec..7794113f5 100755 --- a/ikiwiki +++ b/ikiwiki @@ -1096,7 +1096,9 @@ sub cgi_editpage ($$) { #{{{ rcs_commit($message); } else { + loadindex(); refresh(); + saveindex(); } # The trailing question mark tries to avoid broken -- 2.39.5 From 2885278ebd2e2bfad188a583d7ad5d3c8b7c3a21 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 14 Mar 2006 05:51:57 +0000 Subject: [PATCH 15/16] remove quotes, actualy messed up ikiwiki $(wrapper --params) --foo --- ikiwiki | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ikiwiki b/ikiwiki index 7794113f5..d6057c101 100755 --- a/ikiwiki +++ b/ikiwiki @@ -69,11 +69,8 @@ sub error { #{{{ if ($config{cgi}) { print "Content-type: text/html\n\n"; print misctemplate("Error", "

Error: @_

"); - exit 1; - } - else { - die @_; } + die @_; } #}}} sub debug ($) { #{{{ @@ -364,10 +361,10 @@ sub check_overwrite ($$) { #{{{ my $src=shift; if (! exists $renderedfiles{$src} && -e $dest && ! $config{rebuild}) { - error("$dest exists and was rendered from ". + error("$dest already exists and was rendered from ". join(" ",(grep { $renderedfiles{$_} eq $dest } keys %renderedfiles)). - ", not from $src before not overwriting"); + ", before, so not rendering from $src"); } } #}}} @@ -692,7 +689,7 @@ sub gen_wrapper (@) { #{{{ push @params, "--cgiurl=$config{cgiurl}" if length $config{cgiurl}; push @params, "--historyurl=$config{historyurl}" if length $config{historyurl}; push @params, "--anonok" if $config{anonok}; - my $params=join(" ", map { "\'$_\'" } @params); + my $params=join(" ", @params); my $call=''; foreach my $p ($this, $this, @params) { $call.=qq{"$p", }; -- 2.39.5 From 7f8efe4524fb8cc2066e07c4f9fbad3b14fbccfb Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 14 Mar 2006 06:04:44 +0000 Subject: [PATCH 16/16] fix Discussion links to not take the BestLink. As a bonus we now have meta Disussion/Discussion pages available, etc. Oh well.. :-) --- doc/bugs.mdwn | 4 +--- doc/features.mdwn | 16 +++++++++++++--- doc/todo.mdwn | 11 +++++++++++ ikiwiki | 17 +++++++++-------- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index c9b175453..8ceff9aae 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -4,9 +4,6 @@ to point to it, but will forget to update the linkbacks in Foo/Baz. And if Foo/Bar/Baz is then removed, it forgets to update Foo/Bar to link back to Foo/Baz. - - Basically this makes creating new pages painful, top of TODO list.. - * Foo/Bar/Baz shows up as Bar/Baz in the linkbacks on page Foo/Bar. Should show as just Baz there. * If I try to do a web commit, to a svn+ssh repo, it fails with @@ -20,3 +17,4 @@ replaced with a link to the [[CGI]]? * [[ikiwiki]] should go to the same place as [[index]] (on this wiki). * There's no way to escape a [[WikiLink]] when discussing one on a wiki. +* Doesn't update pages that linked to a page when it is removed. diff --git a/doc/features.mdwn b/doc/features.mdwn index e56a075d7..6f5b638f5 100644 --- a/doc/features.mdwn +++ b/doc/features.mdwn @@ -4,11 +4,21 @@ Currently implemented: * [[Subversion]] - Rather than implement its own system for storing page histories etc, ikiwiki simply uses subversion. (Supporting other revision control systems is also possible, ikiwiki only needs $FOO add, $FOO commit, and $FOO log). + Rather than implement its own system for storing page histories etc, + ikiwiki simply uses subversion. (Supporting other revision control + systems is also possible, ikiwiki only needs $FOO add, $FOO commit, and + $FOO log). - Instead of editing pages in a stupid web form, you can use vim and commit changes via svn. Or work disconnected using svk and push your changes out when you come online. Deal with edit conflicts with others in a sane environment. Take advantage of subversion's smart merges. + Instead of editing pages in a stupid web form, you can use vim and commit + changes via svn. Or work disconnected using svk and push your changes out + when you come online. Deal with edit conflicts with others in a sane + environment. Take advantage of subversion's smart merges. - ikiwiki can be run from a [[post-commit]] hook to update your wiki immediately whenever you commit. + ikiwiki can be run from a [[post-commit]] hook to update your wiki + immediately whenever you commit. + + Note that ikiwiki does not require subversion to function. If you want to + run a simple wiki without page history, it can do that too. * [[MarkDown]] diff --git a/doc/todo.mdwn b/doc/todo.mdwn index dd69e21fb..2b4da3c4f 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -86,4 +86,15 @@ allow for different types of setup files for more than just the one hardcoded thing there is now, and would probably be good for upgrades, incompatible changes, etc, too. +## base wiki + +Need a toned down version of this wiki with a basic frontpage, sandbox and +docs to use as a seed for new wikis. + +## search + +* full text (use third-party tools?) +* list of all missing pages +* list of all pages or some kind of page map + ## [[Bugs]] diff --git a/ikiwiki b/ikiwiki index d6057c101..53a86c1ed 100755 --- a/ikiwiki +++ b/ikiwiki @@ -210,9 +210,15 @@ sub htmllink { #{{{ my $page=shift; my $link=shift; my $noimageinline=shift; # don't turn links into inline html images - my $createsubpage=shift; # force creation of a subpage if page DNE + my $forcesubpage=shift; # force a link to a subpage - my $bestlink=bestlink($page, $link); + my $bestlink; + if (! $forcesubpage) { + $bestlink=bestlink($page, $link); + } + else { + $bestlink="$page/".lc($link); + } return $link if length $bestlink && $page eq $bestlink; @@ -224,12 +230,7 @@ sub htmllink { #{{{ $bestlink=htmlpage($bestlink); } if (! grep { $_ eq $bestlink } values %renderedfiles) { - if (! $createsubpage) { - return "?$link" - } - else { - return "?$link" - } + return "?$link" } $bestlink=File::Spec->abs2rel($bestlink, dirname($page)); -- 2.39.5