Skip to content
Extraits de code Groupes Projets
Valider dc5b321b rédigé par maxwell's avatar maxwell
Parcourir les fichiers

sorry for the monster commit.... 4 small chores...1) moved tons of dynamic...

sorry for the monster commit.... 4 small chores...1) moved tons of dynamic javascript to haml partials in the new js view folder, and moved some of the js that got put in the application layout into view.js 2. set up a static config prefrence loader in initializers, loaded from yaml 3) fixed the top right login text from being pushed over. 4) fixed a bug when no user is on the node and someone hits the landing page.... you still cant create a new user from there, but now at least it doesnt blow up.
parent 93a4ac6f
Branches
Étiquettes
Aucune requête de fusion associée trouvée
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
......
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
......
: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
- 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
...@@ -2,7 +2,8 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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
development:
debug: true
socket_port: 8080
test:
debug: false
socket_port: 8081
production:
debug: false
socket_port: 8080
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 ...@@ -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 ...@@ -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(){ ...@@ -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").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 { ...@@ -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 ...@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter