{"action":"created","comment":{"url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments/51112251","id":51112251,"diff_hunk":"@@ -0,0 +1,68 @@\n+require \"uri\"\n+\n+module LinkHelper\n+  def external_link_to(name = nil, options = nil, html_options = nil, &block)\n+    if block_given?\n+      options = { \"target\" => \"_blank\" }.merge(options || {}) if external_link? name\n+    else\n+      html_options = { \"target\" => \"_blank\" }.merge(html_options || {}) if external_link? options\n+    end\n+\n+    link_to name, options, html_options, &block\n+  end\n+\n+  def external_link?(uri)\n+    UriInspector.new(uri).external?\n+  end\n+\n+  def sanitize_external_links(content)\n+    sanitize content, scrubber: InternalLinkScrubber.new\n+  end\n+\n+  def omission_link_to(name = nil, options = nil, html_options = nil, &block)","path":"app/helpers/link_helper.rb","position":22,"original_position":22,"commit_id":"53f5fc12e62b776d18f9998098a1f8cf4c795be8","original_commit_id":"53f5fc12e62b776d18f9998098a1f8cf4c795be8","user":{"login":"zazaian","id":95957,"avatar_url":"https://avatars.githubusercontent.com/u/95957?v=3","gravatar_id":"","url":"https://api.github.com/users/zazaian","html_url":"https://github.com/zazaian","followers_url":"https://api.github.com/users/zazaian/followers","following_url":"https://api.github.com/users/zazaian/following{/other_user}","gists_url":"https://api.github.com/users/zazaian/gists{/gist_id}","starred_url":"https://api.github.com/users/zazaian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zazaian/subscriptions","organizations_url":"https://api.github.com/users/zazaian/orgs","repos_url":"https://api.github.com/users/zazaian/repos","events_url":"https://api.github.com/users/zazaian/events{/privacy}","received_events_url":"https://api.github.com/users/zazaian/received_events","type":"User","site_admin":false},"body":"Can we break this out into multiple sub-concerns in order to reduce method complexity here?","created_at":"2016-01-28T11:45:49Z","updated_at":"2016-01-28T11:45:49Z","html_url":"https://github.com/UM-USElab/gradecraft-development/pull/1587#discussion_r51112251","pull_request_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587","_links":{"self":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments/51112251"},"html":{"href":"https://github.com/UM-USElab/gradecraft-development/pull/1587#discussion_r51112251"},"pull_request":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587"}}},"pull_request":{"url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587","id":57014211,"html_url":"https://github.com/UM-USElab/gradecraft-development/pull/1587","diff_url":"https://github.com/UM-USElab/gradecraft-development/pull/1587.diff","patch_url":"https://github.com/UM-USElab/gradecraft-development/pull/1587.patch","issue_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1587","number":1587,"state":"open","locked":false,"title":"1313 external submission links","user":{"login":"jwright","id":35017,"avatar_url":"https://avatars.githubusercontent.com/u/35017?v=3","gravatar_id":"","url":"https://api.github.com/users/jwright","html_url":"https://github.com/jwright","followers_url":"https://api.github.com/users/jwright/followers","following_url":"https://api.github.com/users/jwright/following{/other_user}","gists_url":"https://api.github.com/users/jwright/gists{/gist_id}","starred_url":"https://api.github.com/users/jwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwright/subscriptions","organizations_url":"https://api.github.com/users/jwright/orgs","repos_url":"https://api.github.com/users/jwright/repos","events_url":"https://api.github.com/users/jwright/events{/privacy}","received_events_url":"https://api.github.com/users/jwright/received_events","type":"User","site_admin":false},"body":"Redirects all links for `Submission` links and links within the text comments.\r\n\r\nFor links, this PR contains a new helper method called `external_link_to` which adds a `target=_blank` attribute to the link if the link is to an external source. \r\n\r\nIn order to determine whether a link is external, another helper method called `external?` determines if the link is external by parsing it via the [`uri`](http://ruby-doc.org/stdlib-1.9.3/libdoc/uri/rdoc/URI.html) module and checking the `host`.\r\n\r\nIn order to sanitize the links within the text_comment, another helper method was created called `sanitize_external_links` which uses the [`Rails::Html::Sanitizer`](https://github.com/rails/rails-html-sanitizer) with a custom scrubber to add the `target=_blank` attribute for external links. The scrubber was modeled after the [`NoFollow`](https://github.com/flavorjones/loofah/blob/master/lib/loofah/scrubbers.rb#L188) scrubber which adds a `nofollow` attribute.\r\n\r\nNOTE: I could not actually test the sanitizing of the `text_comment` as submissions get stripped of any links when they are saved via this: https://github.com/UM-USElab/gradecraft-development/blob/master/app/models/submission.rb#L18\r\n\r\nCloses #1313 ","created_at":"2016-01-24T21:22:40Z","updated_at":"2016-01-28T11:45:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"052c999330a2c5b1a9ab8ed0adf3fa78101ae2aa","assignee":{"login":"zazaian","id":95957,"avatar_url":"https://avatars.githubusercontent.com/u/95957?v=3","gravatar_id":"","url":"https://api.github.com/users/zazaian","html_url":"https://github.com/zazaian","followers_url":"https://api.github.com/users/zazaian/followers","following_url":"https://api.github.com/users/zazaian/following{/other_user}","gists_url":"https://api.github.com/users/zazaian/gists{/gist_id}","starred_url":"https://api.github.com/users/zazaian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zazaian/subscriptions","organizations_url":"https://api.github.com/users/zazaian/orgs","repos_url":"https://api.github.com/users/zazaian/repos","events_url":"https://api.github.com/users/zazaian/events{/privacy}","received_events_url":"https://api.github.com/users/zazaian/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587/commits","review_comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587/comments","review_comment_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1587/comments","statuses_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/53f5fc12e62b776d18f9998098a1f8cf4c795be8","head":{"label":"UM-USElab:1313-external-submission-links","ref":"1313-external-submission-links","sha":"53f5fc12e62b776d18f9998098a1f8cf4c795be8","user":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"repo":{"id":8105769,"name":"gradecraft-development","full_name":"UM-USElab/gradecraft-development","owner":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UM-USElab/gradecraft-development","description":"GradeCraft is a gameful learning management system, intended to help motivate students to be more engaged in their own learning.","fork":false,"url":"https://api.github.com/repos/UM-USElab/gradecraft-development","forks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/forks","keys_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/teams","hooks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/hooks","issue_events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/events{/number}","events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/events","assignees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/assignees{/user}","branches_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/branches{/branch}","tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/tags","blobs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/refs{/sha}","trees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/{sha}","languages_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/languages","stargazers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/stargazers","contributors_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contributors","subscribers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscribers","subscription_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscription","commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/commits{/sha}","git_commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/commits{/sha}","comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/comments{/number}","issue_comment_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/comments{/number}","contents_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contents/{+path}","compare_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/merges","archive_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/downloads","issues_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues{/number}","pulls_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls{/number}","milestones_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/milestones{/number}","notifications_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/labels{/name}","releases_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/releases{/id}","deployments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/deployments","created_at":"2013-02-09T03:44:54Z","updated_at":"2016-01-27T18:03:56Z","pushed_at":"2016-01-28T11:34:22Z","git_url":"git://github.com/UM-USElab/gradecraft-development.git","ssh_url":"git@github.com:UM-USElab/gradecraft-development.git","clone_url":"https://github.com/UM-USElab/gradecraft-development.git","svn_url":"https://github.com/UM-USElab/gradecraft-development","homepage":"","size":64150,"stargazers_count":27,"watchers_count":27,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":110,"forks":16,"open_issues":110,"watchers":27,"default_branch":"master"}},"base":{"label":"UM-USElab:master","ref":"master","sha":"ca6b52a5ba60545ab8e88492a2bf25c0274c900f","user":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"repo":{"id":8105769,"name":"gradecraft-development","full_name":"UM-USElab/gradecraft-development","owner":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UM-USElab/gradecraft-development","description":"GradeCraft is a gameful learning management system, intended to help motivate students to be more engaged in their own learning.","fork":false,"url":"https://api.github.com/repos/UM-USElab/gradecraft-development","forks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/forks","keys_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/teams","hooks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/hooks","issue_events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/events{/number}","events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/events","assignees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/assignees{/user}","branches_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/branches{/branch}","tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/tags","blobs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/refs{/sha}","trees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/{sha}","languages_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/languages","stargazers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/stargazers","contributors_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contributors","subscribers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscribers","subscription_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscription","commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/commits{/sha}","git_commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/commits{/sha}","comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/comments{/number}","issue_comment_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/comments{/number}","contents_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contents/{+path}","compare_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/merges","archive_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/downloads","issues_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues{/number}","pulls_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls{/number}","milestones_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/milestones{/number}","notifications_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/labels{/name}","releases_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/releases{/id}","deployments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/deployments","created_at":"2013-02-09T03:44:54Z","updated_at":"2016-01-27T18:03:56Z","pushed_at":"2016-01-28T11:34:22Z","git_url":"git://github.com/UM-USElab/gradecraft-development.git","ssh_url":"git@github.com:UM-USElab/gradecraft-development.git","clone_url":"https://github.com/UM-USElab/gradecraft-development.git","svn_url":"https://github.com/UM-USElab/gradecraft-development","homepage":"","size":64150,"stargazers_count":27,"watchers_count":27,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":110,"forks":16,"open_issues":110,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587"},"html":{"href":"https://github.com/UM-USElab/gradecraft-development/pull/1587"},"issue":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1587"},"comments":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1587/comments"},"review_comments":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587/comments"},"review_comment":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1587/commits"},"statuses":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/53f5fc12e62b776d18f9998098a1f8cf4c795be8"}}}}