From 9c7bc4446c2de338ef8321b246b885c590af8756 Mon Sep 17 00:00:00 2001
From: AlexKVal
Date: Sat, 9 May 2015 20:14:05 +0300
Subject: [PATCH 1/2] Return to pages.
First time it was introduced here
https://github.com/react-bootstrap/react-bootstrap/blob/120ba6d38a4/Gruntfile.js#L204
Then it was moved here
https://github.com/react-bootstrap/react-bootstrap/commit/addc3965b0d832a3721983d0a891a03a086c8225#diff-31cfa4797a188b7ab32b049b80c82ea6R63
And finally it was lost here
https://github.com/react-bootstrap/react-bootstrap/commit/804c24a33f390166a89276f68772fa64b1510ba8#diff-4cd8a3a29faaf037ff2ec547bf1635abL10
and here
https://github.com/react-bootstrap/react-bootstrap/commit/804c24a33f390166a89276f68772fa64b1510ba8#diff-ce9d98be04f7a23d325c274fc1a0a089L21
After that `Root.renderToString()` method (and some others) became unused.
---
docs/build.js | 1 +
docs/server.js | 2 +-
docs/src/Root.js | 42 +++++++++---------------------------------
3 files changed, 11 insertions(+), 34 deletions(-)
diff --git a/docs/build.js b/docs/build.js
index cab592dab9..df76d4c1f5 100644
--- a/docs/build.js
+++ b/docs/build.js
@@ -25,6 +25,7 @@ export default function BuildDocs() {
.map(fileName => new Promise((resolve, reject) => {
Router.run(routes, '/' + fileName, Handler => {
let RootHTML = React.renderToString(React.createElement(Handler));
+ RootHTML = '' + RootHTML;
let write = fsp.writeFile(path.join(docsBuilt, fileName), RootHTML);
resolve(write);
});
diff --git a/docs/server.js b/docs/server.js
index 78918d8452..158f5efdd8 100644
--- a/docs/server.js
+++ b/docs/server.js
@@ -26,7 +26,7 @@ if (development) {
Router.run(routes, req.url, Handler => {
let html = React.renderToString();
- res.send(html);
+ res.send('' + html);
});
});
diff --git a/docs/src/Root.js b/docs/src/Root.js
index 293bc24b4d..45370e662a 100644
--- a/docs/src/Root.js
+++ b/docs/src/Root.js
@@ -4,15 +4,6 @@ import Router from 'react-router';
const Root = React.createClass({
statics: {
- /**
- * Get the doctype the page expects to be rendered with
- *
- * @returns {string}
- */
- getDoctype() {
- return '';
- },
-
/**
* Get the list of pages that are renderable
*
@@ -25,21 +16,6 @@ const Root = React.createClass({
'getting-started.html',
'components.html'
];
- },
-
- renderToString(props) {
- return Root.getDoctype() +
- React.renderToString();
- },
-
- /**
- * Get the Base url this app sits at
- * This url is appended to all app urls to make absolute url's within the app.
- *
- * @returns {string}
- */
- getBaseUrl() {
- return '/';
}
},
@@ -84,17 +60,17 @@ const Root = React.createClass({
};
return (
-
-
+
+
-
-
+
+
-
-
-
-
- );
+
+
+
+
+ );
}
});
From e663e82f375f26b88371922fcfb1e45941886ec3 Mon Sep 17 00:00:00 2001
From: AlexKVal
Date: Sat, 9 May 2015 20:34:17 +0300
Subject: [PATCH 2/2] Refactor docs/build.js.
Add more clarity about what's going on.
---
docs/build.js | 31 ++++++++++++++++++++-----------
docs/src/Root.js | 2 +-
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/docs/build.js b/docs/build.js
index df76d4c1f5..e695ee6e78 100644
--- a/docs/build.js
+++ b/docs/build.js
@@ -14,24 +14,33 @@ const license = path.join(repoRoot, 'LICENSE');
const readmeSrc = path.join(__dirname, 'README.docs.md');
const readmeDest = path.join(docsBuilt, 'README.md');
+/**
+ * Generates HTML code for `fileName` page.
+ *
+ * @param {string} fileName Path for Router.Route
+ * @return {Promise} promise
+ * @internal
+ */
+function generateHTML(fileName) {
+ return new Promise((resolve, reject) => {
+ Router.run(routes, '/' + fileName, Handler => {
+ let html = React.renderToString(React.createElement(Handler));
+ html = '' + html;
+ let write = fsp.writeFile(path.join(docsBuilt, fileName), html);
+ resolve(write);
+ });
+ });
+}
+
export default function BuildDocs() {
console.log('Building: '.cyan + 'docs'.green);
return exec(`rimraf ${docsBuilt}`)
.then(() => fsp.mkdir(docsBuilt))
.then(() => {
- let writes = Root
- .getPages()
- .map(fileName => new Promise((resolve, reject) => {
- Router.run(routes, '/' + fileName, Handler => {
- let RootHTML = React.renderToString(React.createElement(Handler));
- RootHTML = '' + RootHTML;
- let write = fsp.writeFile(path.join(docsBuilt, fileName), RootHTML);
- resolve(write);
- });
- }));
+ let pagesGenerators = Root.getPages().map(generateHTML);
- return Promise.all(writes.concat([
+ return Promise.all(pagesGenerators.concat([
exec(`webpack --config webpack.docs.js -p --bail`),
copy(license, docsBuilt),
copy(readmeSrc, readmeDest)
diff --git a/docs/src/Root.js b/docs/src/Root.js
index 45370e662a..b5467ccb0c 100644
--- a/docs/src/Root.js
+++ b/docs/src/Root.js
@@ -75,4 +75,4 @@ const Root = React.createClass({
});
-module.exports = Root;
+export default Root;