From 37795b5f9ad56129f2bdc718033281f9513357f1 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 26 Sep 2014 09:58:30 +0000 Subject: [PATCH] Add "ignore_emoticons" option --- Plugin.php | 22 ++++++++++++++++++++++ README.md | 17 +++++++++++++++++ js/plugin.js | 5 ++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Plugin.php b/Plugin.php index 2efa7ad..44123ef 100644 --- a/Plugin.php +++ b/Plugin.php @@ -32,6 +32,27 @@ use Symfony\Component\HttpFoundation\Request; */ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\PluginInterface { + /** + * List of the plugin configs. + * + * @var array + */ + protected $config; + + /** + * Class constructor. + * + * @param array $config List of the plugin config. The following options are + * supported: + * - 'ignore_emoticons': boolean, if set to true, the plugin only converts + * :emoji: and ignore emoticons like :-) and ;D. The default value is + * false. + */ + public function __construct($config) + { + $this->config = $config + array('ignore_emoticons' => false); + } + /** * The plugin does not need extra initialization thus it is always ready to * work. @@ -100,6 +121,7 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi $args['plugins']['MibewEmoji'] = array( 'imagesDir' => ($request->getBasePath() . '/' . $this->getFilesPath() . '/components/emojify.js/images/emoji'), + 'ignoreEmoticons' => $this->config['ignore_emoticons'], ); } } diff --git a/README.md b/README.md index 5fe7c05..8bc33e5 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ It replaces emojis codes with images in chat messages. The full list of supported emojis can be found at http://www.emoji-cheat-sheet.com/ +Emoticons like :-) and ;D are also supported. + ## Installation @@ -14,9 +16,24 @@ If the "plugins" stucture looks like `plugins: []` it will become: plugins: - name: "Mibew:Emoji" + config: # Plugin's configurations are described below + ignore_emoticons: false ``` +## Plugin's configurations + +The plugin can be configured with values in "``/configs/config.yml" file. + +### config.ignore_emoticons + +Type: `Boolean` + +Default: `false` + +If set to true, the plugin only converts :emoji: and ignore emoticons like :-) and ;D. This value is optional and can be skipped. + + ## Build from sources There are several actions one should do before use the latest version of the plugin from the repository: diff --git a/js/plugin.js b/js/plugin.js index d7e4aee..55d8455 100644 --- a/js/plugin.js +++ b/js/plugin.js @@ -37,7 +37,10 @@ Mibew.Application.Invitation.on(eventsMap); module.addInitializer(function() { - emojify.setConfig({'img_dir': Mibew.PluginOptions.MibewEmoji.imagesDir}); + emojify.setConfig({ + img_dir: Mibew.PluginOptions.MibewEmoji.imagesDir, + ignore_emoticons: Mibew.PluginOptions.MibewEmoji.ignoreEmoticons + }); // Update message body right after it is added to the messages // collection.