From b3eb963a2bdff7735b32085f30c9a715d14482f0 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 12 Mar 2016 07:42:57 +0100 Subject: [PATCH 1/3] fromgplus: Add keywords to imported posts --- fromgplus/fromgplus.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index e0fdc705..d21ece2b 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -10,6 +10,7 @@ define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes require_once('mod/share.php'); +require_once('mod/parse_url.php'); function fromgplus_install() { register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings'); @@ -323,6 +324,11 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) { if ($quote != "") $pagedata["text"] = $quote; + // Add Keywords to page link + $data = parseurl_getsiteinfo_cached($pagedata["url"], true); + if (isset($data["keywords"])) + $pagedata["keywords"] = $data["keywords"]; + break; case "photo": From dea5b336322d07ac4a1052e87f1d5a622c1527ca Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 7 Nov 2016 05:23:19 +0000 Subject: [PATCH 2/3] Prevent posting loops --- fromgplus/fromgplus.php | 21 ++++++++++++++++----- statusnet/statusnet.php | 3 +++ twitter/twitter.php | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index c8026ad3..4c96892c 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -39,6 +39,7 @@ function fromgplus_addon_settings(&$a,&$s) { return; $enable_checked = (intval(get_pconfig(local_user(),'fromgplus','enable')) ? ' checked="checked"' : ''); + $keywords_checked = (intval(get_pconfig(local_user(), 'fromgplus', 'keywords')) ? ' checked="checked"' : ''); $account = get_pconfig(local_user(),'fromgplus','account'); $s .= ''; @@ -57,6 +58,9 @@ function fromgplus_addon_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; $s .= '
'; @@ -74,6 +78,8 @@ function fromgplus_addon_settings_post(&$a,&$b) { set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account'])); $enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0); set_pconfig(local_user(),'fromgplus','enable', $enable); + $keywords = ((x($_POST, 'fromgplus-keywords')) ? intval($_POST['fromgplus-keywords']) : 0); + set_pconfig(local_user(),'fromgplus', 'keywords', $keywords); if (!$enable) del_pconfig(local_user(),'fromgplus','lastdate'); @@ -130,7 +136,7 @@ function fromgplus_cron($a,$b) { set_config('fromgplus','last_poll', time()); } -function fromgplus_post($a, $uid, $source, $body, $location, $coord) { +function fromgplus_post($a, $uid, $source, $body, $location, $coord, $id) { //$uid = 2; @@ -158,6 +164,9 @@ function fromgplus_post($a, $uid, $source, $body, $location, $coord) { $_REQUEST['source'] = $source; $_REQUEST['extid'] = NETWORK_GPLUS; + if (isset($id)) + $_REQUEST['message_id'] = NETWORK_GPLUS.":".$id; + // $_REQUEST['verb'] // $_REQUEST['parent'] // $_REQUEST['parent_uri'] @@ -327,9 +336,9 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) { // Add Keywords to page link $data = parseurl_getsiteinfo_cached($pagedata["url"], true); - if (isset($data["keywords"])) + if (isset($data["keywords"]) AND get_pconfig($uid, 'fromgplus', 'keywords')) { $pagedata["keywords"] = $data["keywords"]; - + } break; case "photo": @@ -452,6 +461,8 @@ function fromgplus_fetch($a, $uid) { if ($lastdate < strtotime($item->published)) $lastdate = strtotime($item->published); + set_pconfig($uid,'fromgplus','lastdate', $lastdate); + if ($first_time) continue; @@ -485,7 +496,7 @@ function fromgplus_fetch($a, $uid) { } elseif (isset($item->address)) $location = $item->address; - fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord); + fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord, $item->id); break; @@ -536,7 +547,7 @@ function fromgplus_fetch($a, $uid) { } elseif (isset($item->address)) $location = $item->address; - fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord); + fromgplus_post($a, $uid, $item->provider->title, $post, $location, $coord, $item->id); break; } } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 4fdd6a74..febe4032 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -872,6 +872,9 @@ function statusnet_fetchtimeline($a, $uid) { $_REQUEST["source"] = $post->source; $_REQUEST["extid"] = NETWORK_STATUSNET; + if (isset($post->id)) + $_REQUEST['message_id'] = NETWORK_STATUSNET.":".$post->id; + //$_REQUEST["date"] = $post->created_at; $_REQUEST["title"] = ""; diff --git a/twitter/twitter.php b/twitter/twitter.php index 8f023dfe..e7429696 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -791,6 +791,9 @@ function twitter_fetchtimeline($a, $uid) { $_REQUEST["source"] = $post->source; $_REQUEST["extid"] = NETWORK_TWITTER; + if (isset($post->id)) + $_REQUEST['message_id'] = NETWORK_TWITTER.":".$post->id; + //$_REQUEST["date"] = $post->created_at; $_REQUEST["title"] = ""; From d1a498ed38230bb2ccd2a422080dab37c3aee03b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 12 Nov 2016 16:54:08 +0000 Subject: [PATCH 3/3] Some language stuff. --- fromgplus/lang/C/messages.po | 28 ++++++++++++++++++++-------- gpluspost/lang/C/messages.po | 26 +++++++++++++------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/fromgplus/lang/C/messages.po b/fromgplus/lang/C/messages.po index f9b40662..d78fb5af 100644 --- a/fromgplus/lang/C/messages.po +++ b/fromgplus/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-02-27 05:01-0500\n" +"POT-Creation-Date: 2016-11-12 16:52+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,22 +17,34 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: fromgplus.php:33 -msgid "Google+ Import Settings" +#: fromgplus.php:46 fromgplus.php:50 +msgid "Google+ Mirror" msgstr "" -#: fromgplus.php:36 +#: fromgplus.php:55 msgid "Enable Google+ Import" msgstr "" -#: fromgplus.php:39 +#: fromgplus.php:58 msgid "Google Account ID" msgstr "" -#: fromgplus.php:44 -msgid "Submit" +#: fromgplus.php:61 +msgid "Add keywords to post" msgstr "" -#: fromgplus.php:59 +#: fromgplus.php:66 fromgplus.php:95 +msgid "Save Settings" +msgstr "" + +#: fromgplus.php:87 msgid "Google+ Import Settings saved." msgstr "" + +#: fromgplus.php:96 +msgid "Key" +msgstr "" + +#: fromgplus.php:103 +msgid "Settings updated." +msgstr "" diff --git a/gpluspost/lang/C/messages.po b/gpluspost/lang/C/messages.po index cedf6cbb..117b72e5 100644 --- a/gpluspost/lang/C/messages.po +++ b/gpluspost/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-06-23 14:44+0200\n" +"POT-Creation-Date: 2016-11-12 16:50+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,50 +17,50 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: gpluspost.php:38 +#: gpluspost.php:39 msgid "Post to Google+" msgstr "" -#: gpluspost.php:93 +#: gpluspost.php:94 msgid "Enable Google+ Post Plugin" msgstr "" -#: gpluspost.php:108 +#: gpluspost.php:109 msgid "Google+ username" msgstr "" -#: gpluspost.php:113 +#: gpluspost.php:114 msgid "Google+ password" msgstr "" -#: gpluspost.php:118 +#: gpluspost.php:119 msgid "Google+ page number" msgstr "" -#: gpluspost.php:124 +#: gpluspost.php:125 msgid "Post to Google+ by default" msgstr "" -#: gpluspost.php:129 +#: gpluspost.php:130 msgid "Do not prevent posting loops" msgstr "" -#: gpluspost.php:135 +#: gpluspost.php:136 msgid "Skip messages without links" msgstr "" -#: gpluspost.php:142 +#: gpluspost.php:143 msgid "Mirror all public posts" msgstr "" -#: gpluspost.php:146 +#: gpluspost.php:147 msgid "Mirror Google Account ID" msgstr "" -#: gpluspost.php:153 +#: gpluspost.php:154 msgid "Save Settings" msgstr "" -#: gpluspost.php:308 +#: gpluspost.php:310 msgid "Google+ post failed. Queued for retry." msgstr ""