Advertisement
xealgo

Simple Tumblr Blog Feed using jQuery

Aug 6th, 2011
4,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.62 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset=utf-8 />
  5.     <title></title>
  6.     <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
  7.     <!--[if IE]>
  8.         <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  9.     <![endif]-->
  10.    
  11.     <style>
  12.         div.posts {
  13.             margin-top: 25px;
  14.             padding: 5px;
  15.         }
  16.         #tumblrfeed {
  17.             width: 500px;
  18.             height:
  19.         }
  20.     </style>
  21.  
  22.     <script type="text/javascript">
  23.         var limit = 5;
  24.         var url = 'http://xealgo.tumblr.com';
  25.        
  26.         $.getJSON(url+'/api/read/json?num='+limit+'&callback=?', function(data) {
  27.             $.each(data.posts, function(i,posts){
  28.                 if(posts.type == 'video'){
  29.                     displayVideoPost(posts);
  30.                 } else if(posts.type == 'link'){
  31.                     displayLinkPost(posts);
  32.                 } else if(posts.type == 'regular'){
  33.                     displayTextPost(posts);
  34.                 }
  35.             });
  36.         });
  37.        
  38.         function displayTextPost(posts){
  39.             if(posts == null) return;
  40.             $('#tumblrfeed').append('<div class="posts"><h1>'+posts['regular-title']+"</h1>");
  41.             $('#tumblrfeed').append(posts['regular-body']+'</div>');
  42.         }
  43.        
  44.         function displayLinkPost(posts){
  45.             if(posts == null) return;
  46.             $('#tumblrfeed').append('<div class="posts"><h1>'+posts['link-text']+"</h1>");
  47.             $('#tumblrfeed').append(posts['link-url']);
  48.             $('#tumblrfeed').append(posts['link-description']+'</div>');
  49.         }
  50.        
  51.         function displayVideoPost(posts){
  52.             if(posts == null) return;
  53.             $('#tumblrfeed').append('<div class="posts"><h1>'+posts['video-caption']+"</h1>");
  54.             $('#tumblrfeed').append(posts['video-player-250']+'</div>');
  55.         }
  56.        
  57.     </script>
  58.    
  59. </head>
  60. <body>
  61.     <div id="tumblrfeed">
  62.     </div>
  63. </body>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement