From 0fdce9175635e2a7d1c9df4924edef5fb3948c22 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 22 Jul 2010 21:27:43 -0700 Subject: [PATCH] DG MS added views for ostatus following --- app/controllers/application_controller.rb | 5 ++-- app/controllers/authors_controller.rb | 9 ++++++ app/controllers/dashboards_controller.rb | 6 +++- app/helpers/dashboards_helper.rb | 8 +++++ app/models/ostatus_post.rb | 8 +++++ app/views/authors/show.html.haml | 12 ++++++++ app/views/dashboards/index.html.haml | 3 +- .../ostatus_posts/_ostatus_post.html.haml | 12 ++++++++ app/views/ostatus_posts/index.html.haml | 9 ++++++ app/views/ostatus_posts/show.html.haml | 17 +++++++++++ app/views/people/_sidebar.html.haml | 11 +++++++ app/views/shared/_publisher.haml | 1 + config/routes.rb | 5 ++++ people/_sidebar.html.haml | 15 ++++++++++ people/index.html.haml | 19 ++++++++++++ people/new.html.haml | 27 +++++++++++++++++ people/show.html.haml | 29 +++++++++++++++++++ .../controllers/dashboards_controller_spec.rb | 1 + 18 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 app/controllers/authors_controller.rb create mode 100644 app/views/authors/show.html.haml create mode 100644 app/views/ostatus_posts/_ostatus_post.html.haml create mode 100644 app/views/ostatus_posts/index.html.haml create mode 100644 app/views/ostatus_posts/show.html.haml create mode 100644 people/_sidebar.html.haml create mode 100644 people/index.html.haml create mode 100644 people/new.html.haml create mode 100644 people/show.html.haml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 26b76f21b..4b851433e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base protect_from_forgery :except => :receive layout 'application' - before_filter :set_friends, :count_requests + before_filter :set_friends_and_authors, :count_requests layout :layout_by_resource @@ -14,8 +14,9 @@ class ApplicationController < ActionController::Base end end - def set_friends + def set_friends_and_authors @friends = Person.friends.all if current_user + @subscribed_persons = Author.all if current_user end def count_requests diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb new file mode 100644 index 000000000..e8ba0ee16 --- /dev/null +++ b/app/controllers/authors_controller.rb @@ -0,0 +1,9 @@ +class AuthorsController < ApplicationController + before_filter :authenticate_user! + + def show + @author= Author.where(:id => params[:id]).first + @author_ostatus_posts = @author.ostatus_posts + end + +end diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 8b4070db8..414f5956a 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -4,7 +4,11 @@ class DashboardsController < ApplicationController def index @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' - @ostatus = OStatusPost.all + end + + def ostatus + @posts = OstatusPost.paginate :page => params[:page], :order => 'created_at DESC' + render :index end def warzombie diff --git a/app/helpers/dashboards_helper.rb b/app/helpers/dashboards_helper.rb index 28cd48d0e..1c11747d7 100644 --- a/app/helpers/dashboards_helper.rb +++ b/app/helpers/dashboards_helper.rb @@ -1,2 +1,10 @@ module DashboardsHelper + + def title_for_page + if params[:action] =='ostatus' + 'OStatus Dashboard' + else + 'Dashboard' + end + end end diff --git a/app/models/ostatus_post.rb b/app/models/ostatus_post.rb index 7a93a0c4c..d8d51a955 100644 --- a/app/models/ostatus_post.rb +++ b/app/models/ostatus_post.rb @@ -2,8 +2,16 @@ class OstatusPost include MongoMapper::Document key :author_id, ObjectId + key :message, String + key :permalink, String + key :published_at, DateTime belongs_to :author, :class_name => 'Author' + cattr_reader :per_page + @@per_page = 10 + + timestamps! + end diff --git a/app/views/authors/show.html.haml b/app/views/authors/show.html.haml new file mode 100644 index 000000000..7191f40a6 --- /dev/null +++ b/app/views/authors/show.html.haml @@ -0,0 +1,12 @@ +.span-20.last + %h1= "#{@author.username}" + +.span-20 + - if @author_ostatus_posts + + %h3 stream + %ul#stream + - for post in @author_ostatus_posts + = render type_partial(post), :post => post + - else + %h3 no posts to display! diff --git a/app/views/dashboards/index.html.haml b/app/views/dashboards/index.html.haml index 28e623010..a19ff1e51 100644 --- a/app/views/dashboards/index.html.haml +++ b/app/views/dashboards/index.html.haml @@ -1,7 +1,8 @@ + +%h1= title_for_page %ul#stream - for post in @posts = render type_partial(post), :post => post #pagination = will_paginate @posts -=@ostatus.inspect diff --git a/app/views/ostatus_posts/_ostatus_post.html.haml b/app/views/ostatus_posts/_ostatus_post.html.haml new file mode 100644 index 000000000..8815885f9 --- /dev/null +++ b/app/views/ostatus_posts/_ostatus_post.html.haml @@ -0,0 +1,12 @@ +%li.message{:id => post.id} + + = image_tag post.author.avatar_thumbnail, :class => "person_picture" + + %span.from + = link_to post.author.username, author_path(post.author) + = auto_link post.message + + %div.time + = link_to(how_long_ago(post), object_path(post)) + from + = link_to post.author.service, post.author.profile_url diff --git a/app/views/ostatus_posts/index.html.haml b/app/views/ostatus_posts/index.html.haml new file mode 100644 index 000000000..28cf8be85 --- /dev/null +++ b/app/views/ostatus_posts/index.html.haml @@ -0,0 +1,9 @@ +%h1.big_text status messages += render "status_messages/new_status_message", :status_message => @status_message +%ul#stream + + - for status_message in @status_messages + = render "status_message", :post => status_message +#pagination + = will_paginate @status_messages + diff --git a/app/views/ostatus_posts/show.html.haml b/app/views/ostatus_posts/show.html.haml new file mode 100644 index 000000000..f40a47884 --- /dev/null +++ b/app/views/ostatus_posts/show.html.haml @@ -0,0 +1,17 @@ +- title "Status Message" + +%p + %strong Message: + = @status_message.message + +%p + %strong Owner: + = @status_message.person.real_name + +%h4= "comments (#{@status_message.comments.count})" += render "comments/comments", :post => @status_message + +%p + = link_to "Destroy", @status_message, :confirm => 'Are you sure?', :method => :delete + | + = link_to "View All", status_messages_path diff --git a/app/views/people/_sidebar.html.haml b/app/views/people/_sidebar.html.haml index 5c9d8fa37..877db490e 100644 --- a/app/views/people/_sidebar.html.haml +++ b/app/views/people/_sidebar.html.haml @@ -1,4 +1,15 @@ %ul#friend_stream.nav + + %h4 friends! - for friend in @friends %li= link_to friend.real_name, person_path(friend) + + %hr + %h4 on other networks! + + - for author in @subscribed_persons + %li= link_to author.username, author_path(author) + %li= link_to "add a new person", new_request_path + + diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index be8df637c..97af3cb30 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -7,6 +7,7 @@ %li{ :class => "bookmark" }= link_to "bookmark", "#" %li{ :class => "blog" }= link_to "blog", "#" %li= link_to "photos", albums_path + %li= link_to "ostatus", ostatus_path #publisher_form = form_for StatusMessage.new, :remote => true do |f| diff --git a/config/routes.rb b/config/routes.rb index 2496e257b..512c8484f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,11 @@ Diaspora::Application.routes.draw do |map| resources :photos resources :albums + resources :authors + resources :ostatus_posts + + match 'ostatus', :to => "dashboards#ostatus" + match "/images/files/*path" => "gridfs#serve" match 'warzombie', :to => "dashboards#warzombie" diff --git a/people/_sidebar.html.haml b/people/_sidebar.html.haml new file mode 100644 index 000000000..877db490e --- /dev/null +++ b/people/_sidebar.html.haml @@ -0,0 +1,15 @@ +%ul#friend_stream.nav + + %h4 friends! + - for friend in @friends + %li= link_to friend.real_name, person_path(friend) + + %hr + %h4 on other networks! + + - for author in @subscribed_persons + %li= link_to author.username, author_path(author) + + %li= link_to "add a new person", new_request_path + + diff --git a/people/index.html.haml b/people/index.html.haml new file mode 100644 index 000000000..efb46e644 --- /dev/null +++ b/people/index.html.haml @@ -0,0 +1,19 @@ +- title "People" + +%table + %tr + %th real name + %th email + %th url + - for person in @people + %tr + %td= person.real_name + %td= person.email + %td= person.url + %td= link_to 'Show', person + %td= link_to 'Destroy', person, :confirm => 'Are you sure?', :method => :delete + +%p= link_to "Add a friend", new_request_path + +#pagination + = will_paginate @people diff --git a/people/new.html.haml b/people/new.html.haml new file mode 100644 index 000000000..e341d8629 --- /dev/null +++ b/people/new.html.haml @@ -0,0 +1,27 @@ +- title "New Person" + += form_for @person do |f| + = f.error_messages + %p + = f.label :email + %br + = f.text_field :email + %p + = f.label :url + %br + = f.text_field :url + + =f.fields_for :profile do |p| + %p + = p.label :first_name + %br + = p.text_field :first_name + + %p + = p.label :last_name + %br + = p.text_field :last_name + = f.submit + + +%p= link_to "Back to List", people_path diff --git a/people/show.html.haml b/people/show.html.haml new file mode 100644 index 000000000..ee0892315 --- /dev/null +++ b/people/show.html.haml @@ -0,0 +1,29 @@ +.span-20.last + %h1= "#{@person.real_name}" + = link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete +%p + %b Active? +%p + = @person.active +- if @person_profile + %p + %b First Name + %p + = @person_profile.first_name + %p + %b Last Name + %p + = @person_profile.last_name + %p + %b url + %p + = @person.url + +.span-20 + - if @person.posts + %h3 stream + %ul#stream + - for post in @person_posts + = render type_partial(post), :post => post + - else + %h3 no posts to display! diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb index d8749727e..87cfe8049 100644 --- a/spec/controllers/dashboards_controller_spec.rb +++ b/spec/controllers/dashboards_controller_spec.rb @@ -13,6 +13,7 @@ describe DashboardsController do Factory.create :person get :index assigns[:friends].should == Person.friends.all + assigns[:subscribed_persons] == Author.all end end