Monday, November 19, 2007

Pulling twitter updates with JSON and jQuery

I wrote a little script tonight to pull in my latest 3 tweets from twitter and display them on my blog.  You can see it in action on the right.

Here is how I did it.  I used the Twitter's API and called my timeline with a JSON call and comsummed it with jQuery and outputted it to a blank div.

       var url = "http://twitter.com/status/user_timeline/RedWolves.json?count=3&callback=?";        $.getJSON(url,         function(data){             $.each(data, function(i, item) {                 $("img#profile").attr("src", item.user["profile_image_url"]);                 $("#tweets ul").append("<li>"                       + item.text.linkify()                       + " <span class='created_at'>"                       + relative_time(item.created_at)                       + " via "                       + item.source                       + "</span></li>");             });         });

Basically what this does is pulls in the data from twitter and makes them available as objects.  I then loop through each item and pull out the data I want and write it out to a unordered list. Update: make sure to look at the complete working example below as it has the two functions this code block is using (linkify and relative_time) to transform the JSON data into how I'd like it to look.

Here is the HTML stub it's going to:

   <div id="tweets">         <img id="profile">         <ul></ul>     </div>

You can download a working example here: twitter-json-jquery.html (1.79 KB)

Sunday, November 18, 2007

DamnRalph gets a face lift

I've been working on a new design now for a couple of weeks and I finally got it to where I am really happy with the design.  I wanted to go for a simplified look and get rid of the big boxy feel of my previous design.

I spent alot of time writing some awesome jQuery to get the site to be a little interactive and to output the HTML exactly the way I wanted it.

I am using three plug-ins:
  • FX Shadow plugin - I grabbed this right from the respository as they fixed the bug that would of hindered my use of the plugin.. click on Contact or Subscribe or any of the Blog Posts by links to see the shadow plugin in use.
  • Rounded Corners - used them for the areas on the right.
  • Chili - Chili is a automatic code syntax highlighter.
example:

<html> <head>  <title>test</title> </head> <body>    Hello World! </body> </html>

Anyway, let me know what you think.  I only have one more planned feature and that is to pull in my latest twitter update and display it using AJAX.  Just need to figure that out.

Wednesday, November 14, 2007

Update on my jQuery bug

Last month I posted about my problems with the jQuery UI shadow plugin where it wasn't working with absolute positioned divs.

I was looking at the Development jQuery UI group on Google groups this morning and came across this post by Brandon Aaron detailing how he cleaned up the shadow plugin.

I politely mentioned my bug I submitted and he politely told me that the latest version in SVN will now solve my problem.

And it does:



Yay, open source!

Interesting fact, when they release the next version there will now be a UI branch and a FX branch. Shadow was moved and will be in the FX branch.

Monday, November 05, 2007

VS.NET IDE Issue - ASPX gets separated from codebehind

Sometimes in VS.NET 2005 the codebehind for the aspx file show up in the solution explorer not connected.

To Solve this problem:

  1. Close Visual Studio
  2. Open up the proj file with a text/XML editor.
  3. Scroll down till you find the <EmbeddedResource> section.
  4. Find around where you need to enter in a new resource in relation to the file you're having issues with.
  5. add this for each file except the aspx file:
    <EmbeddedResource Include="Admin\Author\MassUpload\upload.aspx.cs">
<DependentUpon>upload.aspx</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Admin\Author\MassUpload\upload.aspx.resx">
<DependentUpon>upload.aspx.cs</DependentUpon>
</EmbeddedResource>

Related Links

Form & Designer File Becoming Separated


Blog Posts by:

My Twitter Updates

View Twitter Page