]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Render.pm
Fix issues with combining unicode srcdirs and source files.
[ikiwiki.git] / IkiWiki / Render.pm
index 8b1b9aef4353daec5612c98d3b28dde58d832113..0e7aa9a48a2bd5ddb4267ca948e3f6eba6ba121a 100644 (file)
@@ -84,19 +84,14 @@ sub genpage ($$) {
                $template=template('page.tmpl', 
                        blind_cache => 1);
        }
-       my $actions=0;
 
+       my $actions=0;
        if (length $config{cgiurl}) {
                if (IkiWiki->can("cgi_editpage")) {
                        $template->param(editurl => cgiurl(do => "edit", page => $page));
                        $actions++;
                }
-               if (exists $hooks{auth}) {
-                       $template->param(prefsurl => cgiurl(do => "prefs"));
-                       $actions++;
-               }
        }
-               
        if (defined $config{historyurl} && length $config{historyurl}) {
                my $u=$config{historyurl};
                $u=~s/\[\[file\]\]/$pagesources{$page}/g;
@@ -111,17 +106,10 @@ sub genpage ($$) {
                        $actions++;
                }
        }
-
-       my @actions;
-       run_hooks(pageactions => sub {
-               push @actions, map { { action => $_ } } 
-                       grep { defined } shift->(page => $page);
-       });
-       $template->param(actions => \@actions);
-
-       if ($actions || @actions) {
+       if ($actions) {
                $template->param(have_actions => 1);
        }
+       templateactions($template, $page);
 
        my @backlinks=sort { $a->{page} cmp $b->{page} } backlinks($page);
        my ($backlinks, $more_backlinks);
@@ -304,12 +292,11 @@ sub find_src_files () {
        eval q{use File::Find};
        error($@) if $@;
 
-       my ($page, $dir, $underlay);
+       my ($page, $underlay);
        my $helper=sub {
                my $file=decode_utf8($_);
-
                return if -l $file || -d _;
-               $file=~s/^\Q$dir\E\/?//;
+               $file=~s/^\Q.\/\E//;
                return if ! length $file;
                $page = pagename($file);
                if (! exists $pagesources{$page} &&
@@ -342,17 +329,27 @@ sub find_src_files () {
                }
        };
 
+       eval q{use Cwd};
+       die $@ if $@;
+       my $origdir=getcwd();
+
+       chdir($config{srcdir}) || die "chdir: $!";
        find({
                no_chdir => 1,
                wanted => $helper,
-       }, $dir=$config{srcdir});
+       }, '.');
+       chdir($origdir) || die "chdir: $!";
+
        $underlay=1;
        foreach (@{$config{underlaydirs}}, $config{underlaydir}) {
+               chdir($_) || die "chdir: $!";
                find({
                        no_chdir => 1,
                        wanted => $helper,
-               }, $dir=$_);
+               }, '.');
+               chdir($origdir) || die "chdir: $!";
        };
+
        return \@files, \%pages;
 }
 
@@ -454,6 +451,7 @@ sub remove_del (@) {
                }
        
                delete $pagecase{lc $page};
+               $delpagesources{$page}=$pagesources{$page};
                delete $pagesources{$page};
        }
 }