From c22f65bafa08ea348d55fb1f3c05774b0f320c99 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 19 Dec 2012 12:18:52 +0100 Subject: [PATCH] repeated items from ostatus and diaspora are now using the share-element. Some design changes to repeated items in "vier". --- include/bbcode.php | 5 +++-- include/delivery.php | 19 ++++++++++++++----- include/diaspora.php | 7 ++++++- include/items.php | 14 ++++++++++---- include/notifier.php | 17 +++++++++++++---- include/onepoll.php | 5 +++-- include/text.php | 3 +++ view/de/strings.php | 2 ++ view/theme/vier/style.css | 4 ++-- 9 files changed, 56 insertions(+), 20 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index b3f6aa826..e09b1ed34 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -251,11 +251,11 @@ function bb_ShareAttributes($match) { if ($avatar != "") $headline .= ''; - $headline .= sprintf(t('%s wrote the following post:'), $profile, $author, $link); + $headline .= sprintf(t('%s wrote the following post:'), $profile, $author, $link); $headline .= ""; - $text = "
".$headline.'
'.trim($match[2])."
"; + $text = $headline.'
'.trim($match[2])."
"; return($text); } @@ -314,6 +314,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // We'll emulate it. + $Text = trim($Text); $Text = str_replace("\r\n","\n", $Text); $Text = str_replace(array("\r","\n"), array('
','
'), $Text); diff --git a/include/delivery.php b/include/delivery.php index c56d7d288..e8bf338a8 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -439,14 +439,14 @@ function delivery_run(&$argv, &$argc){ } if(! $it) break; - + $local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid) ); if(! count($local_user)) break; - + $reply_to = ''; $r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($uid) @@ -482,12 +482,21 @@ function delivery_run(&$argv, &$argc){ if($it['uri'] !== $it['parent-uri']) { $headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n"; - if(!strlen($it['title'])) { - $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1", - dbesc($it['parent-uri'])); + if(!$it['title']) { + $r = q("SELECT `title` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($it['parent-uri']), + intval($uid)); if(count($r) AND ($r[0]['title'] != '')) $subject = $r[0]['title']; + else { + $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($it['parent-uri']), + intval($uid)); + + if(count($r) AND ($r[0]['title'] != '')) + $subject = $r[0]['title']; + } } if(strncasecmp($subject,'RE:',3)) $subject = 'Re: '.$subject; diff --git a/include/diaspora.php b/include/diaspora.php index c2b2fbcf4..b14402b5a 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -923,6 +923,7 @@ function diaspora_reshare($importer,$xml,$msg) { $orig_guid = notags(unxmlify($xml->root_guid)); $source_url = 'https://' . substr($orig_author,strpos($orig_author,'@')+1) . '/p/' . $orig_guid . '.xml'; + $orig_url = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid; $x = fetch_url($source_url); if(! $x) $x = fetch_url(str_replace('https://','http://',$source_url)); @@ -1032,10 +1033,14 @@ function diaspora_reshare($importer,$xml,$msg) { $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']); $datarray['body'] = $body; } else { + $prefix = "[share author='".$person['name']. + "' profile='".$person['url']. + "' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']). + "' link='".$orig_url."']"; $datarray['author-name'] = $contact['name']; $datarray['author-link'] = $contact['url']; $datarray['author-avatar'] = $contact['thumb']; - $datarray['body'] = $prefix . $body; + $datarray['body'] = $prefix.$body."[/share]"; } $datarray['tag'] = $str_tags; diff --git a/include/items.php b/include/items.php index fb7a7e25d..5bd4423cf 100755 --- a/include/items.php +++ b/include/items.php @@ -798,6 +798,7 @@ function get_atom_elements($feed,$item) { logger('get_atom_elements: Looking for status.net repeated message'); $message = $child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["content"][0]["data"]; + $orig_uri = $child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["id"][0]["data"]; $author = $child[SIMPLEPIE_NAMESPACE_ATOM_10]["author"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]; $uri = $author["uri"][0]["data"]; $name = $author["name"][0]["data"]; @@ -805,17 +806,22 @@ function get_atom_elements($feed,$item) { $avatar = $avatar["href"]; if (($name != "") and ($uri != "") and ($avatar != "") and ($message != "")) { - logger('get_atom_elements: fixing sender of repeated message'); + logger('get_atom_elements: fixing sender of repeated message. '.print_r($child, true)); - $res["owner-name"] = $res["author-name"]; + /*$res["owner-name"] = $res["author-name"]; $res["owner-link"] = $res["author-link"]; $res["owner-avatar"] = $res["author-avatar"]; $res["author-name"] = $name; $res["author-link"] = $uri; - $res["author-avatar"] = $avatar; + $res["author-avatar"] = $avatar;*/ - $res["body"] = html2bbcode($message); + $prefix = "[share author='".$name. + "' profile='".$uri. + "' avatar='".$avatar. + "' link='".$orig_uri."']"; + + $res["body"] = $prefix.html2bbcode($message)."[/share]"; } } diff --git a/include/notifier.php b/include/notifier.php index b685e1b99..c522bcb6b 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -791,12 +791,21 @@ function notifier_run(&$argv, &$argc){ if($it['uri'] !== $it['parent-uri']) { $headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n"; - if(!strlen($it['title'])) { - $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1", - dbesc($it['parent-uri'])); + if(!$it['title']) { + $r = q("SELECT `title` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($it['parent-uri']), + intval($uid)); - if(count($r) AND ($r[0]['title'] != '')) + if(count($r) AND ($r[0]['title'] != '')) $subject = $r[0]['title']; + else { + $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($it['parent-uri']), + intval($uid)); + + if(count($r) AND ($r[0]['title'] != '')) + $subject = $r[0]['title']; + } } if(strncasecmp($subject,'RE:',3)) $subject = 'Re: '.$subject; diff --git a/include/onepoll.php b/include/onepoll.php index 1e11f2ca1..7b2eba70d 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -405,8 +405,9 @@ function onepoll_run(&$argv, &$argc){ // If it seems to be a reply but a header couldn't be found take the last message with matching subject if(!x($datarray,'parent-uri') and $reply) { - $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) ORDER BY `created` DESC LIMIT 1", - dbesc(protect_sprintf($datarray['title']))); + $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) AND `uid` = %d ORDER BY `created` DESC LIMIT 1", + dbesc(protect_sprintf($datarray['title'])), + intval($importer_uid)); if(count($r)) $datarray['parent-uri'] = $r[0]['parent-uri']; } diff --git a/include/text.php b/include/text.php index 7d26d3550..4212e23ca 100644 --- a/include/text.php +++ b/include/text.php @@ -982,6 +982,9 @@ function prepare_body($item,$attach = false) { $s = $prep_arr['html']; if(! $attach) { + // Replace the blockquotes with quotes that are used in mails + $mailquote = '
'; + $s = str_replace(array('
', '
', '
'), array($mailquote, $mailquote, $mailquote), $s); return $s; } diff --git a/view/de/strings.php b/view/de/strings.php index 7bded94a4..30e2d740f 100644 --- a/view/de/strings.php +++ b/view/de/strings.php @@ -2081,3 +2081,5 @@ $a->strings["Post to Drupal by default"] = "Veröffentliche öffentliche Beiträ $a->strings["OEmbed settings updated"] = "OEmbed Einstellungen aktualisiert."; $a->strings["Use OEmbed for YouTube videos"] = "OEmbed für Youtube Videos verwenden"; $a->strings["URL to embed:"] = "URL zum Einbetten:"; +$a->strings['%s wrote the following post:'] = + '%s hat diesen Beitrag ursprünglich gepostet:'; diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index d6acade69..91680f41c 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -356,8 +356,8 @@ div.pager, .birthday-notice { height: 32px; color: #999; border-top: 1px solid #D2D2D2; - padding-top: 16px; - margin-top: 16px; + padding-top: 5px; + margin-top: 5px; } .shared_header img {