From eb714f0487a78ab64104fe1d2ab6b117c480116d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 18 Oct 2018 22:39:06 -0400 Subject: [PATCH 1/2] Diaspora: Widen the magic link regular expression --- src/Content/Text/BBCode.php | 2 +- src/Protocol/Diaspora.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 8d5da11cda..be2054067b 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1319,7 +1319,7 @@ class BBCode extends BaseObject // Handle Diaspora posts $text = preg_replace_callback( - "&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", + "&\[url=/?posts/([^\[\]]*)\](.*)\[\/url\]&Usi", function ($match) { return "[url=" . System::baseUrl() . "/display/" . $match[1] . "]" . $match[2] . "[/url]"; }, $text diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 0c3a52b2d3..5792d56b6e 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1200,7 +1200,7 @@ class Diaspora ); preg_replace_callback( - "&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", + "&\[url=/?posts/([^\[\]]*)\](.*)\[\/url\]&Usi", function ($match) use ($item) { self::fetchGuidSub($match, $item); }, From d0681075bf7b6d1bf998da8ac2c43ce2134f4804 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 18 Oct 2018 22:49:25 -0400 Subject: [PATCH 2/2] Add itemsource module --- src/Model/Conversation.php | 5 ++++ src/Module/Itemsource.php | 39 +++++++++++++++++++++++++++++ view/templates/debug/itemsource.tpl | 28 +++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/Module/Itemsource.php create mode 100644 view/templates/debug/itemsource.tpl diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index be1eaf2295..25075dcfbe 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -26,6 +26,11 @@ class Conversation const PARCEL_TWITTER = 67; const PARCEL_UNKNOWN = 255; + public static function getByItemUri($item_uri) + { + return DBA::selectFirst('conversation', [], ['item-uri' => $item_uri]); + } + /** * @brief Store the conversation data * diff --git a/src/Module/Itemsource.php b/src/Module/Itemsource.php new file mode 100644 index 0000000000..bcbd557182 --- /dev/null +++ b/src/Module/Itemsource.php @@ -0,0 +1,39 @@ + + */ +class Itemsource extends \Friendica\BaseModule +{ + public static function content() + { + if (!is_site_admin()) { + return; + } + + $source = ''; + $item_uri = ''; + if (!empty($_REQUEST['guid'])) { + $item = Model\Item::selectFirst([], ['guid' => $_REQUEST['guid']]); + + $conversation = Model\Conversation::getByItemUri($item['uri']); + + $item_uri = $item['uri']; + $source = htmlspecialchars($conversation['source']); + } + + $tpl = get_markup_template('debug/itemsource.tpl'); + $o = replace_macros($tpl, [ + '$guid' => ['guid', L10n::t('Item Guid'), htmlentities(defaults($_REQUEST, 'guid', '')), ''], + '$source' => $source, + '$item_uri' => $item_uri + ]); + + return $o; + } +} diff --git a/view/templates/debug/itemsource.tpl b/view/templates/debug/itemsource.tpl new file mode 100644 index 0000000000..377409ebf3 --- /dev/null +++ b/view/templates/debug/itemsource.tpl @@ -0,0 +1,28 @@ +

Item Source

+
+
+
+ {{include file="field_input.tpl" field=$guid}} +
+

+
+
+ +{{if $source}} +
+
+
+

Item URI

+
+
+ {{$item_uri}} +
+
+
+
+

Source

+
+
{{$source}}
+
+
+{{/if}}