From 4f4d6bace60fa3f43efeb675ba4f1617a9d9df58 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 31 Oct 2010 21:57:30 -0700 Subject: [PATCH] add rel=mentioned links for tagged persons --- boot.php | 14 ++++++++++++++ include/items.php | 3 +++ include/notifier.php | 8 ++++++++ mod/item.php | 2 +- view/atom_cmnt.tpl | 1 + view/atom_item.tpl | 1 + 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 30e5a111e5..2de398cfc4 100644 --- a/boot.php +++ b/boot.php @@ -1358,3 +1358,17 @@ function like_puller($a,$item,&$arr,$mode) { return; }} + +function get_mentions($item) { + $o = ''; + if(! strlen($item['tag'])) + return $o; + + $arr = explode(',',$item['tag']); + foreach($arr as $x) { + $matches = null; + if(preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) + $o .= "\t\t" . '' . "\r\n"; + } + return $o; +} \ No newline at end of file diff --git a/include/items.php b/include/items.php index d37f7708f9..7f62f6decd 100644 --- a/include/items.php +++ b/include/items.php @@ -187,6 +187,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) { else { $verb = construct_verb($item); $actobj = construct_activity($item); + $mentioned = get_mentions($item); if($item['parent'] == $item['id']) { $atom .= replace_macros($item_template, array( @@ -207,6 +208,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) { '$content' => xmlify($item['body']), '$verb' => xmlify($verb), '$actobj' => $actobj, // do not xmlify + '$mentioned' => $mentioned, '$comment_allow' => $allow )); } @@ -224,6 +226,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) { '$alt' => xmlify($a->get_baseurl() . '/display/' . $owner_nick . '/' . $item['id']), '$verb' => xmlify($verb), '$actobj' => $actobj, // do not xmlify + '$mentioned' => $mentioned, '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => $allow )); diff --git a/include/notifier.php b/include/notifier.php index 884493a79a..1f6bfa36aa 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -213,6 +213,7 @@ $verb = construct_verb($item); $actobj = construct_activity($item); + $mentioned = get_mentions($item); if($item['id'] == $item_id) { $slap = replace_macros($cmnt_template, array( @@ -231,6 +232,7 @@ '$type' => 'html', '$verb' => xmlify($verb), '$actobj' => $actobj, + '$mentioned' => $mentioned, '$alt' => xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']), '$content' => xmlify(bbcode($item['body'])), '$parent_id' => xmlify($item['parent-uri']), @@ -253,6 +255,7 @@ '$type' => 'text', '$verb' => xmlify($verb), '$actobj' => $actobj, + '$mentioned' => $mentioned, '$alt' => xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']), '$content' => xmlify($item['body']), '$parent_id' => xmlify($item['parent-uri']), @@ -283,6 +286,7 @@ $verb = construct_verb($item); $actobj = construct_activity($item); + $mentioned = get_mentions($item); if($item['parent'] == $item['id']) { $atom .= replace_macros($item_template, array( @@ -301,6 +305,7 @@ '$type' => 'text', '$verb' => xmlify($verb), '$actobj' => $actobj, + '$mentioned' => $mentioned, '$content' => xmlify($item['body']), '$alt' => xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']), '$comment_allow' => (($item['last-child']) ? 1 : 0) @@ -321,6 +326,7 @@ '$type' => 'html', '$verb' => xmlify($verb), '$actobj' => $actobj, + '$mentioned' => $mentioned, '$content' => xmlify(bbcode($item['body'])), '$alt' => xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']), '$comment_allow' => (($item['last-child']) ? 1 : 0) @@ -343,6 +349,7 @@ '$type' => 'text', '$verb' => xmlify($verb), '$actobj' => $actobj, + '$mentioned' => $mentioned, '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => (($item['last-child']) ? 1 : 0) )); @@ -361,6 +368,7 @@ '$type' => 'html', '$verb' => xmlify($verb), '$actobj' => $actobj, + '$mentioned' => $mentioned, '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => (($item['last-child']) ? 1 : 0) )); diff --git a/mod/item.php b/mod/item.php index 67832204d6..703267992d 100644 --- a/mod/item.php +++ b/mod/item.php @@ -165,7 +165,7 @@ function item_post(&$a) { if(strlen($str_tags)) $str_tags .= ','; $profile = str_replace(',','%2c',$profile); - $str_tags .= '[url=' . $profile . ']' . $newname . '[/url]'; + $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'; } } } diff --git a/view/atom_cmnt.tpl b/view/atom_cmnt.tpl index 6c1a15faa9..b70a6dc4ea 100644 --- a/view/atom_cmnt.tpl +++ b/view/atom_cmnt.tpl @@ -16,5 +16,6 @@ $comment_allow $verb $actobj + $mentioned diff --git a/view/atom_item.tpl b/view/atom_item.tpl index b26ba2e694..0d36b579d5 100644 --- a/view/atom_item.tpl +++ b/view/atom_item.tpl @@ -23,5 +23,6 @@ $comment_allow $verb $actobj + $mentioned