From c2655370e0e02e1ee5e6c727ee03c448320b7923 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 8 Oct 2019 09:25:16 +0000 Subject: issue #1401 (cherry picked from commit cac0672a49cd710b3eced1d66f1bfb18747ddbf8) --- view/js/acl.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/view/js/acl.js b/view/js/acl.js index 730b515a0..9415113dd 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -207,7 +207,7 @@ ACL.prototype.on_button_hide = function(event) { ACL.prototype.set_allow = function(itemid) { type = itemid[0]; - id = itemid.substr(1); + id = decodeURIComponent(itemid.substr(1)); switch(type) { case "g": if (that.allow_gid.indexOf(id)<0) { @@ -231,7 +231,7 @@ ACL.prototype.set_allow = function(itemid) { ACL.prototype.set_deny = function(itemid) { type = itemid[0]; - id = itemid.substr(1); + id = decodeURIComponent(itemid.substr(1)); switch(type) { case "g": if (that.deny_gid.indexOf(id)<0) { @@ -310,8 +310,12 @@ ACL.prototype.update_view = function(value) { else { that.list.show(); //show acl-list + datasrc2src('#acl-list-content .list-group-item img[data-src]'); that.info.hide(); //hide acl-info that.update_select('custom'); + if(typeof value === 'undefined') { + value = 'custom'; + } /* jot acl */ if(that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'custom') { @@ -334,7 +338,7 @@ ACL.prototype.update_view = function(value) { $("#acl-list-content .acl-list-item").each(function() { itemid = $(this).attr('id'); type = itemid[0]; - id = itemid.substr(1); + id = decodeURIComponent(itemid.substr(1)); btshow = $(this).children(".acl-button-show").removeClass("btn-success").addClass("btn-outline-success"); bthide = $(this).children(".acl-button-hide").removeClass("btn-danger").addClass("btn-outline-danger"); -- cgit v1.2.3 From 5edeb0250b1fe1cb6b8e89282b661ab13025e7f0 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 13 Oct 2019 14:27:54 +0200 Subject: Revert "Remove visible channels list from pubstream tags cloud creation procedure" This reverts commit 5c4c6e68f600d50deed8ddb32dd6702af9b52853 --- Zotlabs/Module/Articles.php | 12 +++++--- Zotlabs/Module/Channel.php | 21 +++++--------- include/opengraph.php | 71 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 18 deletions(-) create mode 100644 include/opengraph.php diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php index ca132c01e..e3ad54be8 100644 --- a/Zotlabs/Module/Articles.php +++ b/Zotlabs/Module/Articles.php @@ -9,6 +9,7 @@ use Zotlabs\Lib\PermissionDescription; require_once('include/channel.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); +require_once('include/opengraph.php'); class Articles extends Controller { @@ -192,7 +193,7 @@ class Articles extends Controller { $parents_str = ids_to_querystr($r,'id'); - $items = q("SELECT item.*, item.id AS item_id + $r = q("SELECT item.*, item.id AS item_id FROM item WHERE item.uid = %d $item_normal AND item.parent IN ( %s ) @@ -200,15 +201,18 @@ class Articles extends Controller { intval(App::$profile['profile_uid']), dbesc($parents_str) ); - if($items) { - xchan_query($items); - $items = fetch_post_tags($items, true); + if($r) { + xchan_query($r); + $items = fetch_post_tags($r, true); $items = conv_sort($items,'updated'); } else $items = []; } + // Add Opengraph markup + opengraph_add_meta(((! empty($items)) ? $r[0] : array()), App::$profile); + $mode = 'articles'; if(get_pconfig(local_channel(),'system','articles_list_mode') && (! $selected_card)) diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index b1639b213..3f617fd18 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -13,6 +13,7 @@ require_once('include/items.php'); require_once('include/security.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); +require_once('include/opengraph.php'); /** @@ -111,17 +112,6 @@ class Channel extends Controller { // we start loading content profile_load($which,$profile); - - App::$page['htmlhead'] .= '' . "\r\n"; - App::$page['htmlhead'] .= '' . "\r\n"; - - if(App::$profile['about'] && perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_profile')) { - App::$page['htmlhead'] .= '' . "\r\n"; - } - else { - App::$page['htmlhead'] .= '' . "\r\n"; - } - } function get($update = 0, $load = false) { @@ -362,7 +352,7 @@ class Channel extends Controller { $parents_str = ids_to_querystr($r,'item_id'); - $items = q("SELECT item.*, item.id AS item_id + $r = q("SELECT item.*, item.id AS item_id FROM item WHERE item.uid = %d $item_normal AND item.parent IN ( %s ) @@ -371,8 +361,8 @@ class Channel extends Controller { dbesc($parents_str) ); - xchan_query($items); - $items = fetch_post_tags($items, true); + xchan_query($r); + $items = fetch_post_tags($r, true); $items = conv_sort($items,$ordering); if($load && $mid && (! count($items))) { @@ -385,6 +375,9 @@ class Channel extends Controller { $items = array(); } + // Add Opengraph markup + opengraph_add_meta((isset($decoded) && (! empty($items)) ? $r[0] : array()), App::$profile); + if((! $update) && (! $load)) { if($decoded) diff --git a/include/opengraph.php b/include/opengraph.php new file mode 100644 index 000000000..2d72ffca1 --- /dev/null +++ b/include/opengraph.php @@ -0,0 +1,71 @@ + false ]); + $ogdesc = trim(html2plain($ogdesc, 0, true)); + $ogdesc = html_entity_decode($ogdesc, ENT_QUOTES, 'UTF-8'); + + // remove all URLs + $ogdesc = preg_replace("/https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+/", "", $ogdesc); + + // shorten description + $ogdesc = substr($ogdesc, 0, 300); + $ogdesc = str_replace("\n", " ", $ogdesc); + while (strpos($ogdesc, " ") !== false) + $ogdesc = str_replace(" ", " ", $ogdesc); + $ogdesc = rtrim(substr($ogdesc, 0, strrpos($ogdesc, " ")), "?.,:;!-") . "..."; + + $ogtype = "article"; + } + + $channel = channelx_by_n($profile['profile_uid']); + + if(! isset($ogdesc)) { + if($profile['about'] && perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_profile')) { + $ogdesc = $profile['about']; + } + else { + $ogdesc = sprintf( t('This is the home page of %s.'), $channel['channel_name']); + } + } + + if(! isset($ogimage)) + $ogimage = $channel['xchan_photo_l']; + + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + + return true; + } + \ No newline at end of file -- cgit v1.2.3