diff --git a/statusnet.tgz b/statusnet.tgz index 4067e682..3d7c9f58 100755 Binary files a/statusnet.tgz and b/statusnet.tgz differ diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 7e9226a0..f558cbec 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -407,17 +407,31 @@ function statusnet_post_hook(&$a,&$b) { $shortlink = ""; require_once('library/slinky.php'); $slinky = new Slinky( $b['plink'] ); - // setup a cascade of shortening services - // try to get a short link from these services - // in the order ur1.ca, trim, id.gd, tinyurl - $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + $yourls_url = get_config('yourls','url1'); + if ($yourls_url) { + $yourls_username = get_config('yourls','username1'); + $yourls_password = get_config('yourls', 'password1'); + $yourls_ssl = get_config('yourls', 'ssl1'); + $yourls = new Slinky_YourLS(); + $yourls->set( 'username', $yourls_username ); + $yourls->set( 'password', $yourls_password ); + $yourls->set( 'ssl', $yourls_ssl ); + $yourls->set( 'yourls-url', $yourls_url ); + $slinky->set_cascade( array( $yourls, new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + } + else { + // setup a cascade of shortening services + // try to get a short link from these services + // in the order ur1.ca, trim, id.gd, tinyurl + $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + } $shortlink = $slinky->short(); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); - $msg .= '... ' . $shortlink; + $msg .= '... ' . $shortlink; } - // and now tweet it :-) + // and now tweet it :-) if(strlen($msg)) $dent->post('statuses/update', array('status' => $msg)); } diff --git a/twitter.tgz b/twitter.tgz index 740e3c81..25b54d85 100755 Binary files a/twitter.tgz and b/twitter.tgz differ diff --git a/twitter/twitter.php b/twitter/twitter.php index a6f73c86..ef590839 100755 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -269,10 +269,25 @@ function twitter_post_hook(&$a,&$b) { $shortlink = ""; require_once('library/slinky.php'); $slinky = new Slinky( $b['plink'] ); - // setup a cascade of shortening services - // try to get a short link from these services - // in the order ur1.ca, trim, id.gd, tinyurl - $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + $yourls_url = get_config('yourls','url1'); + if ($yourls_url) { + $max_char = 135; + $yourls_username = get_config('yourls','username1'); + $yourls_password = get_config('yourls', 'password1'); + $yourls_ssl = get_config('yourls', 'ssl1'); + $yourls = new Slinky_YourLS(); + $yourls->set( 'username', $yourls_username ); + $yourls->set( 'password', $yourls_password ); + $yourls->set( 'ssl', $yourls_ssl ); + $yourls->set( 'yourls-url', $yourls_url ); + $slinky->set_cascade( array( $yourls, new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + } + else { + // setup a cascade of shortening services + // try to get a short link from these services + // in the order ur1.ca, trim, id.gd, tinyurl + $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + } $shortlink = $slinky->short(); // the new message will be shortened such that "... $shortlink" // will fit into the character limit @@ -282,7 +297,7 @@ function twitter_post_hook(&$a,&$b) { // and now tweet it :-) if(strlen($msg)) { $result = $tweet->post('statuses/update', array('status' => $msg)); - logger('twitter_post send', LOGGER_DEBUG); + logger('twitter_post send' , LOGGER_DEBUG); } } } diff --git a/yourls.tgz b/yourls.tgz new file mode 100755 index 00000000..bf723440 Binary files /dev/null and b/yourls.tgz differ diff --git a/yourls/README b/yourls/README new file mode 100755 index 00000000..3950f027 --- /dev/null +++ b/yourls/README @@ -0,0 +1,8 @@ +YourLS + +For server admins only. +Defines a YourLS url shortener for the Statusnet & Twitter plugins. + +This plugin will not do anything else unless the Statusnet and/or Twitter plugins are installed. + +The message is entered in the admin account at Settings -> Plugin settings. diff --git a/yourls/yourls.css b/yourls/yourls.css new file mode 100755 index 00000000..cfd09c97 --- /dev/null +++ b/yourls/yourls.css @@ -0,0 +1,21 @@ +#yourls-label { + float: left; + width: 300px; + margin-top: 10px; +} + +yourls-url { + float: left; + margin-top: 10px; +} + +#yourls-submit { + margin-top: 15px; +} + +.yourls { + text-align: left; + width 100%; + margin-top: 25px; + font-size: 20px; +} diff --git a/yourls/yourls.php b/yourls/yourls.php new file mode 100755 index 00000000..babfc2c5 --- /dev/null +++ b/yourls/yourls.php @@ -0,0 +1,94 @@ + + * + */ + +function yourls_install() { + register_hook('plugin_settings', 'addon/yourls/yourls.php', 'yourls_addon_settings'); + register_hook('plugin_settings_post', 'addon/yourls/yourls.php', 'yourls_addon_settings_post'); + +} + + +function yourls_uninstall() { + unregister_hook('plugin_settings', 'addon/yourls/yourls.php', 'yourls_addon_settings'); + unregister_hook('plugin_settings_post', 'addon/yourls/yourls.php', 'yourls_addon_settings_post'); + set_config('yourls','url1',trim($_POST[''])); + set_config('yourls','username1',trim($_POST[''])); + set_config('yourls','password1',trim($_POST[''])); + set_config('yourls','ssl1',trim($_POST[''])); + +} + + + + + +function yourls_addon_settings(&$a,&$s) { + + + if(! is_site_admin()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + + $yourls_url = get_config('yourls','url1'); + $yourls_username = get_config('yourls','username1'); + $yourls_password = get_config('yourls', 'password1'); + $ssl_enabled = get_config('yourls','ssl1'); + $ssl_checked = (($ssl_enabled) ? ' checked="checked" ' : ''); + + + +$yourls_ssl = get_config('yourls', 'ssl1'); + + $s .= '