diff --git a/app/controllers/my_profile/profile_design_controller.rb b/app/controllers/my_profile/profile_design_controller.rb index 9abee36..0abff28 100644 --- a/app/controllers/my_profile/profile_design_controller.rb +++ b/app/controllers/my_profile/profile_design_controller.rb @@ -18,6 +18,11 @@ class ProfileDesignController < BoxOrganizerController blocks << FavoriteEnterprisesBlock end + # profile image block exclusive for enterprise + if profile.enterprise? + blocks << ProfileImageBlock + end + # product block exclusive for enterprises in environments that permits it if profile.enterprise? && !profile.environment.enabled?('disable_products_for_enterprises') blocks << ProductsBlock diff --git a/app/models/image.rb b/app/models/image.rb index 5c7fbcf..6c4aa5e 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -5,7 +5,8 @@ class Image < ActiveRecord::Base :storage => :file_system, :max_size => 500.kilobytes, :resize_to => '320x200>', - :thumbnails => { :thumb => '100x100', + :thumbnails => { :big => '150x150', + :thumb => '100x100', :portrait => '64x64', :minor => '50x50', :icon => '20x20!' } diff --git a/app/models/profile_image_block.rb b/app/models/profile_image_block.rb new file mode 100644 index 0000000..c529499 --- /dev/null +++ b/app/models/profile_image_block.rb @@ -0,0 +1,22 @@ +class ProfileImageBlock < Block + + def self.description + _('A block that displays only image of profiles') + end + + def help + _('This block presents the profile image.') + end + + def content + block = self + lambda do + render :file => 'blocks/profile_image', :locals => { :block => block } + end + end + + def editable? + false + end + +end diff --git a/app/views/blocks/profile_image.rhtml b/app/views/blocks/profile_image.rhtml new file mode 100644 index 0000000..3374d05 --- /dev/null +++ b/app/views/blocks/profile_image.rhtml @@ -0,0 +1,13 @@ +
+ +
+
+ + <%= + profile_image(block.owner, :big) +"\n" + %> + +
+
+ +
diff --git a/public/images/icons-app/enterprise-default-pic-big.png b/public/images/icons-app/enterprise-default-pic-big.png new file mode 100644 index 0000000..551bdb1 Binary files /dev/null and b/public/images/icons-app/enterprise-default-pic-big.png differ diff --git a/public/stylesheets/blocks/profile-image-block.css b/public/stylesheets/blocks/profile-image-block.css new file mode 100644 index 0000000..668ef46 --- /dev/null +++ b/public/stylesheets/blocks/profile-image-block.css @@ -0,0 +1,29 @@ + +.profile-image-block { + text-align: center; +} + +.profile-big-image { + position: relative; + display: table; + width: 156px; + height: 156px; + margin: auto; +} + +.profile-big-image-inner1 { + display: table-cell; + text-align: center; + vertical-align: middle; +} +.profile-big-image-inner2 { + position: relative; + left: 0px; + display: block; +} + +.profile-big-image img { + border: 1px solid #888; + padding: 2px; + background: #FFF; +} diff --git a/script/generate-profile-big-images b/script/generate-profile-big-images new file mode 100755 index 0000000..5d4695c --- /dev/null +++ b/script/generate-profile-big-images @@ -0,0 +1,27 @@ +#!/bin/bash + +if ! cd public/images/0000; then + echo " + Rode esse script na raiz do Noosfero para ele redimensionar as + imagens dos usuarios. + " + exit 1 +fi + +echo " + Ok! We are on $(pwd) +" + +big='150x150' + +# Padrao: _. + +find . -type f | +grep --invert-match -E '_(thumb|portrait|minor|icon)\.' | +while read img; do + echo "Criando tamanho big ($big) para $img" + name=$( echo "$img" | sed 's/^\(.*\)\.[^\.]\+$/\1/' ) + ext=$( echo "$img" | sed 's/^.*\.\([^\.]\+\)$/\1/' ) + convert "$img" -resize $big "${name}_big.$ext" +done + diff --git a/test/unit/image_test.rb b/test/unit/image_test.rb index 499d844..15442c5 100644 --- a/test/unit/image_test.rb +++ b/test/unit/image_test.rb @@ -3,8 +3,10 @@ require File.dirname(__FILE__) + '/../test_helper' class ImageTest < Test::Unit::TestCase fixtures :images - # Replace this with your real tests. - def test_truth - assert true + should 'have thumbnails options' do + [:big, :thumb, :portrait, :minor, :icon].each do |option| + assert Image.attachment_options[:thumbnails].include?(option), "should have #{option}" + end end + end diff --git a/test/unit/profile_image_block_test.rb b/test/unit/profile_image_block_test.rb new file mode 100644 index 0000000..0b248f3 --- /dev/null +++ b/test/unit/profile_image_block_test.rb @@ -0,0 +1,20 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ProfileImageBlockTest < Test::Unit::TestCase + + should 'provide description' do + assert_not_equal Block.description, ProfileImageBlock.description + end + + should 'display profile image' do + block = ProfileImageBlock.new + + self.expects(:render).with(:file => 'blocks/profile_image', :locals => { :block => block}) + instance_eval(& block.content) + end + + should 'not be editable' do + assert !ProfileImageBlock.new.editable? + end + +end -- libgit2 0.21.2