{"action":"created","comment":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/23914115","id":23914115,"diff_hunk":"@@ -0,0 +1,52 @@\n+\n+# encoding: utf-8\n+\n+require 'uri'\n+\n+class Api::Json::OembedController < Api::ApplicationController\n+  include CartoDB\n+\n+  skip_before_filter :api_authorization_required\n+\n+  # Returns oembed data as required\n+  def show\n+    url = params[:url]\n+    width = params[:maxwidth] || '100%'\n+    height = params[:maxheight] || '100%'\n+    format = request.query_parameters[:format]\n+\n+    uri = URI.parse(url)\n+\n+    if uri.host != request.host\n+      raise ActionController::RoutingError.new('URL origin not allowed')\n+    end\n+\n+    uuid = uri.path.split('/')[-1]\n+    begin\n+      CartoDB::Visualization::Member.new(id: uuid, type: 'derived').fetch\n+    rescue KeyError\n+      raise ActionController::RoutingError.new('Visualization not found: ' + uuid)\n+    end\n+\n+    if public_visualizations_show_path(id: uuid) != uri.path && public_visualizations_show_path(id: uuid) + '/' != uri.path","path":"app/controllers/api/json/oembed_controller.rb","position":31,"original_position":31,"commit_id":"95a6d4dfc06b9e1f024e34ff98d5182a4560678c","original_commit_id":"95a6d4dfc06b9e1f024e34ff98d5182a4560678c","user":{"login":"danicarrion","id":498023,"avatar_url":"https://avatars.githubusercontent.com/u/498023?v=3","gravatar_id":"","url":"https://api.github.com/users/danicarrion","html_url":"https://github.com/danicarrion","followers_url":"https://api.github.com/users/danicarrion/followers","following_url":"https://api.github.com/users/danicarrion/following{/other_user}","gists_url":"https://api.github.com/users/danicarrion/gists{/gist_id}","starred_url":"https://api.github.com/users/danicarrion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danicarrion/subscriptions","organizations_url":"https://api.github.com/users/danicarrion/orgs","repos_url":"https://api.github.com/users/danicarrion/repos","events_url":"https://api.github.com/users/danicarrion/events{/privacy}","received_events_url":"https://api.github.com/users/danicarrion/received_events","type":"User","site_admin":false},"body":"much more elegant, this is :)","created_at":"2015-02-02T09:35:26Z","updated_at":"2015-02-02T09:35:26Z","html_url":"https://github.com/CartoDB/cartodb/pull/2006#discussion_r23914115","pull_request_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006","_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/23914115"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/2006#discussion_r23914115"},"pull_request":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006"}}},"pull_request":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006","id":28379442,"html_url":"https://github.com/CartoDB/cartodb/pull/2006","diff_url":"https://github.com/CartoDB/cartodb/pull/2006.diff","patch_url":"https://github.com/CartoDB/cartodb/pull/2006.patch","issue_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2006","number":2006,"state":"open","locked":false,"title":"1965 oembed","user":{"login":"danicarrion","id":498023,"avatar_url":"https://avatars.githubusercontent.com/u/498023?v=3","gravatar_id":"","url":"https://api.github.com/users/danicarrion","html_url":"https://github.com/danicarrion","followers_url":"https://api.github.com/users/danicarrion/followers","following_url":"https://api.github.com/users/danicarrion/following{/other_user}","gists_url":"https://api.github.com/users/danicarrion/gists{/gist_id}","starred_url":"https://api.github.com/users/danicarrion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danicarrion/subscriptions","organizations_url":"https://api.github.com/users/danicarrion/orgs","repos_url":"https://api.github.com/users/danicarrion/repos","events_url":"https://api.github.com/users/danicarrion/events{/privacy}","received_events_url":"https://api.github.com/users/danicarrion/received_events","type":"User","site_admin":false},"body":"controller expects a URL such as:\r\n\r\nhttp://development.cartodb.local:3000/api/v1/oembed?format=json&maxwidth=50&url=http://development.cartodb.local:3000/viz/f9dbb21a-a89c-11e4-ae66-80fa5b110da5/\r\n\r\nand will return something like:\r\n\r\n    {\r\n        type: \"rich\",\r\n        version: \"1.0\",\r\n        width: \"100%\",\r\n        height: \"100%\",\r\n        html: \"<iframe width='100%' height='100%' frameborder='0'         src='http://development.cartodb.local:3000/viz/f9dbb21a-a89c-11e4-ae66-80fa5b110da5/embed_map' allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>\"\r\n    }\r\n\r\nit complies with [oEmbed 1.0](http://oembed.com/)\r\n\r\nboth urls must refer to the same host and checks are run to ensure the URL param belong to an actual visualization and is valid\r\n\r\nCR @juanignaciosl","created_at":"2015-01-30T17:48:03Z","updated_at":"2015-02-02T09:35:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e822db1ec36f4ffd3e0d3cb2899503f3cda8984","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006/commits","review_comments_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006/comments","review_comment_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/{number}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2006/comments","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/95a6d4dfc06b9e1f024e34ff98d5182a4560678c","head":{"label":"CartoDB:1965-oembed","ref":"1965-oembed","sha":"95a6d4dfc06b9e1f024e34ff98d5182a4560678c","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Geospatial database for the cloud","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments/{number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","created_at":"2012-07-05T15:23:45Z","updated_at":"2015-02-02T09:28:19Z","pushed_at":"2015-02-02T09:28:17Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"www.cartodb.com","size":395409,"stargazers_count":697,"watchers_count":697,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":163,"mirror_url":null,"open_issues_count":329,"forks":163,"open_issues":329,"watchers":697,"default_branch":"master"}},"base":{"label":"CartoDB:master","ref":"master","sha":"b09d01f59fc246a6a7763f285e3c9c3dfaecf5c7","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Geospatial database for the cloud","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments/{number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","created_at":"2012-07-05T15:23:45Z","updated_at":"2015-02-02T09:28:19Z","pushed_at":"2015-02-02T09:28:17Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"www.cartodb.com","size":395409,"stargazers_count":697,"watchers_count":697,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":163,"mirror_url":null,"open_issues_count":329,"forks":163,"open_issues":329,"watchers":697,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/2006"},"issue":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/2006"},"comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/2006/comments"},"review_comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006/comments"},"review_comment":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/2006/commits"},"statuses":{"href":"https://api.github.com/repos/CartoDB/cartodb/statuses/95a6d4dfc06b9e1f024e34ff98d5182a4560678c"}}}}