{"action":"created","comment":{"url":"https://api.github.com/repos/pebble/cloudpebble/pulls/comments/39450718","id":39450718,"diff_hunk":"@@ -314,11 +324,28 @@ CloudPebble.Resources = (function() {\n             var form = pane.find('form');\n             form.submit(function(e) {\n                 e.preventDefault();\n-                process_resource_form(form, false, \"/ide/project/\" + PROJECT_ID + \"/resource/\" + resource.id + \"/update\", function(data) {\n+                process_resource_form(form, false, resource.file_name, \"/ide/project/\" + PROJECT_ID + \"/resource/\" + resource.id + \"/update\", function(data) {\n                     // Update any previews we have.\n-                    $('.image-resource-preview img').each(function() {\n-                        $(this).attr('src', $(this).attr('src').replace(/#e.*$/,'') + '#e' + (++preview_count));\n+                    _.each(data.variants, function(variant) {\n+                        var variant_div = $('.variant-'+variant);\n+                        variant_div.find('img').attr('src', function(ind, old_src) {\n+                            if (!old_src || /^(\\s*(\\?t=.*)|\\s+)$/.test(old_src)) {\n+                                // If we're uploading a new variant, we need to set its preview url from scratch\n+                                return '/ide/project/' + PROJECT_ID + '/resource/' + resource.id + '/' + variant + '/get';\n+                            }\n+                            else {\n+                                // If not, we have to refresh and bypass the cache the image using a query string\n+                                return old_src.replace(/\\?t=.*$/,'') + '?t=' + (++preview_count);\n+                            }\n+                        });\n+                        if (resource.kind == 'png' || resource.kind == 'png-trans') {","path":"ide/static/ide/js/resources.js","position":89,"original_position":89,"commit_id":"5ad6e5f29a0f3910f9455dfad247e3ff87030fc5","original_commit_id":"3008b248128c771929623c8bb6b28830e1a6a524","user":{"login":"Katharine","id":110792,"avatar_url":"https://avatars.githubusercontent.com/u/110792?v=3","gravatar_id":"","url":"https://api.github.com/users/Katharine","html_url":"https://github.com/Katharine","followers_url":"https://api.github.com/users/Katharine/followers","following_url":"https://api.github.com/users/Katharine/following{/other_user}","gists_url":"https://api.github.com/users/Katharine/gists{/gist_id}","starred_url":"https://api.github.com/users/Katharine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Katharine/subscriptions","organizations_url":"https://api.github.com/users/Katharine/orgs","repos_url":"https://api.github.com/users/Katharine/repos","events_url":"https://api.github.com/users/Katharine/events{/privacy}","received_events_url":"https://api.github.com/users/Katharine/received_events","type":"User","site_admin":false},"body":"Is this the best place to make this check? If we will never show it, why are we bothering to try assembling things to put in it?","created_at":"2015-09-14T21:38:13Z","updated_at":"2015-09-14T21:38:13Z","html_url":"https://github.com/pebble/cloudpebble/pull/186#discussion_r39450718","pull_request_url":"https://api.github.com/repos/pebble/cloudpebble/pulls/186","_links":{"self":{"href":"https://api.github.com/repos/pebble/cloudpebble/pulls/comments/39450718"},"html":{"href":"https://github.com/pebble/cloudpebble/pull/186#discussion_r39450718"},"pull_request":{"href":"https://api.github.com/repos/pebble/cloudpebble/pulls/186"}}},"pull_request":{"url":"https://api.github.com/repos/pebble/cloudpebble/pulls/186","id":40800399,"html_url":"https://github.com/pebble/cloudpebble/pull/186","diff_url":"https://github.com/pebble/cloudpebble/pull/186.diff","patch_url":"https://github.com/pebble/cloudpebble/pull/186.patch","issue_url":"https://api.github.com/repos/pebble/cloudpebble/issues/186","number":186,"state":"open","locked":false,"title":"PBL-6583 File rename, PBL-17067 Allow users to update images in CloudPebble","user":{"login":"Spacerat","id":141427,"avatar_url":"https://avatars.githubusercontent.com/u/141427?v=3","gravatar_id":"","url":"https://api.github.com/users/Spacerat","html_url":"https://github.com/Spacerat","followers_url":"https://api.github.com/users/Spacerat/followers","following_url":"https://api.github.com/users/Spacerat/following{/other_user}","gists_url":"https://api.github.com/users/Spacerat/gists{/gist_id}","starred_url":"https://api.github.com/users/Spacerat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Spacerat/subscriptions","organizations_url":"https://api.github.com/users/Spacerat/orgs","repos_url":"https://api.github.com/users/Spacerat/repos","events_url":"https://api.github.com/users/Spacerat/events{/privacy}","received_events_url":"https://api.github.com/users/Spacerat/received_events","type":"User","site_admin":false},"body":"This PR adds the ability to rename code and resource files. It also fixes the following issues:\r\n- PBL-17067 i.e. updating a resource with a file with the same name as its current name would fail\r\n- Uploading a new variant for an existing PNG resource would not immediately show the new image\r\n- CloudPebble now validates filenames\r\n","created_at":"2015-07-24T18:07:02Z","updated_at":"2015-09-14T21:38:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7794d02aac48b367542d3ae6a27264b06cbff990","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pebble/cloudpebble/pulls/186/commits","review_comments_url":"https://api.github.com/repos/pebble/cloudpebble/pulls/186/comments","review_comment_url":"https://api.github.com/repos/pebble/cloudpebble/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pebble/cloudpebble/issues/186/comments","statuses_url":"https://api.github.com/repos/pebble/cloudpebble/statuses/5ad6e5f29a0f3910f9455dfad247e3ff87030fc5","head":{"label":"pebble:feature/file-rename","ref":"feature/file-rename","sha":"5ad6e5f29a0f3910f9455dfad247e3ff87030fc5","user":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"repo":{"id":14325128,"name":"cloudpebble","full_name":"pebble/cloudpebble","owner":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pebble/cloudpebble","description":"CloudPebble source. Here be dragons.","fork":false,"url":"https://api.github.com/repos/pebble/cloudpebble","forks_url":"https://api.github.com/repos/pebble/cloudpebble/forks","keys_url":"https://api.github.com/repos/pebble/cloudpebble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pebble/cloudpebble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pebble/cloudpebble/teams","hooks_url":"https://api.github.com/repos/pebble/cloudpebble/hooks","issue_events_url":"https://api.github.com/repos/pebble/cloudpebble/issues/events{/number}","events_url":"https://api.github.com/repos/pebble/cloudpebble/events","assignees_url":"https://api.github.com/repos/pebble/cloudpebble/assignees{/user}","branches_url":"https://api.github.com/repos/pebble/cloudpebble/branches{/branch}","tags_url":"https://api.github.com/repos/pebble/cloudpebble/tags","blobs_url":"https://api.github.com/repos/pebble/cloudpebble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pebble/cloudpebble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pebble/cloudpebble/git/refs{/sha}","trees_url":"https://api.github.com/repos/pebble/cloudpebble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pebble/cloudpebble/statuses/{sha}","languages_url":"https://api.github.com/repos/pebble/cloudpebble/languages","stargazers_url":"https://api.github.com/repos/pebble/cloudpebble/stargazers","contributors_url":"https://api.github.com/repos/pebble/cloudpebble/contributors","subscribers_url":"https://api.github.com/repos/pebble/cloudpebble/subscribers","subscription_url":"https://api.github.com/repos/pebble/cloudpebble/subscription","commits_url":"https://api.github.com/repos/pebble/cloudpebble/commits{/sha}","git_commits_url":"https://api.github.com/repos/pebble/cloudpebble/git/commits{/sha}","comments_url":"https://api.github.com/repos/pebble/cloudpebble/comments{/number}","issue_comment_url":"https://api.github.com/repos/pebble/cloudpebble/issues/comments{/number}","contents_url":"https://api.github.com/repos/pebble/cloudpebble/contents/{+path}","compare_url":"https://api.github.com/repos/pebble/cloudpebble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pebble/cloudpebble/merges","archive_url":"https://api.github.com/repos/pebble/cloudpebble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pebble/cloudpebble/downloads","issues_url":"https://api.github.com/repos/pebble/cloudpebble/issues{/number}","pulls_url":"https://api.github.com/repos/pebble/cloudpebble/pulls{/number}","milestones_url":"https://api.github.com/repos/pebble/cloudpebble/milestones{/number}","notifications_url":"https://api.github.com/repos/pebble/cloudpebble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pebble/cloudpebble/labels{/name}","releases_url":"https://api.github.com/repos/pebble/cloudpebble/releases{/id}","created_at":"2013-11-12T07:08:55Z","updated_at":"2015-09-14T01:06:19Z","pushed_at":"2015-09-14T21:13:45Z","git_url":"git://github.com/pebble/cloudpebble.git","ssh_url":"git@github.com:pebble/cloudpebble.git","clone_url":"https://github.com/pebble/cloudpebble.git","svn_url":"https://github.com/pebble/cloudpebble","homepage":"http://cloudpebble.net/","size":3955,"stargazers_count":118,"watchers_count":118,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":76,"forks":30,"open_issues":76,"watchers":118,"default_branch":"master"}},"base":{"label":"pebble:master","ref":"master","sha":"71855435ee879328725b190ab652142052be540d","user":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"repo":{"id":14325128,"name":"cloudpebble","full_name":"pebble/cloudpebble","owner":{"login":"pebble","id":1048268,"avatar_url":"https://avatars.githubusercontent.com/u/1048268?v=3","gravatar_id":"","url":"https://api.github.com/users/pebble","html_url":"https://github.com/pebble","followers_url":"https://api.github.com/users/pebble/followers","following_url":"https://api.github.com/users/pebble/following{/other_user}","gists_url":"https://api.github.com/users/pebble/gists{/gist_id}","starred_url":"https://api.github.com/users/pebble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pebble/subscriptions","organizations_url":"https://api.github.com/users/pebble/orgs","repos_url":"https://api.github.com/users/pebble/repos","events_url":"https://api.github.com/users/pebble/events{/privacy}","received_events_url":"https://api.github.com/users/pebble/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pebble/cloudpebble","description":"CloudPebble source. Here be dragons.","fork":false,"url":"https://api.github.com/repos/pebble/cloudpebble","forks_url":"https://api.github.com/repos/pebble/cloudpebble/forks","keys_url":"https://api.github.com/repos/pebble/cloudpebble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pebble/cloudpebble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pebble/cloudpebble/teams","hooks_url":"https://api.github.com/repos/pebble/cloudpebble/hooks","issue_events_url":"https://api.github.com/repos/pebble/cloudpebble/issues/events{/number}","events_url":"https://api.github.com/repos/pebble/cloudpebble/events","assignees_url":"https://api.github.com/repos/pebble/cloudpebble/assignees{/user}","branches_url":"https://api.github.com/repos/pebble/cloudpebble/branches{/branch}","tags_url":"https://api.github.com/repos/pebble/cloudpebble/tags","blobs_url":"https://api.github.com/repos/pebble/cloudpebble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pebble/cloudpebble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pebble/cloudpebble/git/refs{/sha}","trees_url":"https://api.github.com/repos/pebble/cloudpebble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pebble/cloudpebble/statuses/{sha}","languages_url":"https://api.github.com/repos/pebble/cloudpebble/languages","stargazers_url":"https://api.github.com/repos/pebble/cloudpebble/stargazers","contributors_url":"https://api.github.com/repos/pebble/cloudpebble/contributors","subscribers_url":"https://api.github.com/repos/pebble/cloudpebble/subscribers","subscription_url":"https://api.github.com/repos/pebble/cloudpebble/subscription","commits_url":"https://api.github.com/repos/pebble/cloudpebble/commits{/sha}","git_commits_url":"https://api.github.com/repos/pebble/cloudpebble/git/commits{/sha}","comments_url":"https://api.github.com/repos/pebble/cloudpebble/comments{/number}","issue_comment_url":"https://api.github.com/repos/pebble/cloudpebble/issues/comments{/number}","contents_url":"https://api.github.com/repos/pebble/cloudpebble/contents/{+path}","compare_url":"https://api.github.com/repos/pebble/cloudpebble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pebble/cloudpebble/merges","archive_url":"https://api.github.com/repos/pebble/cloudpebble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pebble/cloudpebble/downloads","issues_url":"https://api.github.com/repos/pebble/cloudpebble/issues{/number}","pulls_url":"https://api.github.com/repos/pebble/cloudpebble/pulls{/number}","milestones_url":"https://api.github.com/repos/pebble/cloudpebble/milestones{/number}","notifications_url":"https://api.github.com/repos/pebble/cloudpebble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pebble/cloudpebble/labels{/name}","releases_url":"https://api.github.com/repos/pebble/cloudpebble/releases{/id}","created_at":"2013-11-12T07:08:55Z","updated_at":"2015-09-14T01:06:19Z","pushed_at":"2015-09-14T21:13:45Z","git_url":"git://github.com/pebble/cloudpebble.git","ssh_url":"git@github.com:pebble/cloudpebble.git","clone_url":"https://github.com/pebble/cloudpebble.git","svn_url":"https://github.com/pebble/cloudpebble","homepage":"http://cloudpebble.net/","size":3955,"stargazers_count":118,"watchers_count":118,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":76,"forks":30,"open_issues":76,"watchers":118,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pebble/cloudpebble/pulls/186"},"html":{"href":"https://github.com/pebble/cloudpebble/pull/186"},"issue":{"href":"https://api.github.com/repos/pebble/cloudpebble/issues/186"},"comments":{"href":"https://api.github.com/repos/pebble/cloudpebble/issues/186/comments"},"review_comments":{"href":"https://api.github.com/repos/pebble/cloudpebble/pulls/186/comments"},"review_comment":{"href":"https://api.github.com/repos/pebble/cloudpebble/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pebble/cloudpebble/pulls/186/commits"},"statuses":{"href":"https://api.github.com/repos/pebble/cloudpebble/statuses/5ad6e5f29a0f3910f9455dfad247e3ff87030fc5"}}}}