mirror of
https://github.com/friendica/friendica
synced 2024-11-10 02:22:55 +00:00
Merge pull request #8792 from MrPetovan/task/share-block-guid
[frio] Add local post link to share block when guid attribute is present
This commit is contained in:
commit
7fd2c00171
7 changed files with 42 additions and 23 deletions
|
@ -2046,7 +2046,7 @@ function api_statuses_repeat($type)
|
||||||
$pos = strpos($item['body'], "[share");
|
$pos = strpos($item['body'], "[share");
|
||||||
$post = substr($item['body'], $pos);
|
$post = substr($item['body'], $pos);
|
||||||
} else {
|
} else {
|
||||||
$post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['guid'], $item['created'], $item['plink']);
|
$post = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']);
|
||||||
|
|
||||||
if (!empty($item['title'])) {
|
if (!empty($item['title'])) {
|
||||||
$post .= '[h3]' . $item['title'] . "[/h3]\n";
|
$post .= '[h3]' . $item['title'] . "[/h3]\n";
|
||||||
|
|
|
@ -43,7 +43,7 @@ function share_init(App $a) {
|
||||||
$pos = strpos($item['body'], "[share");
|
$pos = strpos($item['body'], "[share");
|
||||||
$o = substr($item['body'], $pos);
|
$o = substr($item['body'], $pos);
|
||||||
} else {
|
} else {
|
||||||
$o = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['guid'], $item['created'], $item['plink']);
|
$o = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid']);
|
||||||
|
|
||||||
if ($item['title']) {
|
if ($item['title']) {
|
||||||
$o .= '[h3]'.$item['title'].'[/h3]'."\n";
|
$o .= '[h3]'.$item['title'].'[/h3]'."\n";
|
||||||
|
|
|
@ -978,7 +978,7 @@ class BBCode
|
||||||
function ($match) use ($callback) {
|
function ($match) use ($callback) {
|
||||||
$attribute_string = $match[2];
|
$attribute_string = $match[2];
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach (['author', 'profile', 'avatar', 'link', 'posted'] as $field) {
|
foreach (['author', 'profile', 'avatar', 'link', 'posted', 'guid'] as $field) {
|
||||||
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
|
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
|
||||||
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
|
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
@ -1088,6 +1088,7 @@ class BBCode
|
||||||
'$link' => $attributes['link'],
|
'$link' => $attributes['link'],
|
||||||
'$link_title' => DI::l10n()->t('link to source'),
|
'$link_title' => DI::l10n()->t('link to source'),
|
||||||
'$posted' => $attributes['posted'],
|
'$posted' => $attributes['posted'],
|
||||||
|
'$guid' => $attributes['guid'],
|
||||||
'$network_name' => ContactSelector::networkToName($contact['network'], $attributes['profile']),
|
'$network_name' => ContactSelector::networkToName($contact['network'], $attributes['profile']),
|
||||||
'$network_icon' => ContactSelector::networkToIcon($contact['network'], $attributes['profile']),
|
'$network_icon' => ContactSelector::networkToIcon($contact['network'], $attributes['profile']),
|
||||||
'$content' => self::setMentions(trim($content), 0, $contact['network']),
|
'$content' => self::setMentions(trim($content), 0, $contact['network']),
|
||||||
|
@ -2229,30 +2230,28 @@ class BBCode
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $author
|
* @param string $author Author display name
|
||||||
* @param $profile
|
* @param string $profile Author profile URL
|
||||||
* @param $avatar
|
* @param string $avatar Author profile picture URL
|
||||||
* @param $guid
|
* @param string $link Post source URL
|
||||||
* @param $posted
|
* @param string $posted Post created date
|
||||||
* @param $link
|
* @param string|null $guid Post guid (if any)
|
||||||
* @return string
|
* @return string
|
||||||
* @TODO Rewrite to handle over whole record array
|
* @TODO Rewrite to handle over whole record array
|
||||||
*/
|
*/
|
||||||
public static function getShareOpeningTag($author, $profile, $avatar, $guid, $posted, $link)
|
public static function getShareOpeningTag(string $author, string $profile, string $avatar, string $link, string $posted, string $guid = null)
|
||||||
{
|
{
|
||||||
$header = "[share author='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $author) .
|
$header = "[share author='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $author) .
|
||||||
"' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile) .
|
"' profile='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $profile) .
|
||||||
"' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar);
|
"' avatar='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $avatar) .
|
||||||
|
"' link='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $link) .
|
||||||
|
"' posted='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
|
||||||
|
|
||||||
if ($guid) {
|
if ($guid) {
|
||||||
$header .= "' guid='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
|
$header .= "' guid='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($posted) {
|
$header .= "']";
|
||||||
$header .= "' posted='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $posted);
|
|
||||||
}
|
|
||||||
|
|
||||||
$header .= "' link='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $link)."']";
|
|
||||||
|
|
||||||
return $header;
|
return $header;
|
||||||
}
|
}
|
||||||
|
|
|
@ -864,7 +864,7 @@ class Transmitter
|
||||||
|
|
||||||
// Disguise forum posts as reshares. Will later be converted to a real announce
|
// Disguise forum posts as reshares. Will later be converted to a real announce
|
||||||
$item['body'] = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
|
$item['body'] = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
|
||||||
$item['guid'], $item['created'], $item['plink']) . $item['body'] . '[/share]';
|
$item['plink'], $item['created'], $item['guid']) . $item['body'] . '[/share]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2799,9 +2799,9 @@ class Diaspora
|
||||||
$original_item["author-name"],
|
$original_item["author-name"],
|
||||||
$original_item["author-link"],
|
$original_item["author-link"],
|
||||||
$original_item["author-avatar"],
|
$original_item["author-avatar"],
|
||||||
$original_item["guid"],
|
$orig_url,
|
||||||
$original_item["created"],
|
$original_item["created"],
|
||||||
$orig_url
|
$original_item["guid"]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!empty($original_item['title'])) {
|
if (!empty($original_item['title'])) {
|
||||||
|
@ -3677,7 +3677,7 @@ class Diaspora
|
||||||
if ($item['author-link'] != $item['owner-link']) {
|
if ($item['author-link'] != $item['owner-link']) {
|
||||||
require_once 'mod/share.php';
|
require_once 'mod/share.php';
|
||||||
$body = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
|
$body = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
|
||||||
"", $item['created'], $item['plink']) . $body . '[/share]';
|
$item['plink'], $item['created']) . $body . '[/share]';
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to markdown
|
// convert to markdown
|
||||||
|
|
|
@ -192,6 +192,8 @@ return [
|
||||||
'allow_gid' => '',
|
'allow_gid' => '',
|
||||||
'deny_cid' => '',
|
'deny_cid' => '',
|
||||||
'deny_gid' => '',
|
'deny_gid' => '',
|
||||||
|
'guid' => '1',
|
||||||
|
'plink' => 'http://localhost/display/1',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 2,
|
'id' => 2,
|
||||||
|
@ -209,6 +211,8 @@ return [
|
||||||
'wall' => 1,
|
'wall' => 1,
|
||||||
'starred' => 0,
|
'starred' => 0,
|
||||||
'origin' => 1,
|
'origin' => 1,
|
||||||
|
'guid' => '2',
|
||||||
|
'plink' => 'http://localhost/display/2',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
||||||
|
@ -227,6 +231,8 @@ return [
|
||||||
'wall' => 1,
|
'wall' => 1,
|
||||||
'starred' => 0,
|
'starred' => 0,
|
||||||
'origin' => 1,
|
'origin' => 1,
|
||||||
|
'guid' => '3',
|
||||||
|
'plink' => 'http://localhost/display/3',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 4,
|
'id' => 4,
|
||||||
|
@ -244,6 +250,8 @@ return [
|
||||||
'wall' => 1,
|
'wall' => 1,
|
||||||
'starred' => 0,
|
'starred' => 0,
|
||||||
'origin' => 1,
|
'origin' => 1,
|
||||||
|
'guid' => '4',
|
||||||
|
'plink' => 'http://localhost/display/4',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
||||||
|
@ -266,6 +274,8 @@ return [
|
||||||
'allow_gid' => '',
|
'allow_gid' => '',
|
||||||
'deny_cid' => '',
|
'deny_cid' => '',
|
||||||
'deny_gid' => '',
|
'deny_gid' => '',
|
||||||
|
'guid' => '5',
|
||||||
|
'plink' => 'http://localhost/display/5',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 6,
|
'id' => 6,
|
||||||
|
@ -283,6 +293,8 @@ return [
|
||||||
'wall' => 1,
|
'wall' => 1,
|
||||||
'starred' => 0,
|
'starred' => 0,
|
||||||
'origin' => 1,
|
'origin' => 1,
|
||||||
|
'guid' => '6',
|
||||||
|
'plink' => 'http://localhost/display/6',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'notify' => [
|
'notify' => [
|
||||||
|
|
|
@ -18,7 +18,15 @@
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="shared-wall-item-ago"><small><span class="shared-time">{{$posted}}</span></small></div>
|
<div class="shared-wall-item-ago"><small>
|
||||||
|
{{if $guid}}
|
||||||
|
<a href="/display/{{$guid}}">
|
||||||
|
{{/if}}
|
||||||
|
<span class="shared-time">{{$posted}}</span>
|
||||||
|
{{if $guid}}
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
|
</small></div>
|
||||||
</div>
|
</div>
|
||||||
<blockquote class="shared_content">{{$content nofilter}}</blockquote>
|
<blockquote class="shared_content">{{$content nofilter}}</blockquote>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue