From d64bb0dd8f056fa98cd8c16269318e309add3240 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 18 Feb 2020 06:57:38 +0000 Subject: [PATCH 1/2] Remotely load posts to comment on them on the own page --- src/Model/Profile.php | 2 ++ src/Object/Post.php | 9 +++++++++ view/templates/wall_thread.tpl | 3 +++ view/theme/frio/templates/wall_thread.tpl | 4 ++++ view/theme/quattro/templates/wall_thread.tpl | 4 ++++ view/theme/vier/templates/wall_thread.tpl | 4 ++++ 6 files changed, 26 insertions(+) diff --git a/src/Model/Profile.php b/src/Model/Profile.php index c08138452..4956ef9bb 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -27,6 +27,7 @@ use Friendica\Content\Widget\ContactBlock; use Friendica\Core\Cache\Duration; use Friendica\Core\Hook; use Friendica\Core\Logger; +use Friendica\Network\Probe; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Session; @@ -785,6 +786,7 @@ class Profile $_SESSION['visitor_handle'] = $visitor['addr']; $_SESSION['visitor_home'] = $visitor['url']; $_SESSION['my_url'] = $visitor['url']; + $_SESSION['remote_follow'] = Probe::getRemoteFollowLink($visitor['url']); Session::setVisitorsContacts(); diff --git a/src/Object/Post.php b/src/Object/Post.php index 31cbe7a7e..dc4fc51f5 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -392,6 +392,14 @@ class Post $ago = DI::l10n()->t('%s (Received %s)', $ago, $ago_received); } + // Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments + if (($item['network'] != Protocol::DIASPORA) && empty($comment) && !empty(Session::get('remote_follow'))) { + $remote_comment = [DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('remote comment'), + str_replace('{uri}', urlencode($item['uri']), Session::get('remote_follow'))]; + } else { + $remote_comment = ''; + } + $tmp_item = [ 'template' => $this->getTemplate(), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), @@ -455,6 +463,7 @@ class Post 'switchcomment' => DI::l10n()->t('Comment'), 'reply_label' => DI::l10n()->t('Reply to %s', $name_e), 'comment' => $comment, + 'remote_comment' => $remote_comment, 'menu' => DI::l10n()->t('More'), 'previewing' => $conv->isPreview() ? ' preview ' : '', 'wait' => DI::l10n()->t('Please wait'), diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index 0816400d5..390f99b46 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -83,6 +83,9 @@ {{/if}} + {{if $item.remote_comment}} + + {{/if}} {{if $item.plink}} {{/if}} diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index a8d21500f..5a0cf57fa 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -287,6 +287,10 @@ as the value of $top_child_total (this is done at the end of this file) {{/if}} {{/if}} + {{if $item.remote_comment}} +  {{$item.remote_comment.1}} + {{/if}} + {{* Button to open the comment text field *}} {{if $item.comment}} diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index 77d63f6e5..10f8fe998 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -113,6 +113,10 @@ {{$item.filer}} {{/if}} + {{if $item.remote_comment}} + {{$item.remote_comment.1}} + {{/if}} + {{if $item.vote}} {{$item.vote.like.1}} {{if $item.vote.dislike}} diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index 169d1b214..aef411bca 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -102,6 +102,10 @@
{{if $item.threaded}} {{/if}} + {{if $item.remote_comment}} + {{$item.remote_comment.1}} + {{/if}} + {{if $item.comment}} {{$item.switchcomment}} {{/if}} From efddd248f70c332e3d3c5666dfb219c0480299f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 18 Feb 2020 17:31:02 +0000 Subject: [PATCH 2/2] "remote_follow" is now "remote_comment" --- src/Model/Profile.php | 2 +- src/Object/Post.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 4956ef9bb..cf9e7c620 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -786,7 +786,7 @@ class Profile $_SESSION['visitor_handle'] = $visitor['addr']; $_SESSION['visitor_home'] = $visitor['url']; $_SESSION['my_url'] = $visitor['url']; - $_SESSION['remote_follow'] = Probe::getRemoteFollowLink($visitor['url']); + $_SESSION['remote_comment'] = Probe::getRemoteFollowLink($visitor['url']); Session::setVisitorsContacts(); diff --git a/src/Object/Post.php b/src/Object/Post.php index dc4fc51f5..5f264c988 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -393,9 +393,9 @@ class Post } // Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments - if (($item['network'] != Protocol::DIASPORA) && empty($comment) && !empty(Session::get('remote_follow'))) { + if (($item['network'] != Protocol::DIASPORA) && empty($comment) && !empty(Session::get('remote_comment'))) { $remote_comment = [DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('remote comment'), - str_replace('{uri}', urlencode($item['uri']), Session::get('remote_follow'))]; + str_replace('{uri}', urlencode($item['uri']), Session::get('remote_comment'))]; } else { $remote_comment = ''; }