diff --git a/lib/site/basepage.html b/lib/site/basepage.html deleted file mode 100644 index 20839c28..00000000 --- a/lib/site/basepage.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - {title} - - - - - - - - - - - - - - - - -
{content}
- - - diff --git a/lib/site/generateSingleSection.js b/lib/site/generateSingleSection.js deleted file mode 100644 index 0ca8e957..00000000 --- a/lib/site/generateSingleSection.js +++ /dev/null @@ -1,38 +0,0 @@ -var React = require('react'); -var sections = require('../../components/sections'); -var Page = require('../../components/Page.jsx'); - -module.exports = function generateSingleSection(name) { - var Type, entry; - - var buildComponent = function(name, content, compact, entry) { - return React.createClass({ - render: function() { - return {content}; - } - }); - }; - - // The root has no "section content". - if(name===false) { - var notice = ( -

- This is the one-page-per-section version of the primer, to view - the regular version, please click here. -

- ); - return buildComponent('/',notice, true, -1); - } - - Object.keys(sections).map((n,idx) => { - if (name!==n) return; - entry = idx; - Type = sections[name]; - }); - - var section = , - content = section, - SingleSection = buildComponent(name, content, true, entry); - - return SingleSection; -}; diff --git a/lib/site/handlers.js b/lib/site/handlers.js index e5ec78d2..5ebbb212 100644 --- a/lib/site/handlers.js +++ b/lib/site/handlers.js @@ -1,5 +1,5 @@ -module.exports = { - introduction: { +window["Bezier Section Handlers"] = { + "introduction": { handler: (function() { return { drawQuadratic: function(api) { var curve = api.getDefaultQuadratic(); @@ -19,7 +19,7 @@ module.exports = { }; }()) }, - whatis: { + "whatis": { handler: (function() { return { setup: function(api) { api.setPanelCount(3); @@ -127,7 +127,7 @@ module.exports = { }; }()) }, - explanation: { + "explanation": { handler: (function() { return { statics: { keyHandlingOptions: { @@ -183,7 +183,7 @@ module.exports = { }()), withKeys: true }, - control: { + "control": { handler: (function() { return { drawCubic: function(api) { var curve = api.getDefaultCubic(); @@ -345,7 +345,7 @@ module.exports = { }; }()) }, - extended: { + "extended": { handler: (function() { return { setupQuadratic: function(api) { var curve = new api.Bezier(70, 155, 20, 110, 100,75); @@ -382,7 +382,7 @@ module.exports = { }; }()) }, - decasteljau: { + "decasteljau": { handler: (function() { return { setup: function(api) { var points = [ @@ -421,7 +421,7 @@ module.exports = { }; }()) }, - flattening: { + "flattening": { handler: (function() { return { statics: { keyHandlingOptions: { @@ -487,7 +487,7 @@ module.exports = { }()), withKeys: true }, - splitting: { + "splitting": { handler: (function() { return { setupCubic: function(api) { var curve = api.getDefaultCubic(); @@ -581,7 +581,7 @@ module.exports = { }; }()) }, - reordering: { + "reordering": { handler: (function() { var Reordering = { statics: { // Improve this based on http://www.sirver.net/blog/2011/08/23/degree-reduction-of-bezier-curves/ @@ -692,7 +692,7 @@ return Reordering; }()), withKeys: true }, - pointvectors: { + "pointvectors": { handler: (function() { return { setupQuadratic: function(api) { var curve = api.getDefaultQuadratic(); @@ -727,7 +727,7 @@ return Reordering; }; }()) }, - components: { + "components": { handler: (function() { return { setupQuadratic: function(api) { var curve = api.getDefaultQuadratic(); @@ -774,7 +774,7 @@ return Reordering; }; }()) }, - extremities: { + "extremities": { handler: (function() { return { setupQuadratic: function(api) { var curve = api.getDefaultQuadratic(); @@ -830,7 +830,7 @@ return Reordering; }; }()) }, - boundingbox: { + "boundingbox": { handler: (function() { return { setupQuadratic: function(api) { var curve = api.getDefaultQuadratic(); @@ -857,7 +857,7 @@ return Reordering; }; }()) }, - aligning: { + "aligning": { handler: (function() { return { setupQuadratic: function(api) { var curve = api.getDefaultQuadratic(); @@ -914,7 +914,7 @@ return Reordering; }; }()) }, - tightbounds: { + "tightbounds": { handler: (function() { return { setupQuadratic: function(api) { var curve = api.getDefaultQuadratic(); @@ -988,7 +988,7 @@ return Reordering; }; }()) }, - inflections: { + "inflections": { handler: (function() { return { setupCubic: function(api) { var curve = new api.Bezier(135,25, 25, 135, 215,75, 215,240); @@ -1008,7 +1008,7 @@ return Reordering; }; }()) }, - canonical: { + "canonical": { handler: (function() { return { setup: function(api) { var curve = api.getDefaultCubic(); @@ -1170,7 +1170,7 @@ return Reordering; }; }()) }, - arclength: { + "arclength": { handler: (function() { var sin = Math.sin; var tau = Math.PI*2; @@ -1264,7 +1264,7 @@ return { }; }()) }, - arclengthapprox: { + "arclengthapprox": { handler: (function() { return { statics: { keyHandlingOptions: { @@ -1326,7 +1326,7 @@ return { }()), withKeys: true }, - tracing: { + "tracing": { handler: (function() { return { statics: { keyHandlingOptions: { @@ -1456,7 +1456,7 @@ return { }()), withKeys: true }, - intersections: { + "intersections": { handler: (function() { var min = Math.min, max = Math.max; return { @@ -1534,7 +1534,7 @@ return { }; }()) }, - curveintersection: { + "curveintersection": { handler: (function() { var abs = Math.abs; return { @@ -1654,7 +1654,7 @@ return { }; }()) }, - abc: { + "abc": { handler: (function() { return { onClick: function(evt, api) { api.t = api.curve.on({x: evt.offsetX, y: evt.offsetY},7); @@ -1779,7 +1779,7 @@ return { }; }()) }, - moulding: { + "moulding": { handler: (function() { var abs = Math.abs; return { @@ -1981,7 +1981,7 @@ return { }; }()) }, - pointcurves: { + "pointcurves": { handler: (function() { var abs = Math.abs; return { @@ -2148,7 +2148,7 @@ return { }; }()) }, - catmullmoulding: { + "catmullmoulding": { handler: (function() { return { statics: { keyHandlingOptions: { @@ -2283,7 +2283,7 @@ return { }()), withKeys: true }, - polybezier: { + "polybezier": { handler: (function() { var atan2 = Math.atan2, sqrt = Math.sqrt, sin = Math.sin, cos = Math.cos; return { @@ -2527,7 +2527,7 @@ return { }; }()) }, - shapes: { + "shapes": { handler: (function() { var modes; return { @@ -2619,7 +2619,7 @@ return { }; }()) }, - projections: { + "projections": { handler: (function() { return { setup: function(api) { api.setSize(320,320); @@ -2677,7 +2677,7 @@ return { }; }()) }, - offsetting: { + "offsetting": { handler: (function() { return { statics: { keyHandlingOptions: { @@ -2739,7 +2739,7 @@ return { }()), withKeys: true }, - graduatedoffset: { + "graduatedoffset": { handler: (function() { return { statics: { keyHandlingOptions: { @@ -2780,7 +2780,7 @@ return { }()), withKeys: true }, - circles: { + "circles": { handler: (function() { var sin = Math.sin, cos = Math.cos; @@ -2840,7 +2840,7 @@ return { }; }()) }, - circles_cubic: { + "circles_cubic": { handler: (function() { var sin = Math.sin, cos = Math.cos, tan = Math.tan; return { @@ -3048,7 +3048,7 @@ return { }; }()) }, - arcapproximation: { + "arcapproximation": { handler: (function() { var atan2 = Math.atan2, PI = Math.PI, TAU = 2*PI, cos = Math.cos, sin = Math.sin; return { @@ -3212,7 +3212,7 @@ return { }()), withKeys: true }, - bsplines: { + "bsplines": { handler: (function() { return { basicSketch: require('./basic-sketch'), interpolationGraph: require('./interpolation-graph'), diff --git a/lib/site/pagewrap.js b/lib/site/pagewrap.js deleted file mode 100644 index 2c778260..00000000 --- a/lib/site/pagewrap.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = function(title, html) { - return [ - "", - "", - "", - "", - "", - title, - "", - "", - "", - "", - html, - "", - "" - ].join('\n'); -}; - diff --git a/lib/site/routemap.js b/lib/site/routemap.js deleted file mode 100644 index 15893f29..00000000 --- a/lib/site/routemap.js +++ /dev/null @@ -1,31 +0,0 @@ -var React = require('react'); -var ReactRouter = require('react-router'); -var Router = ReactRouter.Router; -var Route = ReactRouter.Route; - -var Page = require("../../components/Page.jsx"); - -// get all the sections, and generate objects for each. -var sections = require("../../components/sections"); -var generateSingleSection = require("./generateSingleSection"); -var pageIDs = Object.keys(sections); - -// Then we generate each page's -var rootComponent = generateSingleSection(false); -var root = ; -var pages = [root].concat( - pageIDs.map(id => { - - }) -); - -// And finally, the full app's route set, set to use "URL" rather than "hash" navigation. -// var createBrowserHistory = require('history/lib/createBrowserHistory'); -// var history = createBrowserHistory(); -module.exports = { - sections: sections, - paths: pageIDs, - routes: pages, - rootComponent: rootComponent, - RouteSet: {pages} -}; diff --git a/package.json b/package.json index 8927ccb8..e477cba1 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "version": "2.0.0", "description": "pomax.github.io/bezierinfo", "scripts": { - "bootstrap": "run-s makeindex localize", + "bootstrap": "run-s makeindex makehandlers localize", "localize": "node tools/make-locales", "prebuild": "node tools/buildmark -- set", "build": "run-s bootstrap less build:** default", "default": "node tools/copy-default-locale", "postbuild": "node tools/buildmark -- resolve", + "makehandlers": "node tools/aggregate-js-handlers", "makeindex": "node tools/form-section-index-files", "build:en-GB": "webpack -p", "build:zh-CN": "cross-env LOCALE=zh-CN webpack -p", diff --git a/tools/aggregate-js-handlers.js b/tools/aggregate-js-handlers.js index 37a58dff..8d0dafb8 100644 --- a/tools/aggregate-js-handlers.js +++ b/tools/aggregate-js-handlers.js @@ -21,7 +21,7 @@ Object.keys(index).forEach( section => { let content = fs.readFileSync(handlerFile).toString(); content = content.replace("module.exports = ","return "); content = `(function() { ${content} }())`; - let def = ` ${section}: { + let def = ` "${section}": { handler: ${content}`; if (content.indexOf('keyHandlingOptions') > -1) { def += `,\n withKeys: true`; } def += `\n }`; @@ -29,5 +29,5 @@ Object.keys(index).forEach( section => { } }); -var masterFile = `module.exports = {\n${ handlers.join(',\n') }\n};\n`; +var masterFile = `window["Bezier Section Handlers"] = {\n${ handlers.join(',\n') }\n};\n`; fs.writeFileSync(path.join(BASEDIR, "lib/site/handlers.js"), masterFile);