{"action":"created","comment":{"url":"https://api.github.com/repos/cdglabs/moonchild/pulls/comments/36082753","id":36082753,"diff_hunk":"@@ -0,0 +1,26 @@\n+function createFileLoader (moonchild, channel) {\n+  var fileLoader = Object.create(null);\n+\n+  // assuming that the editor doesn't get changed\n+  // weird stuff will happen if the editor -does- get changed\n+  var editor = moonchild.getEditor()._codeMirror;\n+  var filePath;\n+\n+  channel.on(\"fileLoad\", function (messageData) {\n+    // assuming JSON structure of form\n+    // {\n+    //   ...\n+    //   content: \"\",\n+    //   filePath: \"bla.js\"\n+    //   ...\n+    // }\n+\n+    var text = messageData.content;\n+    filePath = messageData.filePath;\n+\n+    editor.setValue(text);\n+\n+    // let the editor know that a change happened\n+    moonchild.poke();","path":"editor/loadFile.js","position":24,"original_position":24,"commit_id":"afc07d20f38fa415b67e2dc160cd743ac6c3ebba","original_commit_id":"afc07d20f38fa415b67e2dc160cd743ac6c3ebba","user":{"login":"pdubroy","id":17293,"avatar_url":"https://avatars.githubusercontent.com/u/17293?v=3","gravatar_id":"","url":"https://api.github.com/users/pdubroy","html_url":"https://github.com/pdubroy","followers_url":"https://api.github.com/users/pdubroy/followers","following_url":"https://api.github.com/users/pdubroy/following{/other_user}","gists_url":"https://api.github.com/users/pdubroy/gists{/gist_id}","starred_url":"https://api.github.com/users/pdubroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdubroy/subscriptions","organizations_url":"https://api.github.com/users/pdubroy/orgs","repos_url":"https://api.github.com/users/pdubroy/repos","events_url":"https://api.github.com/users/pdubroy/events{/privacy}","received_events_url":"https://api.github.com/users/pdubroy/received_events","type":"User","site_admin":false},"body":"I don't mind leaving it separate, but given how little code there is (and it's unlikely to get bigger), I would personally just move it in to the editor itself. But it's up to you.","created_at":"2015-08-03T13:07:12Z","updated_at":"2015-08-03T13:07:12Z","html_url":"https://github.com/cdglabs/moonchild/pull/17#discussion_r36082753","pull_request_url":"https://api.github.com/repos/cdglabs/moonchild/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/cdglabs/moonchild/pulls/comments/36082753"},"html":{"href":"https://github.com/cdglabs/moonchild/pull/17#discussion_r36082753"},"pull_request":{"href":"https://api.github.com/repos/cdglabs/moonchild/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/cdglabs/moonchild/pulls/17","id":40945428,"html_url":"https://github.com/cdglabs/moonchild/pull/17","diff_url":"https://github.com/cdglabs/moonchild/pull/17.diff","patch_url":"https://github.com/cdglabs/moonchild/pull/17.patch","issue_url":"https://api.github.com/repos/cdglabs/moonchild/issues/17","number":17,"state":"open","locked":false,"title":"File loading","user":{"login":"Azeirah","id":4040870,"avatar_url":"https://avatars.githubusercontent.com/u/4040870?v=3","gravatar_id":"","url":"https://api.github.com/users/Azeirah","html_url":"https://github.com/Azeirah","followers_url":"https://api.github.com/users/Azeirah/followers","following_url":"https://api.github.com/users/Azeirah/following{/other_user}","gists_url":"https://api.github.com/users/Azeirah/gists{/gist_id}","starred_url":"https://api.github.com/users/Azeirah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azeirah/subscriptions","organizations_url":"https://api.github.com/users/Azeirah/orgs","repos_url":"https://api.github.com/users/Azeirah/repos","events_url":"https://api.github.com/users/Azeirah/events{/privacy}","received_events_url":"https://api.github.com/users/Azeirah/received_events","type":"User","site_admin":false},"body":"This pull request should be merged after the \"fixes\" one.\r\n\r\nIn this pull request, I've added the ability to load files by passing a filename to the `node server.js filename.js` command. This textfile will then be read, and sent to *all open editors*, that's not intended behavior, but that's how it works right now.\r\n\r\nWhat I've done is, I've made a very light abstraction over websockets, to make it easy to work with. The server-side one is server/channel.js and the client-side one is lib/channel.js.\r\n\r\nserver/FileLoader.js does the actual work on the server side. Whenever a new websocket connection gets established between a Moonchild instance and the server, if the server received a file via the commandline, then it opens that file and sends a \"fileLoad\" event using the channel to *all* clients.\r\n\r\nThe client then handles this \"fileLoad\" event in editor/loadFile.js. On \"fileLoad\", it simply sets the editor content to the received content.","created_at":"2015-07-27T20:28:19Z","updated_at":"2015-08-03T13:07:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"096e6389817370ce49d34318ccc6cf2037e33326","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cdglabs/moonchild/pulls/17/commits","review_comments_url":"https://api.github.com/repos/cdglabs/moonchild/pulls/17/comments","review_comment_url":"https://api.github.com/repos/cdglabs/moonchild/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cdglabs/moonchild/issues/17/comments","statuses_url":"https://api.github.com/repos/cdglabs/moonchild/statuses/afc07d20f38fa415b67e2dc160cd743ac6c3ebba","head":{"label":"Azeirah:fileLoading","ref":"fileLoading","sha":"afc07d20f38fa415b67e2dc160cd743ac6c3ebba","user":{"login":"Azeirah","id":4040870,"avatar_url":"https://avatars.githubusercontent.com/u/4040870?v=3","gravatar_id":"","url":"https://api.github.com/users/Azeirah","html_url":"https://github.com/Azeirah","followers_url":"https://api.github.com/users/Azeirah/followers","following_url":"https://api.github.com/users/Azeirah/following{/other_user}","gists_url":"https://api.github.com/users/Azeirah/gists{/gist_id}","starred_url":"https://api.github.com/users/Azeirah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azeirah/subscriptions","organizations_url":"https://api.github.com/users/Azeirah/orgs","repos_url":"https://api.github.com/users/Azeirah/repos","events_url":"https://api.github.com/users/Azeirah/events{/privacy}","received_events_url":"https://api.github.com/users/Azeirah/received_events","type":"User","site_admin":false},"repo":{"id":33014526,"name":"moonchild","full_name":"Azeirah/moonchild","owner":{"login":"Azeirah","id":4040870,"avatar_url":"https://avatars.githubusercontent.com/u/4040870?v=3","gravatar_id":"","url":"https://api.github.com/users/Azeirah","html_url":"https://github.com/Azeirah","followers_url":"https://api.github.com/users/Azeirah/followers","following_url":"https://api.github.com/users/Azeirah/following{/other_user}","gists_url":"https://api.github.com/users/Azeirah/gists{/gist_id}","starred_url":"https://api.github.com/users/Azeirah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azeirah/subscriptions","organizations_url":"https://api.github.com/users/Azeirah/orgs","repos_url":"https://api.github.com/users/Azeirah/repos","events_url":"https://api.github.com/users/Azeirah/events{/privacy}","received_events_url":"https://api.github.com/users/Azeirah/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Azeirah/moonchild","description":"A toolkit for experimenting with new kinds of programming interfaces.","fork":true,"url":"https://api.github.com/repos/Azeirah/moonchild","forks_url":"https://api.github.com/repos/Azeirah/moonchild/forks","keys_url":"https://api.github.com/repos/Azeirah/moonchild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azeirah/moonchild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azeirah/moonchild/teams","hooks_url":"https://api.github.com/repos/Azeirah/moonchild/hooks","issue_events_url":"https://api.github.com/repos/Azeirah/moonchild/issues/events{/number}","events_url":"https://api.github.com/repos/Azeirah/moonchild/events","assignees_url":"https://api.github.com/repos/Azeirah/moonchild/assignees{/user}","branches_url":"https://api.github.com/repos/Azeirah/moonchild/branches{/branch}","tags_url":"https://api.github.com/repos/Azeirah/moonchild/tags","blobs_url":"https://api.github.com/repos/Azeirah/moonchild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azeirah/moonchild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azeirah/moonchild/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azeirah/moonchild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azeirah/moonchild/statuses/{sha}","languages_url":"https://api.github.com/repos/Azeirah/moonchild/languages","stargazers_url":"https://api.github.com/repos/Azeirah/moonchild/stargazers","contributors_url":"https://api.github.com/repos/Azeirah/moonchild/contributors","subscribers_url":"https://api.github.com/repos/Azeirah/moonchild/subscribers","subscription_url":"https://api.github.com/repos/Azeirah/moonchild/subscription","commits_url":"https://api.github.com/repos/Azeirah/moonchild/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azeirah/moonchild/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azeirah/moonchild/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azeirah/moonchild/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azeirah/moonchild/contents/{+path}","compare_url":"https://api.github.com/repos/Azeirah/moonchild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azeirah/moonchild/merges","archive_url":"https://api.github.com/repos/Azeirah/moonchild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azeirah/moonchild/downloads","issues_url":"https://api.github.com/repos/Azeirah/moonchild/issues{/number}","pulls_url":"https://api.github.com/repos/Azeirah/moonchild/pulls{/number}","milestones_url":"https://api.github.com/repos/Azeirah/moonchild/milestones{/number}","notifications_url":"https://api.github.com/repos/Azeirah/moonchild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azeirah/moonchild/labels{/name}","releases_url":"https://api.github.com/repos/Azeirah/moonchild/releases{/id}","created_at":"2015-03-27T23:54:40Z","updated_at":"2015-07-13T12:21:40Z","pushed_at":"2015-07-28T19:15:53Z","git_url":"git://github.com/Azeirah/moonchild.git","ssh_url":"git@github.com:Azeirah/moonchild.git","clone_url":"https://github.com/Azeirah/moonchild.git","svn_url":"https://github.com/Azeirah/moonchild","homepage":"","size":1592,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"cdglabs:master","ref":"master","sha":"4995da12bc8c425ea2f21e987ac271baf79a550a","user":{"login":"cdglabs","id":9912100,"avatar_url":"https://avatars.githubusercontent.com/u/9912100?v=3","gravatar_id":"","url":"https://api.github.com/users/cdglabs","html_url":"https://github.com/cdglabs","followers_url":"https://api.github.com/users/cdglabs/followers","following_url":"https://api.github.com/users/cdglabs/following{/other_user}","gists_url":"https://api.github.com/users/cdglabs/gists{/gist_id}","starred_url":"https://api.github.com/users/cdglabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdglabs/subscriptions","organizations_url":"https://api.github.com/users/cdglabs/orgs","repos_url":"https://api.github.com/users/cdglabs/repos","events_url":"https://api.github.com/users/cdglabs/events{/privacy}","received_events_url":"https://api.github.com/users/cdglabs/received_events","type":"Organization","site_admin":false},"repo":{"id":22538562,"name":"moonchild","full_name":"cdglabs/moonchild","owner":{"login":"cdglabs","id":9912100,"avatar_url":"https://avatars.githubusercontent.com/u/9912100?v=3","gravatar_id":"","url":"https://api.github.com/users/cdglabs","html_url":"https://github.com/cdglabs","followers_url":"https://api.github.com/users/cdglabs/followers","following_url":"https://api.github.com/users/cdglabs/following{/other_user}","gists_url":"https://api.github.com/users/cdglabs/gists{/gist_id}","starred_url":"https://api.github.com/users/cdglabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdglabs/subscriptions","organizations_url":"https://api.github.com/users/cdglabs/orgs","repos_url":"https://api.github.com/users/cdglabs/repos","events_url":"https://api.github.com/users/cdglabs/events{/privacy}","received_events_url":"https://api.github.com/users/cdglabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cdglabs/moonchild","description":"A toolkit for experimenting with new kinds of programming interfaces.","fork":false,"url":"https://api.github.com/repos/cdglabs/moonchild","forks_url":"https://api.github.com/repos/cdglabs/moonchild/forks","keys_url":"https://api.github.com/repos/cdglabs/moonchild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cdglabs/moonchild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cdglabs/moonchild/teams","hooks_url":"https://api.github.com/repos/cdglabs/moonchild/hooks","issue_events_url":"https://api.github.com/repos/cdglabs/moonchild/issues/events{/number}","events_url":"https://api.github.com/repos/cdglabs/moonchild/events","assignees_url":"https://api.github.com/repos/cdglabs/moonchild/assignees{/user}","branches_url":"https://api.github.com/repos/cdglabs/moonchild/branches{/branch}","tags_url":"https://api.github.com/repos/cdglabs/moonchild/tags","blobs_url":"https://api.github.com/repos/cdglabs/moonchild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cdglabs/moonchild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cdglabs/moonchild/git/refs{/sha}","trees_url":"https://api.github.com/repos/cdglabs/moonchild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cdglabs/moonchild/statuses/{sha}","languages_url":"https://api.github.com/repos/cdglabs/moonchild/languages","stargazers_url":"https://api.github.com/repos/cdglabs/moonchild/stargazers","contributors_url":"https://api.github.com/repos/cdglabs/moonchild/contributors","subscribers_url":"https://api.github.com/repos/cdglabs/moonchild/subscribers","subscription_url":"https://api.github.com/repos/cdglabs/moonchild/subscription","commits_url":"https://api.github.com/repos/cdglabs/moonchild/commits{/sha}","git_commits_url":"https://api.github.com/repos/cdglabs/moonchild/git/commits{/sha}","comments_url":"https://api.github.com/repos/cdglabs/moonchild/comments{/number}","issue_comment_url":"https://api.github.com/repos/cdglabs/moonchild/issues/comments{/number}","contents_url":"https://api.github.com/repos/cdglabs/moonchild/contents/{+path}","compare_url":"https://api.github.com/repos/cdglabs/moonchild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cdglabs/moonchild/merges","archive_url":"https://api.github.com/repos/cdglabs/moonchild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cdglabs/moonchild/downloads","issues_url":"https://api.github.com/repos/cdglabs/moonchild/issues{/number}","pulls_url":"https://api.github.com/repos/cdglabs/moonchild/pulls{/number}","milestones_url":"https://api.github.com/repos/cdglabs/moonchild/milestones{/number}","notifications_url":"https://api.github.com/repos/cdglabs/moonchild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cdglabs/moonchild/labels{/name}","releases_url":"https://api.github.com/repos/cdglabs/moonchild/releases{/id}","created_at":"2014-08-02T03:41:29Z","updated_at":"2015-08-03T05:26:51Z","pushed_at":"2015-07-28T19:04:03Z","git_url":"git://github.com/cdglabs/moonchild.git","ssh_url":"git@github.com:cdglabs/moonchild.git","clone_url":"https://github.com/cdglabs/moonchild.git","svn_url":"https://github.com/cdglabs/moonchild","homepage":"","size":1537,"stargazers_count":63,"watchers_count":63,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":5,"forks":8,"open_issues":5,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cdglabs/moonchild/pulls/17"},"html":{"href":"https://github.com/cdglabs/moonchild/pull/17"},"issue":{"href":"https://api.github.com/repos/cdglabs/moonchild/issues/17"},"comments":{"href":"https://api.github.com/repos/cdglabs/moonchild/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/cdglabs/moonchild/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/cdglabs/moonchild/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cdglabs/moonchild/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/cdglabs/moonchild/statuses/afc07d20f38fa415b67e2dc160cd743ac6c3ebba"}}}}