{"action":"created","comment":{"url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/comments/233429274","pull_request_review_id":174838217,"id":233429274,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMzQyOTI3NA==","diff_hunk":"@@ -0,0 +1,125 @@\n+'use strict';\n+const path = require('path');\n+const express = require('express');\n+const { concat, isArray, pick, get } = require('lodash');\n+\n+const router = express.Router();\n+\n+const { injectBreadcrumbs } = require('../../middleware/inject-content');\n+const { getUpdates } = require('../../services/content-api');\n+const appData = require('../../modules/appData');\n+const { buildPagination } = require('../../modules/pagination');\n+\n+function renderListing({ res, title, entries = [], entriesMeta = null, breadcrumbs = [], isNewsLandingPage = false }) {\n+    const pagination = buildPagination(entriesMeta.pagination);\n+    res.render(path.resolve(__dirname, './views/listing'), {\n+        title,\n+        entries,\n+        entriesMeta,\n+        pagination,\n+        breadcrumbs,\n+        isNewsLandingPage\n+    });\n+}\n+\n+if (appData.isNotProduction) {\n+    router.get('/:type?/:date?/:slug?', injectBreadcrumbs, async (req, res, next) => {\n+        let urlPath = '';\n+        let query = {};\n+\n+        const isSinglePost = req.params.date && req.params.slug;\n+\n+        if (req.params.type) {\n+            // Due to quirks of Craft's entry types,\n+            // we have to convert snake_case into kebab-case\n+            // both at the API end and then in reverse here.\n+            urlPath += `/${req.params.type.replace('-', '_')}`;\n+        }\n+\n+        if (isSinglePost) {\n+            urlPath += `/${req.params.date}/${req.params.slug}`;\n+        } else {\n+            // Listings can be filtered by the following valid query parameters\n+            query = pick(req.query, ['page', 'tag', 'author', 'category']);\n+        }\n+\n+        try {\n+            const response = await getUpdates({\n+                locale: req.i18n.getLocale(),\n+                urlPath: urlPath,\n+                query: query\n+            });\n+\n+            if (response.result) {\n+                // Do we have a listing page?\n+                if (isArray(response.result)) {\n+                    // @TODO i18n for 'All news' and pageTitles below\n+                    // Is this a specific listing page (eg. blog, press releases) or everything?\n+                    const filterType = get(response, 'meta.pageType');\n+                    const isNewsLandingPage = !req.params.type && filterType === 'single';\n+                    // @TODO these titles are singular - should they be pluralised here manually or in the CMS?\n+                    let pageTitle = isNewsLandingPage ? 'All news' : response.result[0].updateType.name;\n+                    let filterLabel;\n+\n+                    if (filterType === 'author') {","path":"controllers/updates/index.js","position":64,"original_position":64,"commit_id":"acca6cf437c5d85afb7fef4fa57ea7463cfc3ddc","original_commit_id":"9c48bf9a572b8a9a806749571186e669c9957f6e","user":{"login":"davidrapson","id":123386,"node_id":"MDQ6VXNlcjEyMzM4Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/123386?v=4","gravatar_id":"","url":"https://api.github.com/users/davidrapson","html_url":"https://github.com/davidrapson","followers_url":"https://api.github.com/users/davidrapson/followers","following_url":"https://api.github.com/users/davidrapson/following{/other_user}","gists_url":"https://api.github.com/users/davidrapson/gists{/gist_id}","starred_url":"https://api.github.com/users/davidrapson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidrapson/subscriptions","organizations_url":"https://api.github.com/users/davidrapson/orgs","repos_url":"https://api.github.com/users/davidrapson/repos","events_url":"https://api.github.com/users/davidrapson/events{/privacy}","received_events_url":"https://api.github.com/users/davidrapson/received_events","type":"User","site_admin":false},"body":"Wondering if we could isolate the blocks of logic a bit more here, something like:\r\n\r\n```js\r\n// @TODO these titles are singular - should they be pluralised here manually or in the CMS?\r\nconst defaultPageTitle = isNewsLandingPage ? 'All news' : response.result[0].updateType.name;\r\n\r\nconst filterLabel = {\r\n    'author': get(response, 'meta.activeAuthor'),\r\n    'tag': get(response, 'meta.activeTag'),\r\n    'category': get(response, 'meta.activeCategory'),\r\n}[filterType];\r\n\r\nconst pageTitle = {\r\n    'author': `Author: ${filterLabel.title}`,\r\n    'tag': `Tag: ${filterLabel.title}`,\r\n    'category': `Category: ${filterLabel.title}`,\r\n}[filterType] || defaultPageTitle;\r\n\r\nconst breadcrumbs = concat(res.locals.breadcrumbs, {\r\n    label: filterLabel ? filterLabel.title : pageTitle\r\n});\r\n```","created_at":"2018-11-14T12:38:41Z","updated_at":"2018-11-14T12:38:41Z","html_url":"https://github.com/biglotteryfund/blf-alpha/pull/1446#discussion_r233429274","pull_request_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/1446","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/comments/233429274"},"html":{"href":"https://github.com/biglotteryfund/blf-alpha/pull/1446#discussion_r233429274"},"pull_request":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/1446"}}},"pull_request":{"url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/1446","id":230808206,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwODA4MjA2","html_url":"https://github.com/biglotteryfund/blf-alpha/pull/1446","diff_url":"https://github.com/biglotteryfund/blf-alpha/pull/1446.diff","patch_url":"https://github.com/biglotteryfund/blf-alpha/pull/1446.patch","issue_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/1446","number":1446,"state":"open","locked":false,"title":"Add updates controller","user":{"login":"mattandrews","id":394376,"node_id":"MDQ6VXNlcjM5NDM3Ng==","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":"Adds a very basic frontend for the new \"updates\" content type:\r\n\r\n![image](https://user-images.githubusercontent.com/394376/48480930-d02dab80-e803-11e8-8d52-f898db1e50c2.png)\r\n\r\n![image](https://user-images.githubusercontent.com/394376/48480945-d6238c80-e803-11e8-81ac-16ab8edf4068.png)\r\n\r\n![image](https://user-images.githubusercontent.com/394376/48480956-db80d700-e803-11e8-9d83-f2abc24d9224.png)\r\n\r\nVery much copied from the existing blog controllers/views. Few things to discuss based off this (see comments!).","created_at":"2018-11-14T11:53:43Z","updated_at":"2018-11-14T12:38:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17ffa5681619b7586cdbbdec53fcf1e09c7c431c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/1446/commits","review_comments_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/1446/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/1446/comments","statuses_url":"https://api.github.com/repos/biglotteryfund/blf-alpha/statuses/acca6cf437c5d85afb7fef4fa57ea7463cfc3ddc","head":{"label":"biglotteryfund:add-updates-controller","ref":"add-updates-controller","sha":"acca6cf437c5d85afb7fef4fa57ea7463cfc3ddc","user":{"login":"biglotteryfund","id":26795798,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2Nzk1Nzk4","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,"node_id":"MDEwOlJlcG9zaXRvcnk4NjMyNjkwNA==","name":"blf-alpha","full_name":"biglotteryfund/blf-alpha","private":false,"owner":{"login":"biglotteryfund","id":26795798,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2Nzk1Nzk4","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},"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":"2018-11-13T14:34:44Z","pushed_at":"2018-11-14T11:55:21Z","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":69378,"stargazers_count":4,"watchers_count":4,"language":"HTML","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":41,"license":null,"forks":0,"open_issues":41,"watchers":4,"default_branch":"master"}},"base":{"label":"biglotteryfund:master","ref":"master","sha":"a9f92ef31286e903124a7d454cfc5210fa5c9202","user":{"login":"biglotteryfund","id":26795798,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2Nzk1Nzk4","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,"node_id":"MDEwOlJlcG9zaXRvcnk4NjMyNjkwNA==","name":"blf-alpha","full_name":"biglotteryfund/blf-alpha","private":false,"owner":{"login":"biglotteryfund","id":26795798,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2Nzk1Nzk4","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},"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":"2018-11-13T14:34:44Z","pushed_at":"2018-11-14T11:55:21Z","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":69378,"stargazers_count":4,"watchers_count":4,"language":"HTML","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":41,"license":null,"forks":0,"open_issues":41,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/1446"},"html":{"href":"https://github.com/biglotteryfund/blf-alpha/pull/1446"},"issue":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/1446"},"comments":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/issues/1446/comments"},"review_comments":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/pulls/1446/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/1446/commits"},"statuses":{"href":"https://api.github.com/repos/biglotteryfund/blf-alpha/statuses/acca6cf437c5d85afb7fef4fa57ea7463cfc3ddc"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"davidrapson"}}