summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_cron/emoji-list1
-rw-r--r--bin/emoji-list.py15
-rw-r--r--config/emoji.jsonbin0 -> 68717 bytes
-rw-r--r--providers/Provider.php19
4 files changed, 34 insertions, 1 deletions
diff --git a/_cron/emoji-list b/_cron/emoji-list
new file mode 100644
index 0000000..f705d00
--- /dev/null
+++ b/_cron/emoji-list
@@ -0,0 +1 @@
+25 15 * * * python $SITEPATH/bin/emoji-list.py
diff --git a/bin/emoji-list.py b/bin/emoji-list.py
new file mode 100644
index 0000000..81b73ea
--- /dev/null
+++ b/bin/emoji-list.py
@@ -0,0 +1,15 @@
+import json, os, urllib
+
+emoji_list = json.load(urllib.urlopen(
+ 'https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json'
+))
+dictionary = {}
+for emoji in emoji_list:
+ character = ''.join([unichr(int(nibble, 16)) for nibble in emoji['unified'].split('-')])
+ name = emoji['name'].replace(' ', '_') if emoji['name'] else emoji['short_name'].upper().replace('-', '_')
+ dictionary[character] = ' <%s> ' % (name)
+
+json.dump(dictionary, file(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ '../config/emoji.json'
+), 'w'))
diff --git a/config/emoji.json b/config/emoji.json
new file mode 100644
index 0000000..30c3560
--- /dev/null
+++ b/config/emoji.json
Binary files differ
diff --git a/providers/Provider.php b/providers/Provider.php
index 2e14d2b..bf85f12 100644
--- a/providers/Provider.php
+++ b/providers/Provider.php
@@ -41,12 +41,29 @@ abstract class Provider {
}
}
+ protected function _filterItemContent($items) {
+ if (in_array('noemoji', $this->_options)) {
+ $dictionary = json_decode(file_get_contents('../config/emoji.json'), TRUE);
+ $filtered = [];
+ foreach ($items as $item) {
+ foreach (['Title', 'Text'] as $field) {
+ $item->{$field} = strtr($item->{$field}, $dictionary);
+ }
+ }
+ }
+ return $items;
+ }
+
public function get() {
$items = $this->_getItems();
if (isset($this->_options['spamfilter'])) {
$items = $this->_spamFilter($items);
}
- return $this->_sortContent($this->_mapItems($items));
+ return $this->_sortContent(
+ $this->_filterItemContent(
+ $this->_mapItems($items)
+ )
+ );
}
public function cacheTime() {