Skip to content

Commit

Permalink
Add tools to work on hydration pathway of the app
Browse files Browse the repository at this point in the history
  • Loading branch information
tnajdek committed Jul 30, 2021
1 parent 07e7976 commit ad9ebef
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -14,7 +14,7 @@
"prebuild": "npm run clean -s && mkdir -p build/static/",
"clean": "rimraf build",
"clean:data": "rimraf data",
"build": "run-p \"build:collect-locale\" \"build:styles-json\" && run-p 'build:js -s' 'build:scss -s' 'build:html -s' 'build:static -s' && npm run build:postprocess",
"build": "run-p \"build:collect-locale\" \"build:styles-json\" && NODE_ENV=production run-p 'build:js -s' 'build:scss -s' 'build:html -s' 'build:static -s' && npm run build:postprocess",
"build:js": "mkdir -p build/static && NODE_ENV=production rollup -c",
"build:scss": "for f in src/scss/*.scss; do sass --no-source-map $f build/static/`basename $f .scss`.css; done;",
"build:html": "node scripts/build-html.cjs",
Expand Down
19 changes: 12 additions & 7 deletions scripts/build-html.cjs
Expand Up @@ -36,20 +36,25 @@ const buildFaqPage = async () => {
console.log('faq page generated');
};

const buildIndexPage = async () => {
const buildPage = async pageName => {
const indexConfig = config.get('indexConfig');
const srcFile = path.join(__dirname, '..', 'src', 'html', 'index.hbs');
const dstFile = path.join(__dirname, '..', 'build', 'index');
const index = await fs.readFile(srcFile);
const template = Handlebars.compile(index.toString());
const srcFile = path.join(__dirname, '..', 'src', 'html', `${pageName}.hbs`);
const dstFile = path.join(__dirname, '..', 'build', pageName);
const page = await fs.readFile(srcFile);
const template = Handlebars.compile(page.toString());
const output = await template({ indexConfig });

await fs.writeFile(dstFile, output);
console.log(`index page generated based on ${config.util.getConfigSources().length} config sources`);
console.log(`${pageName} page generated based on ${config.util.getConfigSources().length} config sources`);
};

(async () => {
const dstDir = path.join(__dirname, '..', 'build');
await fs.ensureDir(dstDir);
await Promise.all([buildIndexPage(), buildFaqPage()]);
if(process.env.NODE_ENV?.startsWith('prod')) {
// if doing a production build skip hydrate.hbs
await Promise.all([buildPage('index'), buildFaqPage()]);
} else {
await Promise.all([buildPage('index'), buildPage('hydrate'), buildFaqPage()]);
}
})();
5 changes: 5 additions & 0 deletions scripts/server.cjs
Expand Up @@ -33,6 +33,11 @@ const handler = (req, resp) => {
resp.setHeader('Content-Type', 'text/html');
resp.end(buf);
});
} else if (req.url.match(/[a-z0-9]{32}/)) {
fs.readFile(path.join(__dirname, '..', 'build', 'hydrate'), (err, buf) => {
resp.setHeader('Content-Type', 'text/html');
resp.end(buf);
});
} else {
serve(req, resp, fallback);
}
Expand Down
20 changes: 20 additions & 0 deletions src/html/hydrate.hbs
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>ZoteroBib: Fast, free bibliography generator - MLA, APA, Chicago, Harvard citations</title>
<meta name="description" content="Free, accurate citation and bibliography maker for APA, Chicago, Harvard, MLA, and 10,000 other styles. No ads, no downloads, no account required.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/static/bib.css">
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
</head>
<body>
<main id="zotero-bib" data-hydrate-items-count="1"><div class="zotero-bib-container read-only"><div class="zotero-bib-inner"><div class="messages"></div><section class="section section-bibliography"><div class="container"><h1 class="h2 bibliography-title">Bibliography</h1><div class="bibliography read-only"><div class="csl-bib-body" style="line-height: 2; margin-left: 2em; text-indent:-2em;">
<div classname="csl-entry"> <div class="csl-entry">Keighley, M. R., et al. “The Importance of an Innervated and Intact Antrum and Pylorus in Preventing Postoperative Duodenogastric Reflux and Gastritis.” <i>The British Journal of Surgery</i>, vol. 62, no. 10, Oct. 1975, pp. 845–49. <i>PubMed</i>, doi:<a href="https://doi.org/10.1002/bjs.1800621024">10.1002/bjs.1800621024</a>.</div>
</div></div></div><script type="application/vnd.zotero.data+json">{&quot;key&quot;:&quot;QPXNLW8S&quot;,&quot;version&quot;:0,&quot;itemType&quot;:&quot;journalArticle&quot;,&quot;creators&quot;:[{&quot;firstName&quot;:&quot;M. R.&quot;,&quot;lastName&quot;:&quot;Keighley&quot;,&quot;creatorType&quot;:&quot;author&quot;},{&quot;firstName&quot;:&quot;P.&quot;,&quot;lastName&quot;:&quot;Asquith&quot;,&quot;creatorType&quot;:&quot;author&quot;},{&quot;firstName&quot;:&quot;J. A.&quot;,&quot;lastName&quot;:&quot;Edwards&quot;,&quot;creatorType&quot;:&quot;author&quot;},{&quot;firstName&quot;:&quot;J.&quot;,&quot;lastName&quot;:&quot;Alexander-Williams&quot;,&quot;creatorType&quot;:&quot;author&quot;}],&quot;tags&quot;:[{&quot;tag&quot;:&quot;Adult&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Bilirubin&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Duodenal Diseases&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Duodenal Ulcer&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Endoscopy&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Female&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Gastric Juice&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Gastric Mucosa&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Gastritis&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Heartburn&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Humans&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Hydrogen-Ion Concentration&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Male&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Middle Aged&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Postoperative Complications&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Pyloric Antrum&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Pylorus&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Radiography&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Stomach Diseases&quot;,&quot;type&quot;:1},{&quot;tag&quot;:&quot;Vagotomy&quot;,&quot;type&quot;:1}],&quot;title&quot;:&quot;The importance of an innervated and intact antrum and pylorus in preventing postoperative duodenogastric reflux and gastritis&quot;,&quot;pages&quot;:&quot;845-849&quot;,&quot;ISSN&quot;:&quot;0007-1323&quot;,&quot;journalAbbreviation&quot;:&quot;Br J Surg&quot;,&quot;publicationTitle&quot;:&quot;The British Journal of Surgery&quot;,&quot;volume&quot;:&quot;62&quot;,&quot;issue&quot;:&quot;10&quot;,&quot;date&quot;:&quot;1975-10&quot;,&quot;language&quot;:&quot;eng&quot;,&quot;abstractNote&quot;:&quot;This study has investigated the relationship between duodenogastric reflux, gastritis and certain symptoms 6-12 months after three operations for uncomplicated duodenal ulcer. The operations studied were proximal gastric vagotomy (PGV, 20 cases), truncal vagotomy and pyloroplasty (TV+P, 22 cases) and truncal vagotomy and antrectomy (TV+A, 21 cases). Duodenogastric reflux was assessed both by a radiological technique and by measuring the concentration of bilirubin in the gastric aspirate before and after operation. Incidence and severity of postoperative gastritis were determined by endoscopic biopsy. Symptoms were assessed by symptomatic score and Visick grading. There was a significant correlation between duodenal reflux and histological evidence of both severe superficial gastritis and glandular atrophy (P less than 0-01). There was also a close association between the degree of reflux and the presence of severe heartburn, epigastric pain and bile vomiting after operation. The amount of reflux did not differ before operation. There was significantly less reflux following PGV than after either TV+P (P less than 0-025) or TV+A (P less than 0-001). The results indicate that an operation which preserves an innervated and intact antrum and pylorus will protect against postoperative duodenogastric reflux, gastritis and symptoms.&quot;,&quot;DOI&quot;:&quot;10.1002/bjs.1800621024&quot;,&quot;extra&quot;:&quot;PMID: 123&quot;,&quot;libraryCatalog&quot;:&quot;PubMed&quot;}</script><button class="btn btn-sm btn-outline-secondary">Edit Bibliography</button></div></section><section class="section section-export"><div class="container"><h2>Export</h2><div class="export-tools"><div class="btn-group dropdown"><button class="btn btn btn-secondary btn-xl copy-to-clipboard" data-format="plain" data-main="true"><span class="inline-feedback"><span class="default-text" aria-hidden="true">Copy to Clipboard</span><span class="shorter feedback">Copied!</span></span></button><button type="button" aria-haspopup="true" aria-expanded="false" class="btn btn-secondary btn-xl dropdown-toggle btn btn-secondary"><span class="dropdown-caret"></span></button><div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu dropdown-menu"><button type="button" data-format="rtf" tabindex="0" role="menuitem" class="btn dropdown-item"><span>Download RTF (all word processors)</span></button><button type="button" data-format="html" tabindex="0" role="menuitem" class="btn clipboard-trigger dropdown-item"><span class="inline-feedback"><span class="default-text" aria-hidden="true">Copy HTML</span><span class="shorter feedback" aria-hidden="false">Copied!</span></span></button><button type="button" data-format="ris" tabindex="0" role="menuitem" class="btn dropdown-item"><span>Download RIS</span></button><button type="button" data-format="bibtex" tabindex="0" role="menuitem" class="btn dropdown-item"><span>Download BibTeX</span></button><button type="button" data-format="zotero" tabindex="0" role="menuitem" class="btn dropdown-item"><span>Save to Zotero</span></button></div></div></div></div></section><section class="section section-brand"><div class="container"><h1 class="brand"><a href="/">ZoteroBib<svg width="188" height="38" viewBox="0 0 188 38"><g><path d="M17.76,16.84,4.608,34.12H18.24V37H0V34.7L13.152,17.416H.672v-2.88H17.76Z" fill="#e52e3d"></path><path d="M43.584,25.768a12.252,12.252,0,0,1-.888,4.7,11.129,11.129,0,0,1-6.24,6.215,12.7,12.7,0,0,1-4.824.889,12.563,12.563,0,0,1-4.776-.889,11.129,11.129,0,0,1-6.24-6.215,12.9,12.9,0,0,1,0-9.408,11.135,11.135,0,0,1,6.24-6.216,12.563,12.563,0,0,1,4.776-.888,12.7,12.7,0,0,1,4.824.888,11.135,11.135,0,0,1,6.24,6.216A12.252,12.252,0,0,1,43.584,25.768Zm-3.456,0a10.075,10.075,0,0,0-.6-3.5,8.44,8.44,0,0,0-1.7-2.832,8.023,8.023,0,0,0-2.664-1.9,9.29,9.29,0,0,0-7.056,0,7.737,7.737,0,0,0-2.64,1.9,8.637,8.637,0,0,0-1.68,2.832,10.529,10.529,0,0,0,0,7.007,8.607,8.607,0,0,0,1.68,2.832A7.713,7.713,0,0,0,28.1,34a9.3,9.3,0,0,0,7.056,0,8,8,0,0,0,2.664-1.9,8.411,8.411,0,0,0,1.7-2.832A10.066,10.066,0,0,0,40.128,25.768Z" fill="#222"></path><path d="M59.039,17.416h-6.48V30.664a7.194,7.194,0,0,0,.24,2.04,2.879,2.879,0,0,0,.672,1.224,2.307,2.307,0,0,0,1.032.6,4.846,4.846,0,0,0,1.32.168,6.222,6.222,0,0,0,1.68-.239,7.722,7.722,0,0,0,1.584-.624l.144,2.928a10.175,10.175,0,0,1-4.272.816,8,8,0,0,1-1.9-.24,4.458,4.458,0,0,1-1.8-.912A5.018,5.018,0,0,1,49.919,34.6a7.316,7.316,0,0,1-.528-3.023V17.416H44.639v-2.88h4.752V8.2h3.168v6.336h6.48Z" fill="#222"></path><path d="M63.646,26.632a9.638,9.638,0,0,0,.816,3.168,8.282,8.282,0,0,0,4.32,4.272,7.761,7.761,0,0,0,3.12.623,7.99,7.99,0,0,0,4.392-1.176A8.79,8.79,0,0,0,79.1,30.808l2.447,2.016a12.169,12.169,0,0,1-4.44,3.648,12.431,12.431,0,0,1-5.208,1.1,11.938,11.938,0,0,1-4.631-.889A10.828,10.828,0,0,1,63.6,34.216a11.7,11.7,0,0,1-2.425-3.744,12.252,12.252,0,0,1-.887-4.7,12.551,12.551,0,0,1,.863-4.7,11.4,11.4,0,0,1,2.4-3.744,11.036,11.036,0,0,1,3.6-2.472,11.174,11.174,0,0,1,4.464-.888,10.943,10.943,0,0,1,4.56.912A10.122,10.122,0,0,1,79.559,17.3a10.372,10.372,0,0,1,2.087,3.552,12.957,12.957,0,0,1,.72,4.344v1.44ZM78.911,24.04a7.191,7.191,0,0,0-1.921-5.208,7.117,7.117,0,0,0-5.376-1.992,7.67,7.67,0,0,0-2.976.6,8.359,8.359,0,0,0-2.519,1.608,8.028,8.028,0,0,0-1.728,2.3,5.928,5.928,0,0,0-.649,2.688Z" fill="#222"></path><path d="M87.022,21.544q0-1.486-.071-3.024t-.12-3.984h3.12v4.176h.1a6.983,6.983,0,0,1,.96-1.752,7.5,7.5,0,0,1,1.513-1.512,7.4,7.4,0,0,1,2.064-1.08,8.118,8.118,0,0,1,2.664-.408,8.61,8.61,0,0,1,2.352.288l-.624,3.12a5.34,5.34,0,0,0-1.825-.24,6.515,6.515,0,0,0-3.12.7A6.913,6.913,0,0,0,91.871,19.6,7.339,7.339,0,0,0,90.6,21.928a7.692,7.692,0,0,0-.409,2.4V37H87.022Z" fill="#222"></path><path d="M123.022,25.768a12.252,12.252,0,0,1-.888,4.7,11.129,11.129,0,0,1-6.24,6.215,12.7,12.7,0,0,1-4.824.889,12.563,12.563,0,0,1-4.776-.889,11.129,11.129,0,0,1-6.24-6.215,12.9,12.9,0,0,1,0-9.408,11.135,11.135,0,0,1,6.24-6.216,12.563,12.563,0,0,1,4.776-.888,12.7,12.7,0,0,1,4.824.888,11.135,11.135,0,0,1,6.24,6.216A12.252,12.252,0,0,1,123.022,25.768Zm-3.456,0a10.075,10.075,0,0,0-.6-3.5,8.41,8.41,0,0,0-1.7-2.832,8,8,0,0,0-2.664-1.9,9.287,9.287,0,0,0-7.055,0,7.737,7.737,0,0,0-2.64,1.9,8.637,8.637,0,0,0-1.68,2.832,10.529,10.529,0,0,0,0,7.007A8.607,8.607,0,0,0,104.9,32.1a7.713,7.713,0,0,0,2.64,1.9,9.3,9.3,0,0,0,7.055,0,7.977,7.977,0,0,0,2.664-1.9,8.381,8.381,0,0,0,1.7-2.832A10.066,10.066,0,0,0,119.566,25.768Z" fill="#222"></path><path d="M126.669.712h4.321v16.8h.095A7.872,7.872,0,0,1,134.4,14.7a10.546,10.546,0,0,1,4.607-1.032,12.047,12.047,0,0,1,4.776.912,10.714,10.714,0,0,1,3.648,2.52,11.192,11.192,0,0,1,2.328,3.792,13.425,13.425,0,0,1,.817,4.728,13.228,13.228,0,0,1-.817,4.7,11.511,11.511,0,0,1-2.328,3.792,10.555,10.555,0,0,1-3.648,2.544,12.065,12.065,0,0,1-4.776.912,10.6,10.6,0,0,1-4.488-1.008,8.216,8.216,0,0,1-3.432-2.832h-.095V37h-4.321Zm11.808,32.832a7.772,7.772,0,0,0,3.12-.6,6.868,6.868,0,0,0,2.352-1.631,7.189,7.189,0,0,0,1.488-2.5,9.913,9.913,0,0,0,0-6.384,7.2,7.2,0,0,0-1.488-2.5A6.9,6.9,0,0,0,141.6,18.3a8.412,8.412,0,0,0-6.24,0,6.889,6.889,0,0,0-2.352,1.632,7.2,7.2,0,0,0-1.488,2.5,9.93,9.93,0,0,0,0,6.384,7.189,7.189,0,0,0,1.488,2.5,6.859,6.859,0,0,0,2.352,1.631A7.775,7.775,0,0,0,138.477,33.544Z" fill="#222"></path><path d="M153.4,6.088a3.047,3.047,0,0,1,.936-2.232,3.129,3.129,0,0,1,4.464,0,3.044,3.044,0,0,1,.937,2.232A3.044,3.044,0,0,1,158.8,8.32a3.129,3.129,0,0,1-4.464,0A3.047,3.047,0,0,1,153.4,6.088Zm1.009,8.16h4.319V37h-4.319Z" fill="#222"></path><path d="M163.676.712H168v16.8h.1A7.882,7.882,0,0,1,171.4,14.7a10.553,10.553,0,0,1,4.608-1.032,12.059,12.059,0,0,1,4.777.912,10.729,10.729,0,0,1,3.647,2.52,11.161,11.161,0,0,1,2.328,3.792,13.4,13.4,0,0,1,.816,4.728,13.206,13.206,0,0,1-.816,4.7,11.478,11.478,0,0,1-2.328,3.792,10.57,10.57,0,0,1-3.647,2.544,12.076,12.076,0,0,1-4.777.912,10.6,10.6,0,0,1-4.488-1.008,8.216,8.216,0,0,1-3.432-2.832H168V37h-4.32Zm11.808,32.832a7.775,7.775,0,0,0,3.12-.6,6.872,6.872,0,0,0,2.353-1.631,7.25,7.25,0,0,0,1.488-2.5,9.93,9.93,0,0,0,0-6.384,7.26,7.26,0,0,0-1.488-2.5A6.9,6.9,0,0,0,178.6,18.3a8.409,8.409,0,0,0-6.239,0,6.873,6.873,0,0,0-2.353,1.632,7.2,7.2,0,0,0-1.488,2.5,9.913,9.913,0,0,0,0,6.384,7.189,7.189,0,0,0,1.488,2.5,6.844,6.844,0,0,0,2.353,1.631A7.764,7.764,0,0,0,175.484,33.544Z" fill="#222"></path></g></svg></a></h1></div></section><footer><nav class="social-nav">Stay in touch! Follow <a href="https://twitter.com/zotero">@zotero</a> on Twitter.</nav><small class="copyright">© 2018–2020 Zotero  •  <a href="/faq#privacy">Privacy</a></small></footer></div></div></main>
<script id="zotero-bib-config" type="application/json">
{{{json indexConfig}}}
</script>
<script src="/static/main.js"></script>
</body>
</html>

0 comments on commit ad9ebef

Please sign in to comment.