]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add rel=nofollow to bookmark links if needed
authorEvan Prodromou <evan@status.net>
Thu, 20 Oct 2011 15:47:44 +0000 (11:47 -0400)
committerEvan Prodromou <evan@status.net>
Thu, 20 Oct 2011 15:47:44 +0000 (11:47 -0400)
plugins/Bookmark/bookmarklistitem.php

index 9b7a3742fa12303b1cb11bf58d2a268bf00da32f..a2dbf8156dafdef83afef57295e23f18edd4e84e 100644 (file)
@@ -62,38 +62,37 @@ class BookmarkListItem extends NoticeListItemAdapter
 
         $nb = Bookmark::getByNotice($notice);
 
-        $profile = $notice->getProfile();
+        if (empty($nb)) {
+            common_log(LOG_ERR, "No bookmark for notice {$notice->id}");
+            parent::showContent();
+            return;
+        } else if (empty($nb->url)) {
+            common_log(LOG_ERR, "No url for bookmark {$nb->id} for notice {$notice->id}");
+            parent::showContent();
+            return;
+        }
 
-        $atts = $notice->attachments();
+        $profile = $notice->getProfile();
 
-        if (empty($atts)) {
+        $out->elementStart('p', array('class' => 'entry-content'));
 
-            // Something went wrong!
+        // Whether to nofollow
 
-            common_log(
-                LOG_ERR,
-                sprintf(
-                    'Bookmark %1$s (notice %2$d) has no attachments.',
-                    $nb->id,
-                    $notice->id
-                )
-            );
+        $attrs = array('href' => $nb->url,
+                       'class' => 'bookmark-title');
 
-            // try to show the notice as plain text
+        $nf = common_config('nofollow', 'external');
 
-            parent::showContent();
-            return;
+        if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
+            $attrs['rel'] = 'external';
+        } else {
+            $attrs['rel'] = 'nofollow external';
         }
 
-        $out->elementStart('p', array('class' => 'entry-content'));
-
-        $att = $atts[0];
-
         $out->elementStart('h3');
         $out->element('a',
-                  array('href' => $att->url,
-                        'class' => 'bookmark-title'),
-                  $nb->title);
+                      $attrs,
+                      $nb->title);
         $out->elementEnd('h3');
 
         // Replies look like "for:" tags