GitHub PullRequestReviewCommentEvent at 2014-10-15 21:00:48
Repository: lastfm_top_albums
Actor: andyjac
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/comments/18922438","id":18922438,"diff_hunk":"@@ -1,58 +1,79 @@\n var express = require('express');\n var request = require('request');\n+var _ = require('lodash');\n+var bodyParser = require('body-parser');\n+var LASTFM_CREDS = require('./lastfm_credentials');\n \n-// import my lastfm API Key\n-var lastfmCreds = require('./lastfm_credentials');\n-\n-// instantiate the express app\n var app = express();\n \n app.set('views', './views');\n app.set('view engine', 'jade');\n+// set app to use bodyParser to parse a url encoded body response from a request\n+app.use(bodyParser.urlencoded({extended: false}));\n+\n+app.post('/search', function(req, res) {\n+  var artist = formatArtistInput(req, artist);\n+  var queryURL = buildTopAlbumsQueryURL(artist);\n+  requestLastfmTopAlbums(queryURL, _.partial(renderResults, res));\n+});\n \n-// GET the home page\n app.get('/', function(req, res) {\n-  makeRequest(searchOnLastfm, renderResults, res);\n+  res.render('index');\n });\n \n-// QUERY is hard-coded for the time being. Eventually will be retrieved from user input\n-var QUERY = 'flying+lotus';\n+function formatArtistInput(req, artist) {\n+  return req.body.artist.replace(/\\s+/g, '+');\n+}\n \n-// API url which will return the top albums of a given artist\n-var searchOnLastfm = 'http://ws.audioscrobbler.com/2.0/?' +\n+function buildTopAlbumsQueryURL(artist) {\n+  return 'http://ws.audioscrobbler.com/2.0/?' +\n     'method=artist.gettopalbums&' +\n-    'artist=' + QUERY + '&' +\n+    'artist=' + artist + '&' +\n     'limit=10&' +\n-    'api_key=' + lastfmCreds + '&' +\n+    'api_key=' + LASTFM_CREDS + '&' +\n     'format=json';\n+}\n+\n+function responseOK(error, response) {\n+  return !error && response.statusCode === 200;\n+}\n+\n+// get the albums names out of the album objects\n+function extractAlbumNames(body) {\n+  return _.map(body.topalbums.album, 'name');","path":"app.js","position":55,"original_position":55,"commit_id":"08e606be2feb4156056ed925f21e942a2c3b0f8b","original_commit_id":"08e606be2feb4156056ed925f21e942a2c3b0f8b","user":{"login":"andyjac","id":5609090,"avatar_url":"https://avatars.githubusercontent.com/u/5609090?v=2","gravatar_id":"","url":"https://api.github.com/users/andyjac","html_url":"https://github.com/andyjac","followers_url":"https://api.github.com/users/andyjac/followers","following_url":"https://api.github.com/users/andyjac/following{/other_user}","gists_url":"https://api.github.com/users/andyjac/gists{/gist_id}","starred_url":"https://api.github.com/users/andyjac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyjac/subscriptions","organizations_url":"https://api.github.com/users/andyjac/orgs","repos_url":"https://api.github.com/users/andyjac/repos","events_url":"https://api.github.com/users/andyjac/events{/privacy}","received_events_url":"https://api.github.com/users/andyjac/received_events","type":"User","site_admin":false},"body":"yeah, i'm using a loop in my jade file to put each album into its own list item, so i don't need the .join() anymore","created_at":"2014-10-15T21:00:48Z","updated_at":"2014-10-15T21:00:48Z","html_url":"https://github.com/andyjac/lastfm_top_albums/pull/3#discussion_r18922438","pull_request_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/comments/18922438"},"html":{"href":"https://github.com/andyjac/lastfm_top_albums/pull/3#discussion_r18922438"},"pull_request":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3","id":22624933,"html_url":"https://github.com/andyjac/lastfm_top_albums/pull/3","diff_url":"https://github.com/andyjac/lastfm_top_albums/pull/3.diff","patch_url":"https://github.com/andyjac/lastfm_top_albums/pull/3.patch","issue_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/3","number":3,"state":"open","locked":false,"title":"create post route","user":{"login":"andyjac","id":5609090,"avatar_url":"https://avatars.githubusercontent.com/u/5609090?v=2","gravatar_id":"","url":"https://api.github.com/users/andyjac","html_url":"https://github.com/andyjac","followers_url":"https://api.github.com/users/andyjac/followers","following_url":"https://api.github.com/users/andyjac/following{/other_user}","gists_url":"https://api.github.com/users/andyjac/gists{/gist_id}","starred_url":"https://api.github.com/users/andyjac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyjac/subscriptions","organizations_url":"https://api.github.com/users/andyjac/orgs","repos_url":"https://api.github.com/users/andyjac/repos","events_url":"https://api.github.com/users/andyjac/events{/privacy}","received_events_url":"https://api.github.com/users/andyjac/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-10-13T03:43:33Z","updated_at":"2014-10-15T21:00:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e180aad6cb5f22f56b566258279714829474a27","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3/commits","review_comments_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3/comments","review_comment_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/comments/{number}","comments_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/3/comments","statuses_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/statuses/08e606be2feb4156056ed925f21e942a2c3b0f8b","head":{"label":"andyjac:post-feature","ref":"post-feature","sha":"08e606be2feb4156056ed925f21e942a2c3b0f8b","user":{"login":"andyjac","id":5609090,"avatar_url":"https://avatars.githubusercontent.com/u/5609090?v=2","gravatar_id":"","url":"https://api.github.com/users/andyjac","html_url":"https://github.com/andyjac","followers_url":"https://api.github.com/users/andyjac/followers","following_url":"https://api.github.com/users/andyjac/following{/other_user}","gists_url":"https://api.github.com/users/andyjac/gists{/gist_id}","starred_url":"https://api.github.com/users/andyjac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyjac/subscriptions","organizations_url":"https://api.github.com/users/andyjac/orgs","repos_url":"https://api.github.com/users/andyjac/repos","events_url":"https://api.github.com/users/andyjac/events{/privacy}","received_events_url":"https://api.github.com/users/andyjac/received_events","type":"User","site_admin":false},"repo":{"id":24964081,"name":"lastfm_top_albums","full_name":"andyjac/lastfm_top_albums","owner":{"login":"andyjac","id":5609090,"avatar_url":"https://avatars.githubusercontent.com/u/5609090?v=2","gravatar_id":"","url":"https://api.github.com/users/andyjac","html_url":"https://github.com/andyjac","followers_url":"https://api.github.com/users/andyjac/followers","following_url":"https://api.github.com/users/andyjac/following{/other_user}","gists_url":"https://api.github.com/users/andyjac/gists{/gist_id}","starred_url":"https://api.github.com/users/andyjac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyjac/subscriptions","organizations_url":"https://api.github.com/users/andyjac/orgs","repos_url":"https://api.github.com/users/andyjac/repos","events_url":"https://api.github.com/users/andyjac/events{/privacy}","received_events_url":"https://api.github.com/users/andyjac/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andyjac/lastfm_top_albums","description":"personal project which requests the top albums for a given artist from the lastfm API","fork":false,"url":"https://api.github.com/repos/andyjac/lastfm_top_albums","forks_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/forks","keys_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/teams","hooks_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/hooks","issue_events_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/events{/number}","events_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/events","assignees_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/assignees{/user}","branches_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/branches{/branch}","tags_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/tags","blobs_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/refs{/sha}","trees_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/statuses/{sha}","languages_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/languages","stargazers_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/stargazers","contributors_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/contributors","subscribers_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/subscribers","subscription_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/subscription","commits_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/commits{/sha}","git_commits_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/commits{/sha}","comments_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/comments{/number}","issue_comment_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/comments/{number}","contents_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/contents/{+path}","compare_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/merges","archive_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/downloads","issues_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues{/number}","pulls_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls{/number}","milestones_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/milestones{/number}","notifications_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/labels{/name}","releases_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/releases{/id}","created_at":"2014-10-08T22:39:35Z","updated_at":"2014-10-08T22:42:17Z","pushed_at":"2014-10-15T20:57:21Z","git_url":"git://github.com/andyjac/lastfm_top_albums.git","ssh_url":"git@github.com:andyjac/lastfm_top_albums.git","clone_url":"https://github.com/andyjac/lastfm_top_albums.git","svn_url":"https://github.com/andyjac/lastfm_top_albums","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"andyjac:master","ref":"master","sha":"6507e8900eff4fca068acfd1b208fa8852505437","user":{"login":"andyjac","id":5609090,"avatar_url":"https://avatars.githubusercontent.com/u/5609090?v=2","gravatar_id":"","url":"https://api.github.com/users/andyjac","html_url":"https://github.com/andyjac","followers_url":"https://api.github.com/users/andyjac/followers","following_url":"https://api.github.com/users/andyjac/following{/other_user}","gists_url":"https://api.github.com/users/andyjac/gists{/gist_id}","starred_url":"https://api.github.com/users/andyjac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyjac/subscriptions","organizations_url":"https://api.github.com/users/andyjac/orgs","repos_url":"https://api.github.com/users/andyjac/repos","events_url":"https://api.github.com/users/andyjac/events{/privacy}","received_events_url":"https://api.github.com/users/andyjac/received_events","type":"User","site_admin":false},"repo":{"id":24964081,"name":"lastfm_top_albums","full_name":"andyjac/lastfm_top_albums","owner":{"login":"andyjac","id":5609090,"avatar_url":"https://avatars.githubusercontent.com/u/5609090?v=2","gravatar_id":"","url":"https://api.github.com/users/andyjac","html_url":"https://github.com/andyjac","followers_url":"https://api.github.com/users/andyjac/followers","following_url":"https://api.github.com/users/andyjac/following{/other_user}","gists_url":"https://api.github.com/users/andyjac/gists{/gist_id}","starred_url":"https://api.github.com/users/andyjac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyjac/subscriptions","organizations_url":"https://api.github.com/users/andyjac/orgs","repos_url":"https://api.github.com/users/andyjac/repos","events_url":"https://api.github.com/users/andyjac/events{/privacy}","received_events_url":"https://api.github.com/users/andyjac/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andyjac/lastfm_top_albums","description":"personal project which requests the top albums for a given artist from the lastfm API","fork":false,"url":"https://api.github.com/repos/andyjac/lastfm_top_albums","forks_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/forks","keys_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/teams","hooks_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/hooks","issue_events_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/events{/number}","events_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/events","assignees_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/assignees{/user}","branches_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/branches{/branch}","tags_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/tags","blobs_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/refs{/sha}","trees_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/statuses/{sha}","languages_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/languages","stargazers_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/stargazers","contributors_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/contributors","subscribers_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/subscribers","subscription_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/subscription","commits_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/commits{/sha}","git_commits_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/git/commits{/sha}","comments_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/comments{/number}","issue_comment_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/comments/{number}","contents_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/contents/{+path}","compare_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/merges","archive_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/downloads","issues_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues{/number}","pulls_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls{/number}","milestones_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/milestones{/number}","notifications_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/labels{/name}","releases_url":"https://api.github.com/repos/andyjac/lastfm_top_albums/releases{/id}","created_at":"2014-10-08T22:39:35Z","updated_at":"2014-10-08T22:42:17Z","pushed_at":"2014-10-15T20:57:21Z","git_url":"git://github.com/andyjac/lastfm_top_albums.git","ssh_url":"git@github.com:andyjac/lastfm_top_albums.git","clone_url":"https://github.com/andyjac/lastfm_top_albums.git","svn_url":"https://github.com/andyjac/lastfm_top_albums","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3"},"html":{"href":"https://github.com/andyjac/lastfm_top_albums/pull/3"},"issue":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/3"},"comments":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/andyjac/lastfm_top_albums/statuses/08e606be2feb4156056ed925f21e942a2c3b0f8b"}}}}