WWW::MeGa - A MediaGallery
use WWW::MeGa; my $webapp = WWW::MeGa->new $webapp->run;
THIS IS A SECURITY BUGFIX RELEASE. PLEASE UPDATE TO 0.1.1 IF YOU HAVE 0.1
WWW::MeGa is a web based media gallery. It should be run from FastCGI (see examples/gallery.fcgi) or mod_perl (not yet tested) because it uses some runtime caching.
Every file will be delievered by the CGI itself. So you don't have to care about setting up picture/thumb dirs.
To see it in action, visit: http://freigeist.org/gallery or http://sophiesfotos.de
on-the-fly image resizing (and orientation tag based autorotating)
video thumbnails
displays text files
reads exif tag
very easy to setup (change one path in the config and your done)
templating with HTML::Template::Compiled
Use your favorite way to install this CPAN-Package and make sure you have ffmpeg somewhere in your path (or specify the path in the config) if you want video thumbnails.
ffmpeg
If you want to install it via the cpan-installer use:
cpan WWW::MeGa
To install a developer release of WWW::MeGa, use the CPAN-Shell:
perl -MCPAN -eshell
Now you can see all releases with ls fish and install the one you want: install FISH/WWW-MeGa-0.09_6.tar.gz
ls fish
install FISH/WWW-MeGa-0.09_6.tar.gz
WARNING: Installation via cpan or the CPAN-Shell is only recommended if you have a local administered perl installation. If you installed perl from your packet manager you should use the packet manager to install this package too. Have a look at g-cpan (Gentoo) and dh-make-perl (Debian/Ubuntu).
cpan
g-cpan
dh-make-perl
Copy examples/gallery.fcgi to some dir and configure your webserver to use it as a FastCGI:
examples/gallery.fcgi
Example for lighttpd:
fastcgi.server = ( "/gallery" => ( "localhost" => ( "socket" => "/var/run/lighttpd/gallery" + PID + ".socket", "check-local" => "disable", "bin-path" => "/var/www/gallery.fcgi" ) ), )
Copy examples/gallery.cgi to your cgi-bin/ directory and make sure its executable. Now WWW::MeGa should have created a default config file. Change 'root' to your images and you are done.
examples/gallery.cgi
cgi-bin/
Make sure the user under which the webserver is running has write permission to the config file. The path to the config file defaults to to 'gallery.conf' in the same dir as your script. In these cases: /var/www/gallery.conf (FCGI) and /path/to/your/cgi-bin/gallery.conf.
/var/www/gallery.conf
/path/to/your/cgi-bin/gallery.conf
You can (and should, at least in the CGI case) specify a custom path to the config by changing the scripts to pass:
PARAMS => { config => '/path/to/your/config' }
to the new method of WWW::MeGa.
... my $app = WWW::MeGa->new ( QUERY => $q, PARAMS => { cache => \%cache, config => '/path/to/your/config' }, ); ...
... my $webapp = WWW::MeGa->new(PARAMS => {config => '/path/to/your/config'}); ...
Now visit the the URL to you script. (In these examples: http://example.com/gallery (FastCGI) and http://example.com/cgi-bin/gallery.cgi (CGI)) and you should see the example photos.
WWW::MeGa uses CGI::Application::Plugin::Config::Simple for config handling. You can specify the path to a (writable) config file in the new methode of WWW::MeGa:
my $gallery = WWW::MeGa->new(PARAMS => { config => '/path/to/gallery.conf' })
It defaults to $RealBin/gallery.conf, see FindBin for more info. After the first run it will create a config containing the defaults.
Path to your images
Path where to store the thumbnails
specifies which file should be used a thumbnail for a folder. Defaults to THUMBNAIL. The file named like that will be skipped when showing the content of the folder.
THUMBNAIL
Type of the thumbnails. WWW::MeGa uses Image::Magick for generating thumbnails. See convert -list format for file types supported by you ImageMagick installation.
convert -list format
If set to 1, enables video-thumbs. Default: 1
specifies which frame to grab in seconds. Default: 10
If set to 1, enables the extraction of exif-data. Default: 1
Specify the path to the ffmpeg-binary. Defaults to 'ffmpeg'. (Should be looked up in your PATH)
A array of valid "thumbnail"/resized image sizes, defaults to [ 120, 600, 800 ]. The CGI parameter size is the index to that array.
[ 120, 600, 800 ]
size
If set to 1, enabled debugging to your server's error log.
Specify the name of the image which will be used as a thumbnail for the containing album, defaults to THUMBNAIL.
So if you want to have the image foo.jpg be the thumbnail for the album bar, copy it to bar/THUMBNAIL (or use a symlink)
foo.jpg
bar
bar/THUMBNAIL
Path to the icons and templates, defaults to icons/ in the module's share dir as defined by Module::Install and File::ShareDir
icons/
the public runmodes, accessable via the rm parameter
rm
shows a thumbnail
shows a html page with one or more items
WWW::MeGa uses the image named THUMBNAIL (or whatever you setup for album_thumb in the config) in each folder as its thumbnail. So if you want to have the image foo/bar.jpg to be the thumbnail for foo, set a symlink called foo/THUMBNAIL to it (or copy it there)
album_thumb
foo/bar.jpg
foo
foo/THUMBNAIL
See ping-mega.pl for that.
I tried to write a clean and elegant app but I'm not a perl guru so please bash me about everything you think suck in this project. I'm willing to learn and appreciate constructive critic.
If you think this app is cool and you like to see new features please let me know!
Thanks to EXP (at least I guess he was it) who suggests me to learn perl some years ago.
And thanks alot to the people from irc.perl.org / #perlde for the current support.
Copyright 2008 by Johannes 'fish' Ziemke.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The shipped icons are copyrighted by the "Tango Desktop Project" and are licensed under the Creative Commons Attribution Share-Alike 2.5 license. See http://creativecommons.org/licenses/by-sa/2.5
biene.jpg and steine.jpg are copyrighted by Sophie Bischoff. For more, see: http://sophiesfotos.de
moewe.jpg is copyrighted by Johannes 'fish' Ziemke.
The shipped example photos are licensed unter the Creative Commons Attribution Share-Alike 3.0 license. See http://creativecommons.org/licenses/by-sa/3.0/
ping-mega.pl
WWW::MeGa::Item
CGI::Application
Johannes 'fish' Ziemke <my nickname at cpan org>
To install WWW::MeGa, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::MeGa
CPAN shell
perl -MCPAN -e shell install WWW::MeGa
For more information on module installation, please visit the detailed CPAN module installation guide.