Merge branch 'master' of github.com:JesperDramsch/additional_plugins into JesperDramsch-master

Conflicts resolved:
	.gitignore
This commit is contained in:
Matthias Mees 2013-09-11 22:07:44 +02:00
commit 70da5a6895
5 changed files with 71 additions and 19 deletions

1
.gitignore vendored
View file

@ -5,6 +5,7 @@
/*.zip
/testxmlrpc.php
/test.php
<<<<<<< HEAD
*.db
*~
DEADJOE

View file

@ -16,12 +16,21 @@ class UrlShortener {
var $piratly_apikey = "0"; // This is the generic API token representing anonymous user
var $yourls_url = 'http://www.yourls.org';
var $yourls_apikey = 'signature';
function setBitlyLogin($login, $apikey) {
if (empty($login) || empty($apikey)) return;
$this->bitly_login = $login;
$this->bitly_apikey = $apikey;
}
function setYourlsLogin($yourl, $apikey) {
if (empty($yourl) || empty($apikey)) return;
$this->yourls_url = $yourl;
$this->yourls_apikey = $apikey;
}
function setPiratlyToken($apitoken) {
if (empty($apitoken)) return;
$this->piratly_apikey = $apitoken;
@ -68,6 +77,9 @@ class UrlShortener {
case 'bitly':
UrlShortener::shorten_via_bitly( $url, $shorturls );
break;
case 'yourls':
UrlShortener::shorten_via_yourls( $url, $shorturls );
break;
case 'jmp':
UrlShortener::shorten_via_jmp( $url, $shorturls );
break;
@ -167,6 +179,15 @@ class UrlShortener {
$shorturls['bitly'] = $short_url;
}
}
function shorten_via_yourls( $url, &$shorturls ) {
if (!empty($shorturls['yourls'])) return;
$url = urlencode($url);
UrlShortener::shorten_via_simple($shorturls, 'yourls', "http://{$this->yourls_url}/yourls-api.php?signature={$this->yourls_apikey}&action=shorturl&format=simple&url=$url");
}
function shorten_via_jmp( $url, &$shorturls ) {
// if we already evaluated the shorturl, stop here

View file

@ -139,9 +139,13 @@
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_FORMAT', 'Ankündigungsformat');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_FORMAT_DESC', 'Hier wird die Formatierung von Ankündigungen beschrieben. Es sollten Platzhalter benutzt werden, um sinnvolle Ankündigungen zu erhalten. #title#: Ersetzt durch den Titel des Artikels (mit Tagersetzungen); #link#: Der Link auf den Blogeintrag; #autor#: Autor des Artikels; #tags#: Übrig gebliebende Tags.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYDESC', '<h3>bitly Benutzername und API Key</h3><b>bit.ly</b> und <b>j.mp</b> KurzURLs benötigen ein bitly login und einen API Key. Wenn Du keine der beiden benutzt, ist diese Einstellung für Dich irrelevant.<br/>Der API Key, der hier eingetragen ist, wird die meiste Zeit über nicht funktionieren, da es ein Demo Key und seine Ratio meist überschritten ist. Wenn Du einen bitly Account hast, so trage Deinen eigenen Namen und API Key ein.<br/><a href="http://bitly.com/a/your_api_key/" target="_blank">Hier findest Du beides</a>.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYLOGIN', 'bit.ly Benutzername');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYAPIKEY', 'bit.ly API Key');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYDESC', '<h3>bitly Benutzername und API Key</h3><b>bit.ly</b> und <b>j.mp</b> KurzURLs benötigen ein bitly login und einen API Key. Wenn Du keine der beiden benutzt, ist diese Einstellung für Dich irrelevant.<br/>Der API Key, der hier eingetragen ist, wird die meiste Zeit über nicht funktionieren, da es ein Demo Key und seine Ratio meist überschritten ist. Wenn Du einen bitly Account hast, so trage Deinen eigenen Namen und API Key ein.<br/><a href="http://bitly.com/a/your_api_key/" target="_blank">Hier findest Du beides</a>.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYLOGIN', 'bit.ly Benutzername');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYAPIKEY', 'bit.ly API Key');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSDESC', '<h3>Yourls Domain und API Signatur</h3><b>yourls</b> Braucht einen eigenen Yourls URL service.<br/>Die Defaults sind nur Platzhalter.<br/><a href="http://yourls.org/" target="_blank">Hier den yourls URL shortener runterladen und auf Server installieren.</a>.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSURL', 'Deine Yourls Domain');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSAPIKEY', 'Yourls API Schluessel');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_PIRATLYDESC', '<h3>pirat.ly API Token</h3>Für <b>pirat.ly</b> KurzURLs kannst Du Dir ein API token abholen, <a href="http://pirat.ly/account" target="_blank">indem Du Dich kostenlos bei dem Service registrierst</a>. Wenn das API Token bei der Artikel Ankündigung verwendet wird, kannst Du die Klick Raten der URL über das piratly Webinterface oder auf dem Android Handy mittels der <a href="http://pirat.ly/shortenerrr" target="_blank">Shortenerrr App</a> beobachten.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_PIRATLYAPIKEY', 'Dein persönliches piratly API Token');
@ -202,12 +206,12 @@ Du must aktuell bei Twitter entweder ausgeloggt oder mit dem <b>richtigen Twitte
@define('PLUGIN_EVENT_TWITTER_GENERALCONSUMER', '<h3>Dein eigener Twitter Client</h3>Normaler Weise nimmt das Plugin einen Twitter Client namens \'s9y\'. Du kannst aber auch <a href="https://dev.twitter.com/apps" target="_blank">Deinen eigenen Twitter Client registrieren</a> und dann den consumer key und das secret hier eintragen, wenn Du möchtest.');
@define('PLUGIN_TWITTER_FILTER_RT', 'Native Retweets filtern');
@define('PLUGIN_TWITTER_FILTER_RT_DESC', 'Sollen native Retweets gefiltert werden? (Nur für die Twitter API 1.1, API 1.0 filtert diese immer heraus)');
@define('PLUGIN_TWITTER_API11', 'OAuth Twitter API 1.1 benutzen');
@define('PLUGIN_TWITTER_API11_DESC', 'Die Twitter API 1.0 ist "auslaufend" und wird 2013 eingestellt. Also solltest Du die API 1.1 benutzen. Allerdings muss dafür bereits eine OAuth Verbindung im Hauptplugin zu Twitter hergestellt worden sein. Wenn Du in der Auswahl hier drunter enien Account siehst, dann wurde das bereits erledigt.');
@define('PLUGIN_TWITTER_OAUTHACC', 'OAuth Verbindung für das Plugin');
@define('PLUGIN_TWITTER_OAUTHACC_DESC', 'Das Plugin benötigt für die neue OAuth Twitter API eine OAuth Verbindung. Der Account, der hier ausgewählt wird, wird auch der sein, auf dessen Rate Limit Calls des Plugins gerechnet werden. Der Account muss Dir gehören, kann aber beliebig sein (also zum Beispiel einer nur für das Plugin, um nur dort das Rate Limit zu belasten)');
@define('PLUGIN_TWITTER_FILTER_RT', 'Native Retweets filtern');
@define('PLUGIN_TWITTER_FILTER_RT_DESC', 'Sollen native Retweets gefiltert werden? (Nur für die Twitter API 1.1, API 1.0 filtert diese immer heraus)');
@define('PLUGIN_TWITTER_API11', 'OAuth Twitter API 1.1 benutzen');
@define('PLUGIN_TWITTER_API11_DESC', 'Die Twitter API 1.0 ist "auslaufend" und wird 2013 eingestellt. Also solltest Du die API 1.1 benutzen. Allerdings muss dafür bereits eine OAuth Verbindung im Hauptplugin zu Twitter hergestellt worden sein. Wenn Du in der Auswahl hier drunter enien Account siehst, dann wurde das bereits erledigt.');
@define('PLUGIN_TWITTER_OAUTHACC', 'OAuth Verbindung für das Plugin');
@define('PLUGIN_TWITTER_OAUTHACC_DESC', 'Das Plugin benötigt für die neue OAuth Twitter API eine OAuth Verbindung. Der Account, der hier ausgewählt wird, wird auch der sein, auf dessen Rate Limit Calls des Plugins gerechnet werden. Der Account muss Dir gehören, kann aber beliebig sein (also zum Beispiel einer nur für das Plugin, um nur dort das Rate Limit zu belasten)');
@define('PLUGIN_EVENT_TWITTER_API_TYPE', 'Twitter API Version');
@define('PLUGIN_EVENT_TWITTER_API_TYPE_DESC', 'Die Twitter API 1.0 ist "auslaufend" und wird 2013 eingestellt. Also solltest Du die API 1.1 benutzen. Allerdings muss dafür bereits (bei Benutzerkonten) eine OAuth Verbindung zu Twitter hergestellt und hier eingestellt worden sein.');

View file

@ -139,9 +139,13 @@
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_FORMAT', 'Announce format');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_FORMAT_DESC', 'Define the format of your announcement. You should use placeholders. #title#: replaced with article title (and matching tags); #link#: link to your article; #author#: Author of the article; #tags#: tags that are left.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYDESC', '<h3>bitly username and API key</h3><b>bit.ly</b> and <b>j.mp</b> short urls need a bit.ly login and an API key. If you use none of them you won\'t need this.<br/>The default key is not working most of the times, as it is a demo key and it\'s ratio is exceeded. If you have a bit.ly account, you should enter your own.<br/><a href="http://bitly.com/a/your_api_key/" target="_blank">You will find it here</a>.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYLOGIN', 'bit.ly username');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYAPIKEY', 'bit.ly API key');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYDESC', '<h3>bitly username and API key</h3><b>bit.ly</b> and <b>j.mp</b> short urls need a bit.ly login and an API key. If you use none of them you won\'t need this.<br/>The default key is not working most of the times, as it is a demo key and it\'s ratio is exceeded. If you have a bit.ly account, you should enter your own.<br/><a href="http://bitly.com/a/your_api_key/" target="_blank">You will find it here</a>.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYLOGIN', 'bit.ly username');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_BITLYAPIKEY', 'bit.ly API key');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSDESC', '<h3>Yourls Domain and API signature</h3><b>yourls</b> short urls need an own yourls setup and an API signature. If you don\'t have one you won\'t need this.<br/>The default key is not working<br/><a href="http://yourls.org/" target="_blank">See about yourls URL shortener</a>. Please do not use without the YOURLS plugin <a href="https://bitbucket.org/laceous/yourls-concurrency-fix" target="_blank">Concurency fix</a>.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSURL', 'Your Yourls Domain');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSAPIKEY', 'Yourls API key');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_PIRATLYDESC', '<h3>pirat.ly API token</h3>For <b>pirat.ly</b> shorturls you can <a href="http://pirat.ly/account" target="_blank">get an API token by registering for free at the piratly service</a>. By using this API token when announcing your articles you can watch the clickrate on the web interface or on your Android mobile using the <a href="http://pirat.ly/shortenerrr" target="_blank">Shortenerrr app</a>.');
@define('PLUGIN_EVENT_TWITTER_ANNOUNCE_PIRATLYAPIKEY', 'Your personal piratly API token');
@ -202,12 +206,12 @@ You have to be logged out or logged in with the <b>matching twitter account</b>
@define('PLUGIN_EVENT_TWITTER_GENERALCONSUMER', '<h3>Your own twitter client</h3>Per default the plugin uses a twitter client named \'s9y\'. You may <a href="https://dev.twitter.com/apps" target="_blank">register your own client</a> and setup the consumer key and secret of your client here if you like.');
@define('PLUGIN_TWITTER_FILTER_RT', 'Filter native retweets');
@define('PLUGIN_TWITTER_FILTER_RT_DESC', 'Should native retweets be filtered? (only for Twitter API 1.1, API 1.0 will always filter)');
@define('PLUGIN_TWITTER_API11', 'Use OAuth Twitter API 1.1');
@define('PLUGIN_TWITTER_API11_DESC', 'Twitter API 1.0 is depreciated and will be closed 2013. So you should switch to API 1.1. But this requires to configure at least one OAuth connection in the main microblogging plugin. If you find some accout in the selector below, you already have done this.');
@define('PLUGIN_TWITTER_OAUTHACC', 'OAuth acc to be used by this plugin');
@define('PLUGIN_TWITTER_OAUTHACC_DESC', 'The new OAuth Twitter API needs to be called using an OAuthorized twitter acc. This acc will be used for rate limiting, too. You may use any acc owned by you, an acc never used anywhere else for example in order to have a seperate rate limit for this plugin.');
@define('PLUGIN_TWITTER_FILTER_RT', 'Filter native retweets');
@define('PLUGIN_TWITTER_FILTER_RT_DESC', 'Should native retweets be filtered? (only for Twitter API 1.1, API 1.0 will always filter)');
@define('PLUGIN_TWITTER_API11', 'Use OAuth Twitter API 1.1');
@define('PLUGIN_TWITTER_API11_DESC', 'Twitter API 1.0 is depreciated and will be closed 2013. So you should switch to API 1.1. But this requires to configure at least one OAuth connection in the main microblogging plugin. If you find some accout in the selector below, you already have done this.');
@define('PLUGIN_TWITTER_OAUTHACC', 'OAuth acc to be used by this plugin');
@define('PLUGIN_TWITTER_OAUTHACC_DESC', 'The new OAuth Twitter API needs to be called using an OAuthorized twitter acc. This acc will be used for rate limiting, too. You may use any acc owned by you, an acc never used anywhere else for example in order to have a seperate rate limit for this plugin.');
@define('PLUGIN_EVENT_TWITTER_API_TYPE', 'Twitter API Version');
@define('PLUGIN_EVENT_TWITTER_API_TYPE_DESC', 'Twitter API 1.0 is depreciated and will be closed 2013. So you should switch to API 1.1. But this requires to configure at least one OAuth connection (in the identities settings).');

View file

@ -38,6 +38,7 @@ class serendipity_event_twitter extends serendipity_plugin {
'7ax.de' => "7ax.de",
'bitly' => "bit.ly",
'piratly' => "pirat.ly",
'yourls' => "yourls",
'jmp' => "j.mp",
'tinyurl' => "tinyurl.com",
'isgd' => "is.gd",
@ -87,7 +88,8 @@ class serendipity_event_twitter extends serendipity_plugin {
$config_announce = array(
'announce_articles_title', 'announce_articles', 'announce_via_accounts',
'announce_format', 'announce_with_tags', 'anounce_url_service', 'announce_articles_default_no',
'announce_bitly_description', 'announce_bitly_login','announce_bitly_apikey','announce_piratly_description', 'announce_piratly_apikey'
'announce_bitly_description', 'announce_bitly_login','announce_bitly_apikey','announce_piratly_description', 'announce_piratly_apikey',
'announce_yourls_description', 'announce_yourls_url', 'announce_yourls_apikey'
);
$config_twitter = array(
@ -494,6 +496,23 @@ class serendipity_event_twitter extends serendipity_plugin {
$propbag->add('name', PLUGIN_EVENT_TWITTER_ANNOUNCE_PIRATLYAPIKEY);
$propbag->add('default', '0');
break;
case 'announce_yourls_description':
$propbag->add('type', 'content');
$propbag->add('default', PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSDESC);
break;
case 'announce_yourls_url':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSURL);
$propbag->add('default', 'http://www.yourls.org');
break;
case 'announce_yourls_apikey':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_TWITTER_ANNOUNCE_YOURLSAPIKEY);
$propbag->add('default', 'API key');
break;
// Tweetbacks
case 'twitter_api' :
@ -743,11 +762,14 @@ class serendipity_event_twitter extends serendipity_plugin {
$urlshortener = new UrlShortener();
$bitlylogin = $this->get_config('announce_bitly_login');
$bitlyapikey = $this->get_config('announce_bitly_apikey');
$yourlsurl = $this->get_config('announce_yourls_url');
$yourlsapikey = $this->get_config('announce_yourls_apikey');
$piratlyapikey = $this->get_config('announce_piratly_apikey','0');
$this->log("blogin:" . $bitlylogin . " bapi: " . $bitlyapikey);
$urlshortener->setBitlyLogin($bitlylogin, $bitlyapikey);
$this->log("slogin:" . $urlshortener->bitly_login . " sapi: " . $urlshortener->bitly_apikey);
$urlshortener->setPiratlyToken($piratlyapikey);
$urlshortener->setYourlsLogin($yourlsurl,$yourlsapikey);
return $urlshortener;
}