chatroom 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/chatroom/marks.js +8 -1
  3. data/app/assets/javascripts/chatroom/messages.js.coffee +20 -2
  4. data/app/assets/stylesheets/chatroom/messages.css.scss +9 -0
  5. data/app/controllers/chatroom/messages_controller.rb +13 -1
  6. data/app/views/chatroom/messages/create.js.erb +11 -1
  7. data/lib/chatroom/version.rb +1 -1
  8. data/lib/generators/chatroom/orm_helpers.rb +11 -2
  9. metadata +2 -47
  10. data/app/assets/images/emotions/100.gif +0 -0
  11. data/app/assets/images/emotions/101.gif +0 -0
  12. data/app/assets/images/emotions/102.gif +0 -0
  13. data/app/assets/images/emotions/103.gif +0 -0
  14. data/app/assets/images/emotions/104.gif +0 -0
  15. data/app/assets/images/emotions/105.gif +0 -0
  16. data/app/assets/images/emotions/106.gif +0 -0
  17. data/app/assets/images/emotions/107.gif +0 -0
  18. data/app/assets/images/emotions/108.gif +0 -0
  19. data/app/assets/images/emotions/109.gif +0 -0
  20. data/app/assets/images/emotions/110.gif +0 -0
  21. data/app/assets/images/emotions/111.gif +0 -0
  22. data/app/assets/images/emotions/112.gif +0 -0
  23. data/app/assets/images/emotions/113.gif +0 -0
  24. data/app/assets/images/emotions/114.gif +0 -0
  25. data/app/assets/images/emotions/115.gif +0 -0
  26. data/app/assets/images/emotions/116.gif +0 -0
  27. data/app/assets/images/emotions/117.gif +0 -0
  28. data/app/assets/images/emotions/118.gif +0 -0
  29. data/app/assets/images/emotions/119.gif +0 -0
  30. data/app/assets/images/emotions/120.gif +0 -0
  31. data/app/assets/images/emotions/121.gif +0 -0
  32. data/app/assets/images/emotions/122.gif +0 -0
  33. data/app/assets/images/emotions/123.gif +0 -0
  34. data/app/assets/images/emotions/124.gif +0 -0
  35. data/app/assets/images/emotions/125.gif +0 -0
  36. data/app/assets/images/emotions/126.gif +0 -0
  37. data/app/assets/images/emotions/127.gif +0 -0
  38. data/app/assets/images/emotions/128.gif +0 -0
  39. data/app/assets/images/emotions/129.gif +0 -0
  40. data/app/assets/images/emotions/130.gif +0 -0
  41. data/app/assets/images/emotions/131.gif +0 -0
  42. data/app/assets/images/emotions/132.gif +0 -0
  43. data/app/assets/images/emotions/133.gif +0 -0
  44. data/app/assets/images/emotions/134.gif +0 -0
  45. data/app/assets/images/emotions/90.gif +0 -0
  46. data/app/assets/images/emotions/91.gif +0 -0
  47. data/app/assets/images/emotions/92.gif +0 -0
  48. data/app/assets/images/emotions/93.gif +0 -0
  49. data/app/assets/images/emotions/94.gif +0 -0
  50. data/app/assets/images/emotions/95.gif +0 -0
  51. data/app/assets/images/emotions/96.gif +0 -0
  52. data/app/assets/images/emotions/97.gif +0 -0
  53. data/app/assets/images/emotions/98.gif +0 -0
  54. data/app/assets/images/emotions/99.gif +0 -0
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDlhYWNiOTIxODA5MGU5Mjc1ZmE5ZWI5ZmVlNmQzOWFmOWMwM2M1NQ==
4
+ ZTUyOWQ0OWVjZDBmMzUwNDYwY2Y2NTk1OTRiMzBhYWQxNTQxODVlOQ==
5
5
  data.tar.gz: !binary |-
6
- ZGRjOWIzMDMwYjI3NGI5NzIwZWNhNDljYjJkMmFlYWM1NmRhMGU0Yg==
6
+ NTY3ZWQ2NjY5OWZhZGFlNGZlZDYyNmUyYmYxNzFjODQ0MWZjMDIwOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ODQ0YTU0ZGM5OWM5OGFkNjM0Y2U4YWQzY2RmZjBiZGY5OTAxZDkxN2EyMzdi
10
- NTQxMTNkNzY3MDdlNTk4YzVkM2FiNDBlNjJiM2Q0OGU0MzZhNjhhOWUyMmU5
11
- YjdjZjhiMTkzNzFhMjg0MThlNTAwYWViYjVkZmEwNzEwMTMyYmQ=
9
+ NGMxYzI2Mjc5MDg2ZTYwNWY3MDBmMDQxMzM3Y2M2ZTA3YzJjZjA4NjE1ZTZm
10
+ N2FlNWJlNTVjMjA5Y2JhMmE1ZGExOTA1YzQ2Nzc3NThjYmRjNjM2YjkyMzA0
11
+ NThlNTc2N2FiNzBkNTM1YjgxNTA2YmZiYWVhYjNkYmY1OGY0N2Q=
12
12
  data.tar.gz: !binary |-
13
- YjEwMTZlNzAxODgyY2U2ZWE1MGM3ZWM4MjA4Mzk3NjQzZTJhYzE5ODNmZmIz
14
- NzY0YWJiN2E1NWZlODc4ZTBjNDY2N2VmNzhjNDUxOWYyOTM1NDgzZDNmYjAx
15
- Mzk2ZTdjYmU5ODc1NzZhODQxMTQzZmQ1YjhmYTA2Zjc1OWE1YzM=
13
+ ZTM3ODgzZDQ1OWEwZjkzZDgwOTBiZmQ2ZDJiYTViZGQwOGY4NWM5ODc1MDQ1
14
+ M2IyMjEyMDc1NjVlN2Q5MGI0ZTVhMWVlNGZkNjc4NDhmNDVhMjhmNGI3OTY0
15
+ MGNjMWNmYTYzMDdhMjlhYTcwN2Q4MzI0YjdlMjZmZmJlNjM4ODU=
@@ -13,7 +13,14 @@ function convertTagToMark(str) {
13
13
  "nap", "big_cry", "awkward_red", "angry", "naughty", "snag", "surprise", "bad",
14
14
  "cool", "awkward", "scream", "vomit", "giggle", "lovely", "who_cares", "zhuai",
15
15
  "hungry", "sleepy", "scared", "sweat", "simper", "solider", "strive", "shout",
16
- "questionaire", "hiss", "dizzy", "impantient", "be_bombed", "skull", "hit_head", "bye"
16
+ "questionaire", "hiss", "dizzy", "impantient", "be_bombed", "skull", "hit_head", "bye",
17
+ "sweat", "pick_nose", "applause", "embarrassed", "cheeky_grin", "not_worth_left", "not_worth_right", "yawn",
18
+ "contempt", "grievance", "sad", "sinister_smile", "kiss", "startle", "pitiful", "chopper",
19
+ "watermelon", "beer", "basketball", "pingpong", "coffee", "rice", "pig", "flower",
20
+ "wither", "love", "heart", "borken_heart", "cake", "light", "bomb", "sword",
21
+ "football", "insect", "shit", "moon", "sun", "gift", "hug", "good",
22
+ "Lously", "agree", "Yeal", "greet", "come", "fist", "little_finger",
23
+ "love_you", "no", "ok"
17
24
  ];
18
25
  var s = "";
19
26
 
@@ -11,6 +11,9 @@ window.Messages =
11
11
 
12
12
  maxChatroom: () ->
13
13
  $("#chatBeam").hide()
14
+ flash = $("#chatBeam .max-chatroom").attr("interval")
15
+ $("#chatBeam .max-chatroom").attr("interval", null)
16
+ clearInterval(flash)
14
17
  $("#chatroom").slideToggle()
15
18
  false
16
19
 
@@ -43,9 +46,13 @@ window.Messages =
43
46
  # Editor: show all the emotions for selecting
44
47
  constructEmotions: () ->
45
48
  table = $("table.chatroom-emotions-images tbody")
49
+ page = $("<div><span class='emotions-page' style='float: left;'><</span><span class='emotions-page' style='float:right;'>></span></div>")
46
50
  if !table.has("span").length
47
- for i in [0...5]
48
- row = $("<tr></tr>")
51
+ for i in [0...10]
52
+ if i < 5
53
+ row = $("<tr></tr>")
54
+ else
55
+ row = $("<tr style='display:none;'></tr>")
49
56
  for j in [0...8]
50
57
  n = i * 8 + j
51
58
  img = $("<span></span>").addClass("emotion-img")
@@ -55,6 +62,17 @@ window.Messages =
55
62
  cell = $("<td></td>").addClass("chat-cell").append(img)
56
63
  row.append(cell)
57
64
  table.append(row)
65
+ table.append(page)
66
+ Messages.emotionsPageTurning()
67
+ false
68
+
69
+ emotionsPageTurning: () ->
70
+ $("span.emotions-page").click ->
71
+ if $(this).html() == "&lt;"
72
+ $("table.chatroom-emotions-images tbody tr").toggle()
73
+ else if $(this).html() == "&gt;"
74
+ $("table.chatroom-emotions-images tbody tr").toggle()
75
+ false
58
76
  false
59
77
 
60
78
  displayAllEmotions: () ->
@@ -242,6 +242,15 @@ table.chatroom-emotions-images {
242
242
  }
243
243
  }
244
244
  }
245
+ div {
246
+ span.emotions-page {
247
+ &:hover {
248
+ color: red;
249
+ border: 1px solid $blueSea;
250
+ }
251
+ color: $blueSea;
252
+ }
253
+ }
245
254
  }
246
255
  }
247
256
 
@@ -8,7 +8,9 @@ module Chatroom
8
8
  # POST /messages
9
9
  # POST /messages.json
10
10
  def create
11
- @message = Message.create!(message_params)
11
+ message = message_params
12
+ message[:content] = prevent_script(message[:content])
13
+ @message = Message.create!(message)
12
14
  end
13
15
 
14
16
  private
@@ -16,5 +18,15 @@ module Chatroom
16
18
  def message_params
17
19
  params.require(:message).permit(:content)
18
20
  end
21
+
22
+ def prevent_script(text)
23
+ txt = text.gsub(/<(\s*)([^\d\W\s]+)(\s*)([;\-\w="'\s:\/\.]+)>/) do |s|
24
+ "\\<#{$1}#{$2}#{$3}#{$4}\>"
25
+ end
26
+ txt = txt.gsub(/<\/(\s*)([^\d\W\s]+)(\s*)([;\-\w="'\s:\/\.]+)>/) do |s|
27
+ "\\</#{$1}#{$2}#{$3}#{$4}>"
28
+ end
29
+ return txt
30
+ end
19
31
  end
20
32
  end
@@ -1,6 +1,16 @@
1
1
  <% publish_to "/messages/new" do %>
2
2
  $("#chat").append("<%= escape_javascript new_communication(@message).html_safe %>");
3
+
4
+ if($("#chatBeam").css("display") != "none") {
5
+ if ($(".max-chatroom").attr("interval") == null ) {
6
+ var flash = setInterval(function() { $(".max-chatroom").fadeOut(100).fadeIn(100)}, 300);
7
+ $(".max-chatroom").attr("interval", flash)
8
+ }
9
+ } else {
10
+ $(".max-chatroom").attr("interval", null)
11
+ }
12
+
13
+ $("#chat").animate({scrollTop: $("#chat")[0].scrollHeight}, 100);
3
14
  <% end %>
4
- $("#chat").animate({scrollTop: $("#chat")[0].scrollHeight}, 100);
5
15
 
6
16
  $("#new_message_content").val('');
@@ -1,3 +1,3 @@
1
1
  module Chatroom
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -11,7 +11,14 @@ module Chatroom
11
11
  "nap", "big_cry", "awkward_red", "angry", "naughty", "snag", "surprise", "bad",
12
12
  "cool", "awkward", "scream", "vomit", "giggle", "lovely", "who_cares", "zhuai",
13
13
  "hungry", "sleepy", "scared", "sweat", "simper", "solider", "strive", "shout",
14
- "questionaire", "hiss", "dizzy", "impantient", "be_bombed", "skull", "hit_head", "bye"
14
+ "questionaire", "hiss", "dizzy", "impantient", "be_bombed", "skull", "hit_head", "bye",
15
+ "sweat", "pick_nose", "applause", "embarrassed", "cheeky_grin", "not_worth_left", "not_worth_right", "yawn",
16
+ "contempt", "grievance", "sad", "sinister_smile", "kiss", "startle", "pitiful", "chopper",
17
+ "watermelon", "beer", "basketball", "pingpong", "coffee", "rice", "pig", "flower",
18
+ "wither", "love", "heart", "borken_heart", "cake", "light", "bomb", "sword",
19
+ "football", "insect", "shit", "moon", "sun", "gift", "hug", "good",
20
+ "Lously", "agree", "Yeal", "greet", "come", "fist", "little_finger",
21
+ "love_you", "no", "ok"
15
22
  ]
16
23
 
17
24
  # The created time of the message
@@ -22,7 +29,9 @@ module Chatroom
22
29
  # convert the marks to html tags
23
30
  def html_content
24
31
  return "" if content.blank?
25
- str = content.gsub(/\\r\\n/, "<br/>")
32
+ str = content.gsub(/<(\\s*)(\\w+)(\\s*)>/){ |s| "<\\\#{$1}#{$2}#{$3}>" }
33
+ str = str.gsub(/<\\/(\\s*)(\\w+)(\\s*)>/){ |s| "<\\\/#{$1}#{$2}#{$3}>" }
34
+ str = str.gsub(/\\r\\n/, "<br/>")
26
35
  str = str.gsub(/(\\s)/, "&nbsp;")
27
36
  str = str.gsub(/\\[bold\\]/, "<b>")
28
37
  str = str.gsub(/\\[-bold\\]/, "</b>")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chatroom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TsaiKoga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-29 00:00:00.000000000 Z
11
+ date: 2013-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,44 +96,9 @@ files:
96
96
  - app/assets/images/emotions/0.gif
97
97
  - app/assets/images/emotions/1.gif
98
98
  - app/assets/images/emotions/10.gif
99
- - app/assets/images/emotions/100.gif
100
- - app/assets/images/emotions/101.gif
101
- - app/assets/images/emotions/102.gif
102
- - app/assets/images/emotions/103.gif
103
- - app/assets/images/emotions/104.gif
104
- - app/assets/images/emotions/105.gif
105
- - app/assets/images/emotions/106.gif
106
- - app/assets/images/emotions/107.gif
107
- - app/assets/images/emotions/108.gif
108
- - app/assets/images/emotions/109.gif
109
99
  - app/assets/images/emotions/11.gif
110
- - app/assets/images/emotions/110.gif
111
- - app/assets/images/emotions/111.gif
112
- - app/assets/images/emotions/112.gif
113
- - app/assets/images/emotions/113.gif
114
- - app/assets/images/emotions/114.gif
115
- - app/assets/images/emotions/115.gif
116
- - app/assets/images/emotions/116.gif
117
- - app/assets/images/emotions/117.gif
118
- - app/assets/images/emotions/118.gif
119
- - app/assets/images/emotions/119.gif
120
100
  - app/assets/images/emotions/12.gif
121
- - app/assets/images/emotions/120.gif
122
- - app/assets/images/emotions/121.gif
123
- - app/assets/images/emotions/122.gif
124
- - app/assets/images/emotions/123.gif
125
- - app/assets/images/emotions/124.gif
126
- - app/assets/images/emotions/125.gif
127
- - app/assets/images/emotions/126.gif
128
- - app/assets/images/emotions/127.gif
129
- - app/assets/images/emotions/128.gif
130
- - app/assets/images/emotions/129.gif
131
101
  - app/assets/images/emotions/13.gif
132
- - app/assets/images/emotions/130.gif
133
- - app/assets/images/emotions/131.gif
134
- - app/assets/images/emotions/132.gif
135
- - app/assets/images/emotions/133.gif
136
- - app/assets/images/emotions/134.gif
137
102
  - app/assets/images/emotions/14.gif
138
103
  - app/assets/images/emotions/15.gif
139
104
  - app/assets/images/emotions/16.gif
@@ -218,16 +183,6 @@ files:
218
183
  - app/assets/images/emotions/88.gif
219
184
  - app/assets/images/emotions/89.gif
220
185
  - app/assets/images/emotions/9.gif
221
- - app/assets/images/emotions/90.gif
222
- - app/assets/images/emotions/91.gif
223
- - app/assets/images/emotions/92.gif
224
- - app/assets/images/emotions/93.gif
225
- - app/assets/images/emotions/94.gif
226
- - app/assets/images/emotions/95.gif
227
- - app/assets/images/emotions/96.gif
228
- - app/assets/images/emotions/97.gif
229
- - app/assets/images/emotions/98.gif
230
- - app/assets/images/emotions/99.gif
231
186
  - app/assets/images/emotions/static.gif
232
187
  - app/assets/javascripts/chatroom/marks.js
233
188
  - app/assets/javascripts/chatroom/messages.js.coffee
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file