diff --git a/README.md b/README.md index 61ea5f2..c8207f0 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ JSONP-Fu is a project inspired by the latest design of 0) { + for (i = 0; i < matches.length; i++) { + if (data[matches[i].substr(1)]) { + url = url.replace(matches[i], data[matches[i].substr(1)]); + delete data[matches[i].substr(1)]; + } + } + } + } + + /* + * This is a bit of a crude way to check to see if all arguments are + * present but it works. Instead of throwing an error, we just silently + * return because some methods have multiple different routes. + */ + if (route.test(url)) { + return; + } + + /* + * Specifying a username in an API call overrides the username + * given when initialized. + */ + if (data.username) { + username = data.username; + delete data.username; + } else { + username = opts.username; + } + + query_url = 'http://' + username + '.tumblr.com/api/'; + query_url += url; + query_url += '/json'; + + script.jsonp_query({ + url: query_url, + data: data, + success: function (data) { + callback(data); + } + }); + + return true; + } + }; + + return { + posts: { + show: function (args, callback) { + API.query('read', args, callback); + } + } + }; + +}); \ No newline at end of file