Fix #47 Allow to upload svg images

This commit is contained in:
Luc Didry
2015-08-02 22:29:16 +02:00
parent 774f3ebda9
commit 080542fd95
4 changed files with 72 additions and 371 deletions
+1
View File
@@ -5,6 +5,7 @@ Revision history for Lutim
- Add spanish translation (thx to Laura Arjona Reina)
- Allow Lutim to be on a sub-directory (like http://example.org/lutim/) (#46 and #57)
- Remove deprecated (due to typo) option "provisionning".
- Allow to upload svg images (no thumbnail for now, ImageMagick in Debian Jessie don't work with svg) (#47)
0.6 2014-10-03
- Add OpenGraph tags in social page (ex-twitter page)
+2 -1
View File
@@ -6,7 +6,6 @@ requires 'Net::Domain::TLD', '>= 1.73'; # Must have the last version to handle (
requires 'Mojolicious::Plugin::I18N';
requires 'Mojolicious::Plugin::AssetPack';
requires 'ORLite';
requires 'File::Type';
requires 'Text::Unidecode';
requires 'DateTime';
requires 'Filesys::DiskUsage';
@@ -16,3 +15,5 @@ requires 'Crypt::CBC';
requires 'Crypt::Blowfish';
requires 'Locale::Maketext';
requires 'Locale::Maketext::Extract';
requires 'File::MimeInfo';
requires 'IO::Scalar';
+64 -366
View File
@@ -1,13 +1,5 @@
# carton snapshot format: version 1.0
DISTRIBUTIONS
Algorithm-Diff-1.1902
pathname: T/TY/TYEMQ/Algorithm-Diff-1.1902.tar.gz
provides:
Algorithm::Diff 1.1902
Algorithm::Diff::_impl 1.1902
Algorithm::DiffOld 1.1
requirements:
ExtUtils::MakeMaker 0
CSS-Minifier-XS-0.09
pathname: G/GT/GTERMARS/CSS-Minifier-XS-0.09.tar.gz
provides:
@@ -21,45 +13,12 @@ DISTRIBUTIONS
Canary::Stability 2006
requirements:
ExtUtils::MakeMaker 0
Class-Data-Inheritable-0.08
pathname: T/TM/TMTM/Class-Data-Inheritable-0.08.tar.gz
provides:
Class::Data::Inheritable 0.08
requirements:
ExtUtils::MakeMaker 0
Class-Load-0.21
pathname: E/ET/ETHER/Class-Load-0.21.tar.gz
provides:
Class::Load 0.21
Class::Load::PP 0.21
requirements:
Carp 0
Data::OptList 0
Exporter 0
ExtUtils::MakeMaker 6.30
Module::Build::Tiny 0.034
Module::Implementation 0.04
Module::Runtime 0.012
Package::Stash 0.14
Scalar::Util 0
Try::Tiny 0
base 0
perl 5.008
strict 0
warnings 0
Class-Singleton-1.4
pathname: A/AB/ABW/Class-Singleton-1.4.tar.gz
provides:
Class::Singleton 1.4
requirements:
ExtUtils::MakeMaker 0
Clone-0.36
pathname: G/GA/GARU/Clone-0.36.tar.gz
provides:
Clone 0.36
requirements:
ExtUtils::MakeMaker 0
Test::More 0
Crypt-Blowfish-2.14
pathname: D/DP/DPARIS/Crypt-Blowfish-2.14.tar.gz
provides:
@@ -184,17 +143,6 @@ DISTRIBUTIONS
ExtUtils::MakeMaker 6.48
Test::Simple 0.90
perl 5.008
Data-OptList-0.109
pathname: R/RJ/RJBS/Data-OptList-0.109.tar.gz
provides:
Data::OptList 0.109
requirements:
ExtUtils::MakeMaker 6.30
List::Util 0
Params::Util 0
Sub::Install 0.921
strict 0
warnings 0
Data-Validate-Domain-0.10
pathname: N/NE/NEELY/Data-Validate-Domain-0.10.tar.gz
provides:
@@ -1114,31 +1062,6 @@ DISTRIBUTIONS
strict 0
vars 0
warnings 0
Devel-StackTrace-1.31
pathname: D/DR/DROLSKY/Devel-StackTrace-1.31.tar.gz
provides:
Devel::StackTrace 1.31
Devel::StackTrace::Frame 1.31
requirements:
ExtUtils::MakeMaker 6.30
File::Spec 0
Scalar::Util 0
overload 0
strict 0
warnings 0
Dist-CheckConflicts-0.10
pathname: D/DO/DOY/Dist-CheckConflicts-0.10.tar.gz
provides:
Dist::CheckConflicts 0.10
requirements:
Carp 0
Exporter 0
ExtUtils::MakeMaker 6.30
List::MoreUtils 0.12
Module::Runtime 0.009
base 0
strict 0
warnings 0
EV-4.21
pathname: M/ML/MLEHMANN/EV-4.21.tar.gz
provides:
@@ -1148,66 +1071,48 @@ DISTRIBUTIONS
Canary::Stability 0
ExtUtils::MakeMaker 6.52
common::sense 0
Exception-Class-1.37
pathname: D/DR/DROLSKY/Exception-Class-1.37.tar.gz
File-BaseDir-0.07
pathname: K/KI/KIMRYAN/File-BaseDir-0.07.tar.gz
provides:
Exception::Class 1.37
Exception::Class::Base 1.37
File::BaseDir 0.07
File::IconTheme 0.07
File::UserDirs 0.07
requirements:
Class::Data::Inheritable 0.02
Devel::StackTrace 1.20
ExtUtils::MakeMaker 6.30
Carp 0
Exporter 0
File::Spec 0
Scalar::Util 0
Test::More 0.88
base 0
overload 0
strict 0
vars 0
warnings 0
ExtUtils-Config-0.007
pathname: L/LE/LEONT/ExtUtils-Config-0.007.tar.gz
provides:
ExtUtils::Config 0.007
requirements:
Config 0
Data::Dumper 0
ExtUtils::MakeMaker 6.30
File::Find 0
File::Temp 0
Test::More 0.88
strict 0
warnings 0
ExtUtils-Helpers-0.021
pathname: L/LE/LEONT/ExtUtils-Helpers-0.021.tar.gz
File::Which 0
IPC::System::Simple 0
Module::Build 0.24
Test::More 0
File-DesktopEntry-0.12
pathname: M/MI/MICHIELB/File-DesktopEntry-0.12.tar.gz
provides:
ExtUtils::Helpers 0.021
ExtUtils::Helpers::Unix 0.021
ExtUtils::Helpers::VMS 0.021
ExtUtils::Helpers::Windows 0.021
File::DesktopEntry 0.12
requirements:
Carp 0
Config 0
Exporter 5.57
ExtUtils::MakeMaker 6.30
File::Basename 0
File::Copy 0
File::Spec::Functions 0
Module::Load 0
Text::ParseWords 3.24
strict 0
warnings 0
ExtUtils-InstallPaths-0.010
pathname: L/LE/LEONT/ExtUtils-InstallPaths-0.010.tar.gz
provides:
ExtUtils::InstallPaths 0.010
requirements:
Carp 0
ExtUtils::Config 0.002
ExtUtils::MakeMaker 6.30
File::BaseDir 0.03
File::Path 0
File::Spec 0
strict 0
warnings 0
perl 5.008006
File-MimeInfo-0.27
pathname: M/MI/MICHIELB/File-MimeInfo-0.27.tar.gz
provides:
File::MimeInfo 0.27
File::MimeInfo::Applications 0.27
File::MimeInfo::Magic 0.27
File::MimeInfo::Rox 0.27
requirements:
Carp 0
Exporter 0
ExtUtils::MakeMaker 6.30
Fcntl 0
File::BaseDir 0.03
File::DesktopEntry 0.04
Pod::Usage 0
perl 5.006001
File-Remove-1.52
pathname: A/AD/ADAMK/File-Remove-1.52.tar.gz
provides:
@@ -1248,15 +1153,6 @@ DISTRIBUTIONS
File::Temp 0
Test::More 0
Test::Warn 0
Hash-Merge-Simple-0.051
pathname: R/RO/ROKR/Hash-Merge-Simple-0.051.tar.gz
provides:
Hash::Merge::Simple 0.051
requirements:
Clone 0
ExtUtils::MakeMaker 6.31
Storable 0
Test::Most 0
IO-Socket-SSL-2.016
pathname: S/SU/SULLR/IO-Socket-SSL-2.016.tar.gz
provides:
@@ -1273,6 +1169,22 @@ DISTRIBUTIONS
ExtUtils::MakeMaker 0
Net::SSLeay 1.46
Scalar::Util 0
IO-stringy-2.111
pathname: D/DS/DSKOLL/IO-stringy-2.111.tar.gz
provides:
IO::AtomicFile 2.111
IO::Clever 1.01
IO::InnerFile 2.111
IO::Lines 2.111
IO::Scalar 2.111
IO::ScalarArray 2.111
IO::Stringy 2.111
IO::Wrap 2.111
IO::WrapTie 2.111
IO::WrapTie::Master 2.111
IO::WrapTie::Slave 2.111
requirements:
ExtUtils::MakeMaker 0
IPC-Run3-0.046
pathname: R/RJ/RJBS/IPC-Run3-0.046.tar.gz
provides:
@@ -1281,6 +1193,21 @@ DISTRIBUTIONS
ExtUtils::MakeMaker 0
Test::More 0.31
Time::HiRes 0
IPC-System-Simple-1.25
pathname: P/PJ/PJF/IPC-System-Simple-1.25.tar.gz
provides:
IPC::System::Simple 1.25
requirements:
Carp 0
Exporter 0
ExtUtils::MakeMaker 6.30
List::Util 0
POSIX 0
Scalar::Util 0
constant 0
re 0
strict 0
warnings 0
JavaScript-Minifier-XS-0.11
pathname: G/GT/GTERMARS/JavaScript-Minifier-XS-0.11.tar.gz
provides:
@@ -1393,31 +1320,6 @@ DISTRIBUTIONS
Text::ParseWords 0
perl 5.006001
version 0.87
Module-Build-Tiny-0.035
pathname: L/LE/LEONT/Module-Build-Tiny-0.035.tar.gz
provides:
Module::Build::Tiny 0.035
requirements:
CPAN::Meta 0
DynaLoader 0
Exporter 5.57
ExtUtils::CBuilder 0
ExtUtils::Config 0.003
ExtUtils::Helpers 0.020
ExtUtils::Install 0
ExtUtils::InstallPaths 0.002
ExtUtils::ParseXS 0
File::Basename 0
File::Find 0
File::Path 0
File::Spec::Functions 0
Getopt::Long 2.36
JSON::PP 2
Pod::Man 0
TAP::Harness::Env 0
perl 5.006
strict 0
warnings 0
Module-Implementation-0.07
pathname: D/DR/DROLSKY/Module-Implementation-0.07.tar.gz
provides:
@@ -1581,14 +1483,6 @@ DISTRIBUTIONS
JavaScript::Minifier::XS 0.11
Mojolicious 5.41
Test::More 0.88
Mojolicious-Plugin-ConfigHashMerge-0.01
pathname: D/DO/DOTAN/Mojolicious-Plugin-ConfigHashMerge-0.01.tar.gz
provides:
Mojolicious::Plugin::ConfigHashMerge 0.01
requirements:
ExtUtils::MakeMaker 0
Hash::Merge::Simple 0.051
Mojolicious 4.85
Mojolicious-Plugin-I18N-1.5
pathname: S/SH/SHARIFULN/Mojolicious-Plugin-I18N-1.5.tar.gz
provides:
@@ -1646,43 +1540,6 @@ DISTRIBUTIONS
Test::More 0.47
Test::Script 1.06
perl 5.006
Package-Stash-0.36
pathname: D/DO/DOY/Package-Stash-0.36.tar.gz
provides:
Package::Stash 0.36
Package::Stash::PP 0.36
requirements:
B 0
Carp 0
Config 0
Dist::CheckConflicts 0.02
ExtUtils::MakeMaker 6.30
File::Find 0
File::Spec 0
File::Temp 0
Getopt::Long 0
Module::Implementation 0.06
Package::Stash::XS 0.26
Scalar::Util 0
Symbol 0
Test::Fatal 0
Test::More 0.88
Test::Requires 0
Text::ParseWords 0
base 0
constant 0
lib 0
strict 0
warnings 0
Package-Stash-XS-0.28
pathname: D/DO/DOY/Package-Stash-XS-0.28.tar.gz
provides:
Package::Stash::XS 0.28
requirements:
ExtUtils::MakeMaker 6.30
XSLoader 0
strict 0
warnings 0
Params-Util-1.07
pathname: A/AD/ADAMK/Params-Util-1.07.tar.gz
provides:
@@ -1725,17 +1582,6 @@ DISTRIBUTIONS
ExtUtils::MakeMaker 6.30
File::Spec 0
strict 0
Sub-Install-0.927
pathname: R/RJ/RJBS/Sub-Install-0.927.tar.gz
provides:
Sub::Install 0.927
requirements:
B 0
Carp 0
ExtUtils::MakeMaker 6.30
Scalar::Util 0
strict 0
warnings 0
Sub-Uplevel-0.24
pathname: D/DA/DAGOLDEN/Sub-Uplevel-0.24.tar.gz
provides:
@@ -1760,133 +1606,6 @@ DISTRIBUTIONS
Text::Balanced 2
if 0
perl 5.005
Test-Deep-0.112
pathname: R/RJ/RJBS/Test-Deep-0.112.tar.gz
provides:
Test::Deep 0.112
Test::Deep::All undef
Test::Deep::Any undef
Test::Deep::Array undef
Test::Deep::ArrayEach undef
Test::Deep::ArrayElementsOnly undef
Test::Deep::ArrayLength undef
Test::Deep::ArrayLengthOnly undef
Test::Deep::Blessed undef
Test::Deep::Boolean undef
Test::Deep::Cache undef
Test::Deep::Cache::Simple undef
Test::Deep::Class undef
Test::Deep::Cmp undef
Test::Deep::Code undef
Test::Deep::Hash undef
Test::Deep::HashEach undef
Test::Deep::HashElements undef
Test::Deep::HashKeys undef
Test::Deep::HashKeysOnly undef
Test::Deep::Ignore undef
Test::Deep::Isa undef
Test::Deep::ListMethods undef
Test::Deep::MM undef
Test::Deep::Methods undef
Test::Deep::NoTest undef
Test::Deep::Number undef
Test::Deep::Obj undef
Test::Deep::Ref undef
Test::Deep::RefType undef
Test::Deep::Regexp undef
Test::Deep::RegexpMatches undef
Test::Deep::RegexpRef undef
Test::Deep::RegexpRefOnly undef
Test::Deep::RegexpVersion undef
Test::Deep::ScalarRef undef
Test::Deep::ScalarRefOnly undef
Test::Deep::Set undef
Test::Deep::Shallow undef
Test::Deep::Stack undef
Test::Deep::String undef
Test::Deep::SubHash undef
Test::Deep::SubHashElements undef
Test::Deep::SubHashKeys undef
Test::Deep::SubHashKeysOnly undef
Test::Deep::SuperHash undef
Test::Deep::SuperHashElements undef
Test::Deep::SuperHashKeys undef
Test::Deep::SuperHashKeysOnly undef
requirements:
ExtUtils::MakeMaker 0
List::Util 1.09
Scalar::Util 1.09
Test::More 0
Test::NoWarnings 0.02
Test::Tester 0.04
Test-Differences-0.61
pathname: O/OV/OVID/Test-Differences-0.61.tar.gz
provides:
Test::Differences 0.61
requirements:
Data::Dumper 2.126
Test::More 0
Text::Diff 0.35
Test-Exception-0.32
pathname: A/AD/ADIE/Test-Exception-0.32.tar.gz
provides:
Test::Exception 0.32
requirements:
Sub::Uplevel 0.18
Test::Builder 0.7
Test::Builder::Tester 1.07
Test::Harness 2.03
Test::More 0.7
Test::Simple 0.7
Test-Fatal-0.013
pathname: R/RJ/RJBS/Test-Fatal-0.013.tar.gz
provides:
Test::Fatal 0.013
requirements:
Carp 0
Exporter 5.57
ExtUtils::MakeMaker 6.30
Test::Builder 0
Try::Tiny 0.07
strict 0
warnings 0
Test-Most-0.33
pathname: O/OV/OVID/Test-Most-0.33.tar.gz
provides:
Test::Most 0.33
Test::Most::Exception 0.33
requirements:
Exception::Class 1.14
ExtUtils::MakeMaker 0
Test::Deep 0.106
Test::Differences 0.61
Test::Exception 0.31
Test::Harness 3.21
Test::More 0.88
Test::Warn 0.23
Test-NoWarnings-1.04
pathname: A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz
provides:
Test::NoWarnings 1.04
Test::NoWarnings::Warning 1.04
requirements:
ExtUtils::MakeMaker 0
Test::Builder 0.86
Test::More 0.47
Test::Tester 0.107
perl 5.006
Test-Requires-0.07
pathname: T/TO/TOKUHIROM/Test-Requires-0.07.tar.gz
provides:
Test::Requires 0.07
requirements:
CPAN::Meta 0
CPAN::Meta::Prereqs 0
ExtUtils::MakeMaker 6.59
Module::Build 0.38
Test::Builder::Module 0
Test::More 0.61
perl 5.008_001
Test-Script-1.07
pathname: A/AD/ADAMK/Test-Script-1.07.tar.gz
provides:
@@ -1900,16 +1619,6 @@ DISTRIBUTIONS
Test::Builder::Tester 1.02
Test::More 0.62
blib 0
Test-Tester-0.109
pathname: F/FD/FDALY/Test-Tester-0.109.tar.gz
provides:
Test::Tester 0.109
Test::Tester::Capture undef
Test::Tester::CaptureRunner undef
Test::Tester::Delegate undef
requirements:
ExtUtils::MakeMaker 0
Test::Builder 0
Test-Warn-0.30
pathname: C/CH/CHORNY/Test-Warn-0.30.tar.gz
provides:
@@ -1924,17 +1633,6 @@ DISTRIBUTIONS
Test::Builder::Tester 1.02
Test::More 0
perl 5.006
Text-Diff-1.41
pathname: O/OV/OVID/Text-Diff-1.41.tar.gz
provides:
Text::Diff 1.41
Text::Diff::Base 1.41
Text::Diff::Config 1.41
Text::Diff::Table 1.41
requirements:
Algorithm::Diff 1.19
Exporter 0
ExtUtils::MakeMaker 0
Text-Unidecode-1.23
pathname: S/SB/SBURKE/Text-Unidecode-1.23.tar.gz
provides:
+5 -4
View File
@@ -3,10 +3,11 @@ package Lutim::Controller;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Util qw(url_unescape b64_encode);
use DateTime;
use File::Type;
use Digest::file qw(digest_file_hex);
use Text::Unidecode;
use Data::Validate::URI qw(is_http_uri is_https_uri);
use File::MimeInfo::Magic;
use IO::Scalar;
use vars qw($im_loaded);
BEGIN {
@@ -246,8 +247,8 @@ sub add {
}
}
my $ft = File::Type->new();
my $mediatype = $ft->mime_type($upload->slurp());
my $io_scalar = new IO::Scalar \$upload->slurp();
my $mediatype = mimetype($io_scalar);
my $ip = $c->ip;
@@ -281,7 +282,7 @@ sub add {
my $path = 'files/'.$records[0]->short.'.'.$ext;
my ($width, $height);
if ($im_loaded) {
if ($im_loaded && $mediatype ne 'image/svg+xml') { # ImageMagick don't work in Debian with svg (for now?)
my $im = Image::Magick->new;
$im->BlobToImage($upload->slurp);
$width = $im->Get('width');