Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

UI stating along; chat running and connected

  • Loading branch information...
commit ebcb66a5f40bb5b63e22ca9515dd75b29bcdc3b3 1 parent ab8283b
J Brien Dilts authored
View
32 app/controllers/chat_rooms_controller.rb
@@ -1,7 +1,7 @@
class ChatRoomsController < ApplicationController
unloadable
- before_filter :require_login, :except => [:broadcast] # GET /chat_rooms
+ # GET /chat_rooms
# GET /chat_rooms.xml
def index
@chat_rooms = ChatRoom.find(:all)
@@ -47,7 +47,7 @@ def create
respond_to do |format|
if @chat_room.save
flash[:notice] = 'ChatRoom was successfully created.'
- format.html { redirect_to(@chat_room) }
+ format.html { redirect_to(:action => 'show', :id => @chat_room) }
format.xml { render :xml => @chat_room, :status => :created, :location => @chat_room }
else
format.html { render :action => "new" }
@@ -86,22 +86,18 @@ def destroy
end
def send_data
- render :juggernaut => {:type => :send_to_channels, :channels => [params[:id].to_i] } do |page|
- page.insert_html :bottom, 'chat_room', "<p>#{current_user.login}: #{h params[:chat_input]}</p>"
- page.call :scrollChatPanel, 'chat_room'
- end
- render :nothing => true
+ m = params[:chat_input]
+ if !m.blank?
+ @message = ChatMessage.new(:message => m, :from => User.current, :created_at => Time.now)
+ render :juggernaut do |page|
+ page.add_message @message
+ end
+ end
+ #render :juggernaut => {:type => :send_to_channels, :channels => [params[:id].to_i] } do |page|
+ # page.insert_html :bottom, 'chat_room', "<p>#{User.current}: #{h params[:chat_input]}</p>"
+ # page.call :scrollChatPanel, 'chat_room'
+ #end
+ render :nothing => true, :status => 200
end
- private
-
- def is_logged_in?
- if logged_in?
- true
- else
- flash[:error] = "You must be logged in to chat"
- redirect_to("/login")
- false
- end
- end
end
View
34 app/controllers/chat_users_controller.rb
@@ -1,8 +1,8 @@
-class ChatDevsController < ApplicationController
+class ChatUsersController < ApplicationController
def idle
current_user.away!
render :juggernaut do |page|
- page.go_away current_user
+ page.go_away User.current
end
render :nothing => true
end
@@ -10,7 +10,7 @@ def idle
def offline
current_user.offline!
render :juggernaut do |page|
- page.go_offline current_user
+ page.go_offline User.current
end
render :nothing => true
end
@@ -19,8 +19,34 @@ def offline
def online
current_user.online!
render :juggernaut do |page|
- page.go_online current_user
+ page.go_online User.current
end
render :nothing => true
end
+
+ private
+
+ def update_user_list
+ @user = ChatUser.find(params[:user_id])
+
+ @channels = params[:channels].collect{|channel| channel.to_i } if params[:channels]
+
+ yield
+
+ Thread.new do
+ users = ChatUser.find(Juggernaut.show_users_for_channels(@channels).collect{ |user| user["id"] })
+
+ render :juggernaut => {:type => :send_to_channels, :channels => @channels } do |page|
+ page.replace_html 'user_list', users.collect{ |user| "<li>"+ link_to_remote(user.login, :url => "/messages/new_private_message/#{user.id}")+"</li>" }.join
+ end
+ end
+ end
+
+ def update_chat_room(action)
+ render :juggernaut => {:type => :send_to_channels, :channels => @channels } do |page|
+ page.insert_html :bottom, 'chat_room', "<p style='color:green;font-size:20px;'>#{@user.login} has #{action} the room</p>"
+ page.call :scrollChatPanel, 'chat_room'
+ end
+ end
+
end
View
13 app/helpers/chat_messages_helper.rb
@@ -1,4 +1,17 @@
module ChatMessagesHelper
+
+ def create_private_message(client_ids)
+ users = User.find(client_ids).collect{|user| user.login}.to_sentence
+ private_chat_room_id = 'private_chat_room_'+client_ids.join('_')
+ private_chat_input_id = 'private_chat_input_'+client_ids.join('_')
+ top ="<div class='private_message'><h3>#{users}</h3><div id='#{private_chat_room_id}' class='private_chat_room scroller'></div><div id='chat_form'>"
+ form = form_remote_tag(:url => { :action => :send_private_message, :client_ids => client_ids }, :complete => "$('#{private_chat_input_id}').value = ''" )
+ text = text_field_tag( private_chat_input_id, '', { :size => '50', :id => private_chat_input_id, :class=> 'private_chat_input'} )
+ submit = submit_tag "Chat"
+ bottom ="</form></div></div>"
+ top+form+text+submit+bottom
+ end
+
def recent_messages(options={})
out = []
#last_message_id = current_user.last_message_id
View
12 app/views/chat_rooms/index.html.erb
@@ -1,4 +1,4 @@
-<%= juggernaut(:channels => [0], :client_id => session[:user_id]) %>
+<%= juggernaut(:debug => true, :client_id => User.current.id) %>
<h1>Listing chat_rooms</h1>
@@ -11,19 +11,19 @@
<% for chat_room in @chat_rooms %>
<tr>
- <td><%=Juggernaut.show_users_for_channels(chat_room.id).size %></td>
+ <td></td>
<td><%=h chat_room.name %></td>
<td><%=h chat_room.description %></td>
- <td><%= link_to 'Show', chat_room %></td>
- <td><%= link_to 'Edit', edit_chat_room_path(chat_room) %></td>
- <td><%= link_to 'Destroy', chat_room, :confirm => 'Are you sure?', :method => :delete %></td>
+ <td><%= link_to 'Show', {:action => 'show', :id => chat_room} %></td>
+ <td><%= link_to 'Edit', {:action => 'edit', :id => chat_room} %></td>
+ <td><%= link_to 'Destroy', {:action => 'destroy', :id => chat_room}, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
-<%= link_to 'New chat_room', new_chat_room_path %>
+<%= link_to 'New chat_room', {:action => 'new'} %>
<br />
View
4 app/views/chat_rooms/new.html.erb
@@ -1,6 +1,6 @@
<h1>New chat_room</h1>
-<% form_for(@chat_room, {:controller => 'chat_rooms'}) do |f| %>
+<% form_for(@chat_room, :url => {:controller => 'chat_rooms', :action => 'create'}) do |f| %>
<%= f.error_messages %>
<p>
@@ -16,4 +16,4 @@
</p>
<% end %>
-<%= link_to 'Back', chat_rooms_path %>
+<%= link_to 'Back', :controller => 'chat_rooms' %>
View
18 app/views/chat_rooms/show.html.erb
@@ -1,6 +1,6 @@
-<%= juggernaut(:channels => [@chat_room.id], :client_id => session[:user_id]) %>
+<%= juggernaut(:channels => [@chat_room.id], :client_id => User.current.id, :debug => true) %>
-<p><%= link_to 'Back', chat_rooms_path %></p>
+<p><%= link_to 'Back', {:action => 'index'} %></p>
<h1><%=h @chat_room.name %></h1>
@@ -21,3 +21,17 @@
</div>
<div id="private_messages"></div>
+
+<% content_for :header_tags do %>
+ <%= stylesheet_link_tag 'chat', :plugin => 'redmine_chat_plugin' %>
+ <%= javascript_include_tag 'juggernaut/juggernaut', 'juggernaut/swfobject', 'autoscroll', :plugin => 'redmine_chat_plugin' %>
+ <script type="text/javascript" charset="utf-8">
+ $$('tr.u-1').each(function(m) {
+ m.addClassName('me');
+ });
+ function scrollChatPanel(room){
+ div = $(room);
+ div.scrollTop = 0xffff;
+ }
+ </script>
+<% end %>
View
321 assets/stylesheets/chat.css
@@ -1,260 +1,63 @@
-#chat_header {
- xbackground: #4F5E85;
- xbackground: #558;
- background: #242424;
- color: #fff;
- width: 100%;
- padding: 5px 0;
- overflow: hidden;
-}
-
-#chat_header table {
- margin: 5px 0;
- xheight: 2px;
- }
-
-#chat_header table td {
- background: none;
- color: #fff;
-}
-#chat_header table td .appname {
- text-align: right;
- font-weight: bold;
- width: 1px;
- padding: 0px 5px 0 10px;
- }
-
-#chat_header table td .slogan {
- color: #CBCBDB;
- color: #777;
- }
-
-#chat_header table td.session {
- text-align: right;
- padding-right: 20px;
- }
-
-#chat_header table td.session a {
- color: #bbe;
- }
-
-
-td#content {
- xbackground: #fff;
- xborder: groove 2px #fff;
-}
-
-#chatwindow {
- xbackground: #fff url(/images/right-bg.gif) repeat-y top right;
- padding: 0;
- border: solid 1px #f7f7f7;
- border-top-color: #aaa;
- border-left-color: #aaa;
-
- margin: 10px 10px 0 0;
-}
-#chatwindow div#chat {
- padding: 10px 10px 0px 10px;
- background: #fff;
- overflow-y: scroll;
- border: solid 1px #eee;
- border-top-color: #aaa;
- border-left-color: #aaa;
- }
-
-#chatwindow div#chat table.chat {
- }
-
-#chatwindow div#chat div.bottom {
- xbackground: #e5e5e5 url(/images/bottom-bg.gif) repeat-x top right;
- xpadding-bottom: 10px;
- }
-
-#bottom td {
- background: #e5e5e5;
- height: 100px;
- padding: 10px;
-}
-
-#chatbox textarea#message {
- width: 100%;
- height: 80px;
- border: none;
- xmargin: 10px 0 0 0;
- padding: 0;
- }
-
-#chat_header #sidebar {
- padding: 0 10px 0 0px;
- width: 120px;
- background: none;
- vertical-align: top;
-}
-#chat_header #sidebar ul#gabbers {
- list-style: none;
- padding: 0;
-}
-#chat_header #sidebar ul#gabbers li {
- background: #E5E5E5;
-}
-#chat_header #sidebar ul#gabbers li .idle, .away {
- color: #777;
- }
-
-#chat_header #sidebar ul#gabbers li .online {
- font-weight: bold;
- }
-
-#chat_header #sidebar ul#gabbers li .offline {
- display: none;
- }
-
-#chat_header #sidebar div.panel {
- width: 100%;
- margin-bottom: 20px;
-}
-
-
-#chat_header #sidebar h2 {
- margin: 1em 0 0.5em 0;
- font-size: 1em;
- background: #ddd;
- padding: 3px 5px;
- border-bottom: solid 1px #ccc;
- }
-
-td#content {
- vertical-align: top;
- padding-left: 10px;
- background: #e5e5e5;
- overflow: scroll;
- vertical-align: top;
-}
-
-#chat_header td {
- vertical-align: top;
- background: #fff;
- color: #333;
- font-size: 12px;
- margin: 0;
- padding: 0;
-}
-
-tr.new td,
-tr.sys td {
- border-top: dotted 1px #ccc;
-}
-
-#chat_header pre {
- background: #f5f5f5;
- padding: 10px;
- xmargin-right: 15px;
- border: dotted 1px #ccc;
- width: 100%;
- overflow: auto;
-}
-
-#chat_headertable {
- border-collapse: collapse;
- border: 0;
- width: 100%;
-}
-
-td.from {
- border-right: solid 1px #ccc;
- padding: 5px 15px 5px 5px;
- width: 65px;
- text-align: right;
-}
-
-td.from div.from {
- font-weight: bold;
- visibility: hidden;
-}
-
-/*tr.notice div.from,*/
-tr.new div.from,
-tr.sys div.from {
- visibility: visible;
-}
-
-td.message {
- padding-left: 15px;
- vertical-align: middle;
-}
-
-td.time {
- width: 50px;
- vertical-align: top;
- padding-top: 7px;
-}
-
-div.time {
- font-size: 9px;
- color: #999;
- white-space: nowrap;
-}
-
-tr.me td {
- xbackground: url(/images/me-bg.png) repeat-y top right;
- background: #FFFFE8;
-}
-tr.me code, pre {
- background: #eed;
- background: #fff;
- }
-
-
-#chat_header tr.sys td,
-#chat_header tr.sys td.from {
- background: #f5f5f5;
- font-weight: bold;
-}
-
-#chat_header tr.notice td {
- background: #E6EEF7 !important;
-}
-
-#chat_header tr.time td {
- padding-top: 15px;
- padding-bottom: 5px;
- border-right: none;
- background: none !important;
- font-size: 0.8em;
- font-weight: normal;
- color: #777;
-}
-
-#chat_header div.message {
- padding: 2px 0;
-}
-
-#chat_header td.message a {
- font-weight: bold;
- color: blue;
-}
-
-#chat_header img {
- border: none;
- padding: 5px 0;
-}
-#chat_header img .glyph {
- padding: 0;
- vertical-align: text-bottom;
- }
-
-#chat_header p.wip {
- background: #FFFFE8;
- padding: 3px;
-}
-
-#chat_header code {
- font-size: 1.1em;
- background: #efefef;
- padding: 2px 3px;
- border: dotted 1px #ccc;
-}
-
-#logging_in {
- padding: 10px 0;
+#chat_room, #user_list{
+ border:1px solid black;
+ overflow-y: scroll;
+ scrollbar-arrow-color:000000;
+ scrollbar-track-color:000000;
+ scrollbar-shadow-color:B1D0F0;
+ scrollbar-face-color:B1D0F0;
+ scrollbar-highlight-color:B1D0F0;
+ scrollbar-darkshadow-color:B1D0F0;
+ scrollbar-3dlight-color:B1D0F0;
+}
+
+.scroller{
+ border:1px solid black;
+ overflow-y: scroll;
+ scrollbar-arrow-color:000000;
+ scrollbar-track-color:000000;
+ scrollbar-shadow-color:B1D0F0;
+ scrollbar-face-color:B1D0F0;
+ scrollbar-highlight-color:B1D0F0;
+ scrollbar-darkshadow-color:B1D0F0;
+ scrollbar-3dlight-color:B1D0F0;
+}
+
+#chat_room
+{
+ float: left;
+ width:600px;
+ height:400px;
+ padding:5px;
+}
+
+#user_list {
+ list-style-type: none;
+ padding:5px;
+ margin-left:10px;
+ float: left;
+ width: 150px;
+ height: 400px;
+}
+
+#chat_form{
+ clear:both;
+}
+
+#chat_input{
+ padding:5px;
+ margin-top: 10px;
+ font-size: 15px;
+ border: 1px solid black;
+}
+
+.private_message{
+ margin-left :10px;
+ float: left;
+ height: 400px;
+ padding: 10px;
+ border: 1px solid black;
+}
+
+.private_chat_room{
+ height: 300px;
}
Please sign in to comment.
Something went wrong with that request. Please try again.