﻿ticket,summary,type,release,owner,status,created,modified,_description,_reporter
2123,Installing Emoticons Can Damage Existing Text (i.e. Dialing codes '(8)' ),defect,0.10,Olemis Lang,new,2007-10-30T02:17:07+01:00,2012-10-05T18:23:42+02:00,"The following change addreses his by requiring emoticons be encapsulated in square brackets before being parsed by the plugin:

{{{
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

import re
from pkg_resources import resource_filename

from trac.core import *
from trac.util import escape
from trac.web.chrome import ITemplateProvider
from trac.wiki import IWikiSyntaxProvider

EMOTICONS = {
    ':/': 'annoyed.png', ':-/': 'annoyed.png',
    '8)': 'cool.png', '8-)': 'cool.png', 'B)': 'cool.png', 'B-)': 'cool.png',
    ':(': 'frown.png', ':-(': 'frown.png',
    ':D': 'happy.png', ':-D': 'happy.png',
    ':P': 'razz.png', ':-P': 'razz.png',
    ':)': 'smile.png', ':-)': 'smile.png',
    ':|': 'stoic.png', ':-|': 'stoic.png',
    ':O': 'suprised.png', ':o': 'suprised.png', ':-O': 'suprised.png',
    ':-o': 'suprised.png',
    ';)': 'wink.png', ';-)': 'wink.png'
}


class EmoticonsSupport(Component):
    """"""Provides support for graphical emoticons in wiki-formatted text.""""""

    implements(ITemplateProvider, IWikiSyntaxProvider)

    # ITemplateProvider methods

    def get_htdocs_dirs(self):
        """"""Return the directories containing static resources.""""""
        return [('emoticons', resource_filename(__name__, 'icons'))]

    def get_templates_dirs(self):
        return []

    # IWikiSyntaxProvider methods

    def get_wiki_syntax(self):
        """"""Replace textual patterns representing emoticons with the
        corresponding icon.""""""
        def _replace(formatter, namespace, match):
            src = self.env.href.chrome('emoticons', EMOTICONS[match.group(0)[1:-1]])
            return '<img src=""%s"" alt=""%s"" class=""emoticon"" width=""18"" ' \
                   'height=""18"" style=""vertical-align: middle"" />' % (
                   escape(src), escape(match.group(0)))
        pattern = '|'.join([re.escape('[' + pattern + ']') for pattern in EMOTICONS])
        yield '\b' + pattern + '\b', _replace

    def get_link_resolvers(self):
        return []
}}}",ryan.gossink@…
11161,"patch and images for adding ""ok"" and ""cancel"" (or ""not-ok"") icons to trac",enhancement,1.0,Olemis Lang,new,2013-06-13T07:11:15+02:00,2015-06-29T23:42:07+02:00,"{{{#!diff
--- tracemoticons/icons/tracok.png      (revision 13282)
+++ tracemoticons/icons/tracok.png      (working copy)

/////////////////////////////////////////////////////////////

--- tracemoticons/__init__.py   (revision 13282)
+++ tracemoticons/__init__.py   (working copy)
@@ -34,7 +34,8 @@
     ':|': 'stoic.png', ':-|': 'stoic.png',
     ':O': 'suprised.png', ':o': 'suprised.png', ':-O': 'suprised.png',
     ':-o': 'suprised.png',
-    ';)': 'wink.png', ';-)': 'wink.png'
+    ';)': 'wink.png', ';-)': 'wink.png',
+    'k-)': 'tracok.png', 'nk-)': 'tracnok.png',
 }
}}}",mz@…
