Created
September 23, 2013 17:50
-
-
Save HoundstoothSTL/6674339 to your computer and use it in GitHub Desktop.
Revisions
-
HoundstoothSTL created this gist
Sep 23, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ var Tumblr = { posts: { // this will get filled by the ajax response upon success }, config: { dataType: 'jsonp', apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx', limit: '1', endpoint: 'http://api.tumblr.com/v2/blog/pixelpressgame.tumblr.com/posts/text', fragment: '?limit=' +this.limit+ '&api_key=' +this.apiKey, dataUrl: this.endpoint + this.fragment }, ajaxSuccess: function(responseData, textStatus, jqXHR) { if( typeof this.posts === "object") { this.posts = responseData; } }, ajaxError: function(responseData, textStatus, errorThrown) { var response = { data: responseData, status: textStatus, err: errorThrown }; console.log(response); }, init: function(options) { if( typeof options === "object" ) { this.config = options; } $.ajax({ type: 'GET', dataType: this.config.dataType, url: this.config.dataUrl, success: function (responseData, textStatus, jqXHR) { Tumblr.ajaxSuccess( responseData, textStatus, jqXHR ); }, error: function (responseData, textStatus, errorThrown) { Tumblr.ajaxError( responseData, textStatus, errorThrown ); } }); } }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ //************************ Load Tumblr Posts **************************** /* * @requires - ./Tumblr.js * @url - https://gist.github.com/HoundstoothSTL/ */ Tumblr.init({ dataType: 'json', apiKey: 'dSObejFjA8z2gAs4Nv0V9bwwj8oP6TRIF124kaXWFfPVwG6iuY', limit: '1', endpoint: 'http://api.tumblr.com/v2/blog/pixelpressgame.tumblr.com/posts/text', fragment: '?limit=' +this.limit+ '&api_key=' +this.apiKey, dataUrl: '/blog.json' }); var loadTemplates = function() { var post = Tumblr.posts[0], title = post.title, body = post.body, author = post.author, date = post.date url = post.url, twitter = post.twitter; // load up template elements here $('[data-template="title"]').text(title); $('[data-template="body"]').html(body); $('[data-template="author"]').text(author); $('[data-template="author"]').attr('href', twitter); $('[data-template="date"]').text(date); $('[data-template="url"]').attr('href', url); }; window.addEventListener('load', function() { loadTemplates(); });