diff --git a/Changes b/Changes index 2ba5335..32433ea 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Lutim +0.5 2014-09-24 + - Add support for animated gif in Twitter cards (#45) + - Update README.md with Twitter integration informations + - bugfixes + 0.4 2014-07-12 - Webapp ! Downloadable directly from the Lutim instance - Configure expiration delay after uploading (#12) diff --git a/README.md b/README.md index 9982891..45f8588 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ It means Let's Upload That Image. ## What does it do? -It stores images and allows you to see them, download them or use them in Twitter. +It stores images and allows you to see them, download them or use them in Twitter. From version 0.5, the gif images can be displayed as animated gifs in Twitter, but you need a HTTPS server (Twitter requires that. Lutim detects if you have a HTTPS server and displays an static image twitter card if you don't); + Images are indefinitly stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year. ## License @@ -34,17 +35,21 @@ sudo apt-get install carton * But, on another hand, some modules that Carton will install need to be compiled. So you will need some tools: ```shell -sudo apt-get install build-essential libssl-dev +sudo apt-get install build-essential ``` -### Thumbnails dependancy -If you want to provide thumbnails of uploaded images, you have to install the *ImageMagick* image manipulation software () and the Image::Magick CPAN module. +### Thumbnails and animated gifs in Twitter dependancy +If you want to provide thumbnails of uploaded images or have animated gifs in Twitter, you have to install the *ImageMagick* image manipulation software () and the Image::Magick CPAN module. On Debian, you can do: ```shell sudo apt-get install perlmagick ``` +## Twitter integration +If you want to share images of your Lutim instance on Twitter, you have to register your site at . + + ## Installation After installing Carton : ```shell @@ -119,6 +124,17 @@ UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE lutim ( short TEXT PRIMARY KEY, pat PRAGMA writable_schema = 0; ``` +***Warning!!!*** + +If you want to update to Lutim **0.5**, from a previous version, you'll have to modify the database. + +``` +sqlite3 lutim.db +PRAGMA writable_schema = 1; +UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE lutim ( short TEXT PRIMARY KEY, path TEXT, footprint TEXT, enabled INTEGER, mediatype TEXT, filename TEXT, counter INTEGER, delete_at_first_view INTEGER, delete_at_day INTEGER, created_at INTEGER, created_by TEXT, last_access_at INTEGER, mod_token TEXT, width INTEGER, height INTEGER)' WHERE NAME = 'lutim'; +PRAGMA writable_schema = 0; +``` + ## Reverse proxy You can use a reverse proxy like Nginx or Varnish (or Apache with the mod_proxy module). The web is full of tutos. diff --git a/lib/Lutim/Controller.pm b/lib/Lutim/Controller.pm index a68d16a..3a5d825 100644 --- a/lib/Lutim/Controller.pm +++ b/lib/Lutim/Controller.pm @@ -279,9 +279,13 @@ sub add { my $filename = unidecode($upload->filename); my $ext = ($filename =~ m/([^.]+)$/)[0]; my $path = 'files/'.$records[0]->short.'.'.$ext; + + my ($width, $height); if ($im_loaded) { - my $im = Image::Magick->new; + my $im = Image::Magick->new; $im->BlobToImage($upload->slurp); + $width = $im->Get('width'); + $height = $im->Get('height'); $im->Resize(geometry=>'x85'); $thumb = 'data:'.$mediatype.';base64,'; @@ -301,7 +305,9 @@ sub add { delete_at_day => ($c->param('delete-day') && $c->param('delete-day') <= $c->max_delay) ? $c->param('delete-day') : $c->max_delay, delete_at_first_view => ($c->param('first-view')) ? 1 : 0, created_at => time(), - created_by => $ip + created_by => $ip, + width => $width, + height => $height ); # Log image creation @@ -413,11 +419,31 @@ sub short { $test = 1; my $short = $images[0]->short; $short .= '/'.$key if (defined($key)); + my ($width, $height) = (340,340); + if ($images[0]->mediatype eq 'image/gif') { + if (defined($images[0]->width) && defined($images[0]->height)) { + ($width, $height) = ($images[0]->width, $images[0]->height); + } elsif ($im_loaded) { + my $upload = $c->decrypt($key, $images[0]->path); + my $im = Image::Magick->new; + $im->BlobToImage($upload->slurp); + $width = $im->Get('width'); + $height = $im->Get('height'); + + $images[0]->update( + width => $width, + height => $height + ); + } + } return $c->render( template => 'twitter', layout => undef, short => $short, - filename => $images[0]->filename + filename => $images[0]->filename, + mimetype => ($c->req->url->to_abs()->scheme eq 'https') ? $images[0]->mediatype : '', + width => $width, + height => $height ); } else { # Delete image if needed diff --git a/lib/LutimModel.pm b/lib/LutimModel.pm index 2af27e4..09c9b84 100644 --- a/lib/LutimModel.pm +++ b/lib/LutimModel.pm @@ -20,7 +20,9 @@ use ORLite { created_at INTEGER, created_by TEXT, last_access_at INTEGER, - mod_token TEXT)' + mod_token TEXT, + width INTEGER, + height INTEGER)' ); return 1; } diff --git a/templates/twitter.html.ep b/templates/twitter.html.ep index e3612bc..7b55862 100644 --- a/templates/twitter.html.ep +++ b/templates/twitter.html.ep @@ -1,17 +1,26 @@ % # vim:set sw=4 ts=4 sts=4 ft=html.epl expandtab: - + Lutim - + +% if ($mimetype eq 'image/gif') { + + + + + + +% } else { +% } - + - <%= $filename %> + <%= $filename %>