4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/generators/chatroom/orm_helpers.rb', line 4
def model_contents
buffer = " # validates\n validates :content, :presence => true, :length => { :maximum => 250 }\n\n EMOTIONS = [\n\"smile\", \"despressed\", \"like\", \"dull\", \"proud\", \"cry\", \"shy\", \"shut_up\",\n\"nap\", \"big_cry\", \"awkward_red\", \"angry\", \"naughty\", \"snag\", \"surprise\", \"bad\",\n\"cool\", \"awkward\", \"scream\", \"vomit\", \"giggle\", \"lovely\", \"who_cares\", \"zhuai\",\n\"hungry\", \"sleepy\", \"scared\", \"sweat\", \"simper\", \"solider\", \"strive\", \"shout\",\n\"questionaire\", \"hiss\", \"dizzy\", \"impantient\", \"be_bombed\", \"skull\", \"hit_head\", \"bye\",\n\"sweat\", \"pick_nose\", \"applause\", \"embarrassed\", \"cheeky_grin\", \"not_worth_left\", \"not_worth_right\", \"yawn\", \n\"contempt\", \"grievance\", \"sad\", \"sinister_smile\", \"kiss\", \"startle\", \"pitiful\", \"chopper\",\n\"watermelon\", \"beer\", \"basketball\", \"pingpong\", \"coffee\", \"rice\", \"pig\", \"flower\",\n\"wither\", \"love\", \"heart\", \"borken_heart\", \"cake\", \"light\", \"bomb\", \"sword\", \n\"football\", \"insect\", \"shit\", \"moon\", \"sun\", \"gift\", \"hug\", \"good\", \n\"Lously\", \"agree\", \"Yeal\", \"greet\", \"come\", \"fist\", \"little_finger\",\n\"love_you\", \"no\", \"ok\"\n ]\n \n # The created time of the message\n def send_time\n self.created_at.strftime(\"%Y-%m-%d %H:%M:%d\")\n end\n\n # convert the marks to html tags\n def html_content\nreturn \"\" if content.blank? \nstr = content.gsub(/<(\\\\s*)(\\\\w+)(\\\\s*)>/){ |s| \"<\\\\\\\#{$1}\#{$2}\#{$3}>\" }\nstr = str.gsub(/<\\\\/(\\\\s*)(\\\\w+)(\\\\s*)>/){ |s| \"<\\\\\\/\#{$1}\#{$2}\#{$3}>\" }\nstr = str.gsub(/\\\\r\\\\n/, \"<br/>\") \nstr = str.gsub(/(\\\\s)/, \" \")\nstr = str.gsub(/\\\\[bold\\\\]/, \"<b>\")\nstr = str.gsub(/\\\\[-bold\\\\]/, \"</b>\")\nstr = str.gsub(/\\\\[italic\\\\]/, \"<i>\")\nstr = str.gsub(/\\\\[-italic\\\\]/, \"</i>\")\nstr = str.gsub(/\\\\[color:(#.{6})\\\\]/){ |s| \"<span style=\\\\\"color:\\\#{$1}\\\\\">\" }\nstr = str.gsub(/\\\\[-color\\\\]/, \"</span>\")\nstr = str.gsub(/\\\\[(\\\\w+)\\\\]/) do |s|\n emotion = EMOTIONS.index($1)\n emotion.nil? ? \"[\\\#{$1}]\": \"<img src=\\\\\"/assets/emotions/\\\#{emotion}.gif\\\\\" />\" \nend\nreturn str\n end\n CONTENT\n buffer\nend\n"
|