Commit a8f00402eaf0e89dd72c98fe1c27190c6b7026cc
1 parent
f037e407
Exists in
master
and in
22 other branches
ActionItem152: adding a login block
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1241 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
25 changed files
with
182 additions
and
36 deletions
Show diff stats
app/controllers/box_organizer_controller.rb
1 | class BoxOrganizerController < ApplicationController | 1 | class BoxOrganizerController < ApplicationController |
2 | 2 | ||
3 | + def index | ||
4 | + end | ||
5 | + | ||
3 | def move_block | 6 | def move_block |
4 | @block = boxes_holder.blocks.find(params[:id].gsub(/^block-/, '')) | 7 | @block = boxes_holder.blocks.find(params[:id].gsub(/^block-/, '')) |
5 | 8 |
app/controllers/my_profile/profile_design_controller.rb
@@ -6,8 +6,4 @@ class ProfileDesignController < BoxOrganizerController | @@ -6,8 +6,4 @@ class ProfileDesignController < BoxOrganizerController | ||
6 | @available_blocks ||= [ Block, ArticleBlock ] | 6 | @available_blocks ||= [ Block, ArticleBlock ] |
7 | end | 7 | end |
8 | 8 | ||
9 | - def index | ||
10 | - end | ||
11 | - | ||
12 | - | ||
13 | end | 9 | end |
app/controllers/public/account_controller.rb
@@ -34,6 +34,14 @@ class AccountController < PublicController | @@ -34,6 +34,14 @@ class AccountController < PublicController | ||
34 | render :action => 'login', :layout => false | 34 | render :action => 'login', :layout => false |
35 | end | 35 | end |
36 | 36 | ||
37 | + def login_block | ||
38 | + if logged_in? | ||
39 | + render :action => 'user_info', :layout => 'block' | ||
40 | + else | ||
41 | + render :action => 'login_block', :layout => 'block' | ||
42 | + end | ||
43 | + end | ||
44 | + | ||
37 | # action to register an user to the application | 45 | # action to register an user to the application |
38 | def signup | 46 | def signup |
39 | begin | 47 | begin |
app/helpers/application_helper.rb
app/helpers/boxes_helper.rb
@@ -20,7 +20,7 @@ module BoxesHelper | @@ -20,7 +20,7 @@ module BoxesHelper | ||
20 | 20 | ||
21 | def display_boxes(holder, main_content) | 21 | def display_boxes(holder, main_content) |
22 | boxes = holder.boxes.first(holder.boxes_limit) | 22 | boxes = holder.boxes.first(holder.boxes_limit) |
23 | - content = boxes.reverse.map { |item| display_box(item, main_content) }.join("\n") | 23 | + content = boxes.map { |item| display_box(item, main_content) }.join("\n") |
24 | content = main_content if (content.blank?) | 24 | content = main_content if (content.blank?) |
25 | content_tag('div', content, :class => 'boxes', :id => 'boxes' ) | 25 | content_tag('div', content, :class => 'boxes', :id => 'boxes' ) |
26 | end | 26 | end |
@@ -40,7 +40,7 @@ module BoxesHelper | @@ -40,7 +40,7 @@ module BoxesHelper | ||
40 | end | 40 | end |
41 | 41 | ||
42 | def display_block(block, main_content = nil) | 42 | def display_block(block, main_content = nil) |
43 | - content = block.content(main_content) | 43 | + content = block.main? ? main_content : block.content |
44 | result = | 44 | result = |
45 | case content | 45 | case content |
46 | when Hash | 46 | when Hash |
@@ -53,7 +53,7 @@ module BoxesHelper | @@ -53,7 +53,7 @@ module BoxesHelper | ||
53 | end | 53 | end |
54 | end | 54 | end |
55 | 55 | ||
56 | - classes = 'block' # ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ') | 56 | + classes = ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ') |
57 | 57 | ||
58 | box_decorator.block_target(block.box, block) + content_tag('div', result + box_decorator.block_edit_buttons(block), :class => classes, :id => "block-#{block.id}") + box_decorator.block_handle(block) | 58 | box_decorator.block_target(block.box, block) + content_tag('div', result + box_decorator.block_edit_buttons(block), :class => classes, :id => "block-#{block.id}") + box_decorator.block_handle(block) |
59 | end | 59 | end |
app/models/block.rb
app/models/main_block.rb
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +<div id="login-box"> | ||
2 | + <% unless logged_in? %> | ||
3 | + | ||
4 | + <h2><%= _('Login') %></h2> | ||
5 | + | ||
6 | + <% labelled_form_for :user, @user, :url => { :controller => 'account', :action => 'login' } do |f| %> | ||
7 | + <%= display_form_field(_('Username'), text_field_tag(:login) ) %> | ||
8 | + <%= display_form_field(_('Password'), password_field_tag(:password) ) %> | ||
9 | + <div> | ||
10 | + <%= submit_button( 'login', _('Log in') )%> | ||
11 | + </div> | ||
12 | + <% end %> | ||
13 | + | ||
14 | + <div> | ||
15 | + <%= link_to _("New user"), :controller => 'account', :action => 'signup' %> | ||
16 | + </div> | ||
17 | + <% else %> | ||
18 | + <h2><%= @profile.identifier %></h2> | ||
19 | + <% end %> | ||
20 | + | ||
21 | +</div><!-- end id="login-box" --> | ||
22 | + |
app/views/home/index.rhtml
@@ -2,9 +2,6 @@ | @@ -2,9 +2,6 @@ | ||
2 | 2 | ||
3 | <h1><%= @environment.name %></h1> | 3 | <h1><%= @environment.name %></h1> |
4 | 4 | ||
5 | -<%# FIXME %> | ||
6 | -<%= render :file => 'account/login.rhtml' %> | ||
7 | - | ||
8 | <h2><%= _('Recent articles') %></h2> | 5 | <h2><%= _('Recent articles') %></h2> |
9 | 6 | ||
10 | <% for article in @articles %> | 7 | <% for article in @articles %> |
app/views/layouts/application.rhtml
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | <% end %> | 30 | <% end %> |
31 | </head> | 31 | </head> |
32 | 32 | ||
33 | - <body class='category<%= category_color %>' onload='noosfero_init();'> | 33 | + <body class='noosfero category<%= category_color %>' onload='noosfero_init();'> |
34 | 34 | ||
35 | <% unless flash[:notice].nil? %> | 35 | <% unless flash[:notice].nil? %> |
36 | <div id='notice' onclick="Element.hide('notice');"> | 36 | <div id='notice' onclick="Element.hide('notice');"> |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +<html> | ||
2 | + <head> | ||
3 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
4 | + <title>noosfero block</title> | ||
5 | + | ||
6 | + <%= stylesheet_link_tag 'common' %> | ||
7 | + <%= stylesheet_link_tag 'button' %> | ||
8 | + <%= stylesheet_link_tag 'search' %> | ||
9 | + <%= stylesheet_link_tag 'block' %> | ||
10 | + | ||
11 | + | ||
12 | + <%# FIXME %> | ||
13 | + <%= stylesheet_link_tag '/designs/templates/default/stylesheets/style.css' %> | ||
14 | + <%= stylesheet_link_tag '/designs/icons/default/style.css' %> | ||
15 | + | ||
16 | + <%= javascript_include_tag(:defaults) %> | ||
17 | + | ||
18 | + <base target='_top'/> | ||
19 | + </head> | ||
20 | + | ||
21 | + <body class='noosfero-block'> | ||
22 | + <%= yield %> | ||
23 | + </body> | ||
24 | + | ||
25 | +</html> |
public/designs/icons/default/README
@@ -38,6 +38,7 @@ gtk-go-up.png Nuovo stock/ | @@ -38,6 +38,7 @@ gtk-go-up.png Nuovo stock/ | ||
38 | gtk-go-down.png Nuovo stock/ | 38 | gtk-go-down.png Nuovo stock/ |
39 | gnome-search.png Nuovo apps/ | 39 | gnome-search.png Nuovo apps/ |
40 | gtk-ok.png Nuovo stock/ | 40 | gtk-ok.png Nuovo stock/ |
41 | +password.png Nuovo apps/ | ||
41 | ### END OF ICONS LISTING ### | 42 | ### END OF ICONS LISTING ### |
42 | 43 | ||
43 | Licensing of GNOME themes | 44 | Licensing of GNOME themes |
921 Bytes
public/designs/icons/default/style.css
@@ -18,3 +18,4 @@ | @@ -18,3 +18,4 @@ | ||
18 | .button.down { background-image: url(gtk-go-down.png); } | 18 | .button.down { background-image: url(gtk-go-down.png); } |
19 | .button.search { background-image: url(gnome-search.png); } | 19 | .button.search { background-image: url(gnome-search.png); } |
20 | .button.ok { background-image: url(gtk-ok.png); } | 20 | .button.ok { background-image: url(gtk-ok.png); } |
21 | +.button.login { background-image: url(password.png); } |
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +body.noosfero-block { | ||
2 | + background: white; | ||
3 | + font-size: 12px; | ||
4 | +} | ||
5 | + | ||
6 | +h2 { | ||
7 | + padding: 0px; | ||
8 | + margin: 0px; | ||
9 | + font-size: 14px; | ||
10 | + border-bottom: 1px solid black; | ||
11 | +} | ||
12 | + | ||
13 | +input { | ||
14 | + font-size: 10px; | ||
15 | +} | ||
16 | + | ||
17 | +#login-box { | ||
18 | + text-align: center; | ||
19 | +} | ||
20 | + |
public/stylesheets/blocks.css
1 | +/*********************************************************** | ||
2 | + * style for blocks | ||
3 | + ***********************************************************/ | ||
1 | 4 | ||
2 | -/* main box */ | ||
3 | -div.box-1 { | ||
4 | - margin-left: 210px; | ||
5 | - margin-right: 210px; | ||
6 | -} | ||
7 | - | ||
8 | -div.box-2 { | ||
9 | - float: left; | ||
10 | - width: 200px; | ||
11 | -} | ||
12 | - | ||
13 | -div.box-3 { | ||
14 | - float: right; | ||
15 | - width: 200px; | 5 | +.block iframe { |
6 | + width: 100%; | ||
7 | + border: none; | ||
16 | } | 8 | } |
17 | 9 | ||
18 | - | ||
19 | -.block { | ||
20 | - margin: 5px; | ||
21 | - padding: 5px; | ||
22 | -} | 10 | +/*********************************************************** |
11 | + * the handles to where you can drag the blocks | ||
12 | + ***********************************************************/ | ||
23 | 13 | ||
24 | .block-target { | 14 | .block-target { |
25 | margin: 5px; | 15 | margin: 5px; |
@@ -34,11 +24,6 @@ div.box-3 { | @@ -34,11 +24,6 @@ div.box-3 { | ||
34 | height: 30px; | 24 | height: 30px; |
35 | } | 25 | } |
36 | 26 | ||
37 | -.block iframe { | ||
38 | - width: 100%; | ||
39 | - border: none; | ||
40 | -} | ||
41 | - | ||
42 | /*********************************************************** | 27 | /*********************************************************** |
43 | * put borders around boxes and blocks when organizing boxes | 28 | * put borders around boxes and blocks when organizing boxes |
44 | ***********************************************************/ | 29 | ***********************************************************/ |
public/stylesheets/common.css
@@ -3,6 +3,8 @@ body { | @@ -3,6 +3,8 @@ body { | ||
3 | margin: 0px; | 3 | margin: 0px; |
4 | font-family: Verdana, Sans-Serif; | 4 | font-family: Verdana, Sans-Serif; |
5 | font-size: 14px; | 5 | font-size: 14px; |
6 | +} | ||
7 | +body.noosfero { | ||
6 | /* | 8 | /* |
7 | ** a imagem de fundo colorida é mais pesada, por isso carregamos | 9 | ** a imagem de fundo colorida é mais pesada, por isso carregamos |
8 | ** essa cinza mais leve antes para melhorar a esperiência do usuário. | 10 | ** essa cinza mais leve antes para melhorar a esperiência do usuário. |
@@ -24,7 +26,7 @@ body.category3 #wrap { background-image: url("../images/bg-top-lilas.png"); } | @@ -24,7 +26,7 @@ body.category3 #wrap { background-image: url("../images/bg-top-lilas.png"); } | ||
24 | body.category4 #wrap { background-image: url("../images/bg-top-vermelho.png"); } | 26 | body.category4 #wrap { background-image: url("../images/bg-top-vermelho.png"); } |
25 | 27 | ||
26 | #header { | 28 | #header { |
27 | - height: 60px; | 29 | + height: 30px; |
28 | } | 30 | } |
29 | 31 | ||
30 | #design_boxes { | 32 | #design_boxes { |
test/fixtures/person_infos.yml
@@ -4,4 +4,5 @@ person_info_for_ze: | @@ -4,4 +4,5 @@ person_info_for_ze: | ||
4 | name: "Zé, José, Zezinho" | 4 | name: "Zé, José, Zezinho" |
5 | address: "house of the hat" | 5 | address: "house of the hat" |
6 | contact_information: "Pavilhão 9, Quadrante 13, Esquina com Avenida das Alamedas, 467, fundos, falar com Dona Ivete após as 16" | 6 | contact_information: "Pavilhão 9, Quadrante 13, Esquina com Avenida das Alamedas, 467, fundos, falar com Dona Ivete após as 16" |
7 | + created_at: '2007-12-01' | ||
7 | 8 |
test/functional/account_controller_test.rb
@@ -246,6 +246,18 @@ class AccountControllerTest < Test::Unit::TestCase | @@ -246,6 +246,18 @@ class AccountControllerTest < Test::Unit::TestCase | ||
246 | assert_no_tag :tag => "body" # e.g. no layout | 246 | assert_no_tag :tag => "body" # e.g. no layout |
247 | end | 247 | end |
248 | 248 | ||
249 | + should 'provide login block' do | ||
250 | + get :login_block | ||
251 | + assert_template 'login_block' | ||
252 | + assert_tag :tag => 'body', :attributes => { :class => 'noosfero-block' } | ||
253 | + end | ||
254 | + | ||
255 | + should 'display user info in login block when logged in' do | ||
256 | + login_as('ze') | ||
257 | + get :login_block | ||
258 | + assert_template 'user_info' | ||
259 | + end | ||
260 | + | ||
249 | protected | 261 | protected |
250 | def create_user(options = {}) | 262 | def create_user(options = {}) |
251 | post :signup, :user => { :login => 'quire', :email => 'quire@example.com', | 263 | post :signup, :user => { :login => 'quire', :email => 'quire@example.com', |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | +require 'environment_design_controller' | ||
3 | + | ||
4 | +# Re-raise errors caught by the controller. | ||
5 | +class EnvironmentDesignController; def rescue_action(e) raise e end; end | ||
6 | + | ||
7 | +class EnvironmentDesignControllerTest < Test::Unit::TestCase | ||
8 | + def setup | ||
9 | + @controller = EnvironmentDesignController.new | ||
10 | + @request = ActionController::TestRequest.new | ||
11 | + @response = ActionController::TestResponse.new | ||
12 | + end | ||
13 | + | ||
14 | + # Replace this with your real tests. | ||
15 | + def test_truth | ||
16 | + assert true | ||
17 | + end | ||
18 | +end |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | + | ||
3 | +class LoginBlockTest < Test::Unit::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @block = LoginBlock.new | ||
7 | + end | ||
8 | + attr_reader :block | ||
9 | + | ||
10 | + should 'describe itself' do | ||
11 | + assert_not_equal Block.description, LoginBlock.description | ||
12 | + end | ||
13 | + | ||
14 | + should 'point to account/login_block' do | ||
15 | + assert_equal({ :controller => 'account', :action => 'login_block' }, block.content) | ||
16 | + end | ||
17 | + | ||
18 | +end |