mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-31 12:01:54 +02:00
new section
This commit is contained in:
@@ -2,6 +2,7 @@ var sha1 = require("sha1");
|
||||
var fs = require("fs");
|
||||
var execSync = require("child_process").execSync;
|
||||
var blockLoader = require("block-loader");
|
||||
var cleanup = require("../tools/cleanup");
|
||||
|
||||
var options = {
|
||||
start: "\\[",
|
||||
@@ -27,6 +28,8 @@ var options = {
|
||||
* still work.
|
||||
*/
|
||||
process: function escapeBlockLaTeX(latex) {
|
||||
latex = cleanup(latex);
|
||||
|
||||
// convert this LaTeX code into an SVG file in ./images/latex,
|
||||
// using mathjax-node in the ./tools directory.
|
||||
var hash = sha1(latex);
|
||||
@@ -37,7 +40,7 @@ var options = {
|
||||
if (!fs.existsSync(destination)) {
|
||||
var cmdarg = new Buffer(latex).toString("base64");
|
||||
var cmd = "npm run latex -- --hash " + hash + " --base64 " + cmdarg;
|
||||
console.log(" generating " + hash + ".svg");
|
||||
console.log(" generating " + hash + ".svg"); // from \n " + latex);
|
||||
execSync(cmd);
|
||||
}
|
||||
|
||||
@@ -46,7 +49,7 @@ var options = {
|
||||
// The SVG contains values in "ex" units, but to maximise legibility we convert
|
||||
// these to "rem" instead, so that formulae are always sized the same, no matter
|
||||
// the textsize around them.
|
||||
var svg = fs.readFileSync(filename).toString();
|
||||
var svg = fs.readFileSync(destination).toString();
|
||||
var ex2rem = 0.45;
|
||||
var w = parseFloat(svg.match(/width="([^"]+)"/)[1]) * ex2rem;
|
||||
var h = parseFloat(svg.match(/height="([^"]+)"/)[1]) * ex2rem;
|
||||
|
28
lib/site/basepage.html
Normal file
28
lib/site/basepage.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{title}</title>
|
||||
|
||||
<!-- opengraph information -->
|
||||
<meta property="og:title" content="A Primer on Bézier Curves">
|
||||
<meta property="og:type" content="text">
|
||||
<meta property="og:url" content="http://pomax.github.io/bezierinfo">
|
||||
<meta property="og:description" content="A detailed explanation of Bézier curves, and how to do the many things that we commonly want to do with them.">
|
||||
<meta property="og:locale" content="en_GB">
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:published_time" content="2013-06-13 12:00:00">
|
||||
<meta property="og:author" content="Mike 'Pomax' Kamermans">
|
||||
<meta property="og:section" content="Bézier Curves">
|
||||
<meta property="og:tag" content="Bézier Curves">
|
||||
|
||||
<style>
|
||||
html, body, article { height: 100%; margin: 0; }
|
||||
body { width: 800px; margin: auto; font-size: 4.25mm!important; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<article><div id="article">{content}</div></article>
|
||||
<script src="../lib/site/referrer.js" async></script>
|
||||
</body>
|
||||
</html>
|
38
lib/site/generateSingleSection.js
Normal file
38
lib/site/generateSingleSection.js
Normal file
@@ -0,0 +1,38 @@
|
||||
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 <Page name={name} compact={compact} prev={entry-1} next={entry+1}>{content}</Page>;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// The root has no "section content".
|
||||
if(name===false) {
|
||||
var notice = (
|
||||
<p className="single-notice">
|
||||
This is the one-page-per-section version of the primer, to view
|
||||
the regular version, please click <a href='..'>here</a>.
|
||||
</p>
|
||||
);
|
||||
return buildComponent('/',notice, true, -1);
|
||||
}
|
||||
|
||||
Object.keys(sections).map((n,idx) => {
|
||||
if (name!==n) return;
|
||||
entry = idx;
|
||||
Type = sections[name];
|
||||
});
|
||||
|
||||
var section = <Type key={name} name={name} number={entry}/>,
|
||||
content = section,
|
||||
SingleSection = buildComponent(name, content, true, entry);
|
||||
|
||||
return SingleSection;
|
||||
};
|
18
lib/site/pagewrap.js
Normal file
18
lib/site/pagewrap.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports = function(title, html) {
|
||||
return [
|
||||
"<!doctype html>",
|
||||
"<html>",
|
||||
"<head>",
|
||||
"<meta charset='utf-8'>",
|
||||
"<title>",
|
||||
title,
|
||||
"</title>",
|
||||
"<base href='..'>",
|
||||
"</head>",
|
||||
"<body>",
|
||||
html,
|
||||
"</body>",
|
||||
"</html>"
|
||||
].join('\n');
|
||||
};
|
||||
|
31
lib/site/routemap.js
Normal file
31
lib/site/routemap.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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 <Route> objects for each.
|
||||
var sections = require("../../components/sections");
|
||||
var generateSingleSection = require("./generateSingleSection");
|
||||
var pageIDs = Object.keys(sections);
|
||||
|
||||
// Then we generate each page's <Route>
|
||||
var rootComponent = generateSingleSection(false);
|
||||
var root = <Route path={'/'} component={rootComponent} key={'/'}/>;
|
||||
var pages = [root].concat(
|
||||
pageIDs.map(id => {
|
||||
<Route path={id} component={generateSingleSection(id)} key={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: <Router>{pages}</Router>
|
||||
};
|
Reference in New Issue
Block a user