Commit f80d883df3aa350577b60811e405a330659eb8da
1 parent
24bb5d14
Exists in
master
and in
29 other branches
ActionItem859: Creating logo box for enterprises
* adding script to generate big versions for images
Showing
9 changed files
with
123 additions
and
4 deletions
Show diff stats
app/controllers/my_profile/profile_design_controller.rb
@@ -18,6 +18,11 @@ class ProfileDesignController < BoxOrganizerController | @@ -18,6 +18,11 @@ class ProfileDesignController < BoxOrganizerController | ||
18 | blocks << FavoriteEnterprisesBlock | 18 | blocks << FavoriteEnterprisesBlock |
19 | end | 19 | end |
20 | 20 | ||
21 | + # profile image block exclusive for enterprise | ||
22 | + if profile.enterprise? | ||
23 | + blocks << ProfileImageBlock | ||
24 | + end | ||
25 | + | ||
21 | # product block exclusive for enterprises in environments that permits it | 26 | # product block exclusive for enterprises in environments that permits it |
22 | if profile.enterprise? && !profile.environment.enabled?('disable_products_for_enterprises') | 27 | if profile.enterprise? && !profile.environment.enabled?('disable_products_for_enterprises') |
23 | blocks << ProductsBlock | 28 | blocks << ProductsBlock |
app/models/image.rb
@@ -5,7 +5,8 @@ class Image < ActiveRecord::Base | @@ -5,7 +5,8 @@ class Image < ActiveRecord::Base | ||
5 | :storage => :file_system, | 5 | :storage => :file_system, |
6 | :max_size => 500.kilobytes, | 6 | :max_size => 500.kilobytes, |
7 | :resize_to => '320x200>', | 7 | :resize_to => '320x200>', |
8 | - :thumbnails => { :thumb => '100x100', | 8 | + :thumbnails => { :big => '150x150', |
9 | + :thumb => '100x100', | ||
9 | :portrait => '64x64', | 10 | :portrait => '64x64', |
10 | :minor => '50x50', | 11 | :minor => '50x50', |
11 | :icon => '20x20!' } | 12 | :icon => '20x20!' } |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +class ProfileImageBlock < Block | ||
2 | + | ||
3 | + def self.description | ||
4 | + _('A block that displays only image of profiles') | ||
5 | + end | ||
6 | + | ||
7 | + def help | ||
8 | + _('This block presents the profile image.') | ||
9 | + end | ||
10 | + | ||
11 | + def content | ||
12 | + block = self | ||
13 | + lambda do | ||
14 | + render :file => 'blocks/profile_image', :locals => { :block => block } | ||
15 | + end | ||
16 | + end | ||
17 | + | ||
18 | + def editable? | ||
19 | + false | ||
20 | + end | ||
21 | + | ||
22 | +end |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<div class="vcard"> | ||
2 | + | ||
3 | +<div class="profile-big-image"> | ||
4 | + <div class="profile-big-image-inner1"> | ||
5 | + <span class="profile-big-image-inner2"> | ||
6 | + <%= | ||
7 | + profile_image(block.owner, :big) +"\n" | ||
8 | + %> | ||
9 | + </span> | ||
10 | + </div> | ||
11 | +</div> | ||
12 | + | ||
13 | +</div><!-- end class="vcard" --> |
24.5 KB
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | + | ||
2 | +.profile-image-block { | ||
3 | + text-align: center; | ||
4 | +} | ||
5 | + | ||
6 | +.profile-big-image { | ||
7 | + position: relative; | ||
8 | + display: table; | ||
9 | + width: 156px; | ||
10 | + height: 156px; | ||
11 | + margin: auto; | ||
12 | +} | ||
13 | + | ||
14 | +.profile-big-image-inner1 { | ||
15 | + display: table-cell; | ||
16 | + text-align: center; | ||
17 | + vertical-align: middle; | ||
18 | +} | ||
19 | +.profile-big-image-inner2 { | ||
20 | + position: relative; | ||
21 | + left: 0px; | ||
22 | + display: block; | ||
23 | +} | ||
24 | + | ||
25 | +.profile-big-image img { | ||
26 | + border: 1px solid #888; | ||
27 | + padding: 2px; | ||
28 | + background: #FFF; | ||
29 | +} |
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +#!/bin/bash | ||
2 | + | ||
3 | +if ! cd public/images/0000; then | ||
4 | + echo " | ||
5 | + Rode esse script na raiz do Noosfero para ele redimensionar as | ||
6 | + imagens dos usuarios. | ||
7 | + " | ||
8 | + exit 1 | ||
9 | +fi | ||
10 | + | ||
11 | +echo " | ||
12 | + Ok! We are on $(pwd) | ||
13 | +" | ||
14 | + | ||
15 | +big='150x150' | ||
16 | + | ||
17 | +# Padrao: <nome>_<tamanho>.<ext> | ||
18 | + | ||
19 | +find . -type f | | ||
20 | +grep --invert-match -E '_(thumb|portrait|minor|icon)\.' | | ||
21 | +while read img; do | ||
22 | + echo "Criando tamanho big ($big) para $img" | ||
23 | + name=$( echo "$img" | sed 's/^\(.*\)\.[^\.]\+$/\1/' ) | ||
24 | + ext=$( echo "$img" | sed 's/^.*\.\([^\.]\+\)$/\1/' ) | ||
25 | + convert "$img" -resize $big "${name}_big.$ext" | ||
26 | +done | ||
27 | + |
test/unit/image_test.rb
@@ -3,8 +3,10 @@ require File.dirname(__FILE__) + '/../test_helper' | @@ -3,8 +3,10 @@ require File.dirname(__FILE__) + '/../test_helper' | ||
3 | class ImageTest < Test::Unit::TestCase | 3 | class ImageTest < Test::Unit::TestCase |
4 | fixtures :images | 4 | fixtures :images |
5 | 5 | ||
6 | - # Replace this with your real tests. | ||
7 | - def test_truth | ||
8 | - assert true | 6 | + should 'have thumbnails options' do |
7 | + [:big, :thumb, :portrait, :minor, :icon].each do |option| | ||
8 | + assert Image.attachment_options[:thumbnails].include?(option), "should have #{option}" | ||
9 | + end | ||
9 | end | 10 | end |
11 | + | ||
10 | end | 12 | end |
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | + | ||
3 | +class ProfileImageBlockTest < Test::Unit::TestCase | ||
4 | + | ||
5 | + should 'provide description' do | ||
6 | + assert_not_equal Block.description, ProfileImageBlock.description | ||
7 | + end | ||
8 | + | ||
9 | + should 'display profile image' do | ||
10 | + block = ProfileImageBlock.new | ||
11 | + | ||
12 | + self.expects(:render).with(:file => 'blocks/profile_image', :locals => { :block => block}) | ||
13 | + instance_eval(& block.content) | ||
14 | + end | ||
15 | + | ||
16 | + should 'not be editable' do | ||
17 | + assert !ProfileImageBlock.new.editable? | ||
18 | + end | ||
19 | + | ||
20 | +end |