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
79
etc/emoticon.xml
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
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 <http://www.mozilla.org/MPL/>.
|
||||||
|
|
||||||
|
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 <erbo@ricochet.com>,
|
||||||
|
for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
|
||||||
|
Contributor(s):
|
||||||
|
-->
|
||||||
|
<!-- Configure the emoticons -->
|
||||||
|
<emoticon-config>
|
||||||
|
<prefix-chars>:;</prefix-chars>
|
||||||
|
<icon name="smile">
|
||||||
|
<pattern>:)</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_smile.gif</image>
|
||||||
|
<text>Smile!</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="frown">
|
||||||
|
<pattern>:(</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_frown.gif</image>
|
||||||
|
<text>frown...</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="redface">
|
||||||
|
<pattern>:o</pattern>
|
||||||
|
<pattern>:O</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_redface.gif</image>
|
||||||
|
<text>Boy, is my face red!</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="biggrin">
|
||||||
|
<pattern>:D</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_biggrin.gif</image>
|
||||||
|
<text>Grinnin'...</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="wink">
|
||||||
|
<pattern>;)</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_wink.gif</image>
|
||||||
|
<text>Wink wink, nudge nudge</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="tongue">
|
||||||
|
<pattern>:p</pattern>
|
||||||
|
<pattern>:P</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_tongue.gif</image>
|
||||||
|
<text>Bleah!</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="cool">
|
||||||
|
<pattern>:cool:</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_cool.gif</image>
|
||||||
|
<text>Cool!</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="rolleyes">
|
||||||
|
<pattern>:rolleyes:</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_rolleyes.gif</image>
|
||||||
|
<text>Rolling my eyes</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="mad">
|
||||||
|
<pattern>:mad:</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_mad.gif</image>
|
||||||
|
<text>I'm mad!</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="eek">
|
||||||
|
<pattern>:eek:</pattern>
|
||||||
|
<image width="15" height="15" fixup="true">emote/ei_eek.gif</image>
|
||||||
|
<text>EEK!</text>
|
||||||
|
</icon>
|
||||||
|
<icon name="confused">
|
||||||
|
<pattern>:confused:</pattern>
|
||||||
|
<image width="15" height="22" fixup="true">emote/ei_confused.gif</image>
|
||||||
|
<text>Huh???</text>
|
||||||
|
</icon>
|
||||||
|
</emoticon-config>
|
|
@ -25,6 +25,9 @@
|
||||||
<!-- The location of the services configuration file, relative to the application root. -->
|
<!-- The location of the services configuration file, relative to the application root. -->
|
||||||
<services-config>WEB-INF/services-config.xml</services-config>
|
<services-config>WEB-INF/services-config.xml</services-config>
|
||||||
|
|
||||||
|
<!-- The pathname of the emoticons configuration file, relative to the Web application root directory. -->
|
||||||
|
<emoticon-config>WEB-INF/emoticon.xml</emoticon-config>
|
||||||
|
|
||||||
<!-- The location of the scripts directory, relative to the application root. -->
|
<!-- The location of the scripts directory, relative to the application root. -->
|
||||||
<script-dir>WEB-INF/scripts</script-dir>
|
<script-dir>WEB-INF/scripts</script-dir>
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
<!-- The pathname of the services config file, relative to the Web application root directory. -->
|
<!-- The pathname of the services config file, relative to the Web application root directory. -->
|
||||||
<services-config>WEB-INF/services-config.xml</services-config>
|
<services-config>WEB-INF/services-config.xml</services-config>
|
||||||
|
|
||||||
|
<!-- The pathname of the emoticons configuration file, relative to the Web application root directory. -->
|
||||||
|
<emoticon-config>WEB-INF/emoticon.xml</emoticon-config>
|
||||||
|
|
||||||
<!-- If this property is set, these addresses are considered "privileged" and able to log in
|
<!-- If this property is set, these addresses are considered "privileged" and able to log in
|
||||||
as any user -->
|
as any user -->
|
||||||
<!-- <privileged-addresses>10.29.99.1,127.0.0.1</privileged-addresses> -->
|
<!-- <privileged-addresses>10.29.99.1,127.0.0.1</privileged-addresses> -->
|
||||||
|
|
|
@ -293,5 +293,3 @@ public final class DOMElementHelper
|
||||||
} // end getAttributeBoolean
|
} // end getAttributeBoolean
|
||||||
|
|
||||||
} // end DOMElementHelper
|
} // end DOMElementHelper
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,9 +143,14 @@ public class GlobalSiteImpl implements GlobalSite
|
||||||
|
|
||||||
// Get the <engine/> section.
|
// Get the <engine/> section.
|
||||||
DOMElementHelper config_h = new DOMElementHelper(config);
|
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);
|
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 <privileged-addresses/> value.
|
// Get the <privileged-addresses/> value.
|
||||||
String s = sect_h.getSubElementText("privileged-addresses");
|
String s = sect_h.getSubElementText("privileged-addresses");
|
||||||
if (!(StringUtil.isStringEmpty(s)))
|
if (!(StringUtil.isStringEmpty(s)))
|
||||||
|
@ -225,6 +230,8 @@ public class GlobalSiteImpl implements GlobalSite
|
||||||
intermediate_map.put(postlink_rewriter.getClass().getName(),postlink_rewriter);
|
intermediate_map.put(postlink_rewriter.getClass().getName(),postlink_rewriter);
|
||||||
UserNameRewriter username_rewriter = new UserNameRewriter(this);
|
UserNameRewriter username_rewriter = new UserNameRewriter(this);
|
||||||
intermediate_map.put(username_rewriter.getClass().getName(),username_rewriter);
|
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 <html-checker/> section.
|
// Get the <html-checker/> section.
|
||||||
sect = loader.configGetSubSection(config_h,"html-checker");
|
sect = loader.configGetSubSection(config_h,"html-checker");
|
||||||
|
|
|
@ -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 <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* 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 <erbo@ricochet.com>,
|
||||||
|
* 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<nl.getLength(); i++)
|
||||||
|
{ // look through all the child nodes...
|
||||||
|
Node n = nl.item(i);
|
||||||
|
if ((n.getNodeType()==Node.ELEMENT_NODE) && n.getNodeName().equals("icon"))
|
||||||
|
{ // load the icon name
|
||||||
|
String icon_name = loader.configGetAttribute((Element)n,"name").intern();
|
||||||
|
|
||||||
|
// get the associated patterns
|
||||||
|
NodeList nl2 = n.getChildNodes();
|
||||||
|
for (int j=0; j<nl2.getLength(); j++)
|
||||||
|
{ // look for <pattern/> 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
|
109
src/com/silverwrist/venice/ui/config/EmoticonManager.java
Normal file
|
@ -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 <http://www.mozilla.org/MPL/>.
|
||||||
|
*
|
||||||
|
* 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 <erbo@ricochet.com>,
|
||||||
|
* 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; i<nl.getLength(); i++)
|
||||||
|
{ // get the element
|
||||||
|
Node n = nl.item(i);
|
||||||
|
if ((n.getNodeType()==Node.ELEMENT_NODE) && n.getNodeName().equals("icon"))
|
||||||
|
{ // load the emoticon
|
||||||
|
Element elt = (Element)n;
|
||||||
|
String icon_name = loader.configGetAttribute(elt,"name").intern();
|
||||||
|
IconDefinition defn = new IconDefinition(elt);
|
||||||
|
tmp.put(icon_name,defn);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end for
|
||||||
|
|
||||||
|
if (tmp.isEmpty())
|
||||||
|
m_iconmap = Collections.EMPTY_MAP;
|
||||||
|
else
|
||||||
|
m_iconmap = Collections.unmodifiableMap(tmp);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
} // end class EmoticonManager
|
|
@ -92,6 +92,7 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
private DialogManager m_dialogs; // the dialog manager
|
private DialogManager m_dialogs; // the dialog manager
|
||||||
private SideBoxManager m_sideboxes; // the sidebox manager
|
private SideBoxManager m_sideboxes; // the sidebox manager
|
||||||
private CommunityMenuFactory m_comm_menu_fact; // the community menu factory
|
private CommunityMenuFactory m_comm_menu_fact; // the community menu factory
|
||||||
|
private EmoticonManager m_emoticons; // the emoticon manager
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -120,6 +121,11 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
if (!(services_config.startsWith("/")))
|
if (!(services_config.startsWith("/")))
|
||||||
services_config = root_file_path + services_config;
|
services_config = root_file_path + services_config;
|
||||||
|
|
||||||
|
// Get the full pathname of the emoticon configuration file.
|
||||||
|
String emoticon_config = loader.configGetSubElementText(sect_h,"emoticon-config");
|
||||||
|
if (!(emoticon_config.startsWith("/")))
|
||||||
|
emoticon_config = root_file_path + emoticon_config;
|
||||||
|
|
||||||
// Get the full pathname of the script directory.
|
// Get the full pathname of the script directory.
|
||||||
m_script_directory = getRelativeDirectory(sect_h,"script-dir",root_file_path,true);
|
m_script_directory = getRelativeDirectory(sect_h,"script-dir",root_file_path,true);
|
||||||
|
|
||||||
|
@ -511,6 +517,14 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
// Get the community section and pass it to the CommunityMenuFactory.
|
// Get the community section and pass it to the CommunityMenuFactory.
|
||||||
m_comm_menu_fact = new CommunityMenuFactory(root_h.getSubElement("community"),this);
|
m_comm_menu_fact = new CommunityMenuFactory(root_h.getSubElement("community"),this);
|
||||||
|
|
||||||
|
// done with the services-config.xml file
|
||||||
|
// Load up the emoticon.xml file.
|
||||||
|
doc = loader.loadConfigDocument(emoticon_config);
|
||||||
|
root = loader.configGetRootElement(doc,"emoticon-config");
|
||||||
|
|
||||||
|
// Load the emoticon manager.
|
||||||
|
m_emoticons = new EmoticonManager(root);
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
|
@ -892,6 +906,12 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
|
|
||||||
} // end addFormatParams
|
} // end addFormatParams
|
||||||
|
|
||||||
|
public final EmoticonManager getEmoticonManager()
|
||||||
|
{
|
||||||
|
return m_emoticons;
|
||||||
|
|
||||||
|
} // end getEmoticonManager
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Static initializer
|
* Static initializer
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
|
|
BIN
web/images/emote/ei_biggrin.gif
Normal file
After Width: | Height: | Size: 152 B |
BIN
web/images/emote/ei_confused.gif
Normal file
After Width: | Height: | Size: 110 B |
BIN
web/images/emote/ei_cool.gif
Normal file
After Width: | Height: | Size: 124 B |
BIN
web/images/emote/ei_eek.gif
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
web/images/emote/ei_frown.gif
Normal file
After Width: | Height: | Size: 94 B |
BIN
web/images/emote/ei_mad.gif
Normal file
After Width: | Height: | Size: 154 B |
BIN
web/images/emote/ei_redface.gif
Normal file
After Width: | Height: | Size: 136 B |
BIN
web/images/emote/ei_rolleyes.gif
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
web/images/emote/ei_smile.gif
Normal file
After Width: | Height: | Size: 93 B |
BIN
web/images/emote/ei_tongue.gif
Normal file
After Width: | Height: | Size: 338 B |
BIN
web/images/emote/ei_wink.gif
Normal file
After Width: | Height: | Size: 135 B |