From 65796ba03ba4cd0470a1e9790d2234c8b42d6cba Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 21 Apr 2010 17:14:54 -0400 Subject: add ClientSideShortenPlugin see plugins/ClientSideShorten/README --- plugins/ClientSideShorten/shorten.php | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 plugins/ClientSideShorten/shorten.php (limited to 'plugins/ClientSideShorten/shorten.php') diff --git a/plugins/ClientSideShorten/shorten.php b/plugins/ClientSideShorten/shorten.php new file mode 100644 index 000000000..4905c62c2 --- /dev/null +++ b/plugins/ClientSideShorten/shorten.php @@ -0,0 +1,68 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Shorten all URLs in a string + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ShortenAction extends Action +{ + private $text; + + function prepare($args) + { + parent::prepare($args); + $this->groups=array(); + $this->users=array(); + $this->text = $this->arg('text'); + if(is_null($this->text)){ + throw new ClientException(_m('\'text\' argument must be specified.')); + } + return true; + } + + function handle($args) + { + parent::handle($args); + header('Content-Type: text/plain'); + $shortened_text = common_shorten_links($this->text, true); + print $shortened_text; + } +} + -- cgit v1.2.3-54-g00ecf