-Index: ikiwiki.in
-===================================================================
---- ikiwiki.in (revision 2770)
-+++ ikiwiki.in (working copy)
-@@ -46,6 +46,7 @@
- "sslcookie!" => \$config{sslcookie},
- "httpauth!" => \$config{httpauth},
- "userdir=s" => \$config{userdir},
-+ "usedirs!" => \$config{usedirs},
- "exclude=s@" => sub {
- push @{$config{wiki_file_prune_regexps}}, $_[1];
- },
-Index: IkiWiki.pm
-===================================================================
---- IkiWiki.pm (revision 2770)
-+++ IkiWiki.pm (working copy)
-@@ -14,7 +14,7 @@
- use Exporter q{import};
- our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
- bestlink htmllink readfile writefile pagetype srcfile pagename
-- displaytime will_render gettext
-+ displaytime will_render gettext urlto
- %config %links %renderedfiles %pagesources);
- our $VERSION = 1.02; # plugin interface version, next is ikiwiki version
- our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
-@@ -72,6 +72,7 @@
- sslcookie => 0,
- httpauth => 0,
- userdir => "",
-+ usedirs => 0
- } #}}}
-
- sub checkconfig () { #{{{
-@@ -226,7 +227,11 @@
- sub htmlpage ($) { #{{{
- my $page=shift;
-
-- return $page.".html";
-+ if (! $config{usedirs} || $page =~ /^index$/ || $page =~ /\/index$/) {
-+ return $page.".html";
-+ } else {
-+ return $page."/index.html";
-+ }
- } #}}}
-
- sub srcfile ($) { #{{{
-@@ -392,6 +397,7 @@
-
- return "$config{url}/" if ! defined $page;
-
-+ $page=htmlpage($page);
- $page=~s/[^\/]+$//;
- $page=~s/[^\/]+\//..\//g;
- return $page;
-@@ -421,6 +427,32 @@
- $config{timeformat}, localtime($time)));
- } #}}}
-
-+sub beautify_url ($) { #{{{
-+ my $url=shift;
-+
-+ $url =~ s!/index.html$!/!;
-+ $url =~ s!^$!./!; # Browsers don't like empty links...
-+
-+ return $url;
-+} #}}}
-+
-+sub urlto ($$) { #{{{
-+ my $to=shift;
-+ my $from=shift;
-+
-+ if (! length $to) {
-+ return beautify_url(baseurl($from));
-+ }
-+
-+ if (! grep { $_ eq $to } map { @{$_} } values %renderedfiles) {
-+ $to=htmlpage($to);
-+ }
-+
-+ my $link = abs2rel($to, dirname(htmlpage($from)));
-+
-+ return beautify_url($link);
-+} #}}}
-+
- sub htmllink ($$$;@) { #{{{
- my $lpage=shift; # the page doing the linking
- my $page=shift; # the page that will contain the link (different for inline)
-@@ -456,7 +488,8 @@
- "\">?</a>$linktext</span>"
- }
-
-- $bestlink=abs2rel($bestlink, dirname($page));
-+ $bestlink=abs2rel($bestlink, dirname(htmlpage($page)));
-+ $bestlink=beautify_url($bestlink);
-
- if (! $opts{noimageinline} && isinlinableimage($bestlink)) {
- return "<img src=\"$bestlink\" alt=\"$linktext\" />";