Merge pull request #128 from annando/master

fromgplus and gpluspost
This commit is contained in:
Tobias Diekershoff 2013-06-10 22:32:49 -07:00
commit 494318cb02
4 changed files with 33 additions and 12 deletions

View file

@ -212,7 +212,7 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
return($cleaned);
}
function fromgplus_handleattachments($item) {
function fromgplus_handleattachments($item, $displaytext) {
$post = "";
$quote = "";
@ -251,7 +251,7 @@ function fromgplus_handleattachments($item) {
elseif ($images["full"] != "")
$post .= "\n[img]".$images["full"]."[/img]\n";
if ($attachment->displayName != "")
if (($attachment->displayName != "") AND ($attachment->displayName != $displaytext))
$post .= fromgplus_html2bbcode($attachment->displayName)."\n";
break;
@ -319,7 +319,7 @@ function fromgplus_fetch($a, $uid) {
$post = fromgplus_html2bbcode($item->object->content);
if (is_array($item->object->attachments))
$post .= fromgplus_handleattachments($item);
$post .= fromgplus_handleattachments($item, $item->object->content);
// geocode, placeName
if (isset($item->address))
@ -346,7 +346,7 @@ function fromgplus_fetch($a, $uid) {
$post .= fromgplus_html2bbcode($item->object->content);
if (is_array($item->object->attachments))
$post .= "\n".trim(fromgplus_handleattachments($item));
$post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
$post .= "[/share]";
} else {
@ -355,7 +355,7 @@ function fromgplus_fetch($a, $uid) {
$post .= fromgplus_html2bbcode($item->object->content);
if (is_array($item->object->attachments))
$post .= "\n".trim(fromgplus_handleattachments($item));
$post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
}
if (isset($item->address))

View file

@ -51,6 +51,9 @@ function gpluspost_settings(&$a,&$s) {
$noloop_enabled = get_pconfig(local_user(),'gpluspost','no_loop_prevention');
$noloop_checked = (($noloop_enabled) ? ' checked="checked" ' : '');
$skip_enabled = get_pconfig(local_user(),'gpluspost','skip_without_link');
$skip_checked = (($skip_enabled) ? ' checked="checked" ' : '');
$s .= '<div class="settings-block">';
$s .= '<h3>' . t('Google+ Post Settings') . '</h3>';
$s .= '<div id="gpluspost-enable-wrapper">';
@ -68,6 +71,11 @@ function gpluspost_settings(&$a,&$s) {
$s .= '<input id="gpluspost-noloopprevention" type="checkbox" name="gpluspost_noloopprevention" value="1" ' . $noloop_checked . '/>';
$s .= '</div><div class="clear"></div>';
$s .= '<div id="gpluspost-skipwithoutlink-wrapper">';
$s .= '<label id="gpluspost-skipwithoutlink-label" for="gpluspost-skipwithoutlink">' . t('Skip messages without links') . '</label>';
$s .= '<input id="gpluspost-skipwithoutlink" type="checkbox" name="gpluspost_skipwithoutlink" value="1" ' . $skip_checked . '/>';
$s .= '</div><div class="clear"></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="gpluspost-submit" name="gpluspost-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
@ -81,6 +89,7 @@ function gpluspost_settings_post(&$a,&$b) {
set_pconfig(local_user(),'gpluspost','post',intval($_POST['gpluspost']));
set_pconfig(local_user(),'gpluspost','post_by_default',intval($_POST['gpluspost_bydefault']));
set_pconfig(local_user(),'gpluspost','no_loop_prevention',intval($_POST['gpluspost_noloopprevention']));
set_pconfig(local_user(),'gpluspost','skip_without_link',intval($_POST['gpluspost_skipwithoutlink']));
}
}
@ -286,7 +295,7 @@ function gpluspost_feeditem($pid, $uid) {
require_once('include/bbcode.php');
require_once("include/html2plain.php");
$max_char = 140;
$skipwithoutlink = get_pconfig($uid,'gpluspost','skip_without_link');
$items = q("SELECT `uri`, `plink`, `author-link`, `author-name`, `created`, `edited`, `id`, `title`, `body` from `item` WHERE id=%d", intval($pid));
foreach ($items AS $item) {
@ -349,7 +358,9 @@ function gpluspost_feeditem($pid, $uid) {
else if ($image != "")
$msglink = $image;
if ($msglink == "")
if (($msglink == "") AND $skipwithoutlink)
continue;
else if ($msglink == "")
$msglink = $item["plink"];
// Fetching the title - or the first line

5
pumpio/README Normal file
View file

@ -0,0 +1,5 @@
To let the connector work properly you should define an application name in the .htconfig:
$a->config['pumpio']['application_name'] = "Name of you site";
This name appears at pump.io and is mportant for not mirroring back posts that came from friendica.

View file

@ -311,7 +311,7 @@ function twitter_shortenmsg($b) {
require_once("include/bbcode.php");
require_once("include/html2plain.php");
$max_char = 130;
$max_char = 140;
// Looking for the first image
$image = '';
@ -414,15 +414,20 @@ function twitter_shortenmsg($b) {
if (($msglink == "") and strlen($msg) > $max_char)
$msglink = $b["plink"];
// If the message is short enough then don't modify it. (if the link exists in the original message)
if ((strlen(trim($origmsg)) <= $max_char) AND (strpos($origmsg, $msglink) OR ($msglink == "")))
// If the message is short enough then don't modify it.
if ((strlen(trim($origmsg)) <= $max_char) AND ($msglink == ""))
return(trim($origmsg));
// If the message is short enough and the link exists in the original message don't modify it as well
// -3 because of the bad shortener of twitter
if ((strlen(trim($origmsg)) <= ($max_char - 3)) AND strpos($origmsg, $msglink))
return(trim($origmsg));
if (strlen($msglink) > 20)
$msglink = short_link($msglink);
if (strlen(trim($msg." ".$msglink)) > $max_char) {
$msg = substr($msg, 0, $max_char - (strlen($msglink)));
if (strlen(trim($msg." ".$msglink)) > ($max_char - 3)) {
$msg = substr($msg, 0, ($max_char - 3) - (strlen($msglink)));
$lastchar = substr($msg, -1);
$msg = substr($msg, 0, -1);
$pos = strrpos($msg, "\n");