OurBigBook
Rerender all articles by all users:
web/bin/rerender-articles.js
Rerender only the articles with specified slugs:
web/bin/rerender-articles.js johnsmith/mathematics maryjane/physics
Rerendering has to be done to see updates on OurBigBook changes that change the render output.
Notably, this would be mandatory in case of CSS changes that require corresponding HTML changes.
As the website grows, we will likely need to do a lazy version of this that marks pages as outdated, and then renders on the fly, plus a background thread that always updates outdated pages.
The functionality of this script should be called from a migration whenever such HTML changes are required. TODO link to an example. We had one at web/migrations/20220321000000-output-update-ancestor.js that seemed to work, but lost it. It was simple though. Just you have to instantiate your own Sequelize instance after making the model change to move any data.
web/bin/rerender-articles.js
#!/usr/bin/env node

const path = require('path')

const commander = require('commander');

const models = require('../models')
const back_js = require('../back/js')

const program = commander.program
program.description('Re-render articles https://docs.ourbigbook.com/_file/web/bin/rerender-articles.js')
program.option('-a, --author <username>', 'only convert articles by this authoru', undefined);
program.option('-i, --ignore-errors', 'ignore errors', false);
program.parse(process.argv);
const opts = program.opts()
const slugs = program.args
const sequelize = models.getSequelize(path.dirname(__dirname));
(async () => {
await sequelize.models.Article.rerender({
  log: true,
  convertOptionsExtra: { katex_macros: back_js.preloadKatex() },
  author: opts.author,
  ignoreErrors: opts.ignoreErrors,
  slugs,
})
})().finally(() => { return sequelize.close() });

Ancestors

  1. Web CLI utils
  2. OurBigBook Web directory structure
  3. OurBigBook Web architecture
  4. OurBigBook Web development
  5. OurBigBook Web
  6. OurBigBook Project