@financial-times/n-myft-ui 24.0.0 → 25.0.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
package/demos/app.js CHANGED
@@ -1,14 +1,13 @@
1
1
  require('sucrase/register');
2
- const express = require('@financial-times/n-internal-tool');
2
+ const nExpress = require('@financial-times/n-express');
3
3
  const chalk = require('chalk');
4
4
  const errorHighlight = chalk.bold.red;
5
5
  const highlight = chalk.bold.green;
6
6
  const { PageKitReactJSX } = require('@financial-times/dotcom-server-react-jsx');
7
7
  const fs = require('fs');
8
8
  const path = require('path');
9
- const xHandlebars = require('@financial-times/x-handlebars');
10
9
  const handlebars = require('handlebars');
11
- const { helpers } = require('@financial-times/dotcom-server-handlebars');
10
+ const { PageKitHandlebars, helpers } = require('@financial-times/dotcom-server-handlebars');
12
11
 
13
12
  const demoJSX = require('./templates/demo').default;
14
13
  const demoLayoutSource = fs.readFileSync(path.join(__dirname, './templates/demo-layout.html'),'utf8').toString();
@@ -22,43 +21,46 @@ const fixtures = {
22
21
  instantAlert: require('./fixtures/instant-alert')
23
22
  };
24
23
 
25
- const app = module.exports = express({
24
+ const app = module.exports = nExpress({
26
25
  name: 'public',
27
26
  systemCode: 'n-myft-ui-demo',
28
27
  withFlags: true,
29
- withHandlebars: true,
30
- withNavigation: false,
28
+ withConsent: false,
29
+ withServiceMetrics: false,
31
30
  withAnonMiddleware: false,
32
31
  hasHeadCss: false,
33
- layoutsDir: 'demos/templates',
34
- viewsDirectory: '/demos/templates',
35
32
  partialsDirectory: process.cwd(),
36
33
  directory: process.cwd(),
37
34
  demo: true,
38
- s3o: false,
39
- helpers: {
40
- x: xHandlebars(),
41
- renderReactComponent: helpers.renderReactComponent
42
- },
35
+ withBackendAuthentication: false,
43
36
  });
44
37
 
38
+ app.set('views', path.join(__dirname, '/templates'));
39
+ app.set('view engine', '.html');
40
+
41
+ app.engine('.html', new PageKitHandlebars({
42
+ cache: false,
43
+ handlebars,
44
+ helpers
45
+ }).engine);
46
+
47
+ app.use('/public', nExpress.static(path.join(__dirname, '../public'), { redirect: false }));
48
+
45
49
  const jsxRenderer = (new PageKitReactJSX({ includeDoctype: false }));
46
50
 
47
51
  app.get('/', (req, res) => {
48
52
  res.render('demo', Object.assign({
49
53
  title: 'n-myft-ui demo',
50
- layout: 'demo-layout',
51
54
  flags: {
52
55
  myFtApi: true,
53
56
  myFtApiWrite: true
54
- }
57
+ },
55
58
  }, fixtures));
56
59
  });
57
60
 
58
61
  app.get('/demo-jsx', async (req, res) => {
59
62
  let demo = await jsxRenderer.render(demoJSX, Object.assign({
60
63
  title: 'n-myft-ui demo',
61
- layout: 'demo-layout',
62
64
  flags: {
63
65
  myFtApi: true,
64
66
  myFtApiWrite: true
@@ -71,17 +73,6 @@ app.get('/demo-jsx', async (req, res) => {
71
73
  res.send(result);
72
74
  });
73
75
 
74
- app.get('/digest-on-follow', (req, res) => {
75
- res.render('digest-on-follow', Object.assign({
76
- title: 'n-myft-ui digest on follow',
77
- layout: 'demo-layout',
78
- flags: {
79
- myFtApi: true,
80
- myFtApiWrite: true,
81
- },
82
- appIsStreamPage: false
83
- }, fixtures.followButtonPlusDigest));
84
- });
85
76
 
86
77
  function runPa11yTests () {
87
78
  const spawn = require('child_process').spawn;
@@ -14,7 +14,7 @@
14
14
  <div class="o-grid-row">
15
15
  <ul>
16
16
  <li><a href="/">Basic</a></li>
17
- <li><a href="/digest-on-follow">Follow plus digest button</a></li>
17
+ <li><a href="/demo-jsx">JSX demo</a></li>
18
18
  </ul>
19
19
  </div>
20
20
  </div>