Twitter Highlight

written in javascript, twitter

Hi guys,

I built a JS helper that will help a lot people.

Fork me: http://github.com/egermano/twitter-highlights-js

In the sources you will find a index.php file in it you will find a complete example. In that file, I call a twitter api to list some tweets and I use a twitter highlight to apply links in usernames, hashtags and links.

How to use

To apply a links using a twitter highlight do so:

example
1
2
3
4
5
6
7
8

var tweet = 'the @egermano blog is #awesome http://blog.egermano.com';

tweet.parseURL(); //to transform the URLs
tweet.parseUsername(); //to trasnform the users
tweet.parseHashtag(); //to trasnform the Hashtags

console.log(tweet);

Link

In the twitter-parsing.js you still find a link method of prototype a String native object. I changed this method to recive more arguments like this:

String.link()
1
2
3
4
5
6
7

/**
* Prototyping String,link
*
* @param string str A url to create a link.
* @param object opt Option param [bool nofollow, bool newWindow, string className]
*///Ex: opt = {nofollow:true, newWindow: true, className: ‘link-twitter’};

Well, thats all folks. For some questions or issues you can comment here or in github. Thanks.


Comments