Commit 966f20be authored by Eric Eastwood's avatar Eric Eastwood

Fix microsite, read version from package.json

parent 4a1983ce
......@@ -33,9 +33,10 @@ var config = {
watch: {
tasks: 'build-microsite-templates',
globs: [
path.join(micrositeBasePath, 'src/index.html'),
// We use the api doc in the documentation section
path.join('./API.md')
path.join('./API.md'),
// We can't do this unless we invalidate the require cache for `./microsite/server/generate-render-response`
//path.join(micrositeBasePath, 'server/**/*'),
]
}
},
......@@ -160,7 +161,7 @@ gulp.task('build-microsite-templates', function() {
this.push(chunk);
return callback();
});
config.paths.micrositeTemplates.generateRenderResponse().then((page) => {
var file = new gutil.File({
cwd: '',
......@@ -168,7 +169,7 @@ gulp.task('build-microsite-templates', function() {
path: 'index.html',
contents: new Buffer(page)
});
stream.write(file);
stream.end();
......@@ -263,5 +264,3 @@ gulp.task('default', function(callback) {
callback
);
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -9,6 +9,7 @@ import { Provider } from 'react-redux';
import marked from 'marked';
import renderFullPage from './render-full-page';
import getLatestSidecarVersion from './get-latest-sidecar-version';
import App from '../src/js/components/MicrositeApp';
import appReducer from '../src/js/reducers/MicrositeReducer';
......@@ -33,7 +34,8 @@ export default function generateRenderResponse(req) {
// Create a new Redux store instance
const store = createStore(appReducer, {
documentation: marked(readmeMarkdown)
documentation: marked(readmeMarkdown),
sidecarVersion: getLatestSidecarVersion()
});
// Render the component to a string
......@@ -49,5 +51,3 @@ export default function generateRenderResponse(req) {
return renderFullPage(html, initialState);
});
}
import semver from 'semver';
import manifest from '../../package.json';
// `0`, `1`, etc
export default function getLatestSidecarVersion() {
return semver.major(manifest.version);
}
import getLatestSidecarVersion from './get-latest-sidecar-version';
export default function renderFullPage(html, initialState = {}) {
return `
<!DOCTYPE html>
......@@ -30,7 +32,7 @@ export default function renderFullPage(html, initialState = {}) {
room: 'gitterHQ/sidecar-demo'
};
</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
<script src="https://sidecar.gitter.im/dist/sidecar.v${getLatestSidecarVersion()}.js" async defer></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
......
......@@ -10,6 +10,13 @@ export function setRoomName(name) {
};
}
export function setSidecarVersion(version) {
return {
type: types.SIDECAR_VERSION_SET,
version
};
}
export function setDocumentation(text) {
return {
type: types.DOCUMENTATION_SET,
......
import React from 'react';
import { connect } from 'react-redux';
import semver from 'semver';
import stripIndent from '../utility/strip-indent-tag';
import $ from '../utility/dom-utility';
......@@ -10,7 +9,6 @@ import CopySnippetBlock from './CopySnippetBlock';
import Arrow from './Arrow';
import { setRoomName } from '../actions/MicrositeActions';
import manifest from 'json!../../../package.json';
class MicrositeApp extends React.Component {
constructor(props) {
......@@ -38,7 +36,12 @@ class MicrositeApp extends React.Component {
render() {
// Injected by connect() call:
const { dispatch, roomName, documentation } = this.props;
const {
dispatch,
roomName,
sidecarVersion,
documentation
} = this.props;
let sidecarBootstrapOptionsCopySnippet = stripIndent`
<script>
......@@ -46,7 +49,7 @@ class MicrositeApp extends React.Component {
room: '${roomName}'
};
</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v${semver.major(manifest.version)}.js" async defer></script>
<script src="https://sidecar.gitter.im/dist/sidecar.v${sidecarVersion}.js" async defer></script>
`;
return (
......@@ -156,7 +159,9 @@ MicrositeApp.propTypes = {
// react-redux injected
dispatch: React.PropTypes.func,
roomName: React.PropTypes.string
roomName: React.PropTypes.string,
sidecarVersion: React.PropTypes.number,
documentation: React.PropTypes.string
};
......@@ -165,6 +170,7 @@ MicrositeApp.propTypes = {
function mapStateToProps(state) {
return {
roomName: state.roomName,
sidecarVersion: state.sidecarVersion,
documentation: state.documentation
};
}
......
......@@ -2,5 +2,6 @@ import keyMirror from 'keymirror';
export default keyMirror({
ROOM_NAME_SET: null,
SIDECAR_VERSION_SET: null,
DOCUMENTATION_SET: null
});
import types from '../constants/MicrositeConstants';
export default function sidecarVersion(state = '', action) {
switch(action.type) {
case types.SIDECAR_VERSION_SET:
return action.version;
default:
return state;
}
}
export { default as roomName } from './RoomNameReducer';
export { default as sidecarVersion } from './SidecarVersionReducer';
export { default as documentation } from './DocumentationReducer';
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment