DG MS added views for ostatus following
This commit is contained in:
parent
3f4219cf94
commit
0fdce91756
18 changed files with 193 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery :except => :receive
|
protect_from_forgery :except => :receive
|
||||||
layout 'application'
|
layout 'application'
|
||||||
|
|
||||||
before_filter :set_friends, :count_requests
|
before_filter :set_friends_and_authors, :count_requests
|
||||||
|
|
||||||
layout :layout_by_resource
|
layout :layout_by_resource
|
||||||
|
|
||||||
|
|
@ -14,8 +14,9 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_friends
|
def set_friends_and_authors
|
||||||
@friends = Person.friends.all if current_user
|
@friends = Person.friends.all if current_user
|
||||||
|
@subscribed_persons = Author.all if current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_requests
|
def count_requests
|
||||||
|
|
|
||||||
9
app/controllers/authors_controller.rb
Normal file
9
app/controllers/authors_controller.rb
Normal file
|
|
@ -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
|
||||||
|
|
@ -4,7 +4,11 @@ class DashboardsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
|
@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
|
end
|
||||||
|
|
||||||
def warzombie
|
def warzombie
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,10 @@
|
||||||
module DashboardsHelper
|
module DashboardsHelper
|
||||||
|
|
||||||
|
def title_for_page
|
||||||
|
if params[:action] =='ostatus'
|
||||||
|
'OStatus Dashboard'
|
||||||
|
else
|
||||||
|
'Dashboard'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,16 @@ class OstatusPost
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
|
|
||||||
key :author_id, ObjectId
|
key :author_id, ObjectId
|
||||||
|
key :message, String
|
||||||
|
key :permalink, String
|
||||||
|
key :published_at, DateTime
|
||||||
|
|
||||||
belongs_to :author, :class_name => 'Author'
|
belongs_to :author, :class_name => 'Author'
|
||||||
|
|
||||||
|
cattr_reader :per_page
|
||||||
|
@@per_page = 10
|
||||||
|
|
||||||
|
timestamps!
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
12
app/views/authors/show.html.haml
Normal file
12
app/views/authors/show.html.haml
Normal file
|
|
@ -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!
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
|
%h1= title_for_page
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for post in @posts
|
- for post in @posts
|
||||||
= render type_partial(post), :post => post
|
= render type_partial(post), :post => post
|
||||||
#pagination
|
#pagination
|
||||||
= will_paginate @posts
|
= will_paginate @posts
|
||||||
|
|
||||||
=@ostatus.inspect
|
|
||||||
|
|
|
||||||
12
app/views/ostatus_posts/_ostatus_post.html.haml
Normal file
12
app/views/ostatus_posts/_ostatus_post.html.haml
Normal file
|
|
@ -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
|
||||||
9
app/views/ostatus_posts/index.html.haml
Normal file
9
app/views/ostatus_posts/index.html.haml
Normal file
|
|
@ -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
|
||||||
|
|
||||||
17
app/views/ostatus_posts/show.html.haml
Normal file
17
app/views/ostatus_posts/show.html.haml
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
%ul#friend_stream.nav
|
%ul#friend_stream.nav
|
||||||
|
|
||||||
|
%h4 friends!
|
||||||
- for friend in @friends
|
- for friend in @friends
|
||||||
%li= link_to friend.real_name, person_path(friend)
|
%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
|
%li= link_to "add a new person", new_request_path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
%li{ :class => "bookmark" }= link_to "bookmark", "#"
|
%li{ :class => "bookmark" }= link_to "bookmark", "#"
|
||||||
%li{ :class => "blog" }= link_to "blog", "#"
|
%li{ :class => "blog" }= link_to "blog", "#"
|
||||||
%li= link_to "photos", albums_path
|
%li= link_to "photos", albums_path
|
||||||
|
%li= link_to "ostatus", ostatus_path
|
||||||
|
|
||||||
#publisher_form
|
#publisher_form
|
||||||
= form_for StatusMessage.new, :remote => true do |f|
|
= form_for StatusMessage.new, :remote => true do |f|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ Diaspora::Application.routes.draw do |map|
|
||||||
resources :photos
|
resources :photos
|
||||||
resources :albums
|
resources :albums
|
||||||
|
|
||||||
|
resources :authors
|
||||||
|
resources :ostatus_posts
|
||||||
|
|
||||||
|
match 'ostatus', :to => "dashboards#ostatus"
|
||||||
|
|
||||||
match "/images/files/*path" => "gridfs#serve"
|
match "/images/files/*path" => "gridfs#serve"
|
||||||
|
|
||||||
match 'warzombie', :to => "dashboards#warzombie"
|
match 'warzombie', :to => "dashboards#warzombie"
|
||||||
|
|
|
||||||
15
people/_sidebar.html.haml
Normal file
15
people/_sidebar.html.haml
Normal file
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
19
people/index.html.haml
Normal file
19
people/index.html.haml
Normal file
|
|
@ -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
|
||||||
27
people/new.html.haml
Normal file
27
people/new.html.haml
Normal file
|
|
@ -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
|
||||||
29
people/show.html.haml
Normal file
29
people/show.html.haml
Normal file
|
|
@ -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!
|
||||||
|
|
@ -13,6 +13,7 @@ describe DashboardsController do
|
||||||
Factory.create :person
|
Factory.create :person
|
||||||
get :index
|
get :index
|
||||||
assigns[:friends].should == Person.friends.all
|
assigns[:friends].should == Person.friends.all
|
||||||
|
assigns[:subscribed_persons] == Author.all
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue