diff options
author | Zach Copley <zach@status.net> | 2010-02-04 03:17:48 +0000 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2010-02-04 03:17:48 +0000 |
commit | feaf938ffd4dc27f2c03b4a532f78b172ddb35e4 (patch) | |
tree | 6a27d386cc7ae1eddf191d2bd52419da4be49bd8 | |
parent | 72f72d17dbc2ddf5228d97079f992a99f2821373 (diff) |
Make Twitter bridge truncate and add a link back to the original notice when notice content is > 140c
-rw-r--r-- | plugins/TwitterBridge/twitter.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index 33dfb788b..6944a1ace 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -1,7 +1,7 @@ <?php /* * StatusNet - the distributed open-source microblogging tool - * Copyright (C) 2008, 2009, StatusNet, Inc. + * Copyright (C) 2008-2010 StatusNet, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -295,8 +295,17 @@ function format_status($notice) $statustxt = preg_replace('/^@/', ' @', $notice->content); // Convert !groups to #hashes + + // XXX: Make this an optional setting? + $statustxt = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/', "\\1#\\2", $statustxt); + if (mb_strlen($statustxt) > 140) { + $noticeUrl = common_shorten_url($notice->uri); + $urlLen = mb_strlen($noticeUrl); + $statustxt = mb_substr($statustxt, 0, 140 - ($urlLen + 3)) . ' … ' . $noticeUrl; + } + return $statustxt; } |