BrightSide Workbench Full Report + Source Code
Emoticons.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.elephant.impl.util;
19 
20 import org.turro.elephant.context.ElephantContext;
21 import org.turro.elephant.context.IConstructor;
22 
27 public class Emoticons {
28  public static final String
29  INIT_EXP = "(\\t|\\r|\\n| |^)",
30  END_EXP = "(\\t|\\r|\\n| |$)";
31 
33  private Emoticons() {
34  }
35 
36  public static String replaceEmoticons(IConstructor constructor, String text) {
37  String emoticonsRoot = ElephantContext.getRootWebPath() + "/_internal/emoticons/";
38  text = text.replaceAll(INIT_EXP + "\\:\\-?\\)" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "smile.gif\"/>$2");
39  text = text.replaceAll(INIT_EXP + "\\:\\-?D" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "big_smile.gif\"/>$2");
40  text = text.replaceAll(INIT_EXP + "\\;\\-?\\)" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "winking.gif\"/>$2");
41  text = text.replaceAll(INIT_EXP + "\\;\\-?D" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "big_winking.gif\"/>$2");
42  text = text.replaceAll(INIT_EXP + "\\:\\-?\\(" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "sad.gif\"/>$2");
43  text = text.replaceAll(INIT_EXP + "\\:\\-?\\/" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "humm.gif\"/>$2");
44  text = text.replaceAll(INIT_EXP + "8\\-?\\|" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "sun_glasses.gif\"/>$2");
45  text = text.replaceAll(INIT_EXP + "\\:\\-?o" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "puzzled.gif\"/>$2");
46  text = text.replaceAll(INIT_EXP + "\\:\\-?\\|" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "frozen.gif\"/>$2");
47  text = text.replaceAll(INIT_EXP + "\\:\\-?\\," + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "unaware.gif\"/>$2");
48  text = text.replaceAll(INIT_EXP + "\\|\\-\\|" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "sleeping.gif\"/>$2");
49  text = text.replaceAll(INIT_EXP + "\\:\\-?s" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "dizzy.gif\"/>$2");
50  text = text.replaceAll(INIT_EXP + "\\(\\>\\)" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "watch.gif\"/>$2");
51  text = text.replaceAll(INIT_EXP + "\\:8\\)" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "ashamed.gif\"/>$2");
52  text = text.replaceAll(INIT_EXP + "\\:\\-?b" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "dummy.gif\"/>$2");
53  text = text.replaceAll(INIT_EXP + "\\:\\-?\\#" + END_EXP, "$1<img border=\"0\" src=\"" + emoticonsRoot + "angry.gif\"/>$2");
54  return text;
55  }
56 
57  public static String showEmoticons(IConstructor constructor) {
58  String emoticonsRoot = constructor.getRequest().getContextPath() + "/_internal/emoticons/";
59  return
60  "<style type=\"text/css\">\n" +
61  "<!--\n" +
62  "SPAN.emoticon {\n" +
63  "border:1px solid gray;\n" +
64  "}\n" +
65  "-->\n" +
66  "</style>\n" +
67  "<span class=\"emoticon\">:-) :) <img src=\"" + emoticonsRoot + "smile.gif\"/></span>\n" +
68  "<span class=\"emoticon\">:D :-D <img src=\"" + emoticonsRoot + "big_smile.gif\"/></span>\n" +
69  "<span class=\"emoticon\">;-) ;) <img src=\"" + emoticonsRoot + "winking.gif\"/></span>\n" +
70  "<span class=\"emoticon\">;-D ;D <img src=\"" + emoticonsRoot + "big_winking.gif\"/></span>\n" +
71  "<span class=\"emoticon\">:-( :( <img src=\"" + emoticonsRoot + "sad.gif\"/></span>\n" +
72  "<span class=\"emoticon\">:-/ :/ <img src=\"" + emoticonsRoot + "humm.gif\"/></span>\n" +
73  "<span class=\"emoticon\">8| 8-| <img src=\"" + emoticonsRoot + "sun_glasses.gif\"/></span>\n" +
74  "<span class=\"emoticon\">:-o :o <img src=\"" + emoticonsRoot + "puzzled.gif\"/></span>\n" +
75  "<span class=\"emoticon\">:| :-| <img src=\"" + emoticonsRoot + "frozen.gif\"/></span>\n" +
76  "<span class=\"emoticon\">:-, :, <img src=\"" + emoticonsRoot + "unaware.gif\"/></span>\n" +
77  "<span class=\"emoticon\">|-| <img src=\"" + emoticonsRoot + "sleeping.gif\"/></span>\n" +
78  "<span class=\"emoticon\">:-s :s <img src=\"" + emoticonsRoot + "dizzy.gif\"/></span>\n" +
79  "<span class=\"emoticon\">(>) <img src=\"" + emoticonsRoot + "watch.gif\"/></span>\n" +
80  "<span class=\"emoticon\">:8) <img src=\"" + emoticonsRoot + "ashamed.gif\"/></span>\n" +
81  "<span class=\"emoticon\">:-b :b <img src=\"" + emoticonsRoot + "dummy.gif\"/></span>\n" +
82  "<span class=\"emoticon\">:-# :# <img src=\"" + emoticonsRoot + "angry.gif\"/></span>\n" +
83  "";
84  }
85 }
static String showEmoticons(IConstructor constructor)
Definition: Emoticons.java:57
static String replaceEmoticons(IConstructor constructor, String text)
Definition: Emoticons.java:36