{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/mercury/pulls/comments/31050858","id":31050858,"diff_hunk":"@@ -0,0 +1,119 @@\n+/// <reference path=\"../app.ts\" />\n+/// <reference path=\"../../baseline/mercury\" />\n+'use strict';\n+\n+App.EditModel = Em.Object.extend({\n+\tcontent: null,\n+\toriginalContent: null,\n+\ttimestamp: null,\n+\ttitle: null,\n+\tsectionIndex: null,\n+\tisDirty: Em.computed('content', 'originalContent', function (): boolean {\n+\t\treturn this.get('content') !== this.get('originalContent');\n+\t})\n+});\n+\n+App.EditModel.reopenClass({\n+\n+\tgetEditToken: function(title: string): Em.RSVP.Promise {\n+\t\treturn new Em.RSVP.Promise((resolve: Function, reject: Function): void => {\n+\t\t\tEm.$.ajax({\n+\t\t\t\turl: Mercury.wiki.basePath + '/api.php',\n+\t\t\t\tdata: {\n+\t\t\t\t\taction: 'query',\n+\t\t\t\t\tprop: 'info',\n+\t\t\t\t\ttitles: title,\n+\t\t\t\t\tintoken: 'edit',\n+\t\t\t\t\tformat: 'json'\n+\t\t\t\t},\n+\t\t\t\tdataType: 'json',\n+\t\t\t\tsuccess: (resp: any): void => {\n+\t\t\t\t\t// FIXME: MediaWiki API, seriously?\n+\t\t\t\t\tvar edittoken = $.map( resp.query.pages, function ( page ) {\n+\t\t\t\t\t\treturn page.edittoken;\n+\t\t\t\t\t} )[0];\n+\t\t\t\t\tresolve(edittoken);\n+\t\t\t\t},\n+\t\t\t\terror: (err): void => {\n+\t\t\t\t\treject(err);\n+\t\t\t\t}\n+\t\t\t});\n+\t\t});\n+\t},\n+\n+\tpublish: function(model: any): Em.RSVP.Promise {\n+\t\treturn new Em.RSVP.Promise((resolve: Function, reject: Function) => {\n+\t\t\tthis.getEditToken(model.title)\n+\t\t\t.then((token: any) => {\n+\t\t\t\tEm.$.ajax({\n+\t\t\t\t\turl: Mercury.wiki.basePath + '/api.php',\n+\t\t\t\t\tdata: {\n+\t\t\t\t\t\taction: 'edit',\n+\t\t\t\t\t\ttitle: model.title,\n+\t\t\t\t\t\tsection: model.sectionIndex,\n+\t\t\t\t\t\ttext: model.content,\n+\t\t\t\t\t\ttoken: token,\n+\t\t\t\t\t\tformat: 'json'\n+\t\t\t\t\t},\n+\t\t\t\t\tdataType: 'json',\n+\t\t\t\t\tmethod: 'POST',\n+\t\t\t\t\tsuccess: (resp: any): void => {\n+\t\t\t\t\t\t//resp = { error: { code: 'autoblockedtext' } };\n+\t\t\t\t\t\tif (resp && resp.edit && resp.edit.result === 'Success') {\n+\t\t\t\t\t\t\tsetTimeout( function() {\n+\t\t\t\t\t\t\t\tresolve();\n+\t\t\t\t\t\t\t}, 1500 );\n+\t\t\t\t\t\t} else if (resp && resp.error) {\n+\t\t\t\t\t\t\treject(resp.error.code);\n+\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\treject();\n+\t\t\t\t\t\t}\n+\t\t\t\t\t},\n+\t\t\t\t\terror: (err): void => {\n+\t\t\t\t\t\treject(err);\n+\t\t\t\t\t}\n+\t\t\t\t});\n+\t\t\t}, (err: any) => {\n+\t\t\t\treject(err);\n+\t\t\t});\n+\t\t});\n+\t},\n+\n+\tload: function(title: string, sectionIndex: number): Em.RSVP.Promise {\n+\t\treturn new Em.RSVP.Promise((resolve: Function, reject: Function): void => {\n+\t\t\tEm.$.getJSON(Mercury.wiki.basePath + '/api.php', {\n+\t\t\t\taction: 'query',\n+\t\t\t\tprop: 'revisions',\n+\t\t\t\t// FIXME: It should be possible to pass props as an array\n+\t\t\t\trvprop: 'content|timestamp',\n+\t\t\t\ttitles: title,\n+\t\t\t\trvsection: sectionIndex,\n+\t\t\t\tformat: 'json'\n+\t\t\t})\n+\t\t\t.done((resp): void => {\n+\t\t\t\tif (resp.error) {\n+\t\t\t\t\treject(resp.error.code);\n+\t\t\t\t\treturn;\n+\t\t\t\t}\n+\n+\t\t\t\t// FIXME: MediaWiki API, seriously?\n+\t\t\t\tvar revision = $.map( resp.query.pages, function ( page ) {","path":"front/scripts/main/models/EditModel.ts","position":100,"original_position":100,"commit_id":"0065a56d2b1b69922b9d10e151d41be1e9164d85","original_commit_id":"0065a56d2b1b69922b9d10e151d41be1e9164d85","user":{"login":"hakubo","id":1018759,"avatar_url":"https://avatars.githubusercontent.com/u/1018759?v=3","gravatar_id":"","url":"https://api.github.com/users/hakubo","html_url":"https://github.com/hakubo","followers_url":"https://api.github.com/users/hakubo/followers","following_url":"https://api.github.com/users/hakubo/following{/other_user}","gists_url":"https://api.github.com/users/hakubo/gists{/gist_id}","starred_url":"https://api.github.com/users/hakubo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hakubo/subscriptions","organizations_url":"https://api.github.com/users/hakubo/orgs","repos_url":"https://api.github.com/users/hakubo/repos","events_url":"https://api.github.com/users/hakubo/events{/privacy}","received_events_url":"https://api.github.com/users/hakubo/received_events","type":"User","site_admin":false},"body":"$.map( resp.query.pages, ( page ) => page.revisions[0] )[0];","created_at":"2015-05-26T16:09:51Z","updated_at":"2015-05-26T16:09:51Z","html_url":"https://github.com/Wikia/mercury/pull/711#discussion_r31050858","pull_request_url":"https://api.github.com/repos/Wikia/mercury/pulls/711","_links":{"self":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/comments/31050858"},"html":{"href":"https://github.com/Wikia/mercury/pull/711#discussion_r31050858"},"pull_request":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/711"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/mercury/pulls/711","id":33805711,"html_url":"https://github.com/Wikia/mercury/pull/711","diff_url":"https://github.com/Wikia/mercury/pull/711.diff","patch_url":"https://github.com/Wikia/mercury/pull/711.patch","issue_url":"https://api.github.com/repos/Wikia/mercury/issues/711","number":711,"state":"open","locked":false,"title":"INT-58: Initial version of article section editing in Mercury","user":{"login":"inez","id":611259,"avatar_url":"https://avatars.githubusercontent.com/u/611259?v=3","gravatar_id":"","url":"https://api.github.com/users/inez","html_url":"https://github.com/inez","followers_url":"https://api.github.com/users/inez/followers","following_url":"https://api.github.com/users/inez/following{/other_user}","gists_url":"https://api.github.com/users/inez/gists{/gist_id}","starred_url":"https://api.github.com/users/inez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inez/subscriptions","organizations_url":"https://api.github.com/users/inez/orgs","repos_url":"https://api.github.com/users/inez/repos","events_url":"https://api.github.com/users/inez/events{/privacy}","received_events_url":"https://api.github.com/users/inez/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-21T21:33:28Z","updated_at":"2015-05-26T16:09:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c7ecca8b7dda91a36d70f30501ed61fe2d4b2c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/mercury/pulls/711/commits","review_comments_url":"https://api.github.com/repos/Wikia/mercury/pulls/711/comments","review_comment_url":"https://api.github.com/repos/Wikia/mercury/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/mercury/issues/711/comments","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/0065a56d2b1b69922b9d10e151d41be1e9164d85","head":{"label":"Wikia:INT-58","ref":"INT-58","sha":"0065a56d2b1b69922b9d10e151d41be1e9164d85","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":16710430,"name":"mercury","full_name":"Wikia/mercury","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/mercury","description":"Wikia Web application","fork":false,"url":"https://api.github.com/repos/Wikia/mercury","forks_url":"https://api.github.com/repos/Wikia/mercury/forks","keys_url":"https://api.github.com/repos/Wikia/mercury/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/mercury/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/mercury/teams","hooks_url":"https://api.github.com/repos/Wikia/mercury/hooks","issue_events_url":"https://api.github.com/repos/Wikia/mercury/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/mercury/events","assignees_url":"https://api.github.com/repos/Wikia/mercury/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/mercury/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/mercury/tags","blobs_url":"https://api.github.com/repos/Wikia/mercury/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/mercury/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/mercury/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/mercury/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/mercury/languages","stargazers_url":"https://api.github.com/repos/Wikia/mercury/stargazers","contributors_url":"https://api.github.com/repos/Wikia/mercury/contributors","subscribers_url":"https://api.github.com/repos/Wikia/mercury/subscribers","subscription_url":"https://api.github.com/repos/Wikia/mercury/subscription","commits_url":"https://api.github.com/repos/Wikia/mercury/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/mercury/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/mercury/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/mercury/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/mercury/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/mercury/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/mercury/merges","archive_url":"https://api.github.com/repos/Wikia/mercury/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/mercury/downloads","issues_url":"https://api.github.com/repos/Wikia/mercury/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/mercury/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/mercury/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/mercury/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/mercury/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/mercury/releases{/id}","created_at":"2014-02-10T21:44:25Z","updated_at":"2015-05-08T20:25:03Z","pushed_at":"2015-05-26T15:36:17Z","git_url":"git://github.com/Wikia/mercury.git","ssh_url":"git@github.com:Wikia/mercury.git","clone_url":"https://github.com/Wikia/mercury.git","svn_url":"https://github.com/Wikia/mercury","homepage":"","size":26428,"stargazers_count":10,"watchers_count":10,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":10,"default_branch":"dev"}},"base":{"label":"Wikia:dev","ref":"dev","sha":"23d72c93e36ed8ab232c24d824537a2819d5f8cb","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":16710430,"name":"mercury","full_name":"Wikia/mercury","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/mercury","description":"Wikia Web application","fork":false,"url":"https://api.github.com/repos/Wikia/mercury","forks_url":"https://api.github.com/repos/Wikia/mercury/forks","keys_url":"https://api.github.com/repos/Wikia/mercury/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/mercury/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/mercury/teams","hooks_url":"https://api.github.com/repos/Wikia/mercury/hooks","issue_events_url":"https://api.github.com/repos/Wikia/mercury/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/mercury/events","assignees_url":"https://api.github.com/repos/Wikia/mercury/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/mercury/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/mercury/tags","blobs_url":"https://api.github.com/repos/Wikia/mercury/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/mercury/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/mercury/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/mercury/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/mercury/languages","stargazers_url":"https://api.github.com/repos/Wikia/mercury/stargazers","contributors_url":"https://api.github.com/repos/Wikia/mercury/contributors","subscribers_url":"https://api.github.com/repos/Wikia/mercury/subscribers","subscription_url":"https://api.github.com/repos/Wikia/mercury/subscription","commits_url":"https://api.github.com/repos/Wikia/mercury/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/mercury/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/mercury/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/mercury/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/mercury/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/mercury/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/mercury/merges","archive_url":"https://api.github.com/repos/Wikia/mercury/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/mercury/downloads","issues_url":"https://api.github.com/repos/Wikia/mercury/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/mercury/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/mercury/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/mercury/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/mercury/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/mercury/releases{/id}","created_at":"2014-02-10T21:44:25Z","updated_at":"2015-05-08T20:25:03Z","pushed_at":"2015-05-26T15:36:17Z","git_url":"git://github.com/Wikia/mercury.git","ssh_url":"git@github.com:Wikia/mercury.git","clone_url":"https://github.com/Wikia/mercury.git","svn_url":"https://github.com/Wikia/mercury","homepage":"","size":26428,"stargazers_count":10,"watchers_count":10,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":10,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/711"},"html":{"href":"https://github.com/Wikia/mercury/pull/711"},"issue":{"href":"https://api.github.com/repos/Wikia/mercury/issues/711"},"comments":{"href":"https://api.github.com/repos/Wikia/mercury/issues/711/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/711/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/711/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/mercury/statuses/0065a56d2b1b69922b9d10e151d41be1e9164d85"}}}}