From: Michael Vogel Date: Sat, 18 Jan 2014 20:32:14 +0000 (+0100) Subject: Beautifiying export of shared posts to other networks X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=de4d0765cb89aa0e46474e20135e1619e7d32a45;p=friendica.git Beautifiying export of shared posts to other networks --- diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index ffe6b3b970..59d0e88226 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -133,6 +133,10 @@ function diaspora_ol($s) { function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { + // Since Diaspora is creating a summary for links, this function removes them before posting + if ($fordiaspora) + $Text = bb_remove_share_information($Text); + // Re-enabling the converter again. // The bbcode parser now handles youtube-links (and the other stuff) correctly. // Additionally the html code is now fixed so that lists are now working. @@ -159,7 +163,10 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { //$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text); // Convert it to HTML - don't try oembed - $Text = bbcode($Text, $preserve_nl, false); + if ($fordiaspora) + $Text = bbcode($Text, $preserve_nl, false, 3); + else + $Text = bbcode($Text, $preserve_nl, false, 4); // Now convert HTML to Markdown $md = new Markdownify(false, false, false); @@ -179,7 +186,7 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { $count++; $pos = bb_find_open_close($Text, '[', ']', $count); - } + } // If the text going into bbcode() has a plain URL in it, i.e. // with no [url] tags around it, it will come out of parseString() diff --git a/include/bbcode.php b/include/bbcode.php index b5936aea48..bede60e23a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1,8 +1,48 @@ ".$st[2].""; } @@ -291,6 +331,112 @@ function bb_ShareAttributes($match) { return($text); } +// Escpecially for Diaspora (there mustn't be links in the share information) +function bb_ShareAttributesDiaspora($match) { + + $attributes = $match[2]; + + $author = ""; + preg_match("/author='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); + + preg_match('/author="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $author = $matches[1]; + + $profile = ""; + preg_match("/profile='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $profile = $matches[1]; + + preg_match('/profile="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $profile = $matches[1]; + + $posted = ""; +// preg_match("/posted='(.*?)'/ism", $attributes, $matches); +// if ($matches[1] != "") +// $posted = " ".date("Y-m-d H:i", strtotime($matches[1])); +// +// preg_match('/posted="(.*?)"/ism', $attributes, $matches); +// if ($matches[1] != "") +// $posted = " ".date("Y-m-d H:i", strtotime($matches[1])); + + $userid = GetProfileUsername($profile,$author); + + $headline = '
'; + $headline .= ''.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$userid.':'; + //$headline .= sprintf(t(''. + // html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'). + // '%s%s:'), $profile, $userid, $posted); + $headline .= "
"; + + $text = trim($match[1]); + + if ($text != "") + $text .= "
"; + + $text .= $headline.'
'.trim($match[3])."

"; + //$text .= $headline."
".trim($match[3])."
"; + + return($text); +} + +// Optimized for Libertree, Wordpress, Tumblr, ... +function bb_ShareAttributesForExport($match) { + + $attributes = $match[2]; + + $author = ""; + preg_match("/author='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); + + preg_match('/author="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $author = $matches[1]; + + $profile = ""; + preg_match("/profile='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $profile = $matches[1]; + + preg_match('/profile="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $profile = $matches[1]; + + $link = ""; + preg_match("/link='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $link = $matches[1]; + + preg_match('/link="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $link = $matches[1]; + + if ($link == "") + $link = $profile; + + $userid = GetProfileUsername($profile,$author); + + $headline = '
'; + $headline .= sprintf(t(''. + html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'). + '%s%s:'), $link, $userid, $posted); + $headline .= "
"; + + $text = trim($match[1]); + + if ($text != "") + $text .= "
"; + + $text .= $headline.'
'.trim($match[3])."

"; + + return($text); +} + +// Still in use? function bb_ShareAttributesSimple($match) { $attributes = $match[1]; @@ -319,6 +465,8 @@ function bb_ShareAttributesSimple($match) { return($text); } + +// Used for text exports (Twitter, Facebook, Google+) function bb_ShareAttributesSimple2($match) { $attributes = $match[1]; @@ -349,17 +497,22 @@ function bb_ShareAttributesSimple2($match) { } function GetProfileUsername($profile, $username) { + + $twitter = preg_replace("=https?://twitter.com/(.*)=ism", "$1@twitter.com", $profile); + if ($twitter != $profile) + return($username." (".$twitter.")"); + + $gplus = preg_replace("=https?://plus.google.com/(.*)=ism", "$1@plus.google.com", $profile); + if ($gplus != $profile) + return($username." (".$gplus.")"); + $friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2@$1", $profile); if ($friendica != $profile) - return($friendica." (".$username.")"); + return($username." (".$friendica.")"); $diaspora = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile); if ($diaspora != $profile) - return($diaspora." (".$username.")"); - - $twitter = preg_replace("=https?://twitter.com/(.*)=ism", "$1@twitter.com", $profile); - if ($twitter != $profile) - return($twitter." (".$username.")"); + return($username." (".$diaspora.")"); $StatusnetHost = preg_replace("=https?://(.*)/user/(.*)=ism", "$1", $profile); if ($StatusnetHost != $profile) { @@ -368,10 +521,15 @@ function GetProfileUsername($profile, $username) { $UserData = fetch_url("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser); $user = json_decode($UserData); if ($user) - return($user->screen_name."@".$StatusnetHost." (".$username.")"); + return($username." (".$user->screen_name."@".$StatusnetHost.")"); } } + // To-Do: Better check for pumpio + $pumpio = preg_replace("=https?://([^/]*).*/(\w*)=ism", "$2@$1", $profile); + if ($pumpio != $profile) + return($username." (".$pumpio.")"); + return($username); } @@ -630,6 +788,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesSimple",$Text); elseif ($simplehtml == 2) $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesSimple2",$Text); + elseif ($simplehtml == 3) + $Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesDiaspora",$Text); + elseif ($simplehtml == 4) + $Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesForExport",$Text); $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 04328e00da..b38900923a 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -1127,6 +1127,18 @@ border-bottom: 1px solid #D2D2D2; display: table; width: 745px; } + +.wall-item-content hr { + background: none repeat scroll 0% 0% rgb(221, 221, 221); + color: rgb(221, 221, 221); + clear: both; + float: none; + width: 100%; + height: 0.1em; + /* margin: 0px 0px 1.45em; */ + border: medium none; +} + .wall-item-container .wall-item-item, .wall-item-container .wall-item-bottom { display: table-row; } @@ -2135,7 +2147,8 @@ blockquote { } .oembed { - font-size: large; + /* font-size: large; */ + font-size: larger; font-weight: bold; }