Permalink
Browse files

WEB-34 better attempt at WEB-34

  • Loading branch information...
1 parent 57e567c commit 0ad278faede1e154d74cdd4cf3972a1eb0bc1e47 @brev brev committed Jan 2, 2017
View
@@ -120,6 +120,15 @@ npm run test:links -- http://numenta.com
# Websites
+**Please change directories to one of the individual website sources, i.e.:**
+
+```shell
+cd packages/numenta.com/
+```
+
+**The rest of this section will assume you are in one of the website
+sub-directories.**
+
## Goals
These sites are an attempt at getting back to the roots of the web: *reading*.
@@ -375,9 +384,10 @@ example, see the local file `.eslintrc.json`).
* Each `React` Component should return 1 small element
* Include spaces manually around React Elements in JSX with: `{' '}`
* Custom [React context](https://facebook.github.io/react/docs/context.html)
- which is available:
- * `config` = Site config (see: `config.toml`).
- * `manifest` = Site `package.json` manifest vars like `repo` and 'version`
+ which is available (in addition to Gatsby defaults):
+ * `config` = Site config object (see: `config.toml`).
+ * `manifest` = Site `package.json` manifest object vars like `repo`, 'version`
+ * `stamp` = Build start timestamp string (for cache-busting)
* Make sure to use the `prefixLink()` helper function on all internal links.
This should be handled auto-magically for you already, but if you have trouble
with links on staging, this may be the problem
@@ -440,16 +450,9 @@ example, see the local file `.eslintrc.json`).
### Packages
-* Use exact versions for dependencies in `package.json`, no version RegExps
- please. All package changes need be exact and on purpose for build
- reproducibility. `npm` has a `--save-exact` parameter for this:
- ```
- npm install package@1.2.34 --save --save-exact
- npm install other@5.6.7 --save-dev --save-exact
- ```
-* Bump version number with each changeset: `npm version patch`
-* Keep packages as up-to-date as possible. Check with: `npm outdated -depth 0`
-* Update and test 1 package at a time
+* Use exact versions for dependencies in `package.json`
+* Keep packages as up-to-date as possible: `npm outdated -depth 0`
+* Update and test 1 package at a time for safety
### Styles
View
@@ -1,9 +1,7 @@
-- Version bump after builds
-- Production deployments
-- Update new rewrites to new style for new sites
- Docs/training
- Where are rewrites
-- .Org ready for code handoff to Matt
+- .Org ready for code handoff to Matt / MD!
+
- .ORG FAQ PAGE!?
- Shared `/components` need to have theme style vars passed in from each site
@@ -12,7 +12,6 @@ const context = {
type: 'git',
url: 'https://github.com/numenta/numenta-web',
},
- version: '0.0.1',
},
route: {
page: post,
@@ -28,6 +27,7 @@ const context = {
replace() {},
setRouteLeaveHook() {},
},
+ stamp: '1318874398', // moment().unix().toString()
}
@@ -5,7 +5,7 @@ exports[`Footer React component Renders correctly 1`] = `
className="footer">
<span>
©
- 2016
+ 2017
<a
@@ -9,6 +9,7 @@ import {prefixLink} from 'gatsby-helpers'
import React from 'react'
import request from 'superagent'
import {stampUrl} from 'numenta-web-shared-utils/lib/shared'
+import root from 'window-or-global'
import Button from '../Button'
import Form from '../Form'
@@ -27,7 +28,7 @@ import styles from './index.css'
class Search extends React.Component {
static contextTypes = {
- manifest: React.PropTypes.object.isRequired,
+ stamp: React.PropTypes.string.isRequired,
}
static propTypes = {
@@ -50,11 +51,10 @@ class Search extends React.Component {
}
componentDidMount() {
- const {manifest} = this.context
- const {version} = manifest
+ const {stamp} = this.context
request
- .get(prefixLink(stampUrl('/_searchIndex.json', version))) // load index
+ .get(prefixLink(stampUrl('/_searchIndex.json', stamp))) // load index
.set('Accept', 'application/json')
.end((error, results) => {
if (error || !results || !('body' in results)) return
@@ -78,6 +78,7 @@ class Search extends React.Component {
}
render() {
+ const {document} = root
const {query} = this.state
let {icon} = this.props
let matches, results
@@ -95,7 +96,7 @@ class Search extends React.Component {
results = (
<SearchResult
onClose={() => this._performSearch('')}
- onOpen={() => global.document.getElementById('q').focus()}
+ onOpen={() => document.getElementById('q').focus()}
query={query}
results={matches}
/>
@@ -94,7 +94,7 @@ exports[`Layout React component Renders correctly 1`] = `
className="footer">
<span>
©
- 2016
+ 2017
<a
@@ -14,7 +14,7 @@ import styles from './index.css'
/**
- *
+ * Numenta.com Post ListRow - React view component.
*/
const PostListRow = ({post}) => {
const {data, path} = post
@@ -8,19 +8,20 @@ import Helmet from 'react-helmet'
import Pingdom from 'numenta-web-shared-components/lib/Pingdom'
import {prefixLink} from 'gatsby-helpers'
import React from 'react'
+import root from 'window-or-global'
-import {version} from './package'
/**
- * Main Numenta.com HTML5 Document skeleton - React view component.
- * Base file for Gatsby.js framework.
+ * Main Numenta.com HTML5 Document skeleton - React view component. Base file
+ * for Gatsby.js framework.
* @author Numenta <info@numenta.com>
* @copyright © 2005—2017 Numenta <http://numenta.com>
* @license MIT
* @requires gatsby react
*/
const HtmlDocument = ({body}) => {
+ const {STAMP} = root
const {analytics} = config
const {htmlAttributes, link, meta, title} = Helmet.rewind()
const attrs = htmlAttributes.toComponent()
@@ -36,7 +37,7 @@ const HtmlDocument = ({body}) => {
</head>
<body className="body">
<div id="react-mount" dangerouslySetInnerHTML={{__html: body}} />
- <script src={prefixLink(stampUrl('/bundle.js', version))} />
+ <script src={prefixLink(stampUrl('/bundle.js', STAMP))} />
</body>
</html>
)
@@ -1,6 +1,6 @@
{
"name": "numenta-web-site-com",
- "version": "0.2.211",
+ "version": "0.0.0",
"description": "Numenta.com company website content, source code, and static generator tooling",
"license": "MIT",
"main": false,
@@ -14,6 +14,7 @@ import moment from 'moment'
import {prefixLink} from 'gatsby-helpers'
import React from 'react'
import {stampUrl} from 'numenta-web-shared-utils/lib/shared'
+import root from 'window-or-global'
import values from 'lodash/values'
import Layout from '../components/Layout'
@@ -22,10 +23,12 @@ import manifest from '../package'
import 'tachyons-base/css/tachyons-base.css' // eslint-disable-line import/first, max-len
import '../static/assets/css/fonts.css'
+root.STAMP = moment().unix().toString() // global! cache-busting id
+
/**
- * Root Gatsby Template, acts as React-router bridge (per Gatsby), and internal
- * Layout and Headmatter manager.
+ * Numenta.com Root Gatsby Template, acts as React-router bridge (per Gatsby),
+ * and internal Layout and Headmatter manager - a React view component.
*/
class Template extends React.Component {
@@ -38,26 +41,28 @@ class Template extends React.Component {
config: React.PropTypes.object,
manifest: React.PropTypes.object,
route: React.PropTypes.object,
+ stamp: React.PropTypes.string,
}
getChildContext() {
+ const {STAMP} = root
const {route} = this.props
- return {config, manifest, route}
+ return {config, manifest, route, stamp: STAMP}
}
componentDidMount() {
- if (global.window) injectTapEventPlugin() // remove @ React 1.0
+ if ('window' in global) injectTapEventPlugin() // remove @ React 1.0
}
render() {
+ const {STAMP} = root
const {children} = this.props
const {analytics, company, description, siteHost} = config
const lang = 'en' // @TODO i18n l10n
const now = moment().toString()
const title = `${siteHost}${description}`
const titleForm = `${siteHost} • %s`
const icons = flatten(values(mapValues(favicons, (value) => keys(value))))
- const {version} = manifest
// react-helmet / head
const attrs = {lang}
@@ -71,15 +76,15 @@ class Template extends React.Component {
{name: 'keywords', content: title.split(' ').join(',')},
{
name: 'generator',
- content: `© ${siteHost} v${version} ${now} Gatsby.js`,
+ content: `© ${now} ${siteHost} v=${STAMP} x Gatsby.js`,
},
]
// production stylesheet bundle
if (process.env.NODE_ENV === 'production') {
links.push({
rel: 'stylesheet',
- href: prefixLink(stampUrl('/styles.css', version)),
+ href: prefixLink(stampUrl('/styles.css', STAMP)),
})
}
@@ -93,7 +93,7 @@ exports[`Layout React component Renders correctly 1`] = `
className="footer">
<span>
©
- 2016
+ 2017
<a
@@ -15,7 +15,7 @@ import styles from './index.css'
/**
- *
+ * Numenta.org Post List Row - React view component.
*/
const PostListRow = ({post}) => {
const {data, path} = post
@@ -8,14 +8,20 @@ import Helmet from 'react-helmet'
import Pingdom from 'numenta-web-shared-components/lib/Pingdom'
import {prefixLink} from 'gatsby-helpers'
import React from 'react'
+import root from 'window-or-global'
-import {version} from './package'
/**
- * Main HTML Document Site wrapper - React view component.
+ * Main Numenta.org HTML5 Document skeleton - React view component. Base file
+ * for Gatsby.js framework.
+ * @author Numenta <info@numenta.com>
+ * @copyright © 2005—2017 Numenta <http://numenta.com>
+ * @license MIT
+ * @requires gatsby react
*/
const HtmlDocument = ({body}) => {
+ const {STAMP} = root
const {analytics} = config
const {htmlAttributes, link, meta, title} = Helmet.rewind()
const attrs = htmlAttributes.toComponent()
@@ -31,7 +37,7 @@ const HtmlDocument = ({body}) => {
</head>
<body className="body">
<div id="react-mount" dangerouslySetInnerHTML={{__html: body}} />
- <script src={prefixLink(stampUrl('/bundle.js', version))} />
+ <script src={prefixLink(stampUrl('/bundle.js', STAMP))} />
</body>
</html>
)
@@ -1,6 +1,6 @@
{
"name": "numenta-web-site-org",
- "version": "0.2.22",
+ "version": "0.0.0",
"description": "Numenta.org HTM Community website content, source code, and static generator tooling",
"license": "MIT",
"main": false,
@@ -14,6 +14,7 @@ import moment from 'moment'
import {prefixLink} from 'gatsby-helpers'
import React from 'react'
import {stampUrl} from 'numenta-web-shared-utils/lib/shared'
+import root from 'window-or-global'
import values from 'lodash/values'
import Layout from '../components/Layout'
@@ -22,9 +23,12 @@ import manifest from '../package'
import 'tachyons-base/css/tachyons-base.css' // eslint-disable-line import/first, max-len
import '../static/assets/css/fonts.css'
+root.STAMP = moment().unix().toString() // global! cache-busting id
+
/**
- *
+ * Numenta.org Root Gatsby Template, acts as React-router bridge (per Gatsby),
+ * and internal Layout and Headmatter manager - a React view component.
*/
class Template extends React.Component {
@@ -37,26 +41,28 @@ class Template extends React.Component {
config: React.PropTypes.object,
manifest: React.PropTypes.object,
route: React.PropTypes.object,
+ stamp: React.PropTypes.string,
}
getChildContext() {
+ const {STAMP} = root
const {route} = this.props
- return {config, manifest, route}
+ return {config, manifest, route, stamp: STAMP}
}
componentDidMount() {
- if (global.window) injectTapEventPlugin() // remove @ React 1.0
+ if ('window' in global) injectTapEventPlugin() // remove @ React 1.0
}
render() {
+ const {STAMP} = root
const {children} = this.props
const {analytics, company, description, siteHost} = config
const lang = 'en' // @TODO i18n l10n
const now = moment().toString()
const title = `${siteHost}${description}`
const titleForm = `${siteHost} • %s`
const icons = flatten(values(mapValues(favicons, (value) => keys(value))))
- const {version} = manifest
// react-helmet / head
const attrs = {lang}
@@ -70,15 +76,15 @@ class Template extends React.Component {
{name: 'keywords', content: title.split(' ').join(',')},
{
name: 'generator',
- content: `© ${siteHost} v${version} ${now} Gatsby.js`,
+ content: `© ${now} ${siteHost} v=${STAMP} x Gatsby.js`,
},
]
// production stylesheet bundle
if (process.env.NODE_ENV === 'production') {
links.push({
rel: 'stylesheet',
- href: prefixLink(stampUrl('/styles.css', version)),
+ href: prefixLink(stampUrl('/styles.css', STAMP)),
})
}
Oops, something went wrong.

0 comments on commit 0ad278f

Please sign in to comment.