{"action":"created","comment":{"url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/comments/169053088","pull_request_review_id":97516535,"id":169053088,"diff_hunk":"@@ -0,0 +1,21 @@\n+'use strict';\n+const { getSecret } = require('../modules/secrets');\n+\n+// Sets a global parameter to indicate if this request came from a preview domain\n+module.exports = (req, res, next) => {\n+    let PREVIEW_DOMAIN = process.env.PREVIEW_DOMAIN || getSecret('preview.domain');","path":"middleware/preview.js","position":null,"original_position":6,"commit_id":"6efea44fcd5cbee3363090514853d95e597e49ea","original_commit_id":"51d783dbbabc331efb744cb28788d02f053fdfa1","user":{"login":"mattandrews","id":394376,"avatar_url":"https://avatars0.githubusercontent.com/u/394376?v=4","gravatar_id":"","url":"https://api.github.com/users/mattandrews","html_url":"https://github.com/mattandrews","followers_url":"https://api.github.com/users/mattandrews/followers","following_url":"https://api.github.com/users/mattandrews/following{/other_user}","gists_url":"https://api.github.com/users/mattandrews/gists{/gist_id}","starred_url":"https://api.github.com/users/mattandrews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattandrews/subscriptions","organizations_url":"https://api.github.com/users/mattandrews/orgs","repos_url":"https://api.github.com/users/mattandrews/repos","events_url":"https://api.github.com/users/mattandrews/events{/privacy}","received_events_url":"https://api.github.com/users/mattandrews/received_events","type":"User","site_admin":false},"body":"Done!","created_at":"2018-02-19T11:47:13Z","updated_at":"2018-02-19T11:47:13Z","html_url":"https://github.com/biglotteryfund/blf-alpha/pull/683#discussion_r169053088","pull_request_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/comments/169053088"},"html":{"href":"https://github.com/biglotteryfund/blf-alpha/pull/683#discussion_r169053088"},"pull_request":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683"}},"in_reply_to_id":169029071},"pull_request":{"url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683","id":169635066,"html_url":"https://github.com/biglotteryfund/blf-alpha/pull/683","diff_url":"https://github.com/biglotteryfund/blf-alpha/pull/683.diff","patch_url":"https://github.com/biglotteryfund/blf-alpha/pull/683.patch","issue_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/683","number":683,"state":"open","locked":false,"title":"[DRAFT] Add preview mode","user":{"login":"mattandrews","id":394376,"avatar_url":"https://avatars0.githubusercontent.com/u/394376?v=4","gravatar_id":"","url":"https://api.github.com/users/mattandrews","html_url":"https://github.com/mattandrews","followers_url":"https://api.github.com/users/mattandrews/followers","following_url":"https://api.github.com/users/mattandrews/following{/other_user}","gists_url":"https://api.github.com/users/mattandrews/gists{/gist_id}","starred_url":"https://api.github.com/users/mattandrews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattandrews/subscriptions","organizations_url":"https://api.github.com/users/mattandrews/orgs","repos_url":"https://api.github.com/users/mattandrews/repos","events_url":"https://api.github.com/users/mattandrews/events{/privacy}","received_events_url":"https://api.github.com/users/mattandrews/received_events","type":"User","site_admin":false},"body":"This is more conceptual than anything else, but worth a look.\r\n\r\nThis adds the concept of a \"preview domain\" (eg. `preview.biglotteryfund.org.uk`) which, if used, would attempt to request draft/revisions of CMS content (based on `?draft=$id` or `?version=$id` parameters in the path).\r\n\r\nThere's a corresponding branch over at https://github.com/biglotteryfund/craft-dev which allows Craft to output this content (for authorised users). This PR passes through all cookies to the API call (when on the preview domain) so we can test this integration out.\r\n\r\nThere's also a discussion to be had around error handling: if someone is unauthorised, should we tell them, or just send them to the non-preview version of the page? Likewise if someone is successful, how should we indicate that the page is a preview/draft?\r\n\r\nThere's also some changes here to update the `/robots.txt` handler to block everything when the site is served over `preview.` (which would need IT to create a duplicate CNAME from the `www`) one.\r\n\r\nAlternatively we could use the internal domain to serve these requests? \r\n\r\nThoughts very welcome.","created_at":"2018-02-16T14:18:59Z","updated_at":"2018-02-19T11:47:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0162e8e2abc5e021e1e58ac54c80a3042ef6bdc9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683/commits","review_comments_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683/comments","review_comment_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/683/comments","statuses_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/statuses/6efea44fcd5cbee3363090514853d95e597e49ea","head":{"label":"biglotteryfund:add-preview-mode","ref":"add-preview-mode","sha":"6efea44fcd5cbee3363090514853d95e597e49ea","user":{"login":"biglotteryfund","id":26795798,"avatar_url":"https://avatars1.githubusercontent.com/u/26795798?v=4","gravatar_id":"","url":"https://api.github.com/users/biglotteryfund","html_url":"https://github.com/biglotteryfund","followers_url":"https://api.github.com/users/biglotteryfund/followers","following_url":"https://api.github.com/users/biglotteryfund/following{/other_user}","gists_url":"https://api.github.com/users/biglotteryfund/gists{/gist_id}","starred_url":"https://api.github.com/users/biglotteryfund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biglotteryfund/subscriptions","organizations_url":"https://api.github.com/users/biglotteryfund/orgs","repos_url":"https://api.github.com/users/biglotteryfund/repos","events_url":"https://api.github.com/users/biglotteryfund/events{/privacy}","received_events_url":"https://api.github.com/users/biglotteryfund/received_events","type":"Organization","site_admin":false},"repo":{"id":86326904,"name":"blf-alpha","full_name":"biglotteryfund/blf-alpha","owner":{"login":"biglotteryfund","id":26795798,"avatar_url":"https://avatars1.githubusercontent.com/u/26795798?v=4","gravatar_id":"","url":"https://api.github.com/users/biglotteryfund","html_url":"https://github.com/biglotteryfund","followers_url":"https://api.github.com/users/biglotteryfund/followers","following_url":"https://api.github.com/users/biglotteryfund/following{/other_user}","gists_url":"https://api.github.com/users/biglotteryfund/gists{/gist_id}","starred_url":"https://api.github.com/users/biglotteryfund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biglotteryfund/subscriptions","organizations_url":"https://api.github.com/users/biglotteryfund/orgs","repos_url":"https://api.github.com/users/biglotteryfund/repos","events_url":"https://api.github.com/users/biglotteryfund/events{/privacy}","received_events_url":"https://api.github.com/users/biglotteryfund/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biglotteryfund/blf-alpha","description":"The Big Lottery Fund gives grants to organisations in the UK to help improve their communities. The money awarded comes from the UK National Lottery.","fork":false,"url":"https://api.github.com/repos/biglotteryfund/blf-alpha","forks_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/forks","keys_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/teams","hooks_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/hooks","issue_events_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/events{/number}","events_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/events","assignees_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/assignees{/user}","branches_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/branches{/branch}","tags_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/tags","blobs_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/refs{/sha}","trees_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/statuses/{sha}","languages_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/languages","stargazers_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/stargazers","contributors_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/contributors","subscribers_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/subscribers","subscription_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/subscription","commits_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/commits{/sha}","git_commits_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/commits{/sha}","comments_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/comments{/number}","issue_comment_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/comments{/number}","contents_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/contents/{+path}","compare_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/merges","archive_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/downloads","issues_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues{/number}","pulls_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls{/number}","milestones_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/milestones{/number}","notifications_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/labels{/name}","releases_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/releases{/id}","deployments_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/deployments","created_at":"2017-03-27T11:24:13Z","updated_at":"2017-12-31T13:01:19Z","pushed_at":"2018-02-19T11:20:42Z","git_url":"git://github.com/biglotteryfund/blf-alpha.git","ssh_url":"git@github.com:biglotteryfund/blf-alpha.git","clone_url":"https://github.com/biglotteryfund/blf-alpha.git","svn_url":"https://github.com/biglotteryfund/blf-alpha","homepage":"https://www.biglotteryfund.org.uk","size":43030,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":79,"license":null,"forks":0,"open_issues":79,"watchers":4,"default_branch":"master"}},"base":{"label":"biglotteryfund:master","ref":"master","sha":"ef2139a910e2e923b2f5c36cb6227594bb6706a1","user":{"login":"biglotteryfund","id":26795798,"avatar_url":"https://avatars1.githubusercontent.com/u/26795798?v=4","gravatar_id":"","url":"https://api.github.com/users/biglotteryfund","html_url":"https://github.com/biglotteryfund","followers_url":"https://api.github.com/users/biglotteryfund/followers","following_url":"https://api.github.com/users/biglotteryfund/following{/other_user}","gists_url":"https://api.github.com/users/biglotteryfund/gists{/gist_id}","starred_url":"https://api.github.com/users/biglotteryfund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biglotteryfund/subscriptions","organizations_url":"https://api.github.com/users/biglotteryfund/orgs","repos_url":"https://api.github.com/users/biglotteryfund/repos","events_url":"https://api.github.com/users/biglotteryfund/events{/privacy}","received_events_url":"https://api.github.com/users/biglotteryfund/received_events","type":"Organization","site_admin":false},"repo":{"id":86326904,"name":"blf-alpha","full_name":"biglotteryfund/blf-alpha","owner":{"login":"biglotteryfund","id":26795798,"avatar_url":"https://avatars1.githubusercontent.com/u/26795798?v=4","gravatar_id":"","url":"https://api.github.com/users/biglotteryfund","html_url":"https://github.com/biglotteryfund","followers_url":"https://api.github.com/users/biglotteryfund/followers","following_url":"https://api.github.com/users/biglotteryfund/following{/other_user}","gists_url":"https://api.github.com/users/biglotteryfund/gists{/gist_id}","starred_url":"https://api.github.com/users/biglotteryfund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biglotteryfund/subscriptions","organizations_url":"https://api.github.com/users/biglotteryfund/orgs","repos_url":"https://api.github.com/users/biglotteryfund/repos","events_url":"https://api.github.com/users/biglotteryfund/events{/privacy}","received_events_url":"https://api.github.com/users/biglotteryfund/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biglotteryfund/blf-alpha","description":"The Big Lottery Fund gives grants to organisations in the UK to help improve their communities. The money awarded comes from the UK National Lottery.","fork":false,"url":"https://api.github.com/repos/biglotteryfund/blf-alpha","forks_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/forks","keys_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/teams","hooks_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/hooks","issue_events_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/events{/number}","events_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/events","assignees_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/assignees{/user}","branches_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/branches{/branch}","tags_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/tags","blobs_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/refs{/sha}","trees_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/statuses/{sha}","languages_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/languages","stargazers_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/stargazers","contributors_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/contributors","subscribers_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/subscribers","subscription_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/subscription","commits_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/commits{/sha}","git_commits_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/git/commits{/sha}","comments_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/comments{/number}","issue_comment_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/comments{/number}","contents_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/contents/{+path}","compare_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/merges","archive_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/downloads","issues_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues{/number}","pulls_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls{/number}","milestones_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/milestones{/number}","notifications_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/labels{/name}","releases_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/releases{/id}","deployments_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/deployments","created_at":"2017-03-27T11:24:13Z","updated_at":"2017-12-31T13:01:19Z","pushed_at":"2018-02-19T11:20:42Z","git_url":"git://github.com/biglotteryfund/blf-alpha.git","ssh_url":"git@github.com:biglotteryfund/blf-alpha.git","clone_url":"https://github.com/biglotteryfund/blf-alpha.git","svn_url":"https://github.com/biglotteryfund/blf-alpha","homepage":"https://www.biglotteryfund.org.uk","size":43030,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":79,"license":null,"forks":0,"open_issues":79,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683"},"html":{"href":"https://github.com/biglotteryfund/blf-alpha/pull/683"},"issue":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/683"},"comments":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/683/comments"},"review_comments":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683/comments"},"review_comment":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/683/commits"},"statuses":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/statuses/6efea44fcd5cbee3363090514853d95e597e49ea"}},"author_association":"OWNER"}}
{"actor":{"display_login":"mattandrews"}}