forked from friendica/friendica-addons
Compare commits
9 commits
040c735243
...
e1de842ffb
Author | SHA1 | Date | |
---|---|---|---|
Hypolite Petovan | e1de842ffb | ||
Tobias Diekershoff | ca134e9ed3 | ||
Tobias Diekershoff | 1a2554fe95 | ||
Tobias Diekershoff | 13da605435 | ||
Hypolite Petovan | df2e9863ed | ||
Entropy Engineer | 199205a07c | ||
Hypolite Petovan | 94eb2ec197 | ||
Michael | 58fce248c1 | ||
Michael | dcd097b5b0 |
|
@ -31,7 +31,7 @@ Open the `config/node.config.php` file and add "piwik" to the list of activated
|
|||
],
|
||||
]
|
||||
|
||||
You can change 4 more configuration variables for the addon in the `config/piwik.config.php` file:
|
||||
You can change 5 more configuration variables for the addon in the `config/piwik.config.php` file:
|
||||
|
||||
return [
|
||||
'piwik' => [
|
||||
|
@ -39,6 +39,7 @@ You can change 4 more configuration variables for the addon in the `config/piwik
|
|||
'sideid' => 1,
|
||||
'optout' => true,
|
||||
'async' => false,
|
||||
'shortendpoint' => false,
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -50,7 +51,7 @@ Configuration fields
|
|||
* The *optout* parameter (true|false) defines whether or not a short notice about the utilization of Piwik will be displayed on every page of your Friendica site (at the bottom of the page with some spacing to the
|
||||
other content). Part of the note is a link that allows the visitor to set an _opt-out_ cookie which will prevent visits from that user be tracked by piwik.
|
||||
* The *async* parameter (true|false) defines whether or not to use asynchronous tracking so pages load (or appear to load) faster.
|
||||
|
||||
* The *shortendpoint* parameter (true|false) defines whether or not to use a short path to the tracking script: "/js/" instead of "/piwik.js".
|
||||
Currently the optional notice states the following:
|
||||
|
||||
> This website is tracked using the Piwik analytics tool. If you do not want that your visits are logged this way you can set a cookie to prevent Piwik from tracking further visits of the site (opt-out).
|
||||
|
|
|
@ -25,5 +25,9 @@ return [
|
|||
// async (Boolean)
|
||||
// This defines whether or not to use asynchronous tracking so pages load (or appear to load) faster.
|
||||
'async' => false,
|
||||
|
||||
// shortendpoint (Boolean)
|
||||
// This defines whether or not to use a short path to the tracking script: "/js/" instead of "/piwik.js".
|
||||
'shortendpoint' => false,
|
||||
],
|
||||
];
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-02-01 18:15+0100\n"
|
||||
"POT-Creation-Date: 2023-05-01 07:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -17,13 +17,13 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: piwik.php:87
|
||||
#: piwik.php:96
|
||||
msgid ""
|
||||
"This website is tracked using the <a href='http://www.matomo.org'>Matomo</a> "
|
||||
"analytics tool."
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:90
|
||||
#: piwik.php:99
|
||||
#, php-format
|
||||
msgid ""
|
||||
"If you do not want that your visits are logged in this way you <a "
|
||||
|
@ -31,28 +31,32 @@ msgid ""
|
|||
"visits of the site</a> (opt-out)."
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:97
|
||||
#: piwik.php:108
|
||||
msgid "Save Settings"
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:98
|
||||
#: piwik.php:109
|
||||
msgid "Matomo (Piwik) Base URL"
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:98
|
||||
#: piwik.php:109
|
||||
msgid ""
|
||||
"Absolute path to your Matomo (Piwik) installation. (without protocol (http/"
|
||||
"s), with trailing slash)"
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:99
|
||||
#: piwik.php:110
|
||||
msgid "Site ID"
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:100
|
||||
#: piwik.php:111
|
||||
msgid "Show opt-out cookie link?"
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:101
|
||||
#: piwik.php:112
|
||||
msgid "Asynchronous tracking"
|
||||
msgstr ""
|
||||
|
||||
#: piwik.php:113
|
||||
msgid "Shortcut path to the script ('/js/' instead of '/piwik.js')"
|
||||
msgstr ""
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
# Andreas H., 2014-2015
|
||||
# Till Mohr <tmtrfx@till-mohr.de>, 2021
|
||||
# Tobias Diekershoff <tobias.diekershoff@gmx.net>, 2014
|
||||
# Tobias Diekershoff <tobias.diekershoff@gmx.net>, 2019
|
||||
# Tobias Diekershoff <tobias.diekershoff@gmx.net>, 2019,2023
|
||||
# Ulf Rompe <transifex.com@rompe.org>, 2019
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: friendica\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-02-01 18:15+0100\n"
|
||||
"POT-Creation-Date: 2023-05-01 07:39+0200\n"
|
||||
"PO-Revision-Date: 2014-06-23 11:18+0000\n"
|
||||
"Last-Translator: Till Mohr <tmtrfx@till-mohr.de>, 2021\n"
|
||||
"Last-Translator: Tobias Diekershoff <tobias.diekershoff@gmx.net>, 2019,2023\n"
|
||||
"Language-Team: German (http://app.transifex.com/Friendica/friendica/language/de/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
@ -23,13 +23,13 @@ msgstr ""
|
|||
"Language: de\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: piwik.php:87
|
||||
#: piwik.php:96
|
||||
msgid ""
|
||||
"This website is tracked using the <a href='http://www.matomo.org'>Matomo</a>"
|
||||
" analytics tool."
|
||||
msgstr "Diese Website benutzt <a href='http://www.matomo.org'>Matomo</a>, eine Open-Source-Software zur statistischen Auswertung der Besucherzugriffe."
|
||||
|
||||
#: piwik.php:90
|
||||
#: piwik.php:99
|
||||
#, php-format
|
||||
msgid ""
|
||||
"If you do not want that your visits are logged in this way you <a "
|
||||
|
@ -37,28 +37,32 @@ msgid ""
|
|||
"visits of the site</a> (opt-out)."
|
||||
msgstr "Wenn du nicht willst, dass Deine Besuche auf diese Weise gespeichert werden, kannst du <a href='%s'>ein Cookie setzen</a>. Dann wird Matomo / Piwik dich auf dieser Website nicht mehr verfolgen (opt-out)."
|
||||
|
||||
#: piwik.php:97
|
||||
#: piwik.php:108
|
||||
msgid "Save Settings"
|
||||
msgstr "Einstellungen speichern"
|
||||
|
||||
#: piwik.php:98
|
||||
#: piwik.php:109
|
||||
msgid "Matomo (Piwik) Base URL"
|
||||
msgstr "Matomo-Basis-URL (Piwik-Basis-URL)"
|
||||
|
||||
#: piwik.php:98
|
||||
#: piwik.php:109
|
||||
msgid ""
|
||||
"Absolute path to your Matomo (Piwik) installation. (without protocol "
|
||||
"(http/s), with trailing slash)"
|
||||
msgstr "Absoluter Pfad zu deiner Matomo-/Piwik-Installation (ohne \"http://\" oder \"https://\"), mit abschließendem Schrägstrich"
|
||||
|
||||
#: piwik.php:99
|
||||
#: piwik.php:110
|
||||
msgid "Site ID"
|
||||
msgstr "Seiten-ID"
|
||||
|
||||
#: piwik.php:100
|
||||
#: piwik.php:111
|
||||
msgid "Show opt-out cookie link?"
|
||||
msgstr "Link zum Setzen des Opt-Out-Cookies anzeigen?"
|
||||
|
||||
#: piwik.php:101
|
||||
#: piwik.php:112
|
||||
msgid "Asynchronous tracking"
|
||||
msgstr "Asynchrones Tracking"
|
||||
|
||||
#: piwik.php:113
|
||||
msgid "Shortcut path to the script ('/js/' instead of '/piwik.js')"
|
||||
msgstr "Shortcut Pfad zum Script ('/js/' anstelle von '/piwik.js')"
|
||||
|
|
|
@ -13,3 +13,4 @@ $a->strings['Absolute path to your Matomo (Piwik) installation. (without protoco
|
|||
$a->strings['Site ID'] = 'Seiten-ID';
|
||||
$a->strings['Show opt-out cookie link?'] = 'Link zum Setzen des Opt-Out-Cookies anzeigen?';
|
||||
$a->strings['Asynchronous tracking'] = 'Asynchrones Tracking';
|
||||
$a->strings['Shortcut path to the script (\'/js/\' instead of \'/piwik.js\')'] = 'Shortcut Pfad zum Script (\'/js/\' anstelle von \'/piwik.js\')';
|
||||
|
|
|
@ -20,13 +20,13 @@ msgstr ""
|
|||
"Language: en_GB\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: piwik.php:94
|
||||
#: piwik.php:95
|
||||
msgid ""
|
||||
"This website is tracked using the <a href='http://www.matomo.org'>Matomo</a>"
|
||||
" analytics tool."
|
||||
msgstr "This website is tracking, using the <a href='http://www.matomo.org'>Matomo</a> analytics tool."
|
||||
|
||||
#: piwik.php:97
|
||||
#: piwik.php:98
|
||||
#, php-format
|
||||
msgid ""
|
||||
"If you do not want that your visits are logged in this way you <a "
|
||||
|
@ -34,32 +34,36 @@ msgid ""
|
|||
"visits of the site</a> (opt-out)."
|
||||
msgstr "If you do not want that your visits logged in this way you <a href='%s'>can set a cookie to prevent Matomo / Piwik from tracking further visits of the site</a> (opt-out)."
|
||||
|
||||
#: piwik.php:104
|
||||
#: piwik.php:107
|
||||
msgid "Save Settings"
|
||||
msgstr "Save settings"
|
||||
|
||||
#: piwik.php:105
|
||||
#: piwik.php:108
|
||||
msgid "Matomo (Piwik) Base URL"
|
||||
msgstr "Matomo (Piwik) Base URL"
|
||||
|
||||
#: piwik.php:105
|
||||
#: piwik.php:108
|
||||
msgid ""
|
||||
"Absolute path to your Matomo (Piwik) installation. (without protocol "
|
||||
"(http/s), with trailing slash)"
|
||||
msgstr "Absolute path to your Matomo (Piwik) installation. (without protocol (http/s), with trailing slash)"
|
||||
|
||||
#: piwik.php:106
|
||||
#: piwik.php:109
|
||||
msgid "Site ID"
|
||||
msgstr "Site ID"
|
||||
|
||||
#: piwik.php:107
|
||||
#: piwik.php:110
|
||||
msgid "Show opt-out cookie link?"
|
||||
msgstr "Show opt-out cookie link?"
|
||||
|
||||
#: piwik.php:108
|
||||
#: piwik.php:111
|
||||
msgid "Asynchronous tracking"
|
||||
msgstr "Asynchronous tracking"
|
||||
|
||||
#: piwik.php:112
|
||||
msgid "Shortcut path to the script ('/js/' instead of '/piwik.js')"
|
||||
msgstr "Shortcut path to the script ('/js/' instead of '/piwik.js')"
|
||||
|
||||
#: piwik.php:120
|
||||
msgid "Settings updated."
|
||||
msgstr "Settings updated."
|
||||
msgstr "Settings updated."
|
|
@ -14,3 +14,4 @@ $a->strings['Site ID'] = 'Site ID';
|
|||
$a->strings['Show opt-out cookie link?'] = 'Show opt-out cookie link?';
|
||||
$a->strings['Asynchronous tracking'] = 'Asynchronous tracking';
|
||||
$a->strings['Settings updated.'] = 'Settings updated.';
|
||||
$a->strings["Shortcut path to the script ('/js/' instead of '/piwik.js')"] = "Shortcut path to the script ('/js/' instead of '/piwik.js')";
|
|
@ -9,3 +9,4 @@ $a->strings["Site ID"] = "ID сайта";
|
|||
$a->strings["Show opt-out cookie link?"] = "Показать ссылку opt-out cookie?";
|
||||
$a->strings["Asynchronous tracking"] = "Асинхронное отслеживание";
|
||||
$a->strings["Settings updated."] = "Настройки обновлены.";
|
||||
$a->strings["Shortcut path to the script ('/js/' instead of '/piwik.js')"] = "Сокращенный путь к скрипту ('/js/' вместо '/piwik.js')";
|
|
@ -25,6 +25,7 @@
|
|||
* 'sideid' => '',
|
||||
* 'optout' => true,
|
||||
* 'async' => false,
|
||||
* 'shortendpoint' => false,
|
||||
* ],
|
||||
* ];
|
||||
*
|
||||
|
@ -60,7 +61,7 @@ function piwik_analytics(string &$b)
|
|||
* associated CSS file. We just have to tell Friendica to get it
|
||||
* into the page header.
|
||||
*/
|
||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl() . '/addon/piwik/piwik.css' . '" media="all" />';
|
||||
DI::page()->registerStylesheet('addon/piwik/piwik.css', 'all');
|
||||
|
||||
/*
|
||||
* Get the configuration values.
|
||||
|
@ -69,16 +70,21 @@ function piwik_analytics(string &$b)
|
|||
$siteid = DI::config()->get('piwik', 'siteid');
|
||||
$optout = DI::config()->get('piwik', 'optout');
|
||||
$async = DI::config()->get('piwik', 'async');
|
||||
$shortendpoint = DI::config()->get('piwik', 'shortendpoint');
|
||||
|
||||
/*
|
||||
* Add the Piwik tracking code for the site.
|
||||
* If async is set to true use asynchronous tracking
|
||||
*/
|
||||
|
||||
$scriptAsyncValue = $async ? 'true' : 'false';
|
||||
$scriptPhpEndpoint = $shortendpoint ? 'js/' : 'piwik.php';
|
||||
$scriptJsEndpoint = $shortendpoint ? 'js/' : 'piwik.js';
|
||||
|
||||
$b .= "<!-- Piwik --> <script type=\"text/javascript\"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://$baseurl\"; _paq.push(['setTrackerUrl', u+'$scriptPhpEndpoint']); _paq.push(['setSiteId', $siteid]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=$scriptAsyncValue; g.src=u+'$scriptJsEndpoint'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Piwik Code -->\r\n";
|
||||
|
||||
if ($async) {
|
||||
$b .= "<!-- Piwik --> <script type=\"text/javascript\"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://".$baseurl."\"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', ".$siteid."]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Piwik Code -->\r\n";
|
||||
$b .= "<div id='piwik-code-block'> <!-- Piwik -->\r\n<noscript><p><img src=\"//".$baseurl."piwik.php?idsite=".$siteid."\" style=\"border:0\" alt=\"\" /></p></noscript>\r\n <!-- End Piwik Tracking Tag --> </div>";
|
||||
} else {
|
||||
$b .= "<!-- Piwik --> <script type=\"text/javascript\"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://".$baseurl."\"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', ".$siteid."]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=false; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Piwik Code -->\r\n";
|
||||
$b .= "<div id='piwik-code-block'> <!-- Piwik -->\r\n<noscript><p><img src=\"//$baseurl$scriptPhpEndpoint?idsite=$siteid\" style=\"border:0\" alt=\"\" /></p></noscript>\r\n <!-- End Piwik Tracking Tag --> </div>";
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -89,7 +95,7 @@ function piwik_analytics(string &$b)
|
|||
$b .= "<div id='piwik-optout-link'>";
|
||||
$b .= DI::l10n()->t("This website is tracked using the <a href='http://www.matomo.org'>Matomo</a> analytics tool.");
|
||||
$b .= " ";
|
||||
$the_url = "http://".$baseurl ."index.php?module=CoreAdminHome&action=optOut";
|
||||
$the_url = "http://{$baseurl}index.php?module=CoreAdminHome&action=optOut";
|
||||
$b .= DI::l10n()->t("If you do not want that your visits are logged in this way you <a href='%s'>can set a cookie to prevent Matomo / Piwik from tracking further visits of the site</a> (opt-out).", $the_url);
|
||||
$b .= "</div>";
|
||||
}
|
||||
|
@ -104,6 +110,7 @@ function piwik_addon_admin (string &$o)
|
|||
'$siteid' => ['siteid', DI::l10n()->t('Site ID'), DI::config()->get('piwik','siteid' ), ''],
|
||||
'$optout' => ['optout', DI::l10n()->t('Show opt-out cookie link?'), DI::config()->get('piwik','optout' ), ''],
|
||||
'$async' => ['async', DI::l10n()->t('Asynchronous tracking'), DI::config()->get('piwik','async' ), ''],
|
||||
'$shortendpoint' => ['shortendpoint', DI::l10n()->t("Shortcut path to the script ('/js/' instead of '/piwik.js')"), DI::config()->get('piwik','shortendpoint' ), ''],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -113,4 +120,5 @@ function piwik_addon_admin_post()
|
|||
DI::config()->set('piwik', 'siteid', trim($_POST['siteid'] ?? ''));
|
||||
DI::config()->set('piwik', 'optout', trim($_POST['optout'] ?? ''));
|
||||
DI::config()->set('piwik', 'async', trim($_POST['async'] ?? ''));
|
||||
DI::config()->set('piwik', 'shortendpoint', trim($_POST['shortendpoint'] ?? ''));
|
||||
}
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
{{include file="field_input.tpl" field=$siteid}}
|
||||
{{include file="field_checkbox.tpl" field=$optout}}
|
||||
{{include file="field_checkbox.tpl" field=$async}}
|
||||
{{include file="field_checkbox.tpl" field=$shortendpoint}}
|
||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-04-22 10:00+0000\n"
|
||||
"POT-Creation-Date: 2023-04-29 06:56+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -17,58 +17,71 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: tumblr.php:60
|
||||
#: tumblr.php:243
|
||||
msgid "Permission denied."
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:111
|
||||
msgid "Could not connect to Tumblr. Refresh the page or try again later."
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:159
|
||||
msgid "Unable to authenticate"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:174
|
||||
#: tumblr.php:296
|
||||
msgid "Save Settings"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:176
|
||||
#: tumblr.php:297
|
||||
msgid "Consumer Key"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:177
|
||||
#: tumblr.php:298
|
||||
msgid "Consumer Secret"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:212
|
||||
#: tumblr.php:299
|
||||
msgid "Maximum tags"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:299
|
||||
msgid ""
|
||||
"Maximum number of tags that a user can follow. Enter 0 to deactivate the "
|
||||
"feature."
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:336
|
||||
msgid "Post to page:"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:218
|
||||
#: tumblr.php:342
|
||||
msgid "(Re-)Authenticate your tumblr page"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:219
|
||||
#: tumblr.php:343
|
||||
msgid "You are not authenticated to tumblr"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:224
|
||||
#: tumblr.php:348
|
||||
msgid "Enable Tumblr Post Addon"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:225
|
||||
#: tumblr.php:349
|
||||
msgid "Post to Tumblr by default"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:226
|
||||
#: tumblr.php:350
|
||||
msgid "Import the remote timeline"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:232
|
||||
#: tumblr.php:351
|
||||
msgid "Subscribed tags"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:351
|
||||
#, php-format
|
||||
msgid ""
|
||||
"Comma separated list of up to %d tags that will be imported additionally to "
|
||||
"the timeline"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:357
|
||||
msgid "Tumblr Import/Export"
|
||||
msgstr ""
|
||||
|
||||
#: tumblr.php:250
|
||||
#: tumblr.php:375
|
||||
msgid "Post to Tumblr"
|
||||
msgstr ""
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{include file="field_input.tpl" field=$consumer_key}}
|
||||
{{include file="field_input.tpl" field=$consumer_secret}}
|
||||
{{include file="field_input.tpl" field=$max_tags}}
|
||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{{include file="field_checkbox.tpl" field=$enable}}
|
||||
{{include file="field_checkbox.tpl" field=$bydefault}}
|
||||
{{include file="field_checkbox.tpl" field=$import}}
|
||||
{{include file="field_input.tpl" field=$tags}}
|
||||
|
||||
{{if $page_select}}
|
||||
{{include file="field_select.tpl" field=$page_select}}
|
||||
|
|
|
@ -39,6 +39,7 @@ use GuzzleHttp\HandlerStack;
|
|||
use GuzzleHttp\Subscriber\Oauth\Oauth1;
|
||||
|
||||
define('TUMBLR_DEFAULT_POLL_INTERVAL', 10); // given in minutes
|
||||
define('TUMBLR_DEFAULT_MAXIMUM_TAGS', 10);
|
||||
|
||||
function tumblr_install()
|
||||
{
|
||||
|
@ -97,8 +98,6 @@ function tumblr_probe_detect(array &$hookData)
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::debug('Search for tumblr blog', ['url' => $hookData['uri']]);
|
||||
|
||||
$hookData['result'] = tumblr_get_contact_by_url($hookData['uri']);
|
||||
}
|
||||
|
||||
|
@ -128,7 +127,7 @@ function tumblr_item_by_link(array &$hookData)
|
|||
|
||||
Logger::debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]);
|
||||
if (!empty($result->response->posts)) {
|
||||
$hookData['item_id'] = tumblr_process_post($result->response->posts[0], $hookData['uid']);
|
||||
$hookData['item_id'] = tumblr_process_post($result->response->posts[0], $hookData['uid'], Item::PR_FETCHED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,6 +296,7 @@ function tumblr_addon_admin(string &$o)
|
|||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$consumer_key' => ['consumer_key', DI::l10n()->t('Consumer Key'), DI::config()->get('tumblr', 'consumer_key'), ''],
|
||||
'$consumer_secret' => ['consumer_secret', DI::l10n()->t('Consumer Secret'), DI::config()->get('tumblr', 'consumer_secret'), ''],
|
||||
'$max_tags' => ['max_tags', DI::l10n()->t('Maximum tags'), DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS, DI::l10n()->t('Maximum number of tags that a user can follow. Enter 0 to deactivate the feature.')],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -304,6 +304,7 @@ function tumblr_addon_admin_post()
|
|||
{
|
||||
DI::config()->set('tumblr', 'consumer_key', trim($_POST['consumer_key'] ?? ''));
|
||||
DI::config()->set('tumblr', 'consumer_secret', trim($_POST['consumer_secret'] ?? ''));
|
||||
DI::config()->set('tumblr', 'max_tags', max(0, intval($_POST['max_tags'] ?? '')));
|
||||
}
|
||||
|
||||
function tumblr_settings(array &$data)
|
||||
|
@ -312,10 +313,14 @@ function tumblr_settings(array &$data)
|
|||
return;
|
||||
}
|
||||
|
||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post', false);
|
||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', false);
|
||||
$import = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'import', false);
|
||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post') ?? false;
|
||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default') ?? false;
|
||||
$import = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'import') ?? false;
|
||||
$tags = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'tags') ?? [];
|
||||
|
||||
$max_tags = DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS;
|
||||
|
||||
$tags_str = implode(', ', $tags);
|
||||
$cachekey = 'tumblr-blogs-' . DI::userSession()->getLocalUserId();
|
||||
$blogs = DI::cache()->get($cachekey);
|
||||
if (empty($blogs)) {
|
||||
|
@ -343,6 +348,7 @@ function tumblr_settings(array &$data)
|
|||
'$enable' => ['tumblr', DI::l10n()->t('Enable Tumblr Post Addon'), $enabled],
|
||||
'$bydefault' => ['tumblr_bydefault', DI::l10n()->t('Post to Tumblr by default'), $def_enabled],
|
||||
'$import' => ['tumblr_import', DI::l10n()->t('Import the remote timeline'), $import],
|
||||
'$tags' => ['tags', DI::l10n()->t('Subscribed tags'), $tags_str, DI::l10n()->t('Comma separated list of up to %d tags that will be imported additionally to the timeline', $max_tags)],
|
||||
'$page_select' => $page_select ?? '',
|
||||
]);
|
||||
|
||||
|
@ -380,6 +386,16 @@ function tumblr_settings_post(array &$b)
|
|||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'page', $_POST['tumblr_page']);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', intval($_POST['tumblr_bydefault']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'import', intval($_POST['tumblr_import']));
|
||||
|
||||
$max_tags = DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS;
|
||||
$tags = [];
|
||||
foreach (explode(',', $_POST['tags']) as $tag) {
|
||||
if (count($tags) < $max_tags) {
|
||||
$tags[] = trim($tag, ' #');
|
||||
}
|
||||
}
|
||||
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'tags', $tags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,7 +411,7 @@ function tumblr_cron()
|
|||
if ($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if ($next > time()) {
|
||||
Logger::notice('poll intervall not reached');
|
||||
Logger::notice('poll interval not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -419,6 +435,7 @@ function tumblr_cron()
|
|||
|
||||
Logger::notice('importing timeline - start', ['user' => $pconfig['uid']]);
|
||||
tumblr_fetch_dashboard($pconfig['uid']);
|
||||
tumblr_fetch_tags($pconfig['uid']);
|
||||
Logger::notice('importing timeline - done', ['user' => $pconfig['uid']]);
|
||||
}
|
||||
|
||||
|
@ -682,6 +699,29 @@ function tumblr_get_post_from_uri(string $uri): array
|
|||
return $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch posts for user defined hashtags for the given user
|
||||
*
|
||||
* @param integer $uid
|
||||
* @return void
|
||||
*/
|
||||
function tumblr_fetch_tags(int $uid)
|
||||
{
|
||||
if (!DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (DI::pConfig()->get($uid, 'tumblr', 'tags') ?? [] as $tag) {
|
||||
$data = tumblr_get($uid, 'tagged', ['tag' => $tag]);
|
||||
foreach (array_reverse($data->response) as $post) {
|
||||
$id = tumblr_process_post($post, $uid, Item::PR_TAG);
|
||||
if (!empty($id)) {
|
||||
Logger::debug('Tag post imported', ['tag' => $tag, 'id' => $id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the dashboard (timeline) for the given user
|
||||
*
|
||||
|
@ -690,8 +730,6 @@ function tumblr_get_post_from_uri(string $uri): array
|
|||
*/
|
||||
function tumblr_fetch_dashboard(int $uid)
|
||||
{
|
||||
$page = tumblr_get_page($uid);
|
||||
|
||||
$parameters = ['reblog_info' => false, 'notes_info' => false, 'npf' => false];
|
||||
|
||||
$last = DI::pConfig()->get($uid, 'tumblr', 'last_id');
|
||||
|
@ -710,36 +748,36 @@ function tumblr_fetch_dashboard(int $uid)
|
|||
}
|
||||
|
||||
foreach (array_reverse($dashboard->response->posts) as $post) {
|
||||
$uri = 'tumblr::' . $post->id_string . ':' . $post->reblog_key;
|
||||
|
||||
if ($post->id > $last) {
|
||||
$last = $post->id;
|
||||
}
|
||||
|
||||
Logger::debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'uri' => $uri]);
|
||||
|
||||
if (Post::exists(['uri' => $uri, 'uid' => $uid]) || ($post->blog->uuid == $page)) {
|
||||
DI::pConfig()->set($uid, 'tumblr', 'last_id', $last);
|
||||
continue;
|
||||
}
|
||||
|
||||
tumblr_process_post($post, $uid, $uri);
|
||||
Logger::debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]);
|
||||
|
||||
tumblr_process_post($post, $uid, Item::PR_NONE);
|
||||
|
||||
DI::pConfig()->set($uid, 'tumblr', 'last_id', $last);
|
||||
}
|
||||
}
|
||||
|
||||
function tumblr_process_post(stdClass $post, int $uid, string $uri = ''): int
|
||||
function tumblr_process_post(stdClass $post, int $uid, int $post_reason): int
|
||||
{
|
||||
if (empty($uri)) {
|
||||
$uri = 'tumblr::' . $post->id_string . ':' . $post->reblog_key;
|
||||
$uri = 'tumblr::' . $post->id_string . ':' . $post->reblog_key;
|
||||
|
||||
if (Post::exists(['uri' => $uri, 'uid' => $uid]) || ($post->blog->uuid == tumblr_get_page($uid))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$item = tumblr_get_header($post, $uri, $uid);
|
||||
|
||||
$item = tumblr_get_content($item, $post);
|
||||
|
||||
$item['post-reason'] = $post_reason;
|
||||
|
||||
if (!empty($post->followed)) {
|
||||
$item['post-reason'] = Item::PR_FOLLOWER;
|
||||
}
|
||||
|
||||
$id = item::insert($item);
|
||||
|
||||
if ($id) {
|
||||
|
@ -1049,7 +1087,7 @@ function tumblr_insert_contact(stdClass $blog, int $uid)
|
|||
'url' => $url,
|
||||
'nurl' => Strings::normaliseLink($url),
|
||||
'alias' => $blog->url,
|
||||
'name' => $blog->title,
|
||||
'name' => $blog->title ?: $blog->name,
|
||||
'nick' => $blog->name,
|
||||
'addr' => $blog->name . '@tumblr.com',
|
||||
'about' => HTML::toBBCode($blog->description),
|
||||
|
@ -1099,7 +1137,7 @@ function tumblr_update_contact(stdClass $blog, int $uid, int $cid, int $pcid)
|
|||
'nurl' => Strings::normaliseLink($url),
|
||||
'uri-id' => $uri_id,
|
||||
'alias' => $info->response->blog->url,
|
||||
'name' => $info->response->blog->title,
|
||||
'name' => $info->response->blog->title ?: $info->response->blog->name,
|
||||
'nick' => $info->response->blog->name,
|
||||
'addr' => $info->response->blog->name . '@tumblr.com',
|
||||
'about' => HTML::toBBCode($info->response->blog->description),
|
||||
|
@ -1209,6 +1247,8 @@ function tumblr_get_contact_by_url(string $url): array
|
|||
return [];
|
||||
}
|
||||
|
||||
Logger::debug('Update Tumblr blog data', ['url' => $url]);
|
||||
|
||||
$curlResult = DI::httpClient()->get('https://api.tumblr.com/v2/blog/' . $blog . '/info?api_key=' . $consumer_key);
|
||||
$body = $curlResult->getBody();
|
||||
$data = json_decode($body);
|
||||
|
@ -1228,7 +1268,7 @@ function tumblr_get_contact_by_url(string $url): array
|
|||
'notify' => '',
|
||||
'poll' => 'tumblr::' . $data->response->blog->uuid,
|
||||
'poco' => '',
|
||||
'name' => $data->response->blog->title,
|
||||
'name' => $data->response->blog->title ?: $data->response->blog->name,
|
||||
'nick' => $data->response->blog->name,
|
||||
'network' => Protocol::TUMBLR,
|
||||
'baseurl' => $baseurl,
|
||||
|
|
Loading…
Reference in a new issue