From 8a745717e155450299f678560100ae66b5e86fb7 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Tue, 27 Jul 2004 04:53:30 +0000 Subject: [PATCH] initial support for the "emoticons" or "smileys" - defined the config file here so we can change over all the custom venice-config.xml and ui-config.xml files before going any further --- etc/emoticon.xml | 79 +++++++++++++ etc/ui-config.xml | 3 + etc/venice-config.xml | 3 + .../silverwrist/util/DOMElementHelper.java | 2 - .../venice/core/internals/GlobalSiteImpl.java | 9 +- .../htmlcheck/filters/EmoticonRewriter.java | 111 ++++++++++++++++++ .../venice/ui/config/EmoticonManager.java | 109 +++++++++++++++++ .../venice/ui/config/RootConfig.java | 20 ++++ web/images/emote/ei_biggrin.gif | Bin 0 -> 152 bytes web/images/emote/ei_confused.gif | Bin 0 -> 110 bytes web/images/emote/ei_cool.gif | Bin 0 -> 124 bytes web/images/emote/ei_eek.gif | Bin 0 -> 1264 bytes web/images/emote/ei_frown.gif | Bin 0 -> 94 bytes web/images/emote/ei_mad.gif | Bin 0 -> 154 bytes web/images/emote/ei_redface.gif | Bin 0 -> 136 bytes web/images/emote/ei_rolleyes.gif | Bin 0 -> 1784 bytes web/images/emote/ei_smile.gif | Bin 0 -> 93 bytes web/images/emote/ei_tongue.gif | Bin 0 -> 338 bytes web/images/emote/ei_wink.gif | Bin 0 -> 135 bytes 19 files changed, 333 insertions(+), 3 deletions(-) create mode 100644 etc/emoticon.xml create mode 100644 src/com/silverwrist/venice/htmlcheck/filters/EmoticonRewriter.java create mode 100644 src/com/silverwrist/venice/ui/config/EmoticonManager.java create mode 100644 web/images/emote/ei_biggrin.gif create mode 100644 web/images/emote/ei_confused.gif create mode 100644 web/images/emote/ei_cool.gif create mode 100644 web/images/emote/ei_eek.gif create mode 100644 web/images/emote/ei_frown.gif create mode 100644 web/images/emote/ei_mad.gif create mode 100644 web/images/emote/ei_redface.gif create mode 100644 web/images/emote/ei_rolleyes.gif create mode 100644 web/images/emote/ei_smile.gif create mode 100644 web/images/emote/ei_tongue.gif create mode 100644 web/images/emote/ei_wink.gif diff --git a/etc/emoticon.xml b/etc/emoticon.xml new file mode 100644 index 0000000..e23edf2 --- /dev/null +++ b/etc/emoticon.xml @@ -0,0 +1,79 @@ + + + + + :; + + :) + emote/ei_smile.gif + Smile! + + + :( + emote/ei_frown.gif + frown... + + + :o + :O + emote/ei_redface.gif + Boy, is my face red! + + + :D + emote/ei_biggrin.gif + Grinnin'... + + + ;) + emote/ei_wink.gif + Wink wink, nudge nudge + + + :p + :P + emote/ei_tongue.gif + Bleah! + + + :cool: + emote/ei_cool.gif + Cool! + + + :rolleyes: + emote/ei_rolleyes.gif + Rolling my eyes + + + :mad: + emote/ei_mad.gif + I'm mad! + + + :eek: + emote/ei_eek.gif + EEK! + + + :confused: + emote/ei_confused.gif + Huh??? + + diff --git a/etc/ui-config.xml b/etc/ui-config.xml index 28357d3..76e12c2 100644 --- a/etc/ui-config.xml +++ b/etc/ui-config.xml @@ -25,6 +25,9 @@ WEB-INF/services-config.xml + + WEB-INF/emoticon.xml + WEB-INF/scripts diff --git a/etc/venice-config.xml b/etc/venice-config.xml index f77b5cf..3b2f45b 100644 --- a/etc/venice-config.xml +++ b/etc/venice-config.xml @@ -30,6 +30,9 @@ WEB-INF/services-config.xml + + WEB-INF/emoticon.xml + diff --git a/src/com/silverwrist/util/DOMElementHelper.java b/src/com/silverwrist/util/DOMElementHelper.java index bb787a4..fce632b 100644 --- a/src/com/silverwrist/util/DOMElementHelper.java +++ b/src/com/silverwrist/util/DOMElementHelper.java @@ -293,5 +293,3 @@ public final class DOMElementHelper } // end getAttributeBoolean } // end DOMElementHelper - - diff --git a/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java b/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java index 6bb9cc5..00f0e1e 100644 --- a/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java +++ b/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java @@ -143,9 +143,14 @@ public class GlobalSiteImpl implements GlobalSite // Get the section. DOMElementHelper config_h = new DOMElementHelper(config); - Element sect = loader.configGetSubSection(config_h,"database"); + Element sect = loader.configGetSubSection(config_h,"engine"); DOMElementHelper sect_h = new DOMElementHelper(sect); + // Get the name of the emoticons configuration file. + String emoticon_config = loader.configGetSubElementText(sect_h,"emoticon-config"); + if (!(emoticon_config.startsWith("/"))) + emoticon_config = application_root + emoticon_config; + // Get the value. String s = sect_h.getSubElementText("privileged-addresses"); if (!(StringUtil.isStringEmpty(s))) @@ -225,6 +230,8 @@ public class GlobalSiteImpl implements GlobalSite intermediate_map.put(postlink_rewriter.getClass().getName(),postlink_rewriter); UserNameRewriter username_rewriter = new UserNameRewriter(this); intermediate_map.put(username_rewriter.getClass().getName(),username_rewriter); + EmoticonRewriter emoticon_rewriter = new EmoticonRewriter(emoticon_config); + intermediate_map.put(emoticon_rewriter.getClass().getName(),emoticon_rewriter); // Get the section. sect = loader.configGetSubSection(config_h,"html-checker"); diff --git a/src/com/silverwrist/venice/htmlcheck/filters/EmoticonRewriter.java b/src/com/silverwrist/venice/htmlcheck/filters/EmoticonRewriter.java new file mode 100644 index 0000000..132856a --- /dev/null +++ b/src/com/silverwrist/venice/htmlcheck/filters/EmoticonRewriter.java @@ -0,0 +1,111 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Community System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.htmlcheck.filters; + +import java.util.*; +import org.w3c.dom.*; +import com.silverwrist.util.*; +import com.silverwrist.venice.except.*; +import com.silverwrist.venice.htmlcheck.Rewriter; +import com.silverwrist.venice.htmlcheck.RewriterServices; +import com.silverwrist.venice.htmlcheck.MarkupData; +import com.silverwrist.venice.util.XMLLoader; + +public class EmoticonRewriter implements Rewriter +{ + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private String m_prefixchars; + private Map m_patmap; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + public EmoticonRewriter(String config_file) throws ConfigException + { + // Load the configuration file. + XMLLoader loader = XMLLoader.get(); + Document config = loader.loadConfigDocument(config_file); + Element root = loader.configGetRootElement(config,"emoticon-config"); + + // Get the set of prefix characters. + m_prefixchars = loader.configGetSubElementText(root,"prefix-chars"); + + HashMap tmp = new HashMap(); + + // Look for all associated icons. + NodeList nl = root.getChildNodes(); + for (int i=0; i elements + Node n2 = nl2.item(i); + if ((n2.getNodeType()==Node.ELEMENT_NODE) && n2.getNodeName().equals("pattern")) + { // get the element text + DOMElementHelper h = new DOMElementHelper((Element)n2); + String pattern = h.getElementText(); + if (m_prefixchars.indexOf(pattern.charAt(0))>=0) + tmp.put(pattern,icon_name); + + } // end if + // else skip this element + + } // end for + + } // end if + // else skip this element + + } // end for + + if (tmp.isEmpty()) + m_patmap = Collections.EMPTY_MAP; + else + m_patmap = Collections.unmodifiableMap(tmp); + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Implementations from interface Rewriter + *-------------------------------------------------------------------------------- + */ + + public String getName() + { + return "emoticon"; + + } // end getName + + public MarkupData rewrite(String data, RewriterServices svc) + { + return null; + + } // end rewrite + +} // end class EmoticonRewriter diff --git a/src/com/silverwrist/venice/ui/config/EmoticonManager.java b/src/com/silverwrist/venice/ui/config/EmoticonManager.java new file mode 100644 index 0000000..d8bbe96 --- /dev/null +++ b/src/com/silverwrist/venice/ui/config/EmoticonManager.java @@ -0,0 +1,109 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.ui.config; + +import java.util.*; +import org.w3c.dom.*; +import com.silverwrist.util.*; +import com.silverwrist.venice.except.*; +import com.silverwrist.venice.util.XMLLoader; + +public class EmoticonManager +{ + /*-------------------------------------------------------------------------------- + * Internal class that contains the icon data. + *-------------------------------------------------------------------------------- + */ + + private static class IconDefinition + { + /*==================================================================== + * Attributes + *==================================================================== + */ + + private int m_width; + private int m_height; + private boolean m_fixup; + private String m_path; + private String m_text; + + /*==================================================================== + * Constructor + *==================================================================== + */ + + IconDefinition(Element icon_elt) throws ConfigException + { + XMLLoader loader = XMLLoader.get(); + DOMElementHelper h = new DOMElementHelper(icon_elt); + + // Get the icon image data. + Element img_elt = loader.configGetSubSection(h,"image"); + m_width = loader.configGetAttributeInt(img_elt,"width"); + m_height = loader.configGetAttributeInt(img_elt,"height"); + DOMElementHelper h2 = new DOMElementHelper(img_elt); + m_fixup = h2.getAttributeBoolean("fixup",false).booleanValue(); + m_path = h2.getElementText(); + + // Get the text data. + m_text = h.getSubElementText("text"); + + } // end constructor + + } // end class IconDefinition + + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private Map m_iconmap; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + EmoticonManager(Element config) throws ConfigException + { + XMLLoader loader = XMLLoader.get(); + HashMap tmp = new HashMap(); + NodeList nl = config.getChildNodes(); + for (int i=0; ip8*Ld{$$}~U|?j>0f~XsI&j1?Fms4_ zEJ!%m$igbXz>uKm+|DAx)*%tN(6yU|EzBe$puweA&bjN1MWEvG$s*o*B{w!abZ=1? tJhVpQlY+-&Q}byeCykdMYUhdG^@hVx!=+O?vaH5(;xhNyj7&@n)&Qe>Eu;Vd literal 0 HcmV?d00001 diff --git a/web/images/emote/ei_confused.gif b/web/images/emote/ei_confused.gif new file mode 100644 index 0000000000000000000000000000000000000000..684b51c98545b827ab9828472b757eb4c35bfef2 GIT binary patch literal 110 zcmZ?wbhEHbCMz|5cn;)CQJnC$PQwC&VkT$rJM>-MC3 zre}V5@=eo>3d?&{xYgr&)cTgr9cWgFjxZs<@F?4 literal 0 HcmV?d00001 diff --git a/web/images/emote/ei_eek.gif b/web/images/emote/ei_eek.gif new file mode 100644 index 0000000000000000000000000000000000000000..43cf2125e64d3d306fd2a60fb425c2e4b8cda9cc GIT binary patch literal 1264 zcmZ?wbhEHb79a*vAp;NmU zYmJCOg2UlSa?W`^JB1dXnkE@4HD$)eWUrZ``Bgp^LMey3*s}R}II!6ehSvtGEgA`l z?yY=`3>_X0OI-U|*mx9Heo}GomyIvlqamnvwoNi!YRyW)#7^eZPYQ$kx z3@)n{HMH{S3Mo_wGBk9s*ffRQxcJz8vb=s1i$TJHlhZT}+j=yOlAU|B@}uUQD1PiW z)!uy470E417iV)8rujr%TyUY0krA8U;;>lAqEjL<@xXyD28M(y8WR;7dnE0fY$61f zcur<><&$72Ns?HTH2qoY`WIA)!g$}7+GEWar490w~@-ure<8ciy0WK0g=}sl>h($ literal 0 HcmV?d00001 diff --git a/web/images/emote/ei_mad.gif b/web/images/emote/ei_mad.gif new file mode 100644 index 0000000000000000000000000000000000000000..a38492bf0a3e5b044475867e7f21ee225966f907 GIT binary patch literal 154 zcmZ?wbhEHb+Xj;G)W@DcaF| u7MUB=PEBNCcyedu<%Ng3teW55`LQ|GcY=7Z)>e+dZMJXVzSckb^&u zI;d9#Tl6ug&QRQ)b@$m!?b@!QIp-^SZks5ad92Kv?sWAn>!zzls@`0}j11NQS42f# literal 0 HcmV?d00001 diff --git a/web/images/emote/ei_rolleyes.gif b/web/images/emote/ei_rolleyes.gif new file mode 100644 index 0000000000000000000000000000000000000000..d5e29f5249b43644303b028c0ee55817bc783907 GIT binary patch literal 1784 zcmZ?wbhEHbZoX@_SDtLLp*Ia%ps4_kiN8BGx-|5=>c+k7Mh z$g}IfAx1gnJQ2xF37!*GyqPpA10SE7BBi@6r=#%Mk=f#+kM?*3rn@zpXumtd8JKpg zMU*$s1-o65g#2|e;draGG9N?01eKE$m0X!3GAE^awQGk?I&(uH`S>g`^;bMAFDtsX zTG;+$x%D~8X*MtrO?C(-I$-nJsBJ?tBm)VilEmYE(#la^ZUijxY}OD@y7D9Nu}6=1 ueBT@kLlxgi(xTH`A~!wq?Gi{o<`W^9dZ=MEb)Xeiqxo!5mLW7q`PKjpS}J+~ literal 0 HcmV?d00001 diff --git a/web/images/emote/ei_smile.gif b/web/images/emote/ei_smile.gif new file mode 100644 index 0000000000000000000000000000000000000000..603ddddbda6d52988a603e467f7b5e35b3238bbd GIT binary patch literal 93 zcmZ?wbhEHb z$e;sc12yn7FmMDgFms4lEJ!%m$iXbaa$v$k#};NOuM!J`M@KrDIjpvDBqX}G^4gX? z(fG9J$RsuMGM}B779X6h=V&Ej(2(ZQYs`9MNk_5D$rcTHwU8f1i4I^(BvCE#CfAZp he>5hiy7g-2hdtS0_|UJJlbH!@{scx8Pf*o-YXA`EY;XVo literal 0 HcmV?d00001 diff --git a/web/images/emote/ei_wink.gif b/web/images/emote/ei_wink.gif new file mode 100644 index 0000000000000000000000000000000000000000..077383e1f2eda4c047116b3ad3ec8e1b058ad75a GIT binary patch literal 135 zcmZ?wbhEHb8X)!pOkD$e;sK3o?U&#l*maGi$Cz$ibgS z9n`CWE&3Q#XS~i@w&v;4H=227QP0<<@0YsYD>CO~$I*DU>pxRWrirLAF<1itP#hrU literal 0 HcmV?d00001