mad_chatter 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.rvmrc +1 -0
- data/Gemfile.lock +1 -3
- data/README.md +25 -20
- data/lib/mad_chatter/actions/dsl.rb +4 -10
- data/lib/mad_chatter/actions.rb +29 -0
- data/lib/mad_chatter/channel.rb +56 -0
- data/lib/mad_chatter/config.rb +22 -5
- data/lib/mad_chatter/connection.rb +29 -0
- data/lib/mad_chatter/extensions.rb +12 -0
- data/lib/mad_chatter/markdown_renderer.rb +6 -0
- data/lib/mad_chatter/message.rb +39 -12
- data/lib/mad_chatter/message_history.rb +8 -5
- data/lib/mad_chatter/message_listener.rb +17 -0
- data/lib/mad_chatter/message_listeners/code.rb +30 -0
- data/lib/mad_chatter/message_listeners/image.rb +27 -0
- data/lib/mad_chatter/message_listeners/join.rb +30 -0
- data/lib/mad_chatter/message_listeners/markdown.rb +45 -0
- data/lib/mad_chatter/message_listeners/nick.rb +26 -0
- data/lib/mad_chatter/server.rb +0 -55
- data/lib/mad_chatter/servers/em_websocket.rb +5 -14
- data/lib/mad_chatter/user.rb +78 -0
- data/lib/mad_chatter/users.rb +32 -24
- data/lib/mad_chatter/version.rb +1 -1
- data/lib/mad_chatter.rb +98 -34
- data/mad_chatter.gemspec +1 -1
- data/screenshot.png +0 -0
- data/spec/actions_spec.rb +7 -0
- data/spec/message_history_spec.rb +12 -10
- data/spec/message_listeners/code_spec.rb +37 -0
- data/spec/message_listeners/join_spec.rb +34 -0
- data/spec/message_listeners/markdown_spec.rb +47 -0
- data/spec/message_spec.rb +28 -16
- data/spec/server_spec.rb +43 -0
- data/spec/users_spec.rb +23 -0
- data/templates/extensions/example.rb +1 -1
- data/templates/extensions.rb +16 -14
- data/templates/web/css/bootstrap.css +3363 -0
- data/templates/web/css/bootstrap.min.css +610 -0
- data/templates/web/css/bootstrap.min.responsive.css +3 -0
- data/templates/web/css/bootstrap.responsive.css +567 -0
- data/templates/web/css/mad_chatter.css +59 -0
- data/templates/web/{styles.css → css/styles.css} +26 -20
- data/templates/web/img/glyphicons-halflings-white.png +0 -0
- data/templates/web/img/glyphicons-halflings.png +0 -0
- data/templates/web/index.html +173 -40
- data/templates/web/js/bootstrap.js +1722 -0
- data/templates/web/js/bootstrap.min.js +1 -0
- data/templates/web/js/mad_chatter.js +292 -0
- data/templates/web/{mad_chatter_actions.js → js/mad_chatter_actions.js} +0 -0
- data/templates/web/js/mad_chatter_config.js +3 -0
- data/templates/web/js/swfobject.js +4 -0
- data/templates/web/js/web_socket.js +389 -0
- data/templates/web/swf/WebSocketMain.swf +0 -0
- metadata +65 -62
- data/TODO.txt +0 -10
- data/templates/web/mad_chatter.js +0 -161
- data/templates/web/mad_chatter_config.js +0 -1
- data/templates/web/markitup/jquery.markitup.js +0 -593
- data/templates/web/markitup/sets/markdown/images/bold.png +0 -0
- data/templates/web/markitup/sets/markdown/images/code.png +0 -0
- data/templates/web/markitup/sets/markdown/images/h1.png +0 -0
- data/templates/web/markitup/sets/markdown/images/h2.png +0 -0
- data/templates/web/markitup/sets/markdown/images/h3.png +0 -0
- data/templates/web/markitup/sets/markdown/images/h4.png +0 -0
- data/templates/web/markitup/sets/markdown/images/h5.png +0 -0
- data/templates/web/markitup/sets/markdown/images/h6.png +0 -0
- data/templates/web/markitup/sets/markdown/images/italic.png +0 -0
- data/templates/web/markitup/sets/markdown/images/link.png +0 -0
- data/templates/web/markitup/sets/markdown/images/list-bullet.png +0 -0
- data/templates/web/markitup/sets/markdown/images/list-numeric.png +0 -0
- data/templates/web/markitup/sets/markdown/images/picture.png +0 -0
- data/templates/web/markitup/sets/markdown/images/preview.png +0 -0
- data/templates/web/markitup/sets/markdown/images/quotes.png +0 -0
- data/templates/web/markitup/sets/markdown/readme.txt +0 -11
- data/templates/web/markitup/sets/markdown/style.css +0 -6
- data/templates/web/markitup/skins/mad_chatter/images/handle.png +0 -0
- data/templates/web/markitup/skins/mad_chatter/images/menu.png +0 -0
- data/templates/web/markitup/skins/mad_chatter/images/submenu.png +0 -0
- data/templates/web/markitup/skins/mad_chatter/style.css +0 -121
@@ -1,161 +0,0 @@
|
|
1
|
-
var MadChatter = {
|
2
|
-
|
3
|
-
init: function(ws_host){
|
4
|
-
if (typeof WebSocket === 'undefined') {
|
5
|
-
alert("Your browser does not support websockets.")
|
6
|
-
return false;
|
7
|
-
}
|
8
|
-
MadChatter.init_websocket(ws_host);
|
9
|
-
$('#chatroom').hide();
|
10
|
-
MadChatter.wait_for_join();
|
11
|
-
MadChatter.add_markdown_editor();
|
12
|
-
},
|
13
|
-
|
14
|
-
init_websocket: function(ws_host){
|
15
|
-
var ws = new WebSocket(ws_host);
|
16
|
-
ws.onopen = function(){};
|
17
|
-
ws.onclose = function(){
|
18
|
-
MadChatter.display_status('You have been disconnected');
|
19
|
-
// setTimeout('("MadChatter.reconnect('+ws_host+'")', 10000); //need to figure out how to re-join chat onopen
|
20
|
-
};
|
21
|
-
ws.onmessage = function(evt){
|
22
|
-
//console.log(evt.data)
|
23
|
-
var data = JSON.parse(evt.data);
|
24
|
-
MadChatter.message_received(data.type, data.username, data.message);
|
25
|
-
};
|
26
|
-
MadChatter.ws = ws;
|
27
|
-
},
|
28
|
-
|
29
|
-
// reconnect: function(){
|
30
|
-
// console.log('trying to reconnect...');
|
31
|
-
// },
|
32
|
-
|
33
|
-
wait_for_join: function(){
|
34
|
-
$('#username').keyup(function (event) {
|
35
|
-
if (event.keyCode == 13) { // The enter key.
|
36
|
-
MadChatter.join_chat();
|
37
|
-
}
|
38
|
-
});
|
39
|
-
$('#join').click(function(){
|
40
|
-
MadChatter.join_chat();
|
41
|
-
});
|
42
|
-
},
|
43
|
-
|
44
|
-
add_markdown_editor: function(){
|
45
|
-
var config = {
|
46
|
-
previewParserPath: '',
|
47
|
-
onEnter: {keepDefault:false, afterInsert: MadChatter.submit_chat },
|
48
|
-
onShiftEnter: {keepDefault:false, openWith:'\n\n'},
|
49
|
-
markupSet: [
|
50
|
-
{name:'Bold', key:'B', openWith:'**', closeWith:'**'},
|
51
|
-
{name:'Italic', key:'I', openWith:'_', closeWith:'_'},
|
52
|
-
{separator:'---------------' },
|
53
|
-
{name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!])'},
|
54
|
-
{name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!])', placeHolder:'Your text to link here...' },
|
55
|
-
{separator:'---------------'},
|
56
|
-
{name:'Quotes', openWith:'> '},
|
57
|
-
{name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'}
|
58
|
-
]
|
59
|
-
};
|
60
|
-
$('#keyboard textarea').markItUp(config);
|
61
|
-
},
|
62
|
-
|
63
|
-
join_chat: function(){
|
64
|
-
var username = $.trim($('#username').val());
|
65
|
-
if (username.length == 0) {
|
66
|
-
alert('Please enter your name.');
|
67
|
-
return false;
|
68
|
-
}
|
69
|
-
MadChatter.send_message('/join ' + username);
|
70
|
-
$('#login_screen').hide();
|
71
|
-
$('#chatroom').show();
|
72
|
-
},
|
73
|
-
|
74
|
-
submit_chat: function(){
|
75
|
-
var keyboard = $("#keyboard textarea"), message = keyboard.val();
|
76
|
-
if ($.trim(message) != '') {
|
77
|
-
MadChatter.send_message(message);
|
78
|
-
keyboard.val('');
|
79
|
-
}
|
80
|
-
},
|
81
|
-
|
82
|
-
message_received: function(type, username, message){
|
83
|
-
if (type == 'error') {
|
84
|
-
console.log('Client error: ' + message)
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
if (type == 'token') {
|
88
|
-
MadChatter.client_token = message;
|
89
|
-
return;
|
90
|
-
}
|
91
|
-
if (type == 'users') {
|
92
|
-
MadChatter.update_users_list(message);
|
93
|
-
return;
|
94
|
-
}
|
95
|
-
if (type == 'status') {
|
96
|
-
MadChatter.display_status(message);
|
97
|
-
}
|
98
|
-
if (type == 'action') {
|
99
|
-
MadChatter.exec_action(message);
|
100
|
-
}
|
101
|
-
if (type == 'message') {
|
102
|
-
MadChatter.display_message(username, message);
|
103
|
-
if (typeof(MadChatterGrowl) != 'undefined') {
|
104
|
-
MadChatterGrowl.send_(username, message);
|
105
|
-
}
|
106
|
-
}
|
107
|
-
MadChatter.scroll_to_bottom_of_chat();
|
108
|
-
},
|
109
|
-
|
110
|
-
update_users_list: function(users){
|
111
|
-
$("#members").html('');
|
112
|
-
$.each(users, function(index, username) {
|
113
|
-
$("#members").append('<li>' + username + '</li>');
|
114
|
-
});
|
115
|
-
},
|
116
|
-
|
117
|
-
exec_action: function(message){
|
118
|
-
window[message.function].apply(window, message.args);
|
119
|
-
},
|
120
|
-
|
121
|
-
display_status: function(message){
|
122
|
-
$("#messages").append("<p class='status'>" + message + "<time>" + MadChatter.get_current_time() + "</time></p>");
|
123
|
-
},
|
124
|
-
|
125
|
-
display_message: function(username, message){
|
126
|
-
$("#messages").append("<p class='message'><time>" + MadChatter.get_current_time() + "</time><span class='username'>" + username + ":</span> " + message + "</p>");
|
127
|
-
},
|
128
|
-
|
129
|
-
scroll_to_bottom_of_chat: function(){
|
130
|
-
$("body")[0].scrollTop = $("#messages")[0].scrollHeight;
|
131
|
-
},
|
132
|
-
|
133
|
-
send_message: function(message){
|
134
|
-
if (message == '/clear') {
|
135
|
-
MadChatter.clear_messages();
|
136
|
-
} else {
|
137
|
-
MadChatter.send_json('message', message);
|
138
|
-
}
|
139
|
-
},
|
140
|
-
|
141
|
-
send_json: function(type, msg){
|
142
|
-
var json = { type: type, token: MadChatter.client_token, message: msg };
|
143
|
-
MadChatter.ws.send(JSON.stringify(json));
|
144
|
-
},
|
145
|
-
|
146
|
-
clear_messages: function(){
|
147
|
-
$('#messages').empty();
|
148
|
-
},
|
149
|
-
|
150
|
-
get_current_time: function(){
|
151
|
-
var time = new Date();
|
152
|
-
var hours = time.getHours();
|
153
|
-
var minutes = time.getMinutes();
|
154
|
-
var ampm = 'am';
|
155
|
-
if (hours > 11) { ampm = 'pm'; }
|
156
|
-
if (minutes < 10) { minutes = "0" + minutes; }
|
157
|
-
if (hours == 0) { hours = 12; }
|
158
|
-
if (hours > 12) { hours = hours - 12; }
|
159
|
-
return hours + ':' + minutes + ampm;
|
160
|
-
}
|
161
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
var mad_chatter_config = 'ws://localhost:8100';
|