diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 02eb7a403..671d593c9 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -24,15 +24,15 @@ class AlbumsController < ApplicationController respond_to :json, :only => [:index, :show] def index - @aspect = current_user.aspect_by_id( params[:aspect] ) unless params[:aspect] == 'all' @albums = current_user.albums_by_aspect(@aspect).paginate - respond_with @albums + respond_with @albums, :aspect => @aspect end def create + aspect = params[:album][:to] @album = current_user.post(:album, params[:album]) flash[:notice] = "You've created an album called #{@album.name}." - respond_with @album + redirect_to :action => :show, :id => @album.id, :aspect => aspect end def new diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7d7c28dd2..2eec8cf23 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,7 +36,12 @@ class ApplicationController < ActionController::Base def set_friends_and_status if current_user - @aspect = :all + if params[:aspect] == nil || params[:aspect] == 'all' + @aspect = :all + else + @aspect = current_user.aspect_by_id( params[:aspect]) + end + @aspects = current_user.aspects @friends = current_user.friends end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index b260095f2..e8dd82889 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -53,8 +53,8 @@ class AspectsController < ApplicationController respond_with @aspect end - def edit - @aspects = current_user.aspects + def manage + @aspect = :manage @remote_requests = Request.for_user current_user end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 04ae66897..a43854240 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -20,11 +20,11 @@ module ApplicationHelper def current_aspect?(aspect) - @aspect != :all && @aspect.id == aspect.id + !@aspect.is_a?(Symbol) && @aspect.id == aspect.id end - def object_path(object) - eval("#{object.class.to_s.underscore}_path(object)") + def object_path(object, opts = {}) + eval("#{object.class.to_s.underscore}_path(object, opts)") end def object_fields(object) diff --git a/app/views/albums/_album.html.haml b/app/views/albums/_album.html.haml index 3ff1a507d..b92611f6f 100644 --- a/app/views/albums/_album.html.haml +++ b/app/views/albums/_album.html.haml @@ -17,17 +17,16 @@ -# .album{:id => post.id, :class => ("mine" if current_user.owns?(post))} - %div.name - = link_to post.name, object_path(post) + = link_to post.name, object_path(post, :aspect => @aspect) %div.time by = link_to ((current_user.person == post.person)? 'you' : post.person.real_name), person_path(post.person) %br - = link_to(how_long_ago(post), object_path(post)) + = link_to(how_long_ago(post), object_path(post, :aspect => @aspect)) %div.image_cycle - for photo in post.photos[0..3] - = link_to (image_tag photo.url(:thumb_large)), album_path(post) + = link_to (image_tag photo.url(:thumb_large)), album_path(post, :aspect => @aspect) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 114eef205..3f54c05ee 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -24,7 +24,7 @@ }); = content_for :page_title do - = link_to "◂ Home", aspects_path + = link_to "◂ Home", aspects_path, :aspect => params[:aspect] - content_for :left_pane do = render "shared/aspect_friends" diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 10a239c64..e55d1962b 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -25,7 +25,7 @@ }); = content_for :page_title do - = link_to "◂ Albums", albums_path + = link_to "◂ Albums", albums_path(:aspect => @aspect) - content_for :left_pane do = render "shared/aspect_friends" diff --git a/app/views/aspects/edit.html.haml b/app/views/aspects/manage.html.haml similarity index 93% rename from app/views/aspects/edit.html.haml rename to app/views/aspects/manage.html.haml index fda97275a..a4a363513 100644 --- a/app/views/aspects/edit.html.haml +++ b/app/views/aspects/manage.html.haml @@ -39,7 +39,7 @@ %ul - content_for :publish do - .new_aspect= link_to("add a new aspect", "#add_aspect_pane", :id => "add_aspect_button", :title => "Add a new relation") + = link_to("add a new aspect", "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => "Add a new aspect") diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0d510228c..9e24a380a 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -68,26 +68,7 @@ %li= link_to "logout", destroy_user_session_path = render "shared/aspect_nav" - - #aspect_header - .container - .span-5.last - - if @person - %h1 - = @person.real_name - - else - - if @aspect == :all - %h1 - = link_to "All Aspects", root_path - - else - %h1 - = link_to @aspect.name, @aspect - - .page_title - = yield :page_title - - .span-19.last{ :style => "position:relative;" } - = yield :publish + = render "shared/sub_header" .container .span-5.last diff --git a/app/views/shared/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml index 72378b84d..f7f29b97f 100644 --- a/app/views/shared/_aspect_nav.haml +++ b/app/views/shared/_aspect_nav.haml @@ -27,8 +27,8 @@ %li{:class => ("selected" if @aspect == :all)} = link_to "All Aspects", root_url - %li{ :style => "margin-right:0;" } - = link_to ( (@request_count == 0)? "manage" : "manage (#{@request_count})"), edit_aspect_path(Aspect.first), :class => "edit_aspect_button", :class => new_request(@request_count), :title => "Manage your Aspects" + %li{ :style => "margin-right:0;", :class => ("selected" if @aspect == :manage)} + = link_to ( (@request_count == 0)? "manage" : "manage (#{@request_count})"), {:controller => :aspects, :action => :manage}, :class => "edit_aspect_button", :class => new_request(@request_count), :title => "Manage your Aspects" .yo{ :style => "display:none;"} #add_aspect_pane diff --git a/app/views/shared/_sub_header.haml b/app/views/shared/_sub_header.haml new file mode 100644 index 000000000..badf8783d --- /dev/null +++ b/app/views/shared/_sub_header.haml @@ -0,0 +1,20 @@ +#aspect_header + .container + .span-5.last + - if @person + %h1 + = @person.real_name + - else + %h1 + - if @aspect == :all + = link_to "All Aspects", root_path + - elsif @aspect == :manage + = link_to "Manage Aspects", root_path + - else + = link_to @aspect.name, @aspect + + .page_title + = yield :page_title + + .span-19.last{ :style => "position:relative;" } + = yield :publish diff --git a/config/routes.rb b/config/routes.rb index ef64b8d5e..c949d232d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,7 +27,8 @@ Diaspora::Application.routes.draw do resources :photos, :except => [:index] resources :albums - resources :aspects + match 'aspects/manage', :to => 'aspects#manage' + resources :aspects, :except => [:edit] match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'