]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
OStatus: override source link with the source domain and link to original message
authorBrion Vibber <brion@pobox.com>
Wed, 17 Feb 2010 02:16:03 +0000 (02:16 +0000)
committerBrion Vibber <brion@pobox.com>
Wed, 17 Feb 2010 02:16:03 +0000 (02:16 +0000)
lib/noticelist.php
plugins/OStatus/OStatusPlugin.php

index c05b990245f01acdce345b4866d94212367b9c46..837cb90faa13bb29a9fdfe0f5734c569995c0650 100644 (file)
@@ -492,30 +492,34 @@ class NoticeListItem extends Widget
                 break;
              default:
 
-                $name = null;
+                $name = $source_name;
                 $url  = null;
 
-                $ns = Notice_source::staticGet($this->notice->source);
-
-                if ($ns) {
-                    $name = $ns->name;
-                    $url  = $ns->url;
-                } else {
-                    $app = Oauth_application::staticGet('name', $this->notice->source);
-                    if ($app) {
-                        $name = $app->name;
-                        $url  = $app->source_url;
+                if (Event::handle('StartNoticeSourceLink', array($this->notice, &$name, &$url, &$title))) {
+                    $ns = Notice_source::staticGet($this->notice->source);
+
+                    if ($ns) {
+                        $name = $ns->name;
+                        $url  = $ns->url;
+                    } else {
+                        $app = Oauth_application::staticGet('name', $this->notice->source);
+                        if ($app) {
+                            $name = $app->name;
+                            $url  = $app->source_url;
+                        }
                     }
                 }
+                Event::handle('EndNoticeSourceLink', array($this->notice, &$name, &$url, &$title));
 
                 if (!empty($name) && !empty($url)) {
                     $this->out->elementStart('span', 'device');
                     $this->out->element('a', array('href' => $url,
-                                                   'rel' => 'external'),
+                                                   'rel' => 'external',
+                                                   'title' => $title),
                                         $name);
                     $this->out->elementEnd('span');
                 } else {
-                    $this->out->element('span', 'device', $source_name);
+                    $this->out->element('span', 'device', $name);
                 }
                 break;
             }
index 3b1329d6c5d1ad2f926a7582c1f42041c6bc105c..b6c9fa1d4c28b2439255f1af31d6f3f657eaf482 100644 (file)
@@ -289,4 +289,17 @@ class OStatusPlugin extends Plugin
         $action->script(common_path('plugins/OStatus/js/ostatus.js'));
         return true;
     }
+
+    function onStartNoticeSourceLink($notice, &$name, &$url, &$title)
+    {
+        if ($notice->source == 'ostatus') {
+            $bits = parse_url($notice->uri);
+            $domain = $bits['host'];
+
+            $name = $domain;
+            $url = $notice->uri;
+            $title = sprintf(_m("Sent from %s via OStatus"), $domain);
+            return false;
+        }
+    }
 }