mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-22 08:13:51 +02:00
further experiments in generating a pure html/js page, with React as build tool only
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,3 +6,5 @@ components/sections/**/index.js
|
|||||||
!components/sections/index.js
|
!components/sections/index.js
|
||||||
.buildmark
|
.buildmark
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
# this gets to be here for as long as I've not figured out how to do the full surgery
|
||||||
|
index.full.html
|
||||||
|
@@ -1,15 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* This is an ordered list of all sections for the article
|
* This is an ordered list of all sections used in the Bezier primer.
|
||||||
* @type {Object}
|
*
|
||||||
|
* The ordering you see here reflects the ordering in which sections
|
||||||
|
* are present on the Primer page: do not change them unless there is
|
||||||
|
* a REALLY good reason to =)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preface: require("./preface"),
|
preface: require("./preface"),
|
||||||
|
|
||||||
|
// the basic topic(s) introduction(s)
|
||||||
introduction: require("./introduction"),
|
introduction: require("./introduction"),
|
||||||
whatis: require("./whatis"),
|
whatis: require("./whatis"),
|
||||||
explanation: require("./explanation"),
|
explanation: require("./explanation"),
|
||||||
control: require("./control"),
|
control: require("./control"),
|
||||||
extended: require("./extended"),
|
extended: require("./extended"),
|
||||||
|
|
||||||
|
// basic operations
|
||||||
matrix: require("./matrix"),
|
matrix: require("./matrix"),
|
||||||
decasteljau: require("./decasteljau"),
|
decasteljau: require("./decasteljau"),
|
||||||
flattening: require("./flattening"),
|
flattening: require("./flattening"),
|
||||||
@@ -17,6 +24,7 @@ module.exports = {
|
|||||||
matrixsplit: require("./matrixsplit"),
|
matrixsplit: require("./matrixsplit"),
|
||||||
reordering: require("./reordering"),
|
reordering: require("./reordering"),
|
||||||
|
|
||||||
|
// information that can be obtained through analysis
|
||||||
derivatives: require("./derivatives"),
|
derivatives: require("./derivatives"),
|
||||||
pointvectors: require("./pointvectors"),
|
pointvectors: require("./pointvectors"),
|
||||||
components: require("./components"),
|
components: require("./components"),
|
||||||
@@ -27,33 +35,41 @@ module.exports = {
|
|||||||
inflections: require("./inflections"),
|
inflections: require("./inflections"),
|
||||||
canonical: require("./canonical"),
|
canonical: require("./canonical"),
|
||||||
|
|
||||||
|
// accurate arc length is hard, yo
|
||||||
arclength: require("./arclength"),
|
arclength: require("./arclength"),
|
||||||
arclengthapprox: require("./arclengthapprox"),
|
arclengthapprox: require("./arclengthapprox"),
|
||||||
tracing: require("./tracing"),
|
tracing: require("./tracing"),
|
||||||
|
|
||||||
|
// curve intersections
|
||||||
intersections: require("./intersections"),
|
intersections: require("./intersections"),
|
||||||
curveintersection: require("./curveintersection"),
|
curveintersection: require("./curveintersection"),
|
||||||
|
|
||||||
|
// curve manipulation
|
||||||
abc: require("./abc"),
|
abc: require("./abc"),
|
||||||
moulding: require("./moulding"),
|
moulding: require("./moulding"),
|
||||||
pointcurves: require("./pointcurves"),
|
pointcurves: require("./pointcurves"),
|
||||||
|
|
||||||
|
// A quick foray into Catmull-Rom splines
|
||||||
catmullconv: require("./catmullconv"),
|
catmullconv: require("./catmullconv"),
|
||||||
catmullmoulding: require("./catmullmoulding"),
|
catmullmoulding: require("./catmullmoulding"),
|
||||||
|
|
||||||
|
// "things made of more than on curve"
|
||||||
polybezier: require("./polybezier"),
|
polybezier: require("./polybezier"),
|
||||||
|
|
||||||
shapes: require("./shapes"),
|
shapes: require("./shapes"),
|
||||||
|
|
||||||
|
// curve offsetting
|
||||||
projections: require("./projections"),
|
projections: require("./projections"),
|
||||||
offsetting: require("./offsetting"),
|
offsetting: require("./offsetting"),
|
||||||
graduatedoffset: require("./graduatedoffset"),
|
graduatedoffset: require("./graduatedoffset"),
|
||||||
|
|
||||||
|
// circle and arc approximation
|
||||||
circles: require("./circles"),
|
circles: require("./circles"),
|
||||||
circles_cubic: require("./circles_cubic"),
|
circles_cubic: require("./circles_cubic"),
|
||||||
arcapproximation: require("./arcapproximation"),
|
arcapproximation: require("./arcapproximation"),
|
||||||
|
|
||||||
|
// A quick foray in to B-Spline land
|
||||||
bsplines: require("./bsplines"),
|
bsplines: require("./bsplines"),
|
||||||
|
|
||||||
|
// comments come last for obvious reasons
|
||||||
comments: require("./comments")
|
comments: require("./comments")
|
||||||
};
|
};
|
||||||
|
33
tools/render-to-string.js
Normal file
33
tools/render-to-string.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* This script takes the article as generated by webpack, and uses the
|
||||||
|
* ReactDOMServer library to serialize it to pure HTML markup. This is
|
||||||
|
* then injected into the index.html template, with code injected to
|
||||||
|
* load the
|
||||||
|
*
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
var fs = require("fs-extra");
|
||||||
|
var path = require("path");
|
||||||
|
const BASEDIR = path.join(__dirname, "..");
|
||||||
|
|
||||||
|
var React = require("react");
|
||||||
|
var Server = require("react-dom/server");
|
||||||
|
|
||||||
|
var FullArticle = require(path.join(BASEDIR, "./article")).FullArticle;
|
||||||
|
var article = React.createElement(FullArticle, {});
|
||||||
|
var staticMarkup = Server.renderToStaticMarkup(article);
|
||||||
|
|
||||||
|
|
||||||
|
// make sure to remove the `<base>` tag from the index, and replace the JSX "className" with "class"
|
||||||
|
var html = fs.readFileSync(path.join(BASEDIR, "index.template.html")).toString();
|
||||||
|
html = html.replace(' <base href="..">\n', '');
|
||||||
|
html = html.replace('<script src="en-GB/article.js');
|
||||||
|
html = "<!-- AUTOGENERATED CONTENT, PLEASE EDIT 'index.template.html' INSTEAD! -->\n" + html;
|
||||||
|
|
||||||
|
// surgery:
|
||||||
|
var parts = html.split('<article>');
|
||||||
|
var leadin = parts[0];
|
||||||
|
var reassembled = leadin + staticMarkup + " </body>\n</html>\n";
|
||||||
|
|
||||||
|
fs.writeFileSync(path.join(BASEDIR, "index.full.html"), reassembled);
|
@@ -1,10 +0,0 @@
|
|||||||
var fs = require("fs-extra");
|
|
||||||
var React = require("react");
|
|
||||||
var Server = require("react-dom/server");
|
|
||||||
|
|
||||||
var FullArticle = require("./article").FullArticle;
|
|
||||||
var article = React.createElement(FullArticle, {});
|
|
||||||
var html = Server.renderToString(article);
|
|
||||||
//var html = Server.renderToStaticMarkup(article);
|
|
||||||
|
|
||||||
fs.writeFileSync("fullhtml.html", html);
|
|
Reference in New Issue
Block a user