habari: convert url to link

The only feature I was missing in habari was tha automatic conversion of urls to clickable links. I googled and found the following code snippet: http://codesnippets.joyent.com/posts/show/2104. To use this in your habari theme, insert the following into your theme.php:

	public function filter_comment_content_out($content){
	$pattern = "@\b(https?://)?(([0-9a-zA-Z_!~*'().&=+$%-]+:)?[0-9a-zA-Z_!~*'().&=+$%-]+\@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\@&=+$,%#-]+)*/?)@";
	return preg_replace($pattern, '\0', $content);
	 }

After this is done all the urls typed in the commentbox will be displayed as clickable links.

Iratkozz fel, hogy elsőnek értesülj új bejegyzésekről:

2 responses to “habari: convert url to link”

  1. Galamb
    Galamb

    google.css-be mintha hiányozna a pre.prettyprint -hez egy overflow: auto, mert így egy pöppet csúnya 😛

  2. kobak

    Jogos. Majd beteszem, aztán megírom a nagy plugin kezelőnek. Köszönöm. Sajnos az utóbbi időben nem sok idő jutott a blogra.

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.