Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
65f4a7f378
13 changed files with 45 additions and 18 deletions
|
|
@ -32,4 +32,9 @@ module ApplicationHelper
|
|||
def mine?(post)
|
||||
post.owner == User.first.email
|
||||
end
|
||||
|
||||
def type_partial(post)
|
||||
class_name = post.class.name.to_s.underscore
|
||||
"#{class_name.pluralize}/#{class_name}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
module DashboardHelper
|
||||
|
||||
def type_partial(post)
|
||||
class_name = post.class.name.to_s.underscore
|
||||
"#{class_name.pluralize}/#{class_name}"
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Post
|
|||
protected
|
||||
|
||||
def send_to_view
|
||||
WebSocket.update_clients (self.to_json)
|
||||
WebSocket.update_clients(self)
|
||||
end
|
||||
|
||||
def set_defaults
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
%b shared a link
|
||||
%br
|
||||
= post.title
|
||||
= link_to post.link
|
||||
/- (foo = post.link.to_s)
|
||||
/- (bar = post.link)
|
||||
%a{:href => "#{post.link}"}
|
||||
= post.link
|
||||
%div.time= link_to "#{time_ago_in_words(post.updated_at)} ago", bookmark_path(post)
|
||||
- if mine?(post)
|
||||
= link_to 'Destroy', bookmark_path(post), :confirm => 'Are you sure?', :method => :delete
|
||||
|
|
|
|||
|
|
@ -10,6 +10,15 @@
|
|||
= javascript_include_tag 'jquery142'
|
||||
/= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"
|
||||
= javascript_include_tag 'rails'
|
||||
|
||||
- unless request.user_agent.include? "Safari" ||"Chrome"
|
||||
= javascript_include_tag 'FABridge'
|
||||
= javascript_include_tag 'swfobject'
|
||||
= javascript_include_tag 'web_socket'
|
||||
:javascript
|
||||
WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf";
|
||||
|
||||
|
||||
= javascript_include_tag 'socket' if user_signed_in?
|
||||
= csrf_meta_tag
|
||||
= yield(:head)
|
||||
|
|
@ -42,6 +51,7 @@
|
|||
= link_to "login", new_user_session_path
|
||||
|
||||
#header_below
|
||||
|
||||
- if user_signed_in?
|
||||
%h1#user_name
|
||||
= link_to User.first.real_name, root_url
|
||||
|
|
|
|||
|
|
@ -26,8 +26,14 @@ module WebSocket
|
|||
end
|
||||
}
|
||||
#this should get folded into message queue i think?
|
||||
def self.update_clients(json)
|
||||
@channel.push(json) if @channel
|
||||
def self.update_clients(object)
|
||||
view = ActionView::Base.new(ActionController::Base.view_paths, {})
|
||||
class << view
|
||||
include ApplicationHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
end
|
||||
n = view.render(:partial =>view.type_partial(object), :locals => {:post => object})
|
||||
@channel.push(n) if @channel
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
$(document).ready(function(){
|
||||
$(document).ready(function(){
|
||||
function debug(str){ $("#debug").append("<p>" + str); };
|
||||
|
||||
ws = new WebSocket("ws://localhost:8080/");
|
||||
ws.onmessage = function(evt) { $(".msg").prepend("<p>"+evt.data+"</p>"); };
|
||||
ws.onmessage = function(evt) {
|
||||
$("#stream").prepend($(evt.data).fadeIn("fast"));
|
||||
};
|
||||
ws.onclose = function() { debug("socket closed"); };
|
||||
ws.onopen = function() {
|
||||
debug("connected...");
|
||||
|
|
|
|||
|
|
@ -125,14 +125,14 @@ ul#stream {
|
|||
ul#stream > li {
|
||||
list-style: none;
|
||||
padding: 1em;
|
||||
border-bottom: 1px solid #f1f1f1; }
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
margin-bottom: 5px; }
|
||||
|
||||
li.message {
|
||||
line-height: 140%;
|
||||
font-size: 120%;
|
||||
font-family: "Lucida Grande";
|
||||
color: #999999;
|
||||
margin-bottom: 5px; }
|
||||
color: #999999; }
|
||||
li.message span.from {
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ ul#stream
|
|||
:padding 1em
|
||||
:border
|
||||
:bottom 1px solid #f1f1f1
|
||||
:margin-bottom 5px
|
||||
|
||||
li.message
|
||||
:line-height 140%
|
||||
|
|
@ -158,7 +159,7 @@ li.message
|
|||
:size 120%
|
||||
:family 'Lucida Grande'
|
||||
:color #999
|
||||
:margin-bottom 5px
|
||||
|
||||
|
||||
span.from
|
||||
:color #000
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|||
describe BookmarksController do
|
||||
before do
|
||||
#TODO(dan) Mocking Warden; this is a temp fix
|
||||
|
||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user)
|
||||
@bob = Factory.build(:user)
|
||||
@bookmark = Factory.build(:bookmark)
|
||||
|
|
@ -31,7 +32,7 @@ describe BookmarksController do
|
|||
it "update action should redirect when model is valid" do
|
||||
#TODO(dan) look into why we need to create a new bookmark object here
|
||||
Bookmark.any_instance.stubs(:valid?).returns(true)
|
||||
n = Factory.create(:bookmark, :link => "http://hotub.com")
|
||||
n = Factory.create(:bookmark, :link => "http://hotub.com/")
|
||||
n.save
|
||||
put :update, :id => Bookmark.first.id
|
||||
response.should redirect_to(bookmark_url(assigns[:bookmark]))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ describe Diaspora do
|
|||
|
||||
describe "body" do
|
||||
before do
|
||||
@post = Factory.create(:post)
|
||||
@post = Factory.create(:status_message)
|
||||
end
|
||||
|
||||
it "should add the following methods to Post on inclusion" do
|
||||
|
|
@ -71,7 +71,7 @@ describe Diaspora do
|
|||
it "should check that it does not send a friends post to an owners friends" do
|
||||
Post.stub(:build_xml_for).and_return(true)
|
||||
Post.should_not_receive(:build_xml_for)
|
||||
Factory.create(:post, :owner => "nottheowner@post.com")
|
||||
Factory.create(:status_message, :owner => "nottheowner@post.com")
|
||||
end
|
||||
|
||||
it "should ensure one url is created for every friend" do
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ describe Post do
|
|||
|
||||
describe 'defaults' do
|
||||
before do
|
||||
@post = Factory.create(:post, :owner => nil, :source => nil, :snippet => nil)
|
||||
WebSocket.stub!(:update_clients)
|
||||
@post = Factory.create(:post, :owner => nil, :source => nil, :snippet => nil)
|
||||
|
||||
end
|
||||
|
||||
it "should add an owner if none is present" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue