sn commented out some regex for various reasons

This commit is contained in:
Tobias Diekershoff 2012-02-16 07:57:41 +01:00
parent 55e99a28bf
commit 884034d120
1 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,7 @@
<?php
/**
* Name: StatusNet Connector
* Description: Relay public postings to a connected StatusNet account
* Version: 1.0.3
* Author: Tobias Diekershoff <https://diekershoff.homeunix.net/friendika/profile/tobias>
*/
@ -393,15 +394,18 @@ function statusnet_post_hook(&$a,&$b) {
$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);
// $tmp = preg_replace( '/\[url\=(\w+.*?)\]\[img\](\w+.*?)\[\/img\]\[\/url\]/i', '$2', $b['body']);
// preserve links to images, videos and audios
$tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $b['body']);
$tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp);
$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);
// this is commented out by default as it means backlinks
// to friendica, if you don't like this feel free to
// uncomment the following line
// $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 apply the shortener to the URLs in the releyed dent