-} # }}}
-
-package IkiWiki::PageSpec;
-
-sub parsesize ($) { #{{{
- my $size=shift;
- no warnings;
- my $base=$size+0; # force to number
- use warnings;
- my $multiple=1;
- if ($size=~/kb?$/i) {
- $multiple=2**10;
- }
- elsif ($size=~/mb?$/i) {
- $multiple=2**20;
- }
- elsif ($size=~/gb?$/i) {
- $multiple=2**30;
- }
- elsif ($size=~/tb?$/i) {
- $multiple=2**40;
- }
- return $base * $multiple;
-} #}}}
-
-sub match_maxsize ($$;@) { #{{{
- shift;
- my $maxsize=eval{parsesize(shift)};
- if ($@) {
- return IkiWiki::FailReason->new("unable to parse maxsize (or number too large)");
- }
-
- my %params=@_;
- if (! exists $params{file}) {
- return IkiWiki::FailReason->new("no file specified");
- }
-
- if (-s $params{file} > $maxsize) {
- return IkiWiki::FailReason->new("file too large");
- }
- else {
- return IkiWiki::SuccessReason->new("file not too large");
+ elsif ($form->submitted eq "Insert Links") {
+ my $page=quotemeta(Encode::decode_utf8($q->param("page")));
+ my $add="";
+ foreach my $f ($q->param("attachment_select")) {
+ $f=Encode::decode_utf8($f);
+ $f=~s/^$page\///;
+ $add.="[[$f]]\n";
+ }
+ $form->field(name => 'editcontent',
+ value => $form->field('editcontent')."\n\n".$add,
+ force => 1) if length $add;