DG MS did some basic work on the dashboard controller and some super basic fallback partial view
This commit is contained in:
parent
e6f3fc1d38
commit
9e89b2e0a7
10 changed files with 62 additions and 5 deletions
14
app/controllers/dashboard_controller.rb
Normal file
14
app/controllers/dashboard_controller.rb
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,2 +1,9 @@
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
def object_path(object)
|
||||||
|
eval("#{object.class.to_s.underscore}_path(object)")
|
||||||
|
end
|
||||||
|
|
||||||
|
def object_fields(object)
|
||||||
|
object.attributes.keys
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
2
app/helpers/dashboard_helper.rb
Normal file
2
app/helpers/dashboard_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
module DashboardHelper
|
||||||
|
end
|
||||||
|
|
@ -2,7 +2,7 @@ module StatusMessagesHelper
|
||||||
def my_latest_message
|
def my_latest_message
|
||||||
message = StatusMessage.my_newest
|
message = StatusMessage.my_newest
|
||||||
unless message.nil?
|
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
|
else
|
||||||
return "No message to display."
|
return "No message to display."
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class Post
|
||||||
|
|
||||||
|
|
||||||
before_create :set_defaults
|
before_create :set_defaults
|
||||||
|
#after_update :notify_friends
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
|
@ -25,6 +26,14 @@ class Post
|
||||||
self.source ||= user_email
|
self.source ||= user_email
|
||||||
self.snippet ||= user_email
|
self.snippet ||= user_email
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
9
app/views/dashboard/index.html.haml
Normal file
9
app/views/dashboard/index.html.haml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
- title "Dashboard"
|
||||||
|
|
||||||
|
%ul
|
||||||
|
- for post in @posts
|
||||||
|
%li
|
||||||
|
= render "shared/post", :post =>post
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
5
app/views/shared/_post.html.haml
Normal file
5
app/views/shared/_post.html.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
%ul
|
||||||
|
%h3= link_to post.class, object_path(post)
|
||||||
|
- for field in object_fields(post)
|
||||||
|
%li= "#{field}: #{post.attributes[field]}"
|
||||||
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
# Add new inflection rules using the following format
|
# Add new inflection rules using the following format
|
||||||
# (all these examples are active by default):
|
# (all these examples are active by default):
|
||||||
# ActiveSupport::Inflector.inflections do |inflect|
|
ActiveSupport::Inflector.inflections do |inflect|
|
||||||
# inflect.plural /^(ox)$/i, '\1en'
|
# inflect.plural /^(ox)$/i, '\1en'
|
||||||
# inflect.singular /^(ox)en/i, '\1'
|
# inflect.singular /^(ox)en/i, '\1'
|
||||||
# inflect.irregular 'person', 'people'
|
# inflect.irregular 'person', 'people'
|
||||||
# inflect.uncountable %w( fish sheep )
|
# inflect.uncountable %w( fish sheep )
|
||||||
# end
|
inflect.uncountable %w(dashboard)
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ Diaspora::Application.routes.draw do |map|
|
||||||
|
|
||||||
resources :users
|
resources :users
|
||||||
resources :status_messages
|
resources :status_messages
|
||||||
match 'dashboard', :to => 'status_messages#index'
|
|
||||||
|
|
||||||
|
|
||||||
# The priority is based upon order of creation:
|
# 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.
|
# Note: This route will make all actions in every controller accessible via GET requests.
|
||||||
# match ':controller(/:action(/:id(.:format)))'
|
# match ':controller(/:action(/:id(.:format)))'
|
||||||
|
|
||||||
root :to => 'status_messages#index'
|
root :to => 'dashboard#index'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
11
spec/controllers/dashboard_controller_spec.rb
Normal file
11
spec/controllers/dashboard_controller_spec.rb
Normal file
|
|
@ -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
|
||||||
Loading…
Reference in a new issue