From 4d65cfab09901a043b0c7fec3140874aae431347 Mon Sep 17 00:00:00 2001 From: maxwell <maxwell@joindiaspora.com> Date: Fri, 25 Jun 2010 19:22:05 -0700 Subject: [PATCH] MS^2 Added the friends panel to application layout --- app/controllers/application_controller.rb | 7 ++++++- app/views/friends/_sidebar.html.haml | 8 ++++++++ app/views/layouts/application.html.haml | 7 +++++-- public/stylesheets/application.css | 12 ++++++++++++ public/stylesheets/sass/application.sass | 14 +++++++++++++- spec/controllers/dashboard_controller_spec.rb | 11 ++++++++++- 6 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 app/views/friends/_sidebar.html.haml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 83445dbdef..d1bc8a521a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,10 @@ class ApplicationController < ActionController::Base protect_from_forgery :except => :receive layout 'application' - + before_filter :set_friends + + def set_friends + @friends = Friend.all + end + end diff --git a/app/views/friends/_sidebar.html.haml b/app/views/friends/_sidebar.html.haml new file mode 100644 index 0000000000..e7b34969fe --- /dev/null +++ b/app/views/friends/_sidebar.html.haml @@ -0,0 +1,8 @@ +%h1 your friends +%ul#stream + - for friend in @friends + = link_to friend.real_name, friend_path(friend) + %br + %br + %hr + = link_to "add a new friend", new_friend_path \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 20553cecc7..0eb53e9ce9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -84,5 +84,8 @@ #content - = yield - = render "posts/debug" + #main + = yield + = render "posts/debug" + #friends_list + = render 'friends/sidebar' \ No newline at end of file diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 9cfea05ebd..599de669cf 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -177,6 +177,18 @@ h3 { width: 100%; margin-bottom: 1em; } +#main { + width: 70%; + min-width: 400px; + max-width: 700px; + float: left; } + +#friends_list { + float: right; + width: 20%; + min-width: 130px; + padding-left: 10%; } + form { font-size: 130%; margin: 1em; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index ff34a75659..9e13e0657a 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -214,7 +214,19 @@ h3 :width 100% :margin :bottom 1em - + +#main + :width 70% + :min-width 400px + :max-width 700px + :float left + +#friends_list + :float right + :width 20% + :min-width 130px + :padding-left 10% + form :font :size 130% diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboard_controller_spec.rb index b6ad08b93c..f37e422d0e 100644 --- a/spec/controllers/dashboard_controller_spec.rb +++ b/spec/controllers/dashboard_controller_spec.rb @@ -3,10 +3,19 @@ require File.dirname(__FILE__) + '/../spec_helper' describe DashboardController do render_views - it "index action should render index template" do + before do request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user) + end + + it "index action should render index template" do get :index response.should render_template(:index) end + + it "on index sets a friends variable" do + Factory.create :friend + get :index + assigns[:friends].should == Friend.all + end end -- GitLab