]> sipb.mit.edu Git - ikiwiki.git/commitdiff
add both kinds of links
authorJoey Hess <joey@kodama.kitenet.net>
Tue, 1 Jul 2008 22:08:31 +0000 (18:08 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Tue, 1 Jul 2008 22:08:31 +0000 (18:08 -0400)
IkiWiki/Plugin/attachment.pm

index 1d392589e4f44d5a29d2e2f7cd67c71e09013539..690b61cbc27255885c84dd48e62cce91759e9fc2 100644 (file)
@@ -27,17 +27,17 @@ sub attachment_location ($) {
 }
 
 sub attachment_list ($) {
-       my $loc=attachment_location(shift);
+       my $page=shift;
+       my $loc=attachment_location($page);
 
        my @ret;
        foreach my $f (values %pagesources) {
-               print STDERR ">>$f\n" if ! defined IkiWiki::pagetype($f);
                if (! defined IkiWiki::pagetype($f) &&
                    $f=~m/^\Q$loc\E[^\/]+$/ &&
                    -e "$config{srcdir}/$f") {
                        push @ret, {
                                "field-select" => '<input type="checkbox" name="attachment_select" value="'.$f.'">',
-                               link => $f,
+                               link => htmllink($page, $page, $f, noimageinline => 1),
                                size => (stat(_))[7],
                                mtime => displaytime($IkiWiki::pagemtime{$f}),
                        };
@@ -87,11 +87,11 @@ sub formbuilder_setup (@) { #{{{
 sub formbuilder (@) { #{{{
        my %params=@_;
        my $form=$params{form};
+       my $q=$params{cgi};
 
        return if $form->field("do") ne "edit";
 
        if ($form->submitted eq "Upload" || $form->submitted eq "Save Page") {
-               my $q=$params{cgi};
                my $session=$params{session};
 
                my $filename=$q->param('attachment');
@@ -163,6 +163,15 @@ sub formbuilder (@) { #{{{
                IkiWiki::refresh();
                IkiWiki::saveindex();
        }
+       elsif ($form->submitted eq "Insert Links") {
+               my $add="";
+               foreach my $f ($q->param("attachment_select")) {
+                       $add.="[[$f]]\n";
+               }
+               $form->field(name => 'editcontent',
+                       value => $form->field('editcontent')."\n\n".$add,
+                       force => 1);
+       }
 } # }}}
 
 package IkiWiki::PageSpec;