From: Joey Hess Date: Tue, 1 Jul 2008 22:08:31 +0000 (-0400) Subject: add both kinds of links X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/8441d3153506bc704d97def187c7a77c10fa7e3f add both kinds of links --- diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index 1d392589e..690b61cbc 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -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" => '', - 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;