From 55e99a28bf1a070532355f4c55666f457d0150e4 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Tue, 14 Feb 2012 19:07:42 +0100 Subject: [PATCH] added more regex to SN addon to deal with tag links and linked images --- statusnet/statusnet.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 20a848df..1975277a 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -22,13 +22,6 @@ * Documentation: http://diekershoff.homeunix.net/redmine/wiki/friendikaplugin/StatusNet_Plugin */ -/* __TODO__ - * - * - what about multimedia content? - * so far we just strip HTML tags from the message - */ - - /*** * We have to alter the TwitterOAuth class a little bit to work with any StatusNet * installation abroad. Basically it's only make the API path variable and be happy. @@ -153,7 +146,6 @@ function statusnet_settings_post ($a,$post) { if (isset($_POST['statusnet-disconnect'])) { /*** * if the statusnet-disconnect checkbox is set, clear the statusnet configuration - * TODO can we revoke the access tokens at Twitter and do we need to do so? */ del_pconfig( local_user(), 'statusnet', 'consumerkey' ); del_pconfig( local_user(), 'statusnet', 'consumersecret' ); @@ -400,17 +392,18 @@ function statusnet_post_hook(&$a,&$b) { require_once('include/bbcode.php'); $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret); $max_char = $dent->get_maxlength(); // max. length for a dent + // if [url=bla][img]blub.png[/img][/url] get blub.png + $tmp = preg_replace( '/\[url\=(\w+.*?)\]\[img\](\w+.*?)\[\/img\]\[\/url\]/i', '$2', $tmp); // preserve links to images, videos and audios $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $b['body']); $tmp = preg_replace( '/\[\\/?video(\\s+.*?\]|\])/i', '', $tmp); $tmp = preg_replace( '/\[\\/?youtube(\\s+.*?\]|\])/i', '', $tmp); $tmp = preg_replace( '/\[\\/?vimeo(\\s+.*?\]|\])/i', '', $tmp); $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp); + // if a #tag is linked, don't send the [url] over to SN + $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp); // preserve links to webpages $tmp = preg_replace( '/\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp); - // TODO if you insert an image with ~f it inserts a link tag to - // the image - thus we have two potential identical links - // following each other... need to strip one of them // TODO apply the shortener to the URLs in the releyed dent logger($tmp); $msg = strip_tags(bbcode($tmp)); -- 2.39.5