diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb new file mode 100644 index 000000000..e534252b6 --- /dev/null +++ b/app/controllers/dashboard_controller.rb @@ -0,0 +1,14 @@ +class DashboardController < ApplicationController + before_filter :authenticate_user! + + def index + @posts = Post.all + + @bookmarks = Bookmark.all + @status_messages = StatusMessage.all + @blogs = Blog.all + #@status_messages = @posts.select{ |x| x._type == "StatusMessage"} + #@blogs = @posts.select{ |x| x._type == "Blog"} + #@bookmarks = @posts.select{ |x| x._type == "Bookmarks"} + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945..f58313c9b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,9 @@ module ApplicationHelper + def object_path(object) + eval("#{object.class.to_s.underscore}_path(object)") + end + + def object_fields(object) + object.attributes.keys + end end diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb new file mode 100644 index 000000000..a94ddfc2e --- /dev/null +++ b/app/helpers/dashboard_helper.rb @@ -0,0 +1,2 @@ +module DashboardHelper +end diff --git a/app/helpers/status_messages_helper.rb b/app/helpers/status_messages_helper.rb index 147486830..4c534a685 100644 --- a/app/helpers/status_messages_helper.rb +++ b/app/helpers/status_messages_helper.rb @@ -2,7 +2,7 @@ module StatusMessagesHelper def my_latest_message message = StatusMessage.my_newest unless message.nil? - return message.message + " " + time_ago_in_words(message.created_at) + "ago." + return message.message + " " + time_ago_in_words(message.created_at) + " ago." else return "No message to display." end diff --git a/app/models/post.rb b/app/models/post.rb index 72238b32d..34af94757 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -16,6 +16,7 @@ class Post before_create :set_defaults + #after_update :notify_friends protected @@ -25,6 +26,14 @@ class Post self.source ||= user_email self.snippet ||= user_email end + + + #def notify_friends + #friends = Permissions.get_list_for(self) + #xml = self.to_xml_to_s + #friends.each{|friend| ping friend :with => xml } + #end + end diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml new file mode 100644 index 000000000..0b4a5224d --- /dev/null +++ b/app/views/dashboard/index.html.haml @@ -0,0 +1,9 @@ +- title "Dashboard" + +%ul + - for post in @posts + %li + = render "shared/post", :post =>post + %br + %br + diff --git a/app/views/shared/_post.html.haml b/app/views/shared/_post.html.haml new file mode 100644 index 000000000..0ec4bc41e --- /dev/null +++ b/app/views/shared/_post.html.haml @@ -0,0 +1,5 @@ +%ul + %h3= link_to post.class, object_path(post) + - for field in object_fields(post) + %li= "#{field}: #{post.attributes[field]}" + diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index d531b8bb8..dded445cc 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -2,9 +2,10 @@ # Add new inflection rules using the following format # (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| + ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) -# end + inflect.uncountable %w(dashboard) + end diff --git a/config/routes.rb b/config/routes.rb index 9f7998572..81cd16e47 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,7 +17,6 @@ Diaspora::Application.routes.draw do |map| resources :users resources :status_messages - match 'dashboard', :to => 'status_messages#index' # The priority is based upon order of creation: @@ -77,6 +76,6 @@ Diaspora::Application.routes.draw do |map| # Note: This route will make all actions in every controller accessible via GET requests. # match ':controller(/:action(/:id(.:format)))' - root :to => 'status_messages#index' + root :to => 'dashboard#index' end diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboard_controller_spec.rb new file mode 100644 index 000000000..010a62677 --- /dev/null +++ b/spec/controllers/dashboard_controller_spec.rb @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe DashboardController do + fixtures :all + integrate_views + + it "index action should render index template" do + get :index + response.should render_template(:index) + end +end