Add "ignore_emoticons" option

This commit is contained in:
Dmitriy Simushev 2014-09-26 09:58:30 +00:00
parent a771330773
commit 37795b5f9a
3 changed files with 43 additions and 1 deletions

View File

@ -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'],
);
}
}

View File

@ -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 "`<Mibew root>`/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:

View File

@ -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.