From 02d1fbe90399929d6c82a7d3d45e1e366564b14c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 May 2020 20:58:37 -0700 Subject: [PATCH 1/5] missing summary tags --- Zotlabs/Module/Item.php | 79 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 8cab7fb1b..9c34b4566 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -393,7 +393,7 @@ class Item extends Controller { $plink = ((x($_REQUEST,'permalink')) ? escape_tags($_REQUEST['permalink']) : ''); $obj_type = ((x($_REQUEST,'obj_type')) ? escape_tags($_REQUEST['obj_type']) : ACTIVITY_OBJ_NOTE); - // allow API to bulk load a bunch of imported items with sending out a bunch of posts. + // allow API to bulk load a bunch of imported items without sending out a bunch of posts. $nopush = ((x($_REQUEST,'nopush')) ? intval($_REQUEST['nopush']) : 0); /* @@ -842,10 +842,7 @@ class Item extends Controller { if($mimetype === 'text/bbcode') { - - require_once('include/text.php'); - - + // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives @@ -864,46 +861,48 @@ class Item extends Controller { $body = cleanup_bbcode($body); // Look for tags and linkify them - $results = linkify_tags($summary, ($uid) ? $uid : $profile_uid); - $results = linkify_tags($body, ($uid) ? $uid : $profile_uid); + $summary_tags = linkify_tags($summary, ($uid) ? $uid : $profile_uid); + $body_tags = linkify_tags($body, ($uid) ? $uid : $profile_uid); + foreach ( [ $summary_tags, $body_tags ] as $results ) { - if($results) { + if ($results) { - // Set permissions based on tag replacements - set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private); + // Set permissions based on tag replacements + set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private); - if (! isset($post_tags)) { - $post_tags = []; - } - foreach($results as $result) { - $success = $result['success']; - if($success['replaced']) { - $post_tags[] = array( - 'uid' => $profile_uid, - 'ttype' => $success['termtype'], - 'otype' => TERM_OBJ_POST, - 'term' => $success['term'], - 'url' => $success['url'] - ); - - // support #collection syntax to post to a collection - // this is accomplished by adding a pcategory tag for each collection target - // this is checked inside tag_deliver() to create a second delivery chain - - if ($success['termtype'] === TERM_HASHTAG) { - $r = q("select xchan_url from channel left join xchan on xchan_hash = channel_hash where channel_address = '%s' and channel_parent = '%s' and channel_removed = 0", - dbesc($success['term']), - dbesc(get_observer_hash()) + if (! isset($post_tags)) { + $post_tags = []; + } + foreach ($results as $result) { + $success = $result['success']; + if ($success['replaced']) { + $post_tags[] = array( + 'uid' => $profile_uid, + 'ttype' => $success['termtype'], + 'otype' => TERM_OBJ_POST, + 'term' => $success['term'], + 'url' => $success['url'] ); - if ($r) { - $post_tags[] = [ - 'uid' => $profile_uid, - 'ttype' => TERM_PCATEGORY, - 'otype' => TERM_OBJ_POST, - 'term' => $success['term'] . '@' . App::get_hostname(), - 'url' => $r[0]['xchan_url'] - ]; + + // support #collection syntax to post to a collection + // this is accomplished by adding a pcategory tag for each collection target + // this is checked inside tag_deliver() to create a second delivery chain + + if ($success['termtype'] === TERM_HASHTAG) { + $r = q("select xchan_url from channel left join xchan on xchan_hash = channel_hash where channel_address = '%s' and channel_parent = '%s' and channel_removed = 0", + dbesc($success['term']), + dbesc(get_observer_hash()) + ); + if ($r) { + $post_tags[] = [ + 'uid' => $profile_uid, + 'ttype' => TERM_PCATEGORY, + 'otype' => TERM_OBJ_POST, + 'term' => $success['term'] . '@' . App::get_hostname(), + 'url' => $r[0]['xchan_url'] + ]; + } } } } From ce0be410230c1d914abd885ae5a6bdfc1f95b71f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 May 2020 17:39:48 -0700 Subject: [PATCH 2/5] hide the automentions in comments. --- Zotlabs/Module/Item.php | 6 ++++-- view/js/main.js | 14 +++++++------- view/tpl/comment_item.tpl | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9c34b4566..2e699c7ff 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -317,6 +317,7 @@ class Item extends Controller { $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : ''); + $hidden_mentions = ((x($_REQUEST,'hidden_mentions')) ? trim($_REQUEST['hidden_mentions']) : ''); /** * Who is viewing this page and posting this thing @@ -863,8 +864,9 @@ class Item extends Controller { // Look for tags and linkify them $summary_tags = linkify_tags($summary, ($uid) ? $uid : $profile_uid); $body_tags = linkify_tags($body, ($uid) ? $uid : $profile_uid); - - foreach ( [ $summary_tags, $body_tags ] as $results ) { + $comment_tags = linkify_tags($hidden_mentions, ($uid) ? $uid : $profile_uid); + + foreach ( [ $summary_tags, $body_tags, $comment_tags ] as $results ) { if ($results) { diff --git a/view/js/main.js b/view/js/main.js index 47dfe6e95..3b8c9926e 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -356,13 +356,13 @@ function commentInsert(obj, id) { } function commentAuthors(id) { - var auths = $("#thread-authors-" + id).html(); - if(typeof(auths) != 'undefined') { - var tmpStr = $("#comment-edit-text-" + id).val(); - if(tmpStr == '') { - $("#comment-edit-text-" + id).val(auths); - } - } + $("#hidden-mentions-" + id).val($("#thread-authors-" + id).html()); +// if(typeof(auths) != 'undefined') { +// var tmpStr = $("#comment-edit-text-" + id).val(); +// if(tmpStr == '') { +// $("#comment-edit-text-" + id).val(auths); +// } +// } } diff --git a/view/tpl/comment_item.tpl b/view/tpl/comment_item.tpl index fec63377e..bd2db5b78 100755 --- a/view/tpl/comment_item.tpl +++ b/view/tpl/comment_item.tpl @@ -13,6 +13,7 @@ + {{if $anoncomments && ! $observer}}