aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-03-09 20:53:18 +0000
committerMario <mario@mariovavti.com>2024-03-09 20:53:18 +0000
commit46fa26502b285213f3438abb1e3bd1482eb55bf5 (patch)
treec40ee65fc9da26319e26758c80339124f5247bea /Zotlabs
parentba1e705c6154d347000ab6c92ef59f7f6f60e886 (diff)
downloadvolse-hubzilla-46fa26502b285213f3438abb1e3bd1482eb55bf5.tar.gz
volse-hubzilla-46fa26502b285213f3438abb1e3bd1482eb55bf5.tar.bz2
volse-hubzilla-46fa26502b285213f3438abb1e3bd1482eb55bf5.zip
more work on emojis
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Activity.php27
-rw-r--r--Zotlabs/Lib/ThreadItem.php2
-rw-r--r--Zotlabs/Module/Emoji.php60
-rw-r--r--Zotlabs/Module/Item.php28
-rw-r--r--Zotlabs/Module/React.php25
-rw-r--r--Zotlabs/Module/Smilies.php16
6 files changed, 137 insertions, 21 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 43f7386e7..e19499c56 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -642,7 +642,7 @@ class Activity {
break;
case 'Emoji':
- $ret[] = ['ttype' => TERM_EMOJI, 'url' => $t['icon']['url'], 'term' => escape_tags($t['name'])];
+ $ret[] = ['ttype' => TERM_EMOJI, 'url' => $t['id'], 'term' => escape_tags($t['name']), 'imgurl' => $t['icon']['url']];
break;
default:
@@ -677,6 +677,10 @@ class Activity {
$ret[] = ['type' => 'Bookmark', 'href' => $t['url'], 'name' => $t['term']];
break;
+ case TERM_EMOJI:
+ $ret[] = ['type' => 'Emoji', 'id' => $t['url'], 'name' => $t['term'], 'icon' => ['type' => 'Image', 'url' => $t['imgurl']]];
+ break;
+
default:
break;
}
@@ -976,10 +980,12 @@ class Activity {
return [];
}
+/* this should not be needed
$t = self::encode_taxonomy($i);
if ($t) {
$ret['tag'] = $t;
}
+*/
$a = self::encode_attachment($i, true);
if ($a) {
@@ -997,6 +1003,7 @@ class Activity {
];
call_hooks('encode_activity', $hookinfo);
+
return $hookinfo['encoded'];
}
@@ -2179,9 +2186,17 @@ class Activity {
// Pleroma reactions
$t = trim(self::get_textfield($act->data, 'content'));
+ $content['content'] = $t;
+
// Unicode emojis
if (grapheme_strlen($t) === 1) {
- $content['content'] = $t;
+ $content['content'] = '<h1>' . $t . '</h1>';
+ }
+
+ $a = self::decode_taxonomy($act->data);
+
+ if ($a) {
+ $s['term'] = $a;
}
}
}
@@ -2885,7 +2900,13 @@ class Activity {
if (isset($item['term']) && !PConfig::Get($channel['channel_id'], 'system', 'no_smilies')) {
foreach ($item['term'] as $t) {
if ($t['ttype'] === TERM_EMOJI) {
- $item['body'] = str_replace($t['term'], '[img class="smiley emoji custom-emoji" alt="' . $t['term'] . '" title="' . $t['term'] . '"]' . $t['url'] . '[/img]', $item['body']);
+ $class = 'emoji';
+ $shortname = ':' . trim($t['term'], ':') . ':';
+ if (is_solo_string($shortname, $item['body'])) {
+ $class .= ' single-emoji';
+ }
+
+ $item['body'] = str_replace($shortname, '[img class="' . $class . '" alt="' . $t['term'] . '" title="' . $t['term'] . '"]' . ($t['imgurl'] ?: $t['url']) . '[/img]', $item['body']);
}
}
}
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 42d76bf17..8f364e945 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -19,7 +19,7 @@ class ThreadItem {
private $comment_box_template = 'comment_item.tpl';
private $commentable = false;
// list of supported reaction emojis - a site can over-ride this via config system.reactions
- private $reactions = ['1f60a','1f44f','1f37e','1f48b','1f61e','2665','1f606','1f62e','1f634','1f61c','1f607','1f608'];
+ private $reactions = ['slightly_smiling_face','clapping_hands','bottle_with_popping_cork','kiss_mark','disappointed_face','red_heart','grinning_face','astonished_face','sleeping_face','winking_face_with_tongue','smiling_face_with_halo','smiling_face_with_horns'];
private $toplevel = false;
private $children = array();
private $parent = null;
diff --git a/Zotlabs/Module/Emoji.php b/Zotlabs/Module/Emoji.php
new file mode 100644
index 000000000..595c9fc60
--- /dev/null
+++ b/Zotlabs/Module/Emoji.php
@@ -0,0 +1,60 @@
+<?php
+namespace Zotlabs\Module;
+
+use Zotlabs\Web\Controller;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\ActivityStreams;
+use App;
+
+
+class Emoji extends Controller {
+
+ function init() {
+
+ $shortname = argv(1);
+
+ if (!$shortname) {
+ killme();
+ }
+
+ $emojis = get_emojis();
+
+ if (!isset($emojis[$shortname])) {
+ killme();
+ }
+
+ $emoji = $emojis[$shortname];
+
+hz_syslog(print_r($emoji, true));
+
+
+ if (!file_exists($emoji['filepath'])) {
+ killme();
+ }
+
+ $image = getimagesize($emoji['filepath']);
+
+ if(ActivityStreams::is_as_request()) {
+ $last_modified = date(ATOM_TIME, filemtime($emoji['filepath']));
+
+ $obj = [
+ 'id' => z_root() . '/emoji/' . $shortname,
+ 'type' => 'Emoji',
+ 'name' => $emoji['shortname'],
+ 'updated' => $last_modified,
+ 'icon' => [
+ 'type' => 'Image',
+ 'mediaType' => $image['mime'],
+ 'url' => z_root() . '/' . $emoji['filepath']
+ ]
+ ];
+
+ as_return_and_die($obj);
+ }
+
+ header('Content-Type: ' . $image['mime']);
+ echo file_get_contents($emoji['filepath']);
+ killme();
+ }
+
+}
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 5c802f557..b158ed4e0 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -938,6 +938,30 @@ class Item extends Controller {
}
}
+ if (preg_match_all('/(\:(\w|\+|\-)+\:)(?=|[\!\.\?]|$)/', $body, $match)) {
+ // emoji shortcodes
+ $emojis = get_emojis();
+ foreach ($match[0] as $mtch) {
+ $shortname = trim($mtch, ':');
+
+ if (!isset($emojis[$shortname])) {
+ continue;
+ }
+
+ $emoji = $emojis[$shortname];
+
+ $post_tags[] = [
+ 'uid' => $profile_uid,
+ 'ttype' => TERM_EMOJI,
+ 'otype' => TERM_OBJ_POST,
+ 'term' => trim($mtch),
+ 'url' => z_root() . '/emoji/' . $shortname,
+ 'imgurl' => z_root() . '/' . $emoji['filepath']
+ ];
+ }
+ }
+
+
// BBCODE end alert
}
@@ -958,6 +982,10 @@ class Item extends Controller {
}
}
+
+
+
+
if ($orig_post) {
// preserve original tags
$t = q("select * from term where oid = %d and otype = %d and uid = %d and ttype in ( %d, %d, %d )",
diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php
index 6a3b525b2..e04b9b257 100644
--- a/Zotlabs/Module/React.php
+++ b/Zotlabs/Module/React.php
@@ -24,7 +24,15 @@ class React extends Controller {
return;
}
- $emoji = $_REQUEST['emoji'];
+ $shortname = $_REQUEST['emoji'];
+
+ $emojis = get_emojis();
+
+ if (!isset($emojis[$shortname])) {
+ return;
+ }
+
+ $emoji = $emojis[$shortname];
if (!$emoji) {
return;
@@ -62,10 +70,19 @@ class React extends Controller {
$n['uuid'] = $uuid;
$n['mid'] = z_root() . '/item/' . $uuid;
$n['verb'] = 'Create';
- $n['body'] = '[zmg=32x32]' . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]';
+ $n['body'] = $emoji['shortname']; //'[img class="emoji single-emoji"]' . z_root() . '/' . $emoji['filepath'] . '[/img]';
$n['author_xchan'] = $channel['channel_hash'];
- $n['obj'] = Activity::fetch_item(['id' => $item['mid']]);
- $n['obj_type'] = ((array_path_exists('obj/type', $n)) ? $n['obj']['type'] : EMPTY_STR);
+ // $n['obj'] = Activity::fetch_item(['id' => $i[0]['mid']]);
+ // $n['obj_type'] = ((array_path_exists('obj/type', $n)) ? $n['obj']['type'] : EMPTY_STR);
+
+ $n['term'][] = [
+ 'uid' => $channel['channel_id'],
+ 'ttype' => TERM_EMOJI,
+ 'otype' => TERM_OBJ_POST,
+ 'term' => $emoji['shortname'],
+ 'url' => z_root() . '/emoji/' . $shortname,
+ 'imgurl' => z_root() . '/' . $emoji['filepath']
+ ];
$x = item_store($n);
diff --git a/Zotlabs/Module/Smilies.php b/Zotlabs/Module/Smilies.php
index efac07f84..7dde8c834 100644
--- a/Zotlabs/Module/Smilies.php
+++ b/Zotlabs/Module/Smilies.php
@@ -4,18 +4,8 @@ namespace Zotlabs\Module;
class Smilies extends \Zotlabs\Web\Controller {
- function get() {
- if (\App::$argv[1]==="json"){
- $tmp = list_smilies();
- $results = array();
- for($i = 0; $i < count($tmp['texts']); $i++) {
- $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
- }
- json_return_and_die($results);
- }
- else {
- return smilies('',true);
- }
+ function init() {
+ json_return_and_die(get_emojis());
}
-
+
}