]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/attachment.pm
po: fixed link to home page when po_link_to=negotiated, added testcase
[git.ikiwiki.info.git] / IkiWiki / Plugin / attachment.pm
index 2d1fe51cf090b0f70595104217bd8d01b34ab0f9..44781165cdaee4d6a0928d4dfe9ec5acc58cb066 100644 (file)
@@ -6,6 +6,7 @@ use strict;
 use IkiWiki 2.00;
 
 sub import { #{{{
 use IkiWiki 2.00;
 
 sub import { #{{{
+       add_underlay("javascript");
        hook(type => "getsetup", id => "attachment", call => \&getsetup);
        hook(type => "checkconfig", id => "attachment", call => \&checkconfig);
        hook(type => "formbuilder_setup", id => "attachment", call => \&formbuilder_setup);
        hook(type => "getsetup", id => "attachment", call => \&getsetup);
        hook(type => "checkconfig", id => "attachment", call => \&checkconfig);
        hook(type => "formbuilder_setup", id => "attachment", call => \&formbuilder_setup);
@@ -104,10 +105,10 @@ sub formbuilder_setup (@) { #{{{
                $form->tmpl_param("field-upload" => '<input name="_submit" type="submit" value="Upload Attachment" />');
                $form->tmpl_param("field-link" => '<input name="_submit" type="submit" value="Insert Links" />');
 
                $form->tmpl_param("field-upload" => '<input name="_submit" type="submit" value="Upload Attachment" />');
                $form->tmpl_param("field-link" => '<input name="_submit" type="submit" value="Insert Links" />');
 
-               # Add the javascript from the toggle plugin;
-               # the attachments interface uses it to toggle visibility.
+               # Add the toggle javascript; the attachments interface uses
+               # it to toggle visibility.
                require IkiWiki::Plugin::toggle;
                require IkiWiki::Plugin::toggle;
-               $form->tmpl_param("javascript" => $IkiWiki::Plugin::toggle::javascript);
+               $form->tmpl_param("javascript" => IkiWiki::Plugin::toggle::include_javascript($params{page}, 1));
                # Start with the attachments interface toggled invisible,
                # but if it was used, keep it open.
                if ($form->submitted ne "Upload Attachment" &&
                # Start with the attachments interface toggled invisible,
                # but if it was used, keep it open.
                if ($form->submitted ne "Upload Attachment" &&
@@ -279,7 +280,6 @@ sub attachment_list ($) { #{{{
                                link => htmllink($page, $page, $f, noimageinline => 1),
                                size => IkiWiki::Plugin::filecheck::humansize((stat(_))[7]),
                                mtime => displaytime($IkiWiki::pagemtime{$f}),
                                link => htmllink($page, $page, $f, noimageinline => 1),
                                size => IkiWiki::Plugin::filecheck::humansize((stat(_))[7]),
                                mtime => displaytime($IkiWiki::pagemtime{$f}),
-                               mtime_raw => $IkiWiki::pagemtime{$f},
                        };
                }
        }
                        };
                }
        }
@@ -289,63 +289,4 @@ sub attachment_list ($) { #{{{
        return sort { $b->{mtime_raw} <=> $a->{mtime_raw} || $a->{link} cmp $b->{link} } @ret;
 } #}}}
 
        return sort { $b->{mtime_raw} <=> $a->{mtime_raw} || $a->{link} cmp $b->{link} } @ret;
 } #}}}
 
-package IkiWiki::PageSpec;
-
-sub match_user ($$;@) { #{{{
-       shift;
-       my $user=shift;
-       my %params=@_;
-       
-       if (! exists $params{user}) {
-               return IkiWiki::FailReason->new("no user specified");
-       }
-
-       if (defined $params{user} && lc $params{user} eq lc $user) {
-               return IkiWiki::SuccessReason->new("user is $user");
-       }
-       elsif (! defined $params{user}) {
-               return IkiWiki::FailReason->new("not logged in");
-       }
-       else {
-               return IkiWiki::FailReason->new("user is $params{user}, not $user");
-       }
-} #}}}
-
-sub match_admin ($$;@) { #{{{
-       shift;
-       shift;
-       my %params=@_;
-       
-       if (! exists $params{user}) {
-               return IkiWiki::FailReason->new("no user specified");
-       }
-
-       if (defined $params{user} && IkiWiki::is_admin($params{user})) {
-               return IkiWiki::SuccessReason->new("user is an admin");
-       }
-       elsif (! defined $params{user}) {
-               return IkiWiki::FailReason->new("not logged in");
-       }
-       else {
-               return IkiWiki::FailReason->new("user is not an admin");
-       }
-} #}}}
-
-sub match_ip ($$;@) { #{{{
-       shift;
-       my $ip=shift;
-       my %params=@_;
-       
-       if (! exists $params{ip}) {
-               return IkiWiki::FailReason->new("no IP specified");
-       }
-
-       if (defined $params{ip} && lc $params{ip} eq lc $ip) {
-               return IkiWiki::SuccessReason->new("IP is $ip");
-       }
-       else {
-               return IkiWiki::FailReason->new("IP is $params{ip}, not $ip");
-       }
-} #}}}
-
 1
 1