Commit f80d883df3aa350577b60811e405a330659eb8da

Authored by Daniela Feitosa
1 parent 24bb5d14

ActionItem859: Creating logo box for enterprises

  * adding script to generate big versions for images
app/controllers/my_profile/profile_design_controller.rb
... ... @@ -18,6 +18,11 @@ class ProfileDesignController < BoxOrganizerController
18 18 blocks << FavoriteEnterprisesBlock
19 19 end
20 20  
  21 + # profile image block exclusive for enterprise
  22 + if profile.enterprise?
  23 + blocks << ProfileImageBlock
  24 + end
  25 +
21 26 # product block exclusive for enterprises in environments that permits it
22 27 if profile.enterprise? && !profile.environment.enabled?('disable_products_for_enterprises')
23 28 blocks << ProductsBlock
... ...
app/models/image.rb
... ... @@ -5,7 +5,8 @@ class Image &lt; ActiveRecord::Base
5 5 :storage => :file_system,
6 6 :max_size => 500.kilobytes,
7 7 :resize_to => '320x200>',
8   - :thumbnails => { :thumb => '100x100',
  8 + :thumbnails => { :big => '150x150',
  9 + :thumb => '100x100',
9 10 :portrait => '64x64',
10 11 :minor => '50x50',
11 12 :icon => '20x20!' }
... ...
app/models/profile_image_block.rb 0 → 100644
... ... @@ -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
... ...
app/views/blocks/profile_image.rhtml 0 → 100644
... ... @@ -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" -->
... ...
public/images/icons-app/enterprise-default-pic-big.png 0 → 100644

24.5 KB

public/stylesheets/blocks/profile-image-block.css 0 → 100644
... ... @@ -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 +}
... ...
script/generate-profile-big-images 0 → 100755
... ... @@ -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__) + &#39;/../test_helper&#39;
3 3 class ImageTest < Test::Unit::TestCase
4 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 10 end
  11 +
10 12 end
... ...
test/unit/profile_image_block_test.rb 0 → 100644
... ... @@ -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
... ...