diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7f0ca264e6dda502b7ea325308f27333252a527e..890d32a1c1833860347c06f28868c20906de3590 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery :except => :receive layout 'application' + before_filter :set_friends layout :layout_by_resource diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 333cb694adfe702841645c8753703fb02b7cb296..7ca1f2441f740cf88dda371d2c49b2dec75ae37a 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -1,7 +1,6 @@ class BlogsController < ApplicationController before_filter :authenticate_user! - def index @blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC' end diff --git a/app/views/js/_google_a_js.haml b/app/views/js/_google_a_js.haml new file mode 100644 index 0000000000000000000000000000000000000000..d160024f418fb98a98f56144c4ae51ae1c06653b --- /dev/null +++ b/app/views/js/_google_a_js.haml @@ -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); + })(); \ No newline at end of file diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml new file mode 100644 index 0000000000000000000000000000000000000000..00d130029f0852c64e60130769caf323de8c33ee --- /dev/null +++ b/app/views/js/_websocket_js.haml @@ -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..."); + };}); \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2cf2f02d648e694274b818fce5e5e198edb8fba6..94b5b87dc132a5914b9ae3fc79db4e4e143de0e9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,7 +2,8 @@ %html %head %title - = "diaspora" + = "diaspora " + = "- #{User.first.real_name}" if User.first %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/ %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 'jquery142', 'rails', 'view', 'publisher' = javascript_include_tag 'tiny_mce/tiny_mce.js','jquery.infieldlabel' - :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); - })(); - - - unless request.user_agent.include? "Safari" ||"Chrome" - = javascript_include_tag 'FABridge', 'swfobject', 'web_socket' - :javascript - WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf"; - + = render "js/google_a_js" + = render "js/websocket_js" = csrf_meta_tag = 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' %body diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml index dfcd5d12c8723803c5865445df28fbeab3417b45..3838ba0d24effc5af98a0d87365b8a5cd508b071 100644 --- a/app/views/layouts/session_wall.html.haml +++ b/app/views/layouts/session_wall.html.haml @@ -18,10 +18,13 @@ .container - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_#{name}" - - %div#huge_text - welcome back, - %span - = User.first.real_name.downcase + - if User.first + %div#huge_text + welcome back, + %span + = User.first.real_name.downcase + -else + %div#huge_text + you need to add a user first! = yield diff --git a/config/app_config.yml b/config/app_config.yml new file mode 100644 index 0000000000000000000000000000000000000000..56f8420066d7e4a3c57eb3e7df31e61db229f849 --- /dev/null +++ b/config/app_config.yml @@ -0,0 +1,11 @@ +development: + debug: true + socket_port: 8080 + +test: + debug: false + socket_port: 8081 + +production: + debug: false + socket_port: 8080 diff --git a/config/initializers/load_app_config.rb b/config/initializers/load_app_config.rb new file mode 100644 index 0000000000000000000000000000000000000000..4e5bbdd9dd47eb664de1385b39b73473d2deaf17 --- /dev/null +++ b/config/initializers/load_app_config.rb @@ -0,0 +1,2 @@ +raw_config = File.read("#{Rails.root}/config/app_config.yml") +APP_CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 3c716ef05265eef3a04fc98a68a82c95e1de883a..105314b8ae1d2ccdbdcc4d4bb158e4a83976aa95 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -11,7 +11,10 @@ module WebSocket SocketRenderer.instantiate_view 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 { sid = @channel.subscribe { |msg| ws.send msg } @@ -25,6 +28,4 @@ module WebSocket def self.update_clients(object) @channel.push(SocketRenderer.view_hash(object).to_json) if @channel end - - end diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 4ec1ed95b3069a88d92395bedbc8be55c33ec5df..3b062b36ae65f32833bbdd87dcd90ce7aa3cb613 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -53,4 +53,23 @@ $(document).ready(function(){ $('#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").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 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 2145ea58543b84e4112637531748014208cf94bc..f80f31bc04cded9375cf91ecd1790d2f722b0f89 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -64,10 +64,10 @@ header { border: none; top: 10px; } header #session_action { - position: absolute; - right: 300px; + float: right; font-size: 110%; - top: 7px; } + top: 7px; + padding-right: 10px; } header #session_action a { color: #cccccc; border: none; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 201c5bf5845889c9bb9554e153aaa30c8e2a22d2..601794136369fb49ee5639d008a642b5033b0f1c 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -71,14 +71,14 @@ header :top 10px #session_action - :position absolute - :right 300px + :float right :font :size 110% :top 7px a :color #ccc :border none + :padding-right 10px #show_filters :z-index 100