RS MS added goog analytics

This commit is contained in:
maxwell 2010-06-29 11:45:41 -07:00
parent 01f048b0a6
commit a683a2c1aa
4 changed files with 20 additions and 47 deletions

View file

@ -9,7 +9,7 @@
= stylesheet_link_tag "blueprint/screen", :media => 'screen' = stylesheet_link_tag "blueprint/screen", :media => 'screen'
= stylesheet_link_tag "application" = stylesheet_link_tag "application"
/= 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' = javascript_include_tag 'jquery142', 'rails', 'view', 'google'
= javascript_include_tag 'tiny_mce/tiny_mce.js' = javascript_include_tag 'tiny_mce/tiny_mce.js'

View file

@ -1,23 +1,14 @@
require 'em-websocket' require 'em-websocket'
require 'eventmachine' require 'eventmachine'
require 'lib/socket_render'
module WebSocket module WebSocket
EM.next_tick { EM.next_tick {
EM.add_timer(0.1) do EM.add_timer(0.1) do
@channel = EM::Channel.new @channel = EM::Channel.new
puts @channel.inspect puts @channel.inspect
#this should really be a controller include SocketRenderer
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
class << @view
include ApplicationHelper
include Rails.application.routes.url_helpers
include ActionController::RequestForgeryProtection::ClassMethods
def protect_against_forgery?
false
end
end
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 => 8080, :debug =>true) do |ws|
@ -32,26 +23,8 @@ module WebSocket
} }
def self.update_clients(object) def self.update_clients(object)
@channel.push(WebSocket.view_hash(object).to_json) if @channel @channel.push(SocketRenderer.view_hash(object).to_json) if @channel
end end
def self.view_hash(object)
begin
puts "I be working hard"
v = WebSocket.view_for(object)
puts v.inspect
rescue Exception => e
puts "in failzord " + v.inspect
puts object.inspect
puts e.message
raise e
end
puts "i made it here"
{:class =>object.class.to_s.underscore.pluralize, :html => v}
end
def self.view_for(object)
@view.render @view.type_partial(object), :post => object
end
end end

View file

@ -0,0 +1,14 @@
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17207587-1']);
_gaq.push(['_setDomainName', '.joindiaspora.com']);
_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);
})();
</script>

View file

@ -2,18 +2,4 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe WebSocket do
it 'should prepare a view along with an objects class in json' do
EventMachine.run {
include WebSocket
user = Factory.create(:user)
post = Factory.create(:status_message)
json = WebSocket.view_hash(post)
json.should include post.message
EventMachine.stop
}
end
end