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
app/controllers/my_profile/profile_design_controller.rb
app/controllers/public/account_controller.rb
... | ... | @@ -34,6 +34,14 @@ class AccountController < PublicController |
34 | 34 | render :action => 'login', :layout => false |
35 | 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 | 45 | # action to register an user to the application |
38 | 46 | def signup |
39 | 47 | begin | ... | ... |
app/helpers/application_helper.rb
app/helpers/boxes_helper.rb
... | ... | @@ -20,7 +20,7 @@ module BoxesHelper |
20 | 20 | |
21 | 21 | def display_boxes(holder, main_content) |
22 | 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 | 24 | content = main_content if (content.blank?) |
25 | 25 | content_tag('div', content, :class => 'boxes', :id => 'boxes' ) |
26 | 26 | end |
... | ... | @@ -40,7 +40,7 @@ module BoxesHelper |
40 | 40 | end |
41 | 41 | |
42 | 42 | def display_block(block, main_content = nil) |
43 | - content = block.content(main_content) | |
43 | + content = block.main? ? main_content : block.content | |
44 | 44 | result = |
45 | 45 | case content |
46 | 46 | when Hash |
... | ... | @@ -53,7 +53,7 @@ module BoxesHelper |
53 | 53 | end |
54 | 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 | 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 | 59 | end | ... | ... |
app/models/block.rb
app/models/main_block.rb
... | ... | @@ -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
app/views/layouts/application.rhtml
... | ... | @@ -30,7 +30,7 @@ |
30 | 30 | <% end %> |
31 | 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 | 35 | <% unless flash[:notice].nil? %> |
36 | 36 | <div id='notice' onclick="Element.hide('notice');"> | ... | ... |
... | ... | @@ -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
921 Bytes
public/designs/icons/default/style.css
... | ... | @@ -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 | 14 | .block-target { |
25 | 15 | margin: 5px; |
... | ... | @@ -34,11 +24,6 @@ div.box-3 { |
34 | 24 | height: 30px; |
35 | 25 | } |
36 | 26 | |
37 | -.block iframe { | |
38 | - width: 100%; | |
39 | - border: none; | |
40 | -} | |
41 | - | |
42 | 27 | /*********************************************************** |
43 | 28 | * put borders around boxes and blocks when organizing boxes |
44 | 29 | ***********************************************************/ | ... | ... |
public/stylesheets/common.css
... | ... | @@ -3,6 +3,8 @@ body { |
3 | 3 | margin: 0px; |
4 | 4 | font-family: Verdana, Sans-Serif; |
5 | 5 | font-size: 14px; |
6 | +} | |
7 | +body.noosfero { | |
6 | 8 | /* |
7 | 9 | ** a imagem de fundo colorida é mais pesada, por isso carregamos |
8 | 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 | 26 | body.category4 #wrap { background-image: url("../images/bg-top-vermelho.png"); } |
25 | 27 | |
26 | 28 | #header { |
27 | - height: 60px; | |
29 | + height: 30px; | |
28 | 30 | } |
29 | 31 | |
30 | 32 | #design_boxes { | ... | ... |
test/fixtures/person_infos.yml
test/functional/account_controller_test.rb
... | ... | @@ -246,6 +246,18 @@ class AccountControllerTest < Test::Unit::TestCase |
246 | 246 | assert_no_tag :tag => "body" # e.g. no layout |
247 | 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 | 261 | protected |
250 | 262 | def create_user(options = {}) |
251 | 263 | post :signup, :user => { :login => 'quire', :email => 'quire@example.com', | ... | ... |
... | ... | @@ -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 @@ |
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 | ... | ... |