]> git.wh0rd.org Git - tt-rss.git/commitdiff
make plaintext urls in article content clickable
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 26 Nov 2010 10:13:09 +0000 (13:13 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 26 Nov 2010 10:13:09 +0000 (13:13 +0300)
functions.php

index 1d37727fe0ab4ca54fba94e0f0bd0bf3b77ae4d2..a7e106a9d8400ccd149fd391d1ca2375026cc1f5 100644 (file)
                        $res = preg_replace('/<img[^>]+>/is', '', $res);
                }
 
+               $res = rewrite_urls($res);
+
                $charset_hack = '<head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                </head>';
 
        }
 
+       function rewrite_urls($line) {
+               global $url_regex;
+
+               $urls = null;
+
+               $result = preg_replace("/((?<!=.)((http|https|ftp)+):\/\/[^ ,!]+)/i", 
+                       "<a target=\"_blank\" href=\"\\1\">\\1</a>", $line);
+
+               return $result;
+       }
+
 ?>