mad_chatter 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +2 -1
  2. data/Gemfile.lock +13 -1
  3. data/Guardfile +9 -0
  4. data/README.md +31 -17
  5. data/TODO.txt +1 -1
  6. data/lib/mad_chatter/message.rb +4 -1
  7. data/lib/mad_chatter/version.rb +1 -1
  8. data/mad_chatter.gemspec +4 -1
  9. data/spec/message_spec.rb +27 -0
  10. data/spec/spec_helper.rb +14 -0
  11. data/templates/extensions.rb +7 -0
  12. data/templates/web/index.html +10 -1
  13. data/templates/web/mad_chatter.js +2 -2
  14. data/templates/web/mad_chatter_actions.js +15 -0
  15. data/templates/web/markitup/jquery.markitup.js +593 -0
  16. data/templates/web/markitup/sets/default/images/bold.png +0 -0
  17. data/templates/web/markitup/sets/default/images/clean.png +0 -0
  18. data/templates/web/markitup/sets/default/images/image.png +0 -0
  19. data/templates/web/markitup/sets/default/images/italic.png +0 -0
  20. data/templates/web/markitup/sets/default/images/link.png +0 -0
  21. data/templates/web/markitup/sets/default/images/list-bullet.png +0 -0
  22. data/templates/web/markitup/sets/default/images/list-numeric.png +0 -0
  23. data/templates/web/markitup/sets/default/images/picture.png +0 -0
  24. data/templates/web/markitup/sets/default/images/preview.png +0 -0
  25. data/templates/web/markitup/sets/default/images/stroke.png +0 -0
  26. data/templates/web/markitup/sets/default/set.js +30 -0
  27. data/templates/web/markitup/sets/default/style.css +34 -0
  28. data/templates/web/markitup/sets/markdown/images/bold.png +0 -0
  29. data/templates/web/markitup/sets/markdown/images/code.png +0 -0
  30. data/templates/web/markitup/sets/markdown/images/h1.png +0 -0
  31. data/templates/web/markitup/sets/markdown/images/h2.png +0 -0
  32. data/templates/web/markitup/sets/markdown/images/h3.png +0 -0
  33. data/templates/web/markitup/sets/markdown/images/h4.png +0 -0
  34. data/templates/web/markitup/sets/markdown/images/h5.png +0 -0
  35. data/templates/web/markitup/sets/markdown/images/h6.png +0 -0
  36. data/templates/web/markitup/sets/markdown/images/italic.png +0 -0
  37. data/templates/web/markitup/sets/markdown/images/link.png +0 -0
  38. data/templates/web/markitup/sets/markdown/images/list-bullet.png +0 -0
  39. data/templates/web/markitup/sets/markdown/images/list-numeric.png +0 -0
  40. data/templates/web/markitup/sets/markdown/images/picture.png +0 -0
  41. data/templates/web/markitup/sets/markdown/images/preview.png +0 -0
  42. data/templates/web/markitup/sets/markdown/images/quotes.png +0 -0
  43. data/templates/web/markitup/sets/markdown/readme.txt +11 -0
  44. data/templates/web/markitup/sets/markdown/set.js +52 -0
  45. data/templates/web/markitup/sets/markdown/style.css +61 -0
  46. data/templates/web/markitup/skins/mad_chatter/images/handle.png +0 -0
  47. data/templates/web/markitup/skins/mad_chatter/images/menu.png +0 -0
  48. data/templates/web/markitup/skins/mad_chatter/images/submenu.png +0 -0
  49. data/templates/web/markitup/skins/mad_chatter/style.css +121 -0
  50. data/templates/web/markitup/skins/markitup/images/bg-container.png +0 -0
  51. data/templates/web/markitup/skins/markitup/images/bg-editor-bbcode.png +0 -0
  52. data/templates/web/markitup/skins/markitup/images/bg-editor-dotclear.png +0 -0
  53. data/templates/web/markitup/skins/markitup/images/bg-editor-html.png +0 -0
  54. data/templates/web/markitup/skins/markitup/images/bg-editor-json.png +0 -0
  55. data/templates/web/markitup/skins/markitup/images/bg-editor-markdown.png +0 -0
  56. data/templates/web/markitup/skins/markitup/images/bg-editor-textile.png +0 -0
  57. data/templates/web/markitup/skins/markitup/images/bg-editor-wiki.png +0 -0
  58. data/templates/web/markitup/skins/markitup/images/bg-editor-xml.png +0 -0
  59. data/templates/web/markitup/skins/markitup/images/bg-editor.png +0 -0
  60. data/templates/web/markitup/skins/markitup/images/handle.png +0 -0
  61. data/templates/web/markitup/skins/markitup/images/menu.png +0 -0
  62. data/templates/web/markitup/skins/markitup/images/submenu.png +0 -0
  63. data/templates/web/markitup/skins/markitup/style.css +147 -0
  64. data/templates/web/markitup/skins/simple/images/handle.png +0 -0
  65. data/templates/web/markitup/skins/simple/images/menu.png +0 -0
  66. data/templates/web/markitup/skins/simple/images/submenu.png +0 -0
  67. data/templates/web/markitup/skins/simple/style.css +121 -0
  68. data/templates/web/markitup/templates/preview.css +5 -0
  69. data/templates/web/markitup/templates/preview.html +11 -0
  70. data/templates/web/styles.css +7 -11
  71. metadata +109 -20
  72. data/test/helper.rb +0 -18
  73. data/test/test_mad_chatter.rb +0 -7
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
2
  .bundle
3
3
  pkg/*
4
- .daemon
4
+ .daemon
5
+ coverage/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mad_chatter (0.2.3)
4
+ mad_chatter (0.2.6)
5
5
  daemons (= 1.1.4)
6
6
  em-websocket
7
7
  eventmachine
@@ -18,6 +18,11 @@ GEM
18
18
  addressable (>= 2.1.1)
19
19
  eventmachine (>= 0.12.9)
20
20
  eventmachine (0.12.10)
21
+ guard (0.8.8)
22
+ thor (~> 0.14.6)
23
+ guard-rspec (0.5.10)
24
+ guard (>= 0.8.4)
25
+ multi_json (1.0.4)
21
26
  redcarpet (2.0.1)
22
27
  rspec (2.7.0)
23
28
  rspec-core (~> 2.7.0)
@@ -28,12 +33,19 @@ GEM
28
33
  diff-lcs (~> 1.1.2)
29
34
  rspec-mocks (2.7.0)
30
35
  shoulda (2.11.3)
36
+ simplecov (0.5.4)
37
+ multi_json (~> 1.0.3)
38
+ simplecov-html (~> 0.5.3)
39
+ simplecov-html (0.5.3)
31
40
  thor (0.14.6)
32
41
 
33
42
  PLATFORMS
34
43
  ruby
35
44
 
36
45
  DEPENDENCIES
46
+ guard
47
+ guard-rspec
37
48
  mad_chatter!
38
49
  rspec
39
50
  shoulda
51
+ simplecov
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :cli => "--color --format nested --fail-fast --drb", :notification => false do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- #Mad Chatter
1
+ # Mad Chatter
2
2
 
3
- Mad Chatter is a fun, easy to customize chat server. It's written in Ruby and utilizes HTML 5 Web Sockets for fast communication.
3
+ Mad Chatter is a fun, easy to customize chat server. It's written in Ruby and utilizes HTML 5 Web Sockets for fast communication. It also has support for Markdown.
4
4
 
5
- ##Getting Started
5
+ ## Getting Started
6
6
 
7
7
  To get started, first install the Mad Chatter gem:
8
8
 
@@ -19,10 +19,9 @@ This command will generate the following structure:
19
19
  extensions.rb
20
20
  web/
21
21
  index.html
22
- javascript.js
23
- stylesheets/
24
- reset.css
25
- styles.css
22
+ styles.css
23
+ mad_chatter.js
24
+ mad_chatter_actions.js
26
25
 
27
26
  To start your chat server, navigate to the directory that was just created and run...
28
27
 
@@ -34,8 +33,7 @@ The start command will launch the web socket server in the background. You can u
34
33
 
35
34
  mad_chatter stop
36
35
 
37
-
38
- ##Chat Actions
36
+ ## Chat Actions
39
37
 
40
38
  Hopefully, the default chatroom will be relatively intuitive to use. However, there are some extra features that Mad Chatter provides. Every chat message is parsed to see if it is a normal chat message, or if its a special action. These actions are much like IRC commands. For example, if I wanted to change my screen name from Andrew to Andy I could chat this message:
41
39
 
@@ -47,29 +45,45 @@ If I wanted to embed a YouTube video for all the members of the chatroom to enjo
47
45
 
48
46
  /youtube http://youtu.be/n1NVfDlU6yQ
49
47
 
50
- You can even create your own actions to do whatever you want.
48
+ Or if I wanted to shake everyone's chat window:
49
+
50
+ /earthquake
51
+
52
+ You can also create your own actions to do whatever you want.
51
53
 
52
54
 
53
- ##Customizing
55
+ ## Customizing
54
56
 
55
57
  The goal of Mad Chatter is to make it easy to create, host, and customize your own chat server. Let's take a look at the different ways you can customize your new chat server.
56
58
 
57
- If you want to customize the html/css of your chatroom, you'll find them in the web directory.
59
+ If you want to customize the html/css of your chatroom, you'll find it in the web directory.
58
60
 
59
61
  There is an example config file that shows a few examples of things you can customize.
60
62
 
61
- The extensions.rb file is for you to create your own chat extensions. You will find an example in that file.
63
+ The extensions.rb file is for you to create your own chat extensions. You will find a few examples in that file.
64
+
65
+
66
+ ## Mac, Windows, and Linux Wrappers
67
+
68
+ Once you've got your chat server running and being used by other people, you might be interested in using/distributing an installable application, so you can leave it running and don't need to pull it up in a browser anymore. Here's a list of the currently available GUI wrapper applications:
69
+
70
+ * [Mad Chatter for Mac](https://github.com/andrewhavens/mad_chatter_for_mac) (a MacRuby app based on WebKit)
71
+
72
+ ## Getting Help / Providing Feedback
73
+
74
+ Feel free to submit a GitHub issue, or post to the [Google Group](https://groups.google.com/group/mad-chatter), or send me a message on GitHub.
62
75
 
76
+ You can also vote on upcoming features: https://madchatter.uservoice.com
63
77
 
64
- ##Contributing
78
+ ## Contributing
65
79
 
66
80
  Please fork and send pull requests! Or submit issues if you have suggestions on how to improve.
67
81
 
68
- ##TODO
82
+ ## TODO
69
83
 
70
- - Add support for alternative web socket servers like Juggernaut, Socket.io, or Cramp and web-socket-js for better cross-browser support
84
+ - Maybe add support for alternative web socket servers like Juggernaut, Socket.io, or Cramp and web-socket-js
71
85
  - Add tests! (I'm new to this, so I need help)
72
86
 
73
87
  ##Copyright
74
88
 
75
- Copyright (c) 2011 Andrew Havens. See LICENSE.txt for further details.
89
+ Copyright (c) 2011-2012 Andrew Havens. MIT license. See LICENSE.txt for further details.
data/TODO.txt CHANGED
@@ -1,4 +1,4 @@
1
- Goal: to become an open-source version of https://www.hipchat.com/
1
+ Goal: to become an open-source version of https://www.hipchat.com/ or https://www.flowdock.com
2
2
 
3
3
  TODO:
4
4
 
@@ -26,7 +26,10 @@ module MadChatter
26
26
 
27
27
  def filter
28
28
  @filtered_text = MadChatter.markdown.render(@original_text)
29
- @filtered_text = /^<p>(.*)<\/p>$/.match(@filtered_text)[1] # remove the <p> tags that markdown wraps by default
29
+ # remove the <p> tags that markdown wraps by default
30
+ @filtered_text.sub!(/^<p>/, '')
31
+ @filtered_text.sub!(/<\/p>$/, '')
32
+ @filtered_text
30
33
  end
31
34
 
32
35
  end
@@ -1,5 +1,5 @@
1
1
  module MadChatter
2
2
 
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
 
5
5
  end
data/mad_chatter.gemspec CHANGED
@@ -23,7 +23,10 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency "em-websocket"
24
24
  s.add_runtime_dependency "redcarpet"
25
25
  s.add_runtime_dependency "daemons", "1.1.4"
26
-
26
+
27
27
  s.add_development_dependency "rspec"
28
28
  s.add_development_dependency "shoulda"
29
+ s.add_development_dependency 'guard'
30
+ s.add_development_dependency 'guard-rspec'
31
+ s.add_development_dependency 'simplecov'
29
32
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper' # see http://stackoverflow.com/q/5061179/314318
2
+
3
+ describe MadChatter::Message do
4
+ let (:message) { MadChatter::Message.new('joy', 'I am the model of the modern major general') }
5
+
6
+ it 'should have a well-known interface' do
7
+ [:text, :to_json, :filter].each do |m|
8
+ message.should respond_to(m)
9
+ end
10
+ end
11
+
12
+ it 'should encode into JSON correctly' do
13
+ message.to_json.should match /modern major general/
14
+ end
15
+
16
+ context '#filter' do
17
+ it 'should remove <p> tags' do
18
+ message.filter.should_not match /<[\s\\]*p[\s]*>/
19
+ end
20
+
21
+ it 'should be able to handle messages made of empty space' do
22
+ message = MadChatter::Message.new('message', " ")
23
+ message.filter.should match ''
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'mad_chatter'
5
+ require 'rspec/mocks'
6
+
7
+ # See http://rubydoc.info/gems/rspec-mocks/frames for more details on
8
+ # the API.
9
+ ## Don't like RSpec mocks? See: https://www.relishapp.com/rspec/rspec-core/docs/mock-framework-integration/mock-with-rspec
10
+ RSpec.configure do |config|
11
+ config.mock_framework = :rspec
12
+ end
13
+
14
+
@@ -19,4 +19,11 @@ end
19
19
 
20
20
  on_message %r{/alert (.*)} do |alert_message|
21
21
  send_action 'show_alert', alert_message
22
+ stop_message_handling
23
+ end
24
+
25
+ on_message %r{/earthquake} do
26
+ send_status_message 'Someone has just caused an earthquake!'
27
+ send_action 'earthquake'
28
+ stop_message_handling
22
29
  end
@@ -7,9 +7,17 @@
7
7
  <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js'></script>
8
8
  <script src='mad_chatter.js'></script>
9
9
  <script src='mad_chatter_actions.js'></script>
10
+
11
+ <!-- markItUp! -->
12
+ <script type="text/javascript" src="markitup/jquery.markitup.js"></script>
13
+ <script type="text/javascript" src="markitup/sets/markdown/set.js"></script>
14
+ <link rel="stylesheet" type="text/css" href="markitup/skins/mad_chatter/style.css" />
15
+ <link rel="stylesheet" type="text/css" href="markitup/sets/markdown/style.css" />
16
+
10
17
  <script>
11
18
  $(document).ready(function(){
12
19
  MadChatter.init('ws://localhost:8100');
20
+ $('#keyboard textarea').markItUp(mySettings);
13
21
  });
14
22
  </script>
15
23
  </head>
@@ -31,7 +39,8 @@
31
39
  <ul id="members"></ul>
32
40
  </div>
33
41
  <div id="keyboard">
34
- <input type="text">
42
+ <!-- <input type="text"> -->
43
+ <textarea></textarea>
35
44
  </div>
36
45
  <div id="messages"></div>
37
46
  </div>
@@ -37,10 +37,10 @@ var MadChatter = {
37
37
  },
38
38
 
39
39
  wait_for_chat_submit: function(){
40
- var keyboard = $("#keyboard input");
40
+ var keyboard = $("#keyboard textarea");
41
41
  keyboard.keyup(function (event) {
42
42
  if (event.keyCode == 13) { // The enter key.
43
- MadChatter.send_message(keyboard.val());
43
+ MadChatter.send_message(keyboard.val());
44
44
  keyboard.val('');
45
45
  }
46
46
  });
@@ -1,4 +1,19 @@
1
1
  // This function is called when '/alert' is sent in a chat message
2
2
  function show_alert(message) {
3
3
  alert(message);
4
+ }
5
+
6
+ // This function is called when '/earthquake' is sent as a chat message
7
+ function earthquake() {
8
+ var n = 4;
9
+ if (parent.moveBy) {
10
+ for (i = 10; i > 0; i--) {
11
+ for (j = n; j > 0; j--) {
12
+ parent.moveBy(0, i);
13
+ parent.moveBy(i, 0);
14
+ parent.moveBy(0, -i);
15
+ parent.moveBy(-i, 0);
16
+ }
17
+ }
18
+ }
4
19
  }