diff --git a/app/controllers/admin/environment_design_controller.rb b/app/controllers/admin/environment_design_controller.rb
new file mode 100644
index 0000000..f033ced
--- /dev/null
+++ b/app/controllers/admin/environment_design_controller.rb
@@ -0,0 +1,7 @@
+class EnvironmentDesignController < BoxOrganizerController
+
+ def available_blocks
+ @available_blocks ||= [ LoginBlock ]
+ end
+
+end
diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb
index 2711bf6..0700ea0 100644
--- a/app/controllers/box_organizer_controller.rb
+++ b/app/controllers/box_organizer_controller.rb
@@ -1,5 +1,8 @@
class BoxOrganizerController < ApplicationController
+ def index
+ end
+
def move_block
@block = boxes_holder.blocks.find(params[:id].gsub(/^block-/, ''))
diff --git a/app/controllers/my_profile/profile_design_controller.rb b/app/controllers/my_profile/profile_design_controller.rb
index 44ce6de..366a8fb 100644
--- a/app/controllers/my_profile/profile_design_controller.rb
+++ b/app/controllers/my_profile/profile_design_controller.rb
@@ -6,8 +6,4 @@ class ProfileDesignController < BoxOrganizerController
@available_blocks ||= [ Block, ArticleBlock ]
end
- def index
- end
-
-
end
diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb
index 31a6427..242ed61 100644
--- a/app/controllers/public/account_controller.rb
+++ b/app/controllers/public/account_controller.rb
@@ -34,6 +34,14 @@ class AccountController < PublicController
render :action => 'login', :layout => false
end
+ def login_block
+ if logged_in?
+ render :action => 'user_info', :layout => 'block'
+ else
+ render :action => 'login_block', :layout => 'block'
+ end
+ end
+
# action to register an user to the application
def signup
begin
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 27433af..f758e3b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -329,4 +329,8 @@ module ApplicationHelper
end
end
+ def user
+ @controller.send(:user)
+ end
+
end
diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb
index ed86bf6..695bd9e 100644
--- a/app/helpers/boxes_helper.rb
+++ b/app/helpers/boxes_helper.rb
@@ -20,7 +20,7 @@ module BoxesHelper
def display_boxes(holder, main_content)
boxes = holder.boxes.first(holder.boxes_limit)
- content = boxes.reverse.map { |item| display_box(item, main_content) }.join("\n")
+ content = boxes.map { |item| display_box(item, main_content) }.join("\n")
content = main_content if (content.blank?)
content_tag('div', content, :class => 'boxes', :id => 'boxes' )
end
@@ -40,7 +40,7 @@ module BoxesHelper
end
def display_block(block, main_content = nil)
- content = block.content(main_content)
+ content = block.main? ? main_content : block.content
result =
case content
when Hash
@@ -53,7 +53,7 @@ module BoxesHelper
end
end
- classes = 'block' # ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ')
+ classes = ['block', block.class.name.underscore.gsub('_', '-') ].uniq.join(' ')
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)
end
diff --git a/app/models/block.rb b/app/models/block.rb
index 189fab6..061d9ce 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -19,4 +19,8 @@ class Block < ActiveRecord::Base
nil
end
+ def main?
+ false
+ end
+
end
diff --git a/app/models/login_block.rb b/app/models/login_block.rb
new file mode 100644
index 0000000..5b33a4f
--- /dev/null
+++ b/app/models/login_block.rb
@@ -0,0 +1,11 @@
+class LoginBlock < Block
+
+ def self.description
+ _('A login box for your users.')
+ end
+
+ def content
+ { :controller => 'account', :action => 'login_block' }
+ end
+
+end
diff --git a/app/models/main_block.rb b/app/models/main_block.rb
index d0d205a..c73d546 100644
--- a/app/models/main_block.rb
+++ b/app/models/main_block.rb
@@ -8,4 +8,8 @@ class MainBlock < Block
main_content
end
+ def main?
+ true
+ end
+
end
diff --git a/app/views/account/login_block.rhtml b/app/views/account/login_block.rhtml
new file mode 100644
index 0000000..09c89d8
--- /dev/null
+++ b/app/views/account/login_block.rhtml
@@ -0,0 +1,22 @@
+
+ <% unless logged_in? %>
+
+
<%= _('Login') %>
+
+ <% labelled_form_for :user, @user, :url => { :controller => 'account', :action => 'login' } do |f| %>
+ <%= display_form_field(_('Username'), text_field_tag(:login) ) %>
+ <%= display_form_field(_('Password'), password_field_tag(:password) ) %>
+
+ <%= submit_button( 'login', _('Log in') )%>
+
+ <% end %>
+
+
+ <%= link_to _("New user"), :controller => 'account', :action => 'signup' %>
+
+ <% else %>
+
<%= @profile.identifier %>
+ <% end %>
+
+
+
diff --git a/app/views/account/user_info.rhtml b/app/views/account/user_info.rhtml
new file mode 100644
index 0000000..71685af
--- /dev/null
+++ b/app/views/account/user_info.rhtml
@@ -0,0 +1,6 @@
+<%= user.identifier %>
+
+
+ - <%= _('User since %d') % user.person_info.created_at.year %>
+ - <%= link_to_homepage _('Homepage') %>
+
diff --git a/app/views/environment_design b/app/views/environment_design
new file mode 120000
index 0000000..1b8d625
--- /dev/null
+++ b/app/views/environment_design
@@ -0,0 +1 @@
+box_organizer/
\ No newline at end of file
diff --git a/app/views/home/index.rhtml b/app/views/home/index.rhtml
index 28436d0..7f0a13a 100644
--- a/app/views/home/index.rhtml
+++ b/app/views/home/index.rhtml
@@ -2,9 +2,6 @@
<%= @environment.name %>
-<%# FIXME %>
-<%= render :file => 'account/login.rhtml' %>
-
<%= _('Recent articles') %>
<% for article in @articles %>
diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml
index 3c1e15c..d5c244c 100644
--- a/app/views/layouts/application.rhtml
+++ b/app/views/layouts/application.rhtml
@@ -30,7 +30,7 @@
<% end %>
-
+
<% unless flash[:notice].nil? %>
diff --git a/app/views/layouts/block.rhtml b/app/views/layouts/block.rhtml
new file mode 100644
index 0000000..f1e1fea
--- /dev/null
+++ b/app/views/layouts/block.rhtml
@@ -0,0 +1,25 @@
+
+
+
+
noosfero block
+
+ <%= stylesheet_link_tag 'common' %>
+ <%= stylesheet_link_tag 'button' %>
+ <%= stylesheet_link_tag 'search' %>
+ <%= stylesheet_link_tag 'block' %>
+
+
+ <%# FIXME %>
+ <%= stylesheet_link_tag '/designs/templates/default/stylesheets/style.css' %>
+ <%= stylesheet_link_tag '/designs/icons/default/style.css' %>
+
+ <%= javascript_include_tag(:defaults) %>
+
+
+
+
+
+ <%= yield %>
+
+
+
diff --git a/public/designs/icons/default/README b/public/designs/icons/default/README
index 461dd18..8e1fae6 100644
--- a/public/designs/icons/default/README
+++ b/public/designs/icons/default/README
@@ -38,6 +38,7 @@ gtk-go-up.png Nuovo stock/
gtk-go-down.png Nuovo stock/
gnome-search.png Nuovo apps/
gtk-ok.png Nuovo stock/
+password.png Nuovo apps/
### END OF ICONS LISTING ###
Licensing of GNOME themes
diff --git a/public/designs/icons/default/password.png b/public/designs/icons/default/password.png
new file mode 100644
index 0000000..f3b7414
Binary files /dev/null and b/public/designs/icons/default/password.png differ
diff --git a/public/designs/icons/default/style.css b/public/designs/icons/default/style.css
index afcb58a..7dfca21 100644
--- a/public/designs/icons/default/style.css
+++ b/public/designs/icons/default/style.css
@@ -18,3 +18,4 @@
.button.down { background-image: url(gtk-go-down.png); }
.button.search { background-image: url(gnome-search.png); }
.button.ok { background-image: url(gtk-ok.png); }
+.button.login { background-image: url(password.png); }
diff --git a/public/stylesheets/block.css b/public/stylesheets/block.css
new file mode 100644
index 0000000..aa1ddbc
--- /dev/null
+++ b/public/stylesheets/block.css
@@ -0,0 +1,20 @@
+body.noosfero-block {
+ background: white;
+ font-size: 12px;
+}
+
+h2 {
+ padding: 0px;
+ margin: 0px;
+ font-size: 14px;
+ border-bottom: 1px solid black;
+}
+
+input {
+ font-size: 10px;
+}
+
+#login-box {
+ text-align: center;
+}
+
diff --git a/public/stylesheets/blocks.css b/public/stylesheets/blocks.css
index 7d060ba..45ea4be 100644
--- a/public/stylesheets/blocks.css
+++ b/public/stylesheets/blocks.css
@@ -1,25 +1,15 @@
+/***********************************************************
+ * style for blocks
+ ***********************************************************/
-/* main box */
-div.box-1 {
- margin-left: 210px;
- margin-right: 210px;
-}
-
-div.box-2 {
- float: left;
- width: 200px;
-}
-
-div.box-3 {
- float: right;
- width: 200px;
+.block iframe {
+ width: 100%;
+ border: none;
}
-
-.block {
- margin: 5px;
- padding: 5px;
-}
+/***********************************************************
+ * the handles to where you can drag the blocks
+ ***********************************************************/
.block-target {
margin: 5px;
@@ -34,11 +24,6 @@ div.box-3 {
height: 30px;
}
-.block iframe {
- width: 100%;
- border: none;
-}
-
/***********************************************************
* put borders around boxes and blocks when organizing boxes
***********************************************************/
diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css
index 6f9c950..9312cff 100644
--- a/public/stylesheets/common.css
+++ b/public/stylesheets/common.css
@@ -3,6 +3,8 @@ body {
margin: 0px;
font-family: Verdana, Sans-Serif;
font-size: 14px;
+}
+body.noosfero {
/*
** a imagem de fundo colorida é mais pesada, por isso carregamos
** 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"); }
body.category4 #wrap { background-image: url("../images/bg-top-vermelho.png"); }
#header {
- height: 60px;
+ height: 30px;
}
#design_boxes {
diff --git a/test/fixtures/person_infos.yml b/test/fixtures/person_infos.yml
index b858b1e..8ed3f60 100644
--- a/test/fixtures/person_infos.yml
+++ b/test/fixtures/person_infos.yml
@@ -4,4 +4,5 @@ person_info_for_ze:
name: "Zé, José, Zezinho"
address: "house of the hat"
contact_information: "Pavilhão 9, Quadrante 13, Esquina com Avenida das Alamedas, 467, fundos, falar com Dona Ivete após as 16"
+ created_at: '2007-12-01'
diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb
index 7f56572..c4123df 100644
--- a/test/functional/account_controller_test.rb
+++ b/test/functional/account_controller_test.rb
@@ -246,6 +246,18 @@ class AccountControllerTest < Test::Unit::TestCase
assert_no_tag :tag => "body" # e.g. no layout
end
+ should 'provide login block' do
+ get :login_block
+ assert_template 'login_block'
+ assert_tag :tag => 'body', :attributes => { :class => 'noosfero-block' }
+ end
+
+ should 'display user info in login block when logged in' do
+ login_as('ze')
+ get :login_block
+ assert_template 'user_info'
+ end
+
protected
def create_user(options = {})
post :signup, :user => { :login => 'quire', :email => 'quire@example.com',
diff --git a/test/functional/environment_design_controller_test.rb b/test/functional/environment_design_controller_test.rb
new file mode 100644
index 0000000..9c89fe6
--- /dev/null
+++ b/test/functional/environment_design_controller_test.rb
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'environment_design_controller'
+
+# Re-raise errors caught by the controller.
+class EnvironmentDesignController; def rescue_action(e) raise e end; end
+
+class EnvironmentDesignControllerTest < Test::Unit::TestCase
+ def setup
+ @controller = EnvironmentDesignController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff --git a/test/unit/login_block_test.rb b/test/unit/login_block_test.rb
new file mode 100644
index 0000000..06ade83
--- /dev/null
+++ b/test/unit/login_block_test.rb
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class LoginBlockTest < Test::Unit::TestCase
+
+ def setup
+ @block = LoginBlock.new
+ end
+ attr_reader :block
+
+ should 'describe itself' do
+ assert_not_equal Block.description, LoginBlock.description
+ end
+
+ should 'point to account/login_block' do
+ assert_equal({ :controller => 'account', :action => 'login_block' }, block.content)
+ end
+
+end
--
libgit2 0.21.2