Commit 28dd8dad5c58c3b8da3f3d8ad0d48d1475118225

Authored by Aurelio A. Heckert
2 parents bf1d4b12 977ef7ad

Merge branch 'master' of git://git.colivre.coop.br/noosfero

Conflicts:

	app/controllers/my_profile/profile_design_controller.rb
app/controllers/my_profile/profile_design_controller.rb
@@ -20,6 +20,7 @@ class ProfileDesignController < BoxOrganizerController @@ -20,6 +20,7 @@ class ProfileDesignController < BoxOrganizerController
20 20
21 # blocks exclusive for enterprises 21 # blocks exclusive for enterprises
22 if profile.enterprise? 22 if profile.enterprise?
  23 + blocks << ProfileImageBlock
23 blocks << LocalizationBlock 24 blocks << LocalizationBlock
24 end 25 end
25 26
app/models/image.rb
@@ -5,7 +5,8 @@ class Image &lt; ActiveRecord::Base @@ -5,7 +5,8 @@ class Image &lt; 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!' }
app/models/profile_image_block.rb 0 → 100644
@@ -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
app/views/blocks/profile_image.rhtml 0 → 100644
@@ -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" -->
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 @@ @@ -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 @@ @@ -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,8 +3,10 @@ require File.dirname(__FILE__) + &#39;/../test_helper&#39;
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
test/unit/profile_image_block_test.rb 0 → 100644
@@ -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