]> git.mxchange.org Git - friendica.git/commitdiff
Support for server independant Diaspora style links
authorMichael <heluecht@pirati.ca>
Wed, 6 Sep 2017 04:55:36 +0000 (04:55 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 6 Sep 2017 04:55:36 +0000 (04:55 +0000)
include/bbcode.php
include/diaspora.php

index aabf261616c24a31dca383358db7619739721519..be4667a2988f6bbb34c9c427e5a88631fe755824 100644 (file)
@@ -985,6 +985,10 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
        // Handle Diaspora posts
        $Text = preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", 'bb_DiasporaLinks', $Text);
 
+       // Server independent link to posts and comments
+       // See issue: https://github.com/diaspora/diaspora_federation/issues/75
+       $Text = preg_replace("=diaspora://(.*?)/([^\s\]]*)=ism", System::baseUrl()."/display/$2", $Text);
+
        // if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
 //     if ($simplehtml != 7) {
                if (!$forplaintext) {
index 4cc177a15bd25b0bd977f1781b2b9fd77f50206f..1907c0d5ad74366101a5640dbef1fbcfcc54a098 100644 (file)
@@ -1013,10 +1013,15 @@ class Diaspora {
         * @param array $item The item array
         */
        private static function fetch_guid($item) {
+               preg_replace_callback("=diaspora://.*?/([^\s\]]*)=ism",
+                       function ($match) use ($item) {
+                               return self::fetch_guid_sub($match, $item);
+                       }, $item["body"]);
+
                preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi",
-                       function ($match) use ($item){
-                               return(self::fetch_guid_sub($match, $item));
-                       },$item["body"]);
+                       function ($match) use ($item) {
+                               return self::fetch_guid_sub($match, $item);
+                       }, $item["body"]);
        }
 
        /**