{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments/61989782","id":61989782,"diff_hunk":"@@ -0,0 +1,85 @@\n+import React, { Component, PropTypes } from 'react';\n+import ReactDOM from 'react-dom/server';\n+import serialize from 'serialize-javascript';\n+import Helmet from 'react-helmet';\n+\n+\n+export default class ServerHtml extends Component {\n+\n+  static propTypes = {\n+    appName: PropTypes.string.isRequired,\n+    assets: PropTypes.object.isRequired,\n+    component: PropTypes.object.isRequired,\n+    env: PropTypes.string.isRequired,\n+    sriData: PropTypes.object,\n+    store: PropTypes.object.isRequired,\n+  };\n+\n+  getStatic({filePath, type} = {}) {\n+    const { env, sriData, appName } = this.props;\n+    const leafName = filePath.split('/').pop();\n+    const isDeployed = ['stage', 'dev', 'production'].indexOf(env) > -1;\n+    let sriProps = {};\n+    // Only output files for the current app.\n+    if (leafName.startsWith(appName)) {\n+      if (isDeployed) {\n+        sriProps = {\n+          integrity: sriData[leafName],\n+          crossOrigin: 'anonymous',\n+        };\n+        if (!sriProps.integrity) {\n+          throw new Error(`SRI Data is missing for ${leafName}`);\n+        }\n+      }\n+      switch (type) {\n+        case 'css':\n+          return (<link href={filePath} {...sriProps}\n+                       rel=\"stylesheet\" type=\"text/css\" />);\n+        case 'js':\n+          return <script src={filePath} {...sriProps}></script>;\n+        default:\n+          throw new Error('Unknown static type');\n+      }\n+    } else {\n+      return null;\n+    }\n+  }\n+\n+  getStyle() {\n+    const { assets } = this.props;\n+    return Object.keys(assets.styles).map((style) =>\n+      this.getStatic({filePath: assets.styles[style], type: 'css'}));\n+  }\n+\n+  getScript() {\n+    const { assets } = this.props;\n+    return Object.keys(assets.javascript).map((js) =>\n+      this.getStatic({filePath: assets.javascript[js], type: 'js'}));\n+  }\n+\n+  render() {\n+    const { component, store } = this.props;\n+    const content = component ? ReactDOM.renderToString(component) : '';\n+    const head = Helmet.rewind();\n+    const htmlAttrs = head.htmlAttributes.toComponent();","path":"src/core/containers/ServerHtml.js","position":64,"original_position":64,"commit_id":"188eb5cbc84e73aead847a623f59f8596e83fe8f","original_commit_id":"188eb5cbc84e73aead847a623f59f8596e83fe8f","user":{"login":"mstriemer","id":211578,"avatar_url":"https://avatars.githubusercontent.com/u/211578?v=3","gravatar_id":"","url":"https://api.github.com/users/mstriemer","html_url":"https://github.com/mstriemer","followers_url":"https://api.github.com/users/mstriemer/followers","following_url":"https://api.github.com/users/mstriemer/following{/other_user}","gists_url":"https://api.github.com/users/mstriemer/gists{/gist_id}","starred_url":"https://api.github.com/users/mstriemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstriemer/subscriptions","organizations_url":"https://api.github.com/users/mstriemer/orgs","repos_url":"https://api.github.com/users/mstriemer/repos","events_url":"https://api.github.com/users/mstriemer/events{/privacy}","received_events_url":"https://api.github.com/users/mstriemer/received_events","type":"User","site_admin":false},"body":"I find the API for helmet pretty disappointing. Shouldn't this be `.toObject()`? What does it mean to rewind a helmet? I'm no American football expert but I don't think that's a thing.\r\n\r\nIt does what we need though, so I guess I can put up with this.","created_at":"2016-05-04T04:37:05Z","updated_at":"2016-05-04T04:37:05Z","html_url":"https://github.com/mozilla/addons-frontend/pull/302#discussion_r61989782","pull_request_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302","_links":{"self":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments/61989782"},"html":{"href":"https://github.com/mozilla/addons-frontend/pull/302#discussion_r61989782"},"pull_request":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302","id":68787200,"html_url":"https://github.com/mozilla/addons-frontend/pull/302","diff_url":"https://github.com/mozilla/addons-frontend/pull/302.diff","patch_url":"https://github.com/mozilla/addons-frontend/pull/302.patch","issue_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/302","number":302,"state":"open","locked":false,"title":"Refactor HTML for apps","user":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"body":"Fixes #270 \r\nFixes #255\r\nFixes #248\r\n\r\n* Moves to using JSX for the HTML\r\n\r\nTODO: As a follow-up will need to wrap the search code when login is required in the App component so that it gets the App title.\r\n\r\n","created_at":"2016-05-03T22:43:02Z","updated_at":"2016-05-04T04:37:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0b6d6556501a0d4592205fde086e0fe365c0430a","assignee":{"login":"mstriemer","id":211578,"avatar_url":"https://avatars.githubusercontent.com/u/211578?v=3","gravatar_id":"","url":"https://api.github.com/users/mstriemer","html_url":"https://github.com/mstriemer","followers_url":"https://api.github.com/users/mstriemer/followers","following_url":"https://api.github.com/users/mstriemer/following{/other_user}","gists_url":"https://api.github.com/users/mstriemer/gists{/gist_id}","starred_url":"https://api.github.com/users/mstriemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstriemer/subscriptions","organizations_url":"https://api.github.com/users/mstriemer/orgs","repos_url":"https://api.github.com/users/mstriemer/repos","events_url":"https://api.github.com/users/mstriemer/events{/privacy}","received_events_url":"https://api.github.com/users/mstriemer/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302/commits","review_comments_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302/comments","review_comment_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/302/comments","statuses_url":"https://api.github.com/repos/mozilla/addons-frontend/statuses/188eb5cbc84e73aead847a623f59f8596e83fe8f","head":{"label":"muffinresearch:better-html","ref":"better-html","sha":"188eb5cbc84e73aead847a623f59f8596e83fe8f","user":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"repo":{"id":52104378,"name":"addons-frontend","full_name":"muffinresearch/addons-frontend","owner":{"login":"muffinresearch","id":1514,"avatar_url":"https://avatars.githubusercontent.com/u/1514?v=3","gravatar_id":"","url":"https://api.github.com/users/muffinresearch","html_url":"https://github.com/muffinresearch","followers_url":"https://api.github.com/users/muffinresearch/followers","following_url":"https://api.github.com/users/muffinresearch/following{/other_user}","gists_url":"https://api.github.com/users/muffinresearch/gists{/gist_id}","starred_url":"https://api.github.com/users/muffinresearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffinresearch/subscriptions","organizations_url":"https://api.github.com/users/muffinresearch/orgs","repos_url":"https://api.github.com/users/muffinresearch/repos","events_url":"https://api.github.com/users/muffinresearch/events{/privacy}","received_events_url":"https://api.github.com/users/muffinresearch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/muffinresearch/addons-frontend","description":"Front-end infrastructure and code to complement mozilla/addons-server","fork":true,"url":"https://api.github.com/repos/muffinresearch/addons-frontend","forks_url":"https://api.github.com/repos/muffinresearch/addons-frontend/forks","keys_url":"https://api.github.com/repos/muffinresearch/addons-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/muffinresearch/addons-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/muffinresearch/addons-frontend/teams","hooks_url":"https://api.github.com/repos/muffinresearch/addons-frontend/hooks","issue_events_url":"https://api.github.com/repos/muffinresearch/addons-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/muffinresearch/addons-frontend/events","assignees_url":"https://api.github.com/repos/muffinresearch/addons-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/muffinresearch/addons-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/muffinresearch/addons-frontend/tags","blobs_url":"https://api.github.com/repos/muffinresearch/addons-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/muffinresearch/addons-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/muffinresearch/addons-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/muffinresearch/addons-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/muffinresearch/addons-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/muffinresearch/addons-frontend/languages","stargazers_url":"https://api.github.com/repos/muffinresearch/addons-frontend/stargazers","contributors_url":"https://api.github.com/repos/muffinresearch/addons-frontend/contributors","subscribers_url":"https://api.github.com/repos/muffinresearch/addons-frontend/subscribers","subscription_url":"https://api.github.com/repos/muffinresearch/addons-frontend/subscription","commits_url":"https://api.github.com/repos/muffinresearch/addons-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/muffinresearch/addons-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/muffinresearch/addons-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/muffinresearch/addons-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/muffinresearch/addons-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/muffinresearch/addons-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/muffinresearch/addons-frontend/merges","archive_url":"https://api.github.com/repos/muffinresearch/addons-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/muffinresearch/addons-frontend/downloads","issues_url":"https://api.github.com/repos/muffinresearch/addons-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/muffinresearch/addons-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/muffinresearch/addons-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/muffinresearch/addons-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/muffinresearch/addons-frontend/labels{/name}","releases_url":"https://api.github.com/repos/muffinresearch/addons-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/muffinresearch/addons-frontend/deployments","created_at":"2016-02-19T17:26:17Z","updated_at":"2016-03-11T16:08:46Z","pushed_at":"2016-05-03T22:38:49Z","git_url":"git://github.com/muffinresearch/addons-frontend.git","ssh_url":"git@github.com:muffinresearch/addons-frontend.git","clone_url":"https://github.com/muffinresearch/addons-frontend.git","svn_url":"https://github.com/muffinresearch/addons-frontend","homepage":null,"size":247,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"e50f50b9cc16c7c8d7d194a3d5452866f64df580","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":52104368,"name":"addons-frontend","full_name":"mozilla/addons-frontend","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/addons-frontend","description":"Front-end infrastructure and code to complement mozilla/addons-server","fork":false,"url":"https://api.github.com/repos/mozilla/addons-frontend","forks_url":"https://api.github.com/repos/mozilla/addons-frontend/forks","keys_url":"https://api.github.com/repos/mozilla/addons-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/addons-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/addons-frontend/teams","hooks_url":"https://api.github.com/repos/mozilla/addons-frontend/hooks","issue_events_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/addons-frontend/events","assignees_url":"https://api.github.com/repos/mozilla/addons-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/addons-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/addons-frontend/tags","blobs_url":"https://api.github.com/repos/mozilla/addons-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/addons-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/addons-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/addons-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/addons-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/addons-frontend/languages","stargazers_url":"https://api.github.com/repos/mozilla/addons-frontend/stargazers","contributors_url":"https://api.github.com/repos/mozilla/addons-frontend/contributors","subscribers_url":"https://api.github.com/repos/mozilla/addons-frontend/subscribers","subscription_url":"https://api.github.com/repos/mozilla/addons-frontend/subscription","commits_url":"https://api.github.com/repos/mozilla/addons-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/addons-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/addons-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/addons-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/addons-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/addons-frontend/merges","archive_url":"https://api.github.com/repos/mozilla/addons-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/addons-frontend/downloads","issues_url":"https://api.github.com/repos/mozilla/addons-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/addons-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/addons-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/addons-frontend/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/addons-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/addons-frontend/deployments","created_at":"2016-02-19T17:25:57Z","updated_at":"2016-02-23T16:02:34Z","pushed_at":"2016-05-04T03:46:21Z","git_url":"git://github.com/mozilla/addons-frontend.git","ssh_url":"git@github.com:mozilla/addons-frontend.git","clone_url":"https://github.com/mozilla/addons-frontend.git","svn_url":"https://github.com/mozilla/addons-frontend","homepage":null,"size":312,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":35,"forks":4,"open_issues":35,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302"},"html":{"href":"https://github.com/mozilla/addons-frontend/pull/302"},"issue":{"href":"https://api.github.com/repos/mozilla/addons-frontend/issues/302"},"comments":{"href":"https://api.github.com/repos/mozilla/addons-frontend/issues/302/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/302/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/addons-frontend/statuses/188eb5cbc84e73aead847a623f59f8596e83fe8f"}}}}