From f22386484a68426dfe16f52797df76cd60b7e060 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 20 Nov 2014 08:44:50 +0100 Subject: [PATCH] Improved logo upload. --- .../app/lib/app_post/image_service.js.coffee | 6 ++++++ lib/static_assets.rb | 9 +++++++++ test/browser/aaa_getting_started_test.rb | 10 +++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/image_service.js.coffee b/app/assets/javascripts/app/lib/app_post/image_service.js.coffee index bee94d889..940424626 100644 --- a/app/assets/javascripts/app/lib/app_post/image_service.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/image_service.js.coffee @@ -37,14 +37,20 @@ class App.ImageService context.drawImage( imageObject, 0, 0, x, y ) @canvas + checkUrl: => + ignore = /\.svg$/i + ignore.test( @orgDataURL ) + toDataURL: (type, quallity = 1) => #@resize() @canvas.toDataURL( type, quallity ) toDataURLForAvatar: ( x, y ) => + return if @checkUrl() @resize( x * 2, y * 2 ) @toDataURL( 'image/jpeg', 0.7 ) toDataURLForApp: ( x, y ) => + return if @checkUrl() @resize( x * 2, y * 2 ) @toDataURL( 'image/png', 0.7 ) diff --git a/lib/static_assets.rb b/lib/static_assets.rb index 7be1464fc..9b28764a2 100644 --- a/lib/static_assets.rb +++ b/lib/static_assets.rb @@ -52,7 +52,16 @@ module StaticAssets # read image def self.read + + # use reduced dimensions list = Store.list( :object => 'System::Logo', :o_id => 2 ) + + # as fallback use 1:1 + if !list || !list[0] + list = Store.list( :object => 'System::Logo', :o_id => 1 ) + end + + # store hash in config if list && list[0] file = Store.find( list[0] ) hash = Digest::MD5.hexdigest( file.content ) diff --git a/test/browser/aaa_getting_started_test.rb b/test/browser/aaa_getting_started_test.rb index 72f49f1ed..8fdaa166d 100644 --- a/test/browser/aaa_getting_started_test.rb +++ b/test/browser/aaa_getting_started_test.rb @@ -59,13 +59,9 @@ class AaaGettingStartedTest < TestCase :css => '.js-admin .btn--success', }, { - :execute => 'wait', - :value => 3, - }, - { - :execute => 'check', - :element => :url, - :result => '#getting_started', + :execute => 'watch_for', + :area => '.js-base h2', + :value => 'Organization', }, ], },