diff --git a/README.md b/README.md
index 7598dbd4..6f54f938 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ Use the latest Node v14, with all dependencies installed via `npm install`. Note
#### Specialised commands:
-- `polish` runs `prettier` on the final .html files, as well as `link-checker` to make sure there are no dead links in the content.
+- `regenerate` runs a build followed by running `prettier` on the final .html files, as well as `link-checker` to make sure there are no dead links in the content.
#### Even more specialized commands:
diff --git a/docs/index.html b/docs/index.html
index 1c9ca633..f891eded 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -3,10 +3,12 @@
-
A Primer on Bézier Curves
+
+
+
@@ -29,7 +31,7 @@
-
+
@@ -430,7 +432,7 @@
- First commit for the bezierinfo site, based on the pre-Primer webpage that covered
+ First commit for the bezierinfo site, based on the pre-Primer webpage that covered
the basics of Bezier curves in HTML with Processing.js examples.
- First commit for the bezierinfo site, based on the pre-Primer webpage that covered
+ First commit for the bezierinfo site, based on the pre-Primer webpage that covered
the basics of Bezier curves in HTML with Processing.js examples.
- Once upon a time, I needed to draw some Bezier curves because I was trying to create a Japanese kanji composition system that turned strokes
- into outlines, and that required knowing how to offset Bezier curves and... at the time (2011, time flies) there was no good single source of
- information for Bezier curves on the web. So I made one. Sure it started small, but it turns out that if you just keep adding bits to
- something, several years later you have quite the monster, and a single HTML file becomes intractible.
-
-
- So, in 2016, when React.js exploded onto the scene, I rewrote the primer as a React app, and it became a lot easier to
- maintain. Like, a lot a lot. However, there was a downside: no JS meant no content. Sure, server-side rendering sort of existed, but
- not really, and because the Primer is hosted through github, there was no "server" to run. Plus, trying to rehydrate an app the size of the
- Primer from a giant HTML file had truly dire performance.
-
-
- So I left it a regular React app, and every time I thought "wouldn't it be nice if it was just... a web page again?" the browser landscape
- just hadn't caught up. Finally, in 2020, things are different: with a global pandemic, and some vacation time, and something random causing me
- to look up the state of HTML custom elements, everything was pointing at it being time to finally, finally, turn the Primer back into
- a normal web page.
-
-
- The new tech stack is, frankly, pretty amazing. It does some thing that weren't possible even a year ago, let alone back in 2016, and this is
- the first in a series of posts on how the new tech stack works. To give a bit of a teaser, the series will cover:
-
-
-
Essentially reinventing (a limited form of) Processing.js
-
Writing a custom build system, because I'm exhausted with Webpack and hope to never use it again.
-
Using modern ES module code that runs in both the browser and Node.js.
-
Chapter content written as easy to read and write markdown format.
-
A custom <graphics-element> element that turns a src="blah.js" into an interactive canvas graphic...
-
...with that same source code being read in and run by Node.js on a canvas to generate fallback images.
-
- Real LaTeX code, that gets compiled into optimized SVG using xelatex, pdfcrop, pdf2svg, and
- svgo.
-
-
Localized content based on a simple filenaming scheme.
-
Nicely formatted HTML, CSS, and JS thanks to prettier.
-
Responsive CSS, so the content intelligently reflows where possible.
-
A "Live build" setup for working on the content and code.
-
Automatic link-checking to make sure none of the links in the Primer lead you to a 404.
-
This "news" section, so that I can write posts to go along with new sections getting added, or notable changes being made.
-
-
- It's going to take me a while to detail the entire tech stack, but ultimately what matters is that you get a Primer that is a normal "vanilla"
- HTML, CSS, and JS page again, that "just works" even with JS disabled.
-
-
-
diff --git a/docs/news/rss.xml b/docs/news/rss.xml
new file mode 100644
index 00000000..5fcc3c80
--- /dev/null
+++ b/docs/news/rss.xml
@@ -0,0 +1,51 @@
+
+
+
+ A Primer on Bézier Curves
+ https://pomax.github.io/bezierinfo
+
+ News updates for the primer on Bézier Curves by Pomax
+ en-GB
+ undefinedT12:00:00+00:00
+
+ https://pomax.github.io/bezierinfo/iamges/og-image.png
+ A Primer on Bézier Curves
+ https://pomax.github.io/bezierinfo
+
+
+
+
+ Rewriting the tech stack
+ https://pomax.github.io/bezierinfo/news/2020-08-28.html
+
+<p>Once upon a time, I needed to draw some Bezier curves because I was trying to create a Japanese kanji composition system that turned strokes into outlines, and that required knowing how to offset Bezier curves and... at the time (2011, time flies) there was no good single source of information for Bezier curves on the web. So I made one. Sure it started small, but it turns out that if you just keep adding bits to something, several years later you have quite the monster, and a single HTML file becomes intractible.</p>
+<p>So, in 2016, when <a href="">React.js</a> exploded onto the scene, I rewrote the primer as a React app, and it became a lot easier to maintain. Like, <em>a lot</em> a lot. However, there was a downside: no JS meant no content. Sure, server-side rendering sort of existed, but not really, and because the Primer is hosted through github, there was no "server" to run. Plus, trying to rehydrate an app the size of the Primer from a giant HTML file had truly <em>dire</em> performance.</p>
+<p>So I left it a regular React app, and every time I thought "wouldn't it be nice if it was just... a web page again?" the browser landscape just hadn't caught up. Finally, in 2020, things are different: with a global pandemic, and some vacation time, and something random causing me to look up the state of HTML custom elements, everything was pointing at it being time to finally, <em>finally</em>, turn the Primer back into a normal web page.</p>
+<p>The new tech stack is, frankly, pretty amazing. It does some thing that weren't possible even a year ago, let alone back in 2016, and this is the first in a series of posts on how the new tech stack works. To give a bit of a teaser, the series will cover:</p>
+<ul>
+<li>Essentially reinventing (a limited form of) Processing.js</li>
+<li>Writing a custom build system, because I'm exhausted with Webpack and hope to never use it again.</li>
+<li>Using modern ES module code that runs in both the browser and Node.js.</li>
+<li>Chapter content written as easy to read and write markdown format.</li>
+<li>A custom <code><graphics-element></code> element that turns a <code>src="blah.js"</code> into an interactive canvas graphic...</li>
+<li>...with that same source code being read in and run by Node.js <em>on a canvas</em> to generate fallback images.</li>
+<li>Real LaTeX code, that gets compiled into optimized SVG using <code>xelatex</code>, <code>pdfcrop</code>, <code>pdf2svg</code>, and <code>svgo</code>.</li>
+<li>Localized content based on a simple filenaming scheme.</li>
+<li>Nicely formatted HTML, CSS, and JS thanks to <code>prettier</code>.</li>
+<li>Responsive CSS, so the content intelligently reflows where possible.</li>
+<li>A "Live build" setup for working on the content and code.</li>
+<li>Automatic link-checking to make sure none of the links in the Primer lead you to a 404.</li>
+<li>This "news" section, so that I can write posts to go along with new sections getting added, or notable changes being made.</li>
+</ul>
+<p>It's going to take me a while to detail the entire tech stack, but ultimately what matters is that you get a Primer that is a normal "vanilla" HTML, CSS, and JS page again, that "just works" even with JS disabled.</p>
+<p>Enjoy <a href="https://pomax.github.io/bezierinfo">The new Primer on Bézier Curves</a>, and if you find any problems, <a href="https://github.com/Pomax/BezierInfo-2/issues">you know where to go</a>.</p>
+<p>See you in the next post!</p>
+<p>— Pomax</p>
+
+ 2020-08-28
+ 2020-08-28.html
+
+
+
+
+
diff --git a/docs/placeholder-style.css b/docs/placeholder-style.css
index 7502ebcf..baa15bd1 100644
--- a/docs/placeholder-style.css
+++ b/docs/placeholder-style.css
@@ -106,6 +106,10 @@ label[for="changelogtoggle"] {
margin-left: 2em;
}
+main {
+ min-height: 75vh;
+}
+
#changelogtoggle {
display: none;
}
diff --git a/docs/zh-CN/index.html b/docs/zh-CN/index.html
index aa1d9a1d..3d29454b 100644
--- a/docs/zh-CN/index.html
+++ b/docs/zh-CN/index.html
@@ -3,11 +3,12 @@
-
贝塞尔曲线底漆
+
+
-
+
@@ -31,7 +32,7 @@
-
+
@@ -390,7 +391,7 @@
- First commit for the bezierinfo site, based on the pre-Primer webpage that covered
+ First commit for the bezierinfo site, based on the pre-Primer webpage that covered
the basics of Bezier curves in HTML with Processing.js examples.
diff --git a/package.json b/package.json
index 3d4fa6af..8e5380fa 100644
--- a/package.json
+++ b/package.json
@@ -19,8 +19,9 @@
"------": "--- note that due to github's naming policy, the public dir is called 'docs' rather than 'public' ---",
"browser": "open-cli http://localhost:8000",
"build": "node ./src/build.js",
- "clean": "rm -f .timing && rm -rf ./temp",
+ "clean": "rm -f .timing && rm -rf ./temp && rm -f ./docs/news/*.html",
"polish": "run-s pretty link-checker",
+ "regenerate": "run-s start polish",
"lint:tools": "prettier \"./src/**/*.js\" --print-width 150 --write",
"lint:lib": "prettier \"./docs/js/**/*.js\" --print-width 150 --write",
"lint:css": "prettier \"./docs/**/*.css\" --print-width 150 --write",
diff --git a/src/build/create-news-pages.js b/src/build/create-news-pages.js
index 7bf434c8..d2e223f1 100644
--- a/src/build/create-news-pages.js
+++ b/src/build/create-news-pages.js
@@ -7,15 +7,19 @@ import convert from "./markdown/convert.js";
nunjucks.configure(paths.html, { autoescape: false });
+const base = ``;
+const locale = `en-GB`;
+
/**
* ...docs go here...
*/
async function createNewsPages() {
const start = Date.now();
const files = await getNewsFiles();
- const details = files.filter((f) => !f.includes(`draft`)).map((file) => generateNewsPage(file));
+ const details = files.filter((f) => !f.includes(`draft`)).map((file) => generatePost(file));
console.log(`Processing News posts took ${(Date.now() - start) / 1000}s`);
generateNewsIndex(details);
+ generateRSSFeed(details);
}
export { createNewsPages };
@@ -33,44 +37,57 @@ function getNewsFiles() {
/**
* ...docs go here...
*/
-function generateNewsPage(file) {
+function generatePost(file) {
+ // get the post, and the data its filename implies
const filename = path.basename(file).replace(`.md`, `.html`);
const postDate = filename.replace(`.html`, ``);
const data = fs.readFileSync(file).toString(`utf8`);
const dateString = new Date(postDate).toUTCString().substring(0, 16);
- const post = convert(data).replace(``, `
${dateString}
`);
+
+ // split off the post's title
+ let post = convert(data);
const title = post.substring(post.indexOf(`
`) + 4, post.indexOf(`
`));
+ post = post.replace(`
${title}
`, ``);
+
const renderContext = {
- base: ``,
+ base,
post,
title,
description: title,
urlSuffix: `/news/`,
filename,
- locale: `en-GB`,
+ locale,
+ dateString,
publishTime: `${postDate}T12:00:00+00:00`,
currentTime: new Date().toISOString().substring(0, 19) + "+00:00",
};
- const newspage = nunjucks.render(`news.template.html`, renderContext);
+ const newspage = nunjucks.render(`post.template.html`, renderContext);
fs.writeFileSync(path.join(paths.news, filename), newspage, `utf8`);
- return { filename, title, dateString };
+ return { filename, postDate, title, post, dateString };
}
/**
* ...docs go here...
*/
function generateNewsIndex(details) {
- // TODO: make this a real thing...
- const html = `
-
-
-
-
-
- `;
- fs.writeFileSync(path.join(paths.news, `index.html`), html, `utf8`);
+ const renderContext = {
+ base,
+ details,
+ locale,
+ publishTime: `${details.postDate}T12:00:00+00:00`,
+ };
+ const index = nunjucks.render(`news.template.html`, renderContext);
+ fs.writeFileSync(path.join(paths.news, `index.html`), index, `utf8`);
+}
+
+/**
+ * ...docs go here...
+ */
+function generateRSSFeed(details) {
+ const renderContext = {
+ items: details,
+ buildDate: `${details.postDate}T12:00:00+00:00`,
+ };
+ const index = nunjucks.render(`rss.template.xml`, renderContext);
+ fs.writeFileSync(path.join(paths.news, `rss.xml`), index, `utf8`);
}
diff --git a/src/changelog.js b/src/changelog.js
index 554402aa..2d61fbad 100644
--- a/src/changelog.js
+++ b/src/changelog.js
@@ -73,7 +73,7 @@ const CHANGELOG = Object.fromEntries(
],
"October 2011": [
- `First commit for the [bezierinfo](https://pomax.github.io/bezierinfo) site, based on the pre-Primer webpage that covered the basics of Bezier curves in HTML with Processing.js examples.`,
+ `First commit for the [bezierinfo](https://pomax.github.io/bezierinfo/) site, based on the pre-Primer webpage that covered the basics of Bezier curves in HTML with Processing.js examples.`,
],
}).map((p) => [p[0], p[1].map((v) => marked(v))])
);
diff --git a/src/html/index.template.html b/src/html/index.template.html
index f5570ce0..2021fae8 100644
--- a/src/html/index.template.html
+++ b/src/html/index.template.html
@@ -3,12 +3,14 @@
-
{% block title %}{{ title }}{% endblock %}
-
-
{{ base }}
+
+ {% block alternate %}
+
+ {% endblock %}
+
diff --git a/src/html/news.template.html b/src/html/news.template.html
index 1ae0533f..4e81444f 100644
--- a/src/html/news.template.html
+++ b/src/html/news.template.html
@@ -1,14 +1,34 @@
{% extends "index.template.html" %}
-{% block title %}{{ title }}{% endblock %}
+{% block title %}A Primer on Bézier Curves - News{% endblock %}
{% block publishedTime %}{{ publishTime }}{% endblock %}
-{% block header %}{% endblock %}
+{% block header %}
+
News posts
+{% endblock %}
{% block share %}{% endblock %}
-{% block main %}{{ post }}{% endblock %}
+{% block main %}
+
+ Every now and then the Primer gets updated - these posts chronicle the evolution of the site,
+ and hopefully offer interesting information not just about the process of maintaining a resource
+ like this, but also neat tech tricks, implementation approaches, maths that didn't make it into
+ the primer itself, etc.
+
+
+
+ This section is still very new, so for the moment there aren't all that many posts up yet, but
+ there's a series of posts planned already, and if you're the kind of person who likes to keep
+ tabs on updates by using RSS: good news, have an RSS link!.
+
+{% endblock %}
{% block footer %}
This post is a news entry for the Primer on Bézier Curves
diff --git a/src/html/post.template.html b/src/html/post.template.html
new file mode 100644
index 00000000..8d6f5390
--- /dev/null
+++ b/src/html/post.template.html
@@ -0,0 +1,18 @@
+{% extends "index.template.html" %}
+
+{% block title %}A Primer on Bézier Curves - {{ title }}{% endblock %}
+
+{% block publishedTime %}{{ publishTime }}{% endblock %}
+
+{% block header %}
+
{{ title }}
+
{{ dateString }}
+{% endblock %}
+
+{% block share %}{% endblock %}
+
+{% block main %}{{ post }}{% endblock %}
+
+{% block footer %}
+ This post is a news entry for the Primer on Bézier Curves
+{% endblock%}
\ No newline at end of file
diff --git a/src/html/rss.template.xml b/src/html/rss.template.xml
new file mode 100644
index 00000000..e0f0cdc1
--- /dev/null
+++ b/src/html/rss.template.xml
@@ -0,0 +1,27 @@
+
+
+
+ A Primer on Bézier Curves
+ https://pomax.github.io/bezierinfo
+
+ News updates for the primer on Bézier Curves by Pomax
+ en-GB
+ {{ buildDate }}
+
+ https://pomax.github.io/bezierinfo/iamges/og-image.png
+ A Primer on Bézier Curves
+ https://pomax.github.io/bezierinfo
+
+
+ {% for item in items %}
+
+ {{ item.title }}
+ https://pomax.github.io/bezierinfo/news/{{ item.filename }}
+ {{ item.post | escape }}
+ {{ item.postDate }}
+ {{ item.filename }}
+
+ {% endfor %}
+
+
+