{"action":"created","comment":{"url":"https://api.github.com/repos/DockYard/reefpoints/pulls/comments/52258376","id":52258376,"diff_hunk":"@@ -0,0 +1,148 @@\n+---\n+layout: post\n+title: \"Setting up revision previews with Ember CLI Deploy\"\n+author: 'Marten Schilstra'\n+twitter: 'martndemus'\n+github: martndemus\n+published: true\n+tags: ember\n+---\n+\n+I recently set up previewing revisions with [Ember CLI Deploy][ember-cli-deploy].\n+There is no single best practice on how to do this yet, but here is how I did\n+it.\n+\n+_This post assumes you use the\n+[ember-cli-deploy-revision-data][ember-cli-deploy-revision-data] plugin in\n+conjunction with an index adapter ([Redis][redis-index], [S3][s3-index],\n+[SSH][ssh-index]) for Ember CLI Deploy._\n+\n+### About revisions\n+\n+Everytime you deploy `index.html` with Ember CLI deploy it gets tagged with a\n+revision. By default this is an MD5 hash of the `index.html` file itself, but it\n+can also be a Git commit hash, or the version from your `package.json`.\n+\n+It depends on the index adapter how the `index.html` get tagged exactly. For\n+example: using the S3 adapter, it will append the tag to the filename; using\n+Redis, the tag will be part of the key where the file is stored.\n+\n+Once you have one or more revisions deployed to the target server, you can\n+activate one of the revisions, which will be the default `index.html`\n+the users of your app will see.\n+\n+### Viewing revisions without having to activate them\n+\n+It would be very nice to be able preview (maybe QA test) on the production\n+server, before you activate it and release it to the public. My idea was to be\n+able to do this by visiting `https://example.com/rev-a76df687f97e9ab8ca82d1a1/`.\n+\n+It is really simple to set up your webserver to do this, so I won't go into\n+that, but there is a caveat on the Ember side of this. If you navigate to the\n+revision, the router will throw an error: `The route rev-a76df687f97e9ab8ca82d1a1/\n+was not found`.\n+\n+What is happening? The `Ember.Router` is not intelligent enough to know that you\n+meant to route after the `/rev-a76df687f97e9ab8ca82d1a1/` portion of the path.\n+\n+You have to explicitly configure the router to route on a path other than `/`.\n+\n+### Fixing the router\n+\n+It's pretty simple to set up the router to work from a base path, for example\n+to route on `/awesome-app/` you can set the [`rootUrl`][ember-docs-root-url]:\n+\n+```javascript\n+import Ember from 'ember';\n+\n+const { Router } = Ember;\n+\n+const Router = Router.extend({\n+  location: 'auto',\n+  rootURL: `/awesome-app/`\n+});\n+```\n+\n+To route revisions is a little more complex, as you can't just type in a simple\n+string and be done with it. To be able to handle  revisions, you can make the\n+`rootURL` a computed property instead:\n+\n+```javascript\n+import ember from 'ember';\n+\n+const {\n+  Router,\n+  computed,\n+  isNone\n+} = Ember;\n+\n+const Router = Router.extend({\n+  location: 'auto',\n+\n+  rootURL: computed(() => {\n+    let path = window.location.pathname;\n+\n+    // Looks for /rev-a76df687f97e9ab8ca82d1a1/ at the beginning of the path\n+    // Tweak this regex to match your own style of revisions.\n+    let revisionMatch = new RegExp('^/(rev-.{20}))').exec(path);\n+\n+    // If there was a revision at the beginning of the path\n+    // return it as rootURL\n+    if (revisionMatch && !isNone(revisionMatch[1])) {\n+      return `/${revisionMatch[1]}/`;\n+    } else {\n+      return '/';\n+    }\n+  })\n+});\n+```\n+\n+When the application loads the `rootURL` computed property will be executed once,\n+if the `rev-` part is in the path it will return that as the `rootURL`, else it\n+will just return the default `/`.\n+\n+### Caveat: baseURL is set in ENV\n+\n+By default the `baseURL` property in your `config/environment.js` is `/` and\n+does not interfere with the `rootURL` in the router, but when it is something\n+like `/awesome-app`, then you will run into trouble.\n+\n+It is best to not use `baseURL` in conjunction with `rootURL`. If you have a bae\n+path the app is served from I would recommend you add it to the `rootURL`.\n+\n+Here is how I solved it:\n+\n+```javascript\n+import ember from 'ember';","path":"source/posts/2016-02-03-ember-cli-deploy-revision-previews.md","position":116,"original_position":116,"commit_id":"f3b8cc30d556c18f09901982d6223b44f362111f","original_commit_id":"f3b8cc30d556c18f09901982d6223b44f362111f","user":{"login":"brzpegasus","id":1691398,"avatar_url":"https://avatars.githubusercontent.com/u/1691398?v=3","gravatar_id":"","url":"https://api.github.com/users/brzpegasus","html_url":"https://github.com/brzpegasus","followers_url":"https://api.github.com/users/brzpegasus/followers","following_url":"https://api.github.com/users/brzpegasus/following{/other_user}","gists_url":"https://api.github.com/users/brzpegasus/gists{/gist_id}","starred_url":"https://api.github.com/users/brzpegasus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brzpegasus/subscriptions","organizations_url":"https://api.github.com/users/brzpegasus/orgs","repos_url":"https://api.github.com/users/brzpegasus/repos","events_url":"https://api.github.com/users/brzpegasus/events{/privacy}","received_events_url":"https://api.github.com/users/brzpegasus/received_events","type":"User","site_admin":false},"body":"Capitalize `Ember`.","created_at":"2016-02-09T01:52:01Z","updated_at":"2016-02-09T01:52:01Z","html_url":"https://github.com/DockYard/reefpoints/pull/451#discussion_r52258376","pull_request_url":"https://api.github.com/repos/DockYard/reefpoints/pulls/451","_links":{"self":{"href":"https://api.github.com/repos/DockYard/reefpoints/pulls/comments/52258376"},"html":{"href":"https://github.com/DockYard/reefpoints/pull/451#discussion_r52258376"},"pull_request":{"href":"https://api.github.com/repos/DockYard/reefpoints/pulls/451"}}},"pull_request":{"url":"https://api.github.com/repos/DockYard/reefpoints/pulls/451","id":58146372,"html_url":"https://github.com/DockYard/reefpoints/pull/451","diff_url":"https://github.com/DockYard/reefpoints/pull/451.diff","patch_url":"https://github.com/DockYard/reefpoints/pull/451.patch","issue_url":"https://api.github.com/repos/DockYard/reefpoints/issues/451","number":451,"state":"open","locked":false,"title":"Setting up revision previews with Ember CLI deploy","user":{"login":"martndemus","id":903637,"avatar_url":"https://avatars.githubusercontent.com/u/903637?v=3","gravatar_id":"","url":"https://api.github.com/users/martndemus","html_url":"https://github.com/martndemus","followers_url":"https://api.github.com/users/martndemus/followers","following_url":"https://api.github.com/users/martndemus/following{/other_user}","gists_url":"https://api.github.com/users/martndemus/gists{/gist_id}","starred_url":"https://api.github.com/users/martndemus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martndemus/subscriptions","organizations_url":"https://api.github.com/users/martndemus/orgs","repos_url":"https://api.github.com/users/martndemus/repos","events_url":"https://api.github.com/users/martndemus/events{/privacy}","received_events_url":"https://api.github.com/users/martndemus/received_events","type":"User","site_admin":false},"body":"Closes #450\n\nI'm not a native english speaker, spellcheck please.","created_at":"2016-02-03T14:44:41Z","updated_at":"2016-02-09T01:52:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5331eccebd0678fb7aaf97939b2d5fd5e015c319","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DockYard/reefpoints/pulls/451/commits","review_comments_url":"https://api.github.com/repos/DockYard/reefpoints/pulls/451/comments","review_comment_url":"https://api.github.com/repos/DockYard/reefpoints/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DockYard/reefpoints/issues/451/comments","statuses_url":"https://api.github.com/repos/DockYard/reefpoints/statuses/f3b8cc30d556c18f09901982d6223b44f362111f","head":{"label":"DockYard:450-ember-cli-deploy-revision-previews","ref":"450-ember-cli-deploy-revision-previews","sha":"f3b8cc30d556c18f09901982d6223b44f362111f","user":{"login":"DockYard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/DockYard","html_url":"https://github.com/DockYard","followers_url":"https://api.github.com/users/DockYard/followers","following_url":"https://api.github.com/users/DockYard/following{/other_user}","gists_url":"https://api.github.com/users/DockYard/gists{/gist_id}","starred_url":"https://api.github.com/users/DockYard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DockYard/subscriptions","organizations_url":"https://api.github.com/users/DockYard/orgs","repos_url":"https://api.github.com/users/DockYard/repos","events_url":"https://api.github.com/users/DockYard/events{/privacy}","received_events_url":"https://api.github.com/users/DockYard/received_events","type":"Organization","site_admin":false},"repo":{"id":2262874,"name":"reefpoints","full_name":"DockYard/reefpoints","owner":{"login":"DockYard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/DockYard","html_url":"https://github.com/DockYard","followers_url":"https://api.github.com/users/DockYard/followers","following_url":"https://api.github.com/users/DockYard/following{/other_user}","gists_url":"https://api.github.com/users/DockYard/gists{/gist_id}","starred_url":"https://api.github.com/users/DockYard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DockYard/subscriptions","organizations_url":"https://api.github.com/users/DockYard/orgs","repos_url":"https://api.github.com/users/DockYard/repos","events_url":"https://api.github.com/users/DockYard/events{/privacy}","received_events_url":"https://api.github.com/users/DockYard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DockYard/reefpoints","description":"DockYard Blog","fork":false,"url":"https://api.github.com/repos/DockYard/reefpoints","forks_url":"https://api.github.com/repos/DockYard/reefpoints/forks","keys_url":"https://api.github.com/repos/DockYard/reefpoints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DockYard/reefpoints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DockYard/reefpoints/teams","hooks_url":"https://api.github.com/repos/DockYard/reefpoints/hooks","issue_events_url":"https://api.github.com/repos/DockYard/reefpoints/issues/events{/number}","events_url":"https://api.github.com/repos/DockYard/reefpoints/events","assignees_url":"https://api.github.com/repos/DockYard/reefpoints/assignees{/user}","branches_url":"https://api.github.com/repos/DockYard/reefpoints/branches{/branch}","tags_url":"https://api.github.com/repos/DockYard/reefpoints/tags","blobs_url":"https://api.github.com/repos/DockYard/reefpoints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DockYard/reefpoints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DockYard/reefpoints/git/refs{/sha}","trees_url":"https://api.github.com/repos/DockYard/reefpoints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DockYard/reefpoints/statuses/{sha}","languages_url":"https://api.github.com/repos/DockYard/reefpoints/languages","stargazers_url":"https://api.github.com/repos/DockYard/reefpoints/stargazers","contributors_url":"https://api.github.com/repos/DockYard/reefpoints/contributors","subscribers_url":"https://api.github.com/repos/DockYard/reefpoints/subscribers","subscription_url":"https://api.github.com/repos/DockYard/reefpoints/subscription","commits_url":"https://api.github.com/repos/DockYard/reefpoints/commits{/sha}","git_commits_url":"https://api.github.com/repos/DockYard/reefpoints/git/commits{/sha}","comments_url":"https://api.github.com/repos/DockYard/reefpoints/comments{/number}","issue_comment_url":"https://api.github.com/repos/DockYard/reefpoints/issues/comments{/number}","contents_url":"https://api.github.com/repos/DockYard/reefpoints/contents/{+path}","compare_url":"https://api.github.com/repos/DockYard/reefpoints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DockYard/reefpoints/merges","archive_url":"https://api.github.com/repos/DockYard/reefpoints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DockYard/reefpoints/downloads","issues_url":"https://api.github.com/repos/DockYard/reefpoints/issues{/number}","pulls_url":"https://api.github.com/repos/DockYard/reefpoints/pulls{/number}","milestones_url":"https://api.github.com/repos/DockYard/reefpoints/milestones{/number}","notifications_url":"https://api.github.com/repos/DockYard/reefpoints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DockYard/reefpoints/labels{/name}","releases_url":"https://api.github.com/repos/DockYard/reefpoints/releases{/id}","deployments_url":"https://api.github.com/repos/DockYard/reefpoints/deployments","created_at":"2011-08-24T16:55:40Z","updated_at":"2016-01-08T22:43:24Z","pushed_at":"2016-02-08T21:01:23Z","git_url":"git://github.com/DockYard/reefpoints.git","ssh_url":"git@github.com:DockYard/reefpoints.git","clone_url":"https://github.com/DockYard/reefpoints.git","svn_url":"https://github.com/DockYard/reefpoints","homepage":"https://dockyard.com/blog","size":86858,"stargazers_count":35,"watchers_count":35,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":63,"mirror_url":null,"open_issues_count":15,"forks":63,"open_issues":15,"watchers":35,"default_branch":"master"}},"base":{"label":"DockYard:master","ref":"master","sha":"37289c26dd2b5a70725a40f89a446eb279e58fb8","user":{"login":"DockYard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/DockYard","html_url":"https://github.com/DockYard","followers_url":"https://api.github.com/users/DockYard/followers","following_url":"https://api.github.com/users/DockYard/following{/other_user}","gists_url":"https://api.github.com/users/DockYard/gists{/gist_id}","starred_url":"https://api.github.com/users/DockYard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DockYard/subscriptions","organizations_url":"https://api.github.com/users/DockYard/orgs","repos_url":"https://api.github.com/users/DockYard/repos","events_url":"https://api.github.com/users/DockYard/events{/privacy}","received_events_url":"https://api.github.com/users/DockYard/received_events","type":"Organization","site_admin":false},"repo":{"id":2262874,"name":"reefpoints","full_name":"DockYard/reefpoints","owner":{"login":"DockYard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/DockYard","html_url":"https://github.com/DockYard","followers_url":"https://api.github.com/users/DockYard/followers","following_url":"https://api.github.com/users/DockYard/following{/other_user}","gists_url":"https://api.github.com/users/DockYard/gists{/gist_id}","starred_url":"https://api.github.com/users/DockYard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DockYard/subscriptions","organizations_url":"https://api.github.com/users/DockYard/orgs","repos_url":"https://api.github.com/users/DockYard/repos","events_url":"https://api.github.com/users/DockYard/events{/privacy}","received_events_url":"https://api.github.com/users/DockYard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DockYard/reefpoints","description":"DockYard Blog","fork":false,"url":"https://api.github.com/repos/DockYard/reefpoints","forks_url":"https://api.github.com/repos/DockYard/reefpoints/forks","keys_url":"https://api.github.com/repos/DockYard/reefpoints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DockYard/reefpoints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DockYard/reefpoints/teams","hooks_url":"https://api.github.com/repos/DockYard/reefpoints/hooks","issue_events_url":"https://api.github.com/repos/DockYard/reefpoints/issues/events{/number}","events_url":"https://api.github.com/repos/DockYard/reefpoints/events","assignees_url":"https://api.github.com/repos/DockYard/reefpoints/assignees{/user}","branches_url":"https://api.github.com/repos/DockYard/reefpoints/branches{/branch}","tags_url":"https://api.github.com/repos/DockYard/reefpoints/tags","blobs_url":"https://api.github.com/repos/DockYard/reefpoints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DockYard/reefpoints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DockYard/reefpoints/git/refs{/sha}","trees_url":"https://api.github.com/repos/DockYard/reefpoints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DockYard/reefpoints/statuses/{sha}","languages_url":"https://api.github.com/repos/DockYard/reefpoints/languages","stargazers_url":"https://api.github.com/repos/DockYard/reefpoints/stargazers","contributors_url":"https://api.github.com/repos/DockYard/reefpoints/contributors","subscribers_url":"https://api.github.com/repos/DockYard/reefpoints/subscribers","subscription_url":"https://api.github.com/repos/DockYard/reefpoints/subscription","commits_url":"https://api.github.com/repos/DockYard/reefpoints/commits{/sha}","git_commits_url":"https://api.github.com/repos/DockYard/reefpoints/git/commits{/sha}","comments_url":"https://api.github.com/repos/DockYard/reefpoints/comments{/number}","issue_comment_url":"https://api.github.com/repos/DockYard/reefpoints/issues/comments{/number}","contents_url":"https://api.github.com/repos/DockYard/reefpoints/contents/{+path}","compare_url":"https://api.github.com/repos/DockYard/reefpoints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DockYard/reefpoints/merges","archive_url":"https://api.github.com/repos/DockYard/reefpoints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DockYard/reefpoints/downloads","issues_url":"https://api.github.com/repos/DockYard/reefpoints/issues{/number}","pulls_url":"https://api.github.com/repos/DockYard/reefpoints/pulls{/number}","milestones_url":"https://api.github.com/repos/DockYard/reefpoints/milestones{/number}","notifications_url":"https://api.github.com/repos/DockYard/reefpoints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DockYard/reefpoints/labels{/name}","releases_url":"https://api.github.com/repos/DockYard/reefpoints/releases{/id}","deployments_url":"https://api.github.com/repos/DockYard/reefpoints/deployments","created_at":"2011-08-24T16:55:40Z","updated_at":"2016-01-08T22:43:24Z","pushed_at":"2016-02-08T21:01:23Z","git_url":"git://github.com/DockYard/reefpoints.git","ssh_url":"git@github.com:DockYard/reefpoints.git","clone_url":"https://github.com/DockYard/reefpoints.git","svn_url":"https://github.com/DockYard/reefpoints","homepage":"https://dockyard.com/blog","size":86858,"stargazers_count":35,"watchers_count":35,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":63,"mirror_url":null,"open_issues_count":15,"forks":63,"open_issues":15,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DockYard/reefpoints/pulls/451"},"html":{"href":"https://github.com/DockYard/reefpoints/pull/451"},"issue":{"href":"https://api.github.com/repos/DockYard/reefpoints/issues/451"},"comments":{"href":"https://api.github.com/repos/DockYard/reefpoints/issues/451/comments"},"review_comments":{"href":"https://api.github.com/repos/DockYard/reefpoints/pulls/451/comments"},"review_comment":{"href":"https://api.github.com/repos/DockYard/reefpoints/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DockYard/reefpoints/pulls/451/commits"},"statuses":{"href":"https://api.github.com/repos/DockYard/reefpoints/statuses/f3b8cc30d556c18f09901982d6223b44f362111f"}}}}