]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/attachment.pm
document external links
[git.ikiwiki.info.git] / IkiWiki / Plugin / attachment.pm
index 8c3ff887af16076e9f6d41126d11ddac47fb3567..ce688ca40df0f8c13f9f09206e54a871438a2f10 100644 (file)
@@ -134,9 +134,12 @@ sub formbuilder (@) {
                        }
                }
 
                        }
                }
 
+               $filename=IkiWiki::basename($filename);
+               $filename=~s/.*\\+(.+)/$1/; # hello, windows
+
                $filename=linkpage(IkiWiki::possibly_foolish_untaint(
                                attachment_location($form->field('page')).
                $filename=linkpage(IkiWiki::possibly_foolish_untaint(
                                attachment_location($form->field('page')).
-                               IkiWiki::basename($filename)));
+                               $filename));
                if (IkiWiki::file_pruned($filename)) {
                        error(gettext("bad attachment filename"));
                }
                if (IkiWiki::file_pruned($filename)) {
                        error(gettext("bad attachment filename"));
                }
@@ -195,7 +198,14 @@ sub formbuilder (@) {
                foreach my $f ($q->param("attachment_select")) {
                        $f=Encode::decode_utf8($f);
                        $f=~s/^$page\///;
                foreach my $f ($q->param("attachment_select")) {
                        $f=Encode::decode_utf8($f);
                        $f=~s/^$page\///;
-                       $add.="[[$f]]\n";
+                       if (IkiWiki::isinlinableimage($f) &&
+                           UNIVERSAL::can("IkiWiki::Plugin::img", "import")) {
+                               $add.='[[!img '.$f.' align="right" size="" alt=""]]';
+                       }
+                       else {
+                               $add.="[[$f]]";
+                       }
+                       $add.="\n";
                }
                $form->field(name => 'editcontent',
                        value => $form->field('editcontent')."\n\n".$add,
                }
                $form->field(name => 'editcontent',
                        value => $form->field('editcontent')."\n\n".$add,
@@ -225,8 +235,7 @@ sub attachment_list ($) {
        my @ret;
        foreach my $f (values %pagesources) {
                if (! defined pagetype($f) &&
        my @ret;
        foreach my $f (values %pagesources) {
                if (! defined pagetype($f) &&
-                   $f=~m/^\Q$loc\E[^\/]+$/ &&
-                   -e "$config{srcdir}/$f") {
+                   $f=~m/^\Q$loc\E[^\/]+$/) {
                        push @ret, {
                                "field-select" => '<input type="checkbox" name="attachment_select" value="'.$f.'" />',
                                link => htmllink($page, $page, $f, noimageinline => 1),
                        push @ret, {
                                "field-select" => '<input type="checkbox" name="attachment_select" value="'.$f.'" />',
                                link => htmllink($page, $page, $f, noimageinline => 1),