cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

Displaying Tweets With MooTools Widget

If you’re looking for a way to be able to display tweets in your website using a MooTools-built widget, then today’s your lucky day. Today we are highlighting ‘Tweet Display’, a nifty widget developed by Thomas Kunambi that allows you to embed tweets in a designated container by pulling the information from a specified Twitter user via the Twitter API.

Its features include control of the date syntax, hyperlinking of URLs, and setting how many tweet to pull. The retrieved tweets are in JSON/P format and are cached client side using sessionStorage.

Your HTML markup will simply look like this:

<div id="tweetdisplay">
 </div>
You’ll be initializing the JavaScript as such:
window.addEvent("domready", function() {
var TD = new TweetDisplay({
element: document.id("div#tweetdisplay"),
username: "23critters"
});
 });

While there’s almost nothing much to do in CSS, unless of course you feel like doing any further tweak in the tweet’s appearance:

DIV#tweetdisplay {background-color: #ccc;}
Below are the options for the widget as follows:
element: (string||object) Reference to DOM element container. if passing a string, supply the elements' id
actions: (object) A set of "instructions" if you want to pass information from Twitter via different parsers | default: {"text":"linkify", "created_at":"formatdate"}
locale: (string) When you parse the date, define which locale you'd like to use (requires More/Locale/Locale, but is already dependency of Date.js). More information at http://mootools.net/docs/more/Locale/Date
dateformat: (string) A model over how to format the printed date, more information at http://mootools.net/docs/more/Types/Date#Date:format | default: "%Y-%m-%d %H:%M:%S"
count: (integer) How many tweets to pull from Twitters API | default: 5
cachetimer: (integer) How many seconds should the cache be kept before being invalidated (nb! not purged) | default: 3600
cachekey: (string) a identifier for the cache. Good if you want to have different timers for your many TweetDisplays
template: (string) Path to the template containing the HTML | default: "TweetDisplay.html"
 username: (string) Username of user from who to fetch information from | default: "23critters"

And the following methods are available publicly:

linkify: takes string and returns http://, ftp://, file:// clickable. Also @usernames and #tags
formatdate: formats date according to specification at http://mootools.net/docs/more/Types/Date#Date:format
 clear_cache: clears the cache (sessionStorage)

You can download the source files here (v1.3). If you encounter any bugs or errors, do feel free to report about it on its page over at GitHub.

Related Posts

Adding Instagram Badges to Your WordPress Profile

Creating Your Own Twitter Widget

Create An Instagram Widget In Photoshop

Twitter Retires @Spam Account

1 Comment

  1. The Print Blog

    07.20.2012

    Hey thanks for the code. It would have been nice to display a live demo of it though.