Kwiki-Attachments

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension Kwiki::Attachments.

0.15  Mon Apr 18
      - Fixed missing cgi parameter 'uploaded_file'.
      - Changed filename filter for uploaded_file so that '-' is
        not changed to '_'.

0.16  Mon Aug 16 2005
      - Added thumbnail support if Imager or Image::Magick is installed.
      - Includes a wafl directive {thumb:[page/]filename}.

0.17  Tue Aug 17 2005
      - Amended pod in Attachments.pm

0.18  Fri Sep 9 2006
      - Fixed code typos in thumbnail creation code when Imager.pm is used.
      - Embellished the pod in Attachments.pm.
      - Added config options:
         make_thumbnails : turn thumbnail creation on/off
         im_override : use Image::Magick instead of Imager if both installed
      - Added more tests
      - Updated README.

0.19  Sun 31 May 2009
      - Fixed test case which required a file that wasn't included in the distro.

0.21  Tue 14 Jul 2009
      - Removed Mac OS X related garbage files in release tarball.

README  view on Meta::CPAN


SYNOPSIS

   1. Install this module.
   2. Run 'kwiki -add Kwiki::Attachments'

DESCRIPTION

   This module gives a Kwiki wiki the ability to upload, store and manage file 
   attachments on any page. Thumbnails will be created for supported file
   types if Imager or Image::Magick is installed. For more information, read the
   module POD.

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

lib/Kwiki/Attachments.pm  view on Meta::CPAN

         }
      }
      if ($supported) {
         my $image = Imager->new;
         return unless ref($image);
         if ($image->read(file=>$file)) {
            my $thumb_img = $image->scale(xpixels=>80,ypixels=>80);
            $thumb_img->write(file=>$thumb);
         }
      }
   } elsif (eval { require Image::Magick }) {
      # Image::Magick does the right thing with image files regardless
      # of whether the file extension looks like ".jpg", ".png" etc.
      my $image = Image::Magick->new;
      return unless ref($image);
      if (!$image->Read($file)) {
         if (!$image->Scale(geometry=>'80x80')) {
            if (!$image->Contrast(sharpen=>"true")) {
               $image->Write($thumb);
            }
         }
      }
   }
   return;

lib/Kwiki/Attachments.pm  view on Meta::CPAN

Run 'kwiki -add Kwiki::Attachments'

=back

=head1 DESCRIPTION

=head3 B<General>

Kwiki::Attachments gives a Kwiki wiki the ability to upload, store and manage
file attachments on any page. By default, if you have an image creation module 
such as Imager or Image::Magick installed, then a thumbnail will be created for 
every supported image file type that is uploaded. Thumbnails are displayed on 
the attachments page, and can also be displayed on wiki pages via the wafl
directives described in the next paragraph. The thumbnail files have "thumb_"
prepended to the original filename and are not displayed separately  in the 
attachment page or widget. For this reason, you cannot upload files beginning
with "thumb_".

=head3 B<WAFL>

This module provides 3 wafl tags which can be used to link to or display

lib/Kwiki/Attachments.pm  view on Meta::CPAN

matched by the given regular expression.  By default, it is set to reject files
beginning with "thumb_" or "." and those ending with "~" or ".bak".

=item *  make_thumbnails: [on|off]

This flag controls whether thumbnails are created from uploaded image files.
It is set to 'on' by default. 

=item *  im_override: [on|off]

If both Imager.pm and Image::Magick.pm are available, Kwiki::Attachments uses
Imager, unless im_override is set to 'on'. This parameter has no effect if only
one of the two image manipulation modules is installed. It is set to 'off' by
default.

=head1 AUTHOR

Sue Spence <sue_cpan@pennine.com>

This module is based almost entirely on work by
Eric Lowry <eric@clubyo.com> and Brian Ingerson <INGY@cpan.org>

lib/Kwiki/Attachments.pm  view on Meta::CPAN

__config/attachments.yaml__
# Kwiki::Attachments configuration options

# attachments_skip: regex describing file names to be excluded
attachments_skip: (^\.)|(^thumb_)|(~$)|(\.bak$)

# make_thumbnails: on|off
make_thumbnails: on

# 'im_override' overrides the preference for Imager for 
# thumbnail creation if both Imager & Image::Magick are installed.
# im_override: on|off
im_override: off

__css/attachments.css__
table.attachments {
    color: #999;
}
th.delete { text-align: left;width: 15% }
th.file   { text-align: left;width: 35% }
th.size   { text-align: left;width: 15% }

t/Kwiki-Attachments.t  view on Meta::CPAN

SKIP: {
   eval { require Imager };
   skip "Imager not installed (for thumbnails) ", 2 if $@;
   my $image = Imager->new;
   isa_ok($image, "Imager" );
   my $ok = $image->read(file=>"t/test.png");
   isa_ok($image, "Imager" );
#   is($ok, 0, "No errors reading image with Imager");
}
SKIP: {
   eval { require Image::Magick };
   skip "Image::Magick not installed (for thumbnails)", 2 if $@;
   my $im = Image::Magick->new;
   isa_ok($im, "Image::Magick" );
   my $ok = $im->Read("t/test.png");
   is($ok, 0, "No errors reading image with Image::Magick");
}




( run in 1.591 second using v1.01-cache-2.11-cpan-beeb90c9504 )