Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
f7e4f1db32
20 changed files with 119 additions and 84 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery :except => :receive
|
protect_from_forgery :except => :receive
|
||||||
layout 'application'
|
layout 'application'
|
||||||
|
|
||||||
before_filter :set_friends
|
before_filter :set_friends
|
||||||
|
|
||||||
layout :layout_by_resource
|
layout :layout_by_resource
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
class BlogsController < ApplicationController
|
class BlogsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC'
|
@blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ class Comment
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
include ROXML
|
include ROXML
|
||||||
xml_accessor :text
|
xml_accessor :text
|
||||||
|
xml_accessor :person, :as => Person
|
||||||
|
|
||||||
key :text, String
|
key :text, String
|
||||||
key :target, String
|
key :target, String
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ class Person
|
||||||
|
|
||||||
xml_accessor :email
|
xml_accessor :email
|
||||||
xml_accessor :url
|
xml_accessor :url
|
||||||
|
xml_accessor :profile, :as => Profile
|
||||||
|
|
||||||
key :email, String
|
key :email, String
|
||||||
key :url, String
|
key :url, String
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ class Post
|
||||||
include Diaspora::Webhooks
|
include Diaspora::Webhooks
|
||||||
|
|
||||||
xml_accessor :_id
|
xml_accessor :_id
|
||||||
|
xml_accessor :person, :as => Person
|
||||||
|
|
||||||
key :person_id, ObjectId
|
key :person_id, ObjectId
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
class Profile
|
class Profile
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
|
include ROXML
|
||||||
|
|
||||||
|
xml_accessor :first_name
|
||||||
|
xml_accessor :last_name
|
||||||
|
|
||||||
key :first_name, String
|
key :first_name, String
|
||||||
key :last_name, String
|
key :last_name, String
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
%li.comment{:id => comment.id}
|
%li.comment{:id => comment.id}
|
||||||
%span.from
|
%span.from
|
||||||
= link_to_person comment.person
|
= link_to_person comment.person
|
||||||
= comment.text
|
= auto_link comment.text
|
||||||
%div.time
|
%div.time
|
||||||
= "#{time_ago_in_words(comment.updated_at)} ago"
|
= "#{time_ago_in_words(comment.updated_at)} ago"
|
||||||
|
|
|
||||||
11
app/views/js/_google_a_js.haml
Normal file
11
app/views/js/_google_a_js.haml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
:javascript
|
||||||
|
var _gaq = _gaq || [];
|
||||||
|
_gaq.push(['_setAccount', 'UA-17207587-1']);
|
||||||
|
_gaq.push(['_setDomainName', '#{root_url}']);
|
||||||
|
_gaq.push(['_trackPageview']);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||||
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||||
|
})();
|
||||||
27
app/views/js/_websocket_js.haml
Normal file
27
app/views/js/_websocket_js.haml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
- if user_signed_in?
|
||||||
|
- unless request.user_agent.include? "Safari" ||"Chrome"
|
||||||
|
= javascript_include_tag 'FABridge', 'swfobject', 'web_socket'
|
||||||
|
:javascript
|
||||||
|
WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf";
|
||||||
|
:javascript
|
||||||
|
$(document).ready(function(){
|
||||||
|
function debug(str){ $("#debug").append("<p>" + str); };
|
||||||
|
|
||||||
|
ws = new WebSocket("ws://#{request.host}:8080/");
|
||||||
|
ws.onmessage = function(evt) {
|
||||||
|
var obj = jQuery.parseJSON(evt.data);
|
||||||
|
debug("got a " + obj['class']);
|
||||||
|
if((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) {
|
||||||
|
$("#stream").prepend(
|
||||||
|
$(obj['html']).fadeIn("fast", function(){
|
||||||
|
$("#stream label:first").inFieldLabels();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
ws.onclose = function() { debug("socket closed"); };
|
||||||
|
ws.onopen = function() {
|
||||||
|
ws.send(location.pathname);
|
||||||
|
debug("connected...");
|
||||||
|
};});
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
%title
|
%title
|
||||||
= "diaspora"
|
= "diaspora "
|
||||||
|
= "- #{User.first.real_name}" if User.first
|
||||||
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
||||||
%meta{"http-equiv"=> "X-UA-Compatible", :content =>"chrome=1" }
|
%meta{"http-equiv"=> "X-UA-Compatible", :content =>"chrome=1" }
|
||||||
|
|
||||||
|
|
@ -11,73 +12,12 @@
|
||||||
/= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
/= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
||||||
= javascript_include_tag 'jquery142', 'rails', 'view', 'publisher'
|
= javascript_include_tag 'jquery142', 'rails', 'view', 'publisher'
|
||||||
= javascript_include_tag 'tiny_mce/tiny_mce.js','jquery.infieldlabel'
|
= javascript_include_tag 'tiny_mce/tiny_mce.js','jquery.infieldlabel'
|
||||||
:javascript
|
= render "js/google_a_js"
|
||||||
var _gaq = _gaq || [];
|
= render "js/websocket_js"
|
||||||
_gaq.push(['_setAccount', 'UA-17207587-1']);
|
|
||||||
_gaq.push(['_setDomainName', '#{root_url}']);
|
|
||||||
_gaq.push(['_trackPageview']);
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
||||||
})();
|
|
||||||
|
|
||||||
- unless request.user_agent.include? "Safari" ||"Chrome"
|
|
||||||
= javascript_include_tag 'FABridge', 'swfobject', 'web_socket'
|
|
||||||
:javascript
|
|
||||||
WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf";
|
|
||||||
|
|
||||||
|
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
= yield(:head)
|
= yield(:head)
|
||||||
|
|
||||||
- if user_signed_in?
|
|
||||||
:javascript
|
|
||||||
$(document).ready(function(){
|
|
||||||
function debug(str){ $("#debug").append("<p>" + str); };
|
|
||||||
|
|
||||||
ws = new WebSocket("ws://#{request.host}:8080/");
|
|
||||||
ws.onmessage = function(evt) {
|
|
||||||
var obj = jQuery.parseJSON(evt.data);
|
|
||||||
debug("got a " + obj['class']);
|
|
||||||
if((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) {
|
|
||||||
$("#stream").prepend(
|
|
||||||
$(obj['html']).fadeIn("fast", function(){
|
|
||||||
$("#stream label:first").inFieldLabels();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
ws.onclose = function() { debug("socket closed"); };
|
|
||||||
ws.onopen = function() {
|
|
||||||
ws.send(location.pathname);
|
|
||||||
debug("connected...");
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$("#stream li").hover(function() {
|
|
||||||
$(this).children(".destroy_link").fadeIn(0);
|
|
||||||
}, function() {
|
|
||||||
$(this).children(".destroy_link").fadeOut(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// in field label plugin
|
|
||||||
|
|
||||||
$(".show_post_comments").click( function() {
|
|
||||||
if( $(this).hasClass( "visible" )) {
|
|
||||||
$(this).html($(this).html().replace("hide", "show"));
|
|
||||||
$(this).parents("li").children(".comments").fadeOut(100);
|
|
||||||
} else {
|
|
||||||
$(this).html($(this).html().replace("show", "hide"));
|
|
||||||
$(this).parents("li").children(".comments").fadeIn(100);
|
|
||||||
}
|
|
||||||
$(this).toggleClass( "visible" );
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
= javascript_include_tag 'satisfaction' , 'satisfaction-display'
|
= javascript_include_tag 'satisfaction' , 'satisfaction-display'
|
||||||
%body
|
%body
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,13 @@
|
||||||
.container
|
.container
|
||||||
- flash.each do |name, msg|
|
- flash.each do |name, msg|
|
||||||
= content_tag :div, msg, :id => "flash_#{name}"
|
= content_tag :div, msg, :id => "flash_#{name}"
|
||||||
|
- if User.first
|
||||||
%div#huge_text
|
%div#huge_text
|
||||||
welcome back,
|
welcome back,
|
||||||
%span
|
%span
|
||||||
= User.first.real_name.downcase
|
= User.first.real_name.downcase
|
||||||
|
-else
|
||||||
|
%div#huge_text
|
||||||
|
you need to add a user first!
|
||||||
|
|
||||||
= yield
|
= yield
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
%li.message{:id => post.id, :class => ("mine" if mine?(post))}
|
%li.message{:id => post.id, :class => ("mine" if mine?(post))}
|
||||||
%span.from
|
%span.from
|
||||||
= link_to_person post.person
|
= link_to_person post.person
|
||||||
= post.message
|
= auto_link post.message
|
||||||
|
|
||||||
%div.time
|
%div.time
|
||||||
= link_to(how_long_ago(post), status_message_path(post))
|
= link_to(how_long_ago(post), status_message_path(post))
|
||||||
|
|
|
||||||
11
config/app_config.yml
Normal file
11
config/app_config.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
development:
|
||||||
|
debug: true
|
||||||
|
socket_port: 8080
|
||||||
|
|
||||||
|
test:
|
||||||
|
debug: false
|
||||||
|
socket_port: 8081
|
||||||
|
|
||||||
|
production:
|
||||||
|
debug: false
|
||||||
|
socket_port: 8080
|
||||||
2
config/initializers/load_app_config.rb
Normal file
2
config/initializers/load_app_config.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
raw_config = File.read("#{Rails.root}/config/app_config.yml")
|
||||||
|
APP_CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys
|
||||||
|
|
@ -11,7 +11,10 @@ module WebSocket
|
||||||
SocketRenderer.instantiate_view
|
SocketRenderer.instantiate_view
|
||||||
end
|
end
|
||||||
|
|
||||||
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug =>true) do |ws|
|
EventMachine::WebSocket.start(
|
||||||
|
:host => "0.0.0.0",
|
||||||
|
:port => APP_CONFIG[:socket_port],
|
||||||
|
:debug =>APP_CONFIG[:debug]) do |ws|
|
||||||
ws.onopen {
|
ws.onopen {
|
||||||
sid = @channel.subscribe { |msg| ws.send msg }
|
sid = @channel.subscribe { |msg| ws.send msg }
|
||||||
|
|
||||||
|
|
@ -25,6 +28,4 @@ module WebSocket
|
||||||
def self.update_clients(object)
|
def self.update_clients(object)
|
||||||
@channel.push(SocketRenderer.view_hash(object).to_json) if @channel
|
@channel.push(SocketRenderer.view_hash(object).to_json) if @channel
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -53,4 +53,23 @@ $(document).ready(function(){
|
||||||
$('#flash_notice, #flash_error, #flash_alert').delay(1500).slideUp(130);
|
$('#flash_notice, #flash_error, #flash_alert').delay(1500).slideUp(130);
|
||||||
|
|
||||||
|
|
||||||
|
$("#stream li").hover(function() {
|
||||||
|
$(this).children(".destroy_link").fadeIn(0);
|
||||||
|
}, function() {
|
||||||
|
$(this).children(".destroy_link").fadeOut(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
// in field label plugin
|
||||||
|
|
||||||
|
$(".show_post_comments").live('click', function() {
|
||||||
|
if( $(this).hasClass( "visible" )) {
|
||||||
|
$(this).html($(this).html().replace("hide", "show"));
|
||||||
|
$(this).parents("li").children(".comments").fadeOut(100);
|
||||||
|
} else {
|
||||||
|
$(this).html($(this).html().replace("show", "hide"));
|
||||||
|
$(this).parents("li").children(".comments").fadeIn(100);
|
||||||
|
}
|
||||||
|
$(this).toggleClass( "visible" );
|
||||||
|
});
|
||||||
|
|
||||||
});//end document ready
|
});//end document ready
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,10 @@ header {
|
||||||
border: none;
|
border: none;
|
||||||
top: 10px; }
|
top: 10px; }
|
||||||
header #session_action {
|
header #session_action {
|
||||||
position: absolute;
|
float: right;
|
||||||
right: 300px;
|
|
||||||
font-size: 110%;
|
font-size: 110%;
|
||||||
top: 7px; }
|
top: 7px;
|
||||||
|
padding-right: 10px; }
|
||||||
header #session_action a {
|
header #session_action a {
|
||||||
color: #cccccc;
|
color: #cccccc;
|
||||||
border: none; }
|
border: none; }
|
||||||
|
|
|
||||||
|
|
@ -71,14 +71,14 @@ header
|
||||||
:top 10px
|
:top 10px
|
||||||
|
|
||||||
#session_action
|
#session_action
|
||||||
:position absolute
|
:float right
|
||||||
:right 300px
|
|
||||||
:font
|
:font
|
||||||
:size 110%
|
:size 110%
|
||||||
:top 7px
|
:top 7px
|
||||||
a
|
a
|
||||||
:color #ccc
|
:color #ccc
|
||||||
:border none
|
:border none
|
||||||
|
:padding-right 10px
|
||||||
|
|
||||||
#show_filters
|
#show_filters
|
||||||
:z-index 100
|
:z-index 100
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,14 @@ describe Person do
|
||||||
friend.valid?.should == false
|
friend.valid?.should == false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
it 'should serialize to xml' do
|
||||||
|
friend_one = Factory.create(:friend)
|
||||||
|
xml = friend_one.to_xml.to_s
|
||||||
|
(xml.include? "friend").should == true
|
||||||
|
end
|
||||||
|
it 'should have a profile in its xml' do
|
||||||
|
user = Factory.create(:user)
|
||||||
|
xml = user.to_xml.to_s
|
||||||
|
(xml.include? "first_name").should == true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,11 @@ describe Post do
|
||||||
friend_posts.count.should == 2
|
friend_posts.count.should == 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
describe 'xml' do
|
||||||
|
it 'should serialize to xml with its person' do
|
||||||
|
message = Factory.create(:status_message, :person => @user)
|
||||||
|
(message.to_xml.to_s.include? @user.email).should == true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue