2017-08-24 23:54:02 +02:00
|
|
|
const choo = require('choo');
|
2017-11-08 00:54:42 +01:00
|
|
|
const html = require('choo/html');
|
2018-02-21 01:00:19 +01:00
|
|
|
const nanotiming = require('nanotiming');
|
2017-08-24 23:54:02 +02:00
|
|
|
const download = require('./download');
|
2017-11-08 00:54:42 +01:00
|
|
|
const header = require('../templates/header');
|
|
|
|
const footer = require('../templates/footer');
|
|
|
|
const fxPromo = require('../templates/fxPromo');
|
2018-06-19 21:58:42 +02:00
|
|
|
const activeBackground = require('../templates/activeBackground');
|
2017-08-24 23:54:02 +02:00
|
|
|
|
2018-02-21 01:00:19 +01:00
|
|
|
nanotiming.disabled = true;
|
2017-08-24 23:54:02 +02:00
|
|
|
const app = choo();
|
|
|
|
|
2018-01-24 19:23:13 +01:00
|
|
|
function banner(state, emit) {
|
|
|
|
if (state.promo && !state.route.startsWith('/unsupported/')) {
|
|
|
|
return fxPromo(state, emit);
|
|
|
|
}
|
2018-01-12 06:22:11 +01:00
|
|
|
}
|
|
|
|
|
2017-11-08 00:54:42 +01:00
|
|
|
function body(template) {
|
|
|
|
return function(state, emit) {
|
2018-06-21 20:28:31 +02:00
|
|
|
const b = html`<body class="background ${activeBackground(state)}">
|
2018-01-24 19:23:13 +01:00
|
|
|
${banner(state, emit)}
|
2017-11-08 00:54:42 +01:00
|
|
|
${header(state)}
|
2018-02-20 08:10:03 +01:00
|
|
|
<main class="main">
|
2017-11-08 00:54:42 +01:00
|
|
|
<noscript>
|
2018-02-20 08:10:03 +01:00
|
|
|
<div class="noscript">
|
|
|
|
<h2>${state.translate('javascriptRequired')}</h2>
|
|
|
|
<p>
|
|
|
|
<a class="link" href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-does-firefox-send-require-javascript">
|
|
|
|
${state.translate('whyJavascript')}
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
<p>${state.translate('enableJavascript')}</p>
|
|
|
|
</div>
|
2017-11-08 00:54:42 +01:00
|
|
|
</noscript>
|
2018-06-21 00:23:15 +02:00
|
|
|
<div class="stripedBox">
|
|
|
|
<div class="mainContent">
|
|
|
|
${template(state, emit)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="spacer"></div>
|
|
|
|
<div class="uploads"></div>
|
2018-02-20 08:10:03 +01:00
|
|
|
</main>
|
2017-11-08 00:54:42 +01:00
|
|
|
${footer(state)}
|
|
|
|
</body>`;
|
|
|
|
if (state.layout) {
|
2018-01-24 19:23:13 +01:00
|
|
|
// server side only
|
2017-11-08 00:54:42 +01:00
|
|
|
return state.layout(state, b);
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
app.route('/', body(require('./home')));
|
2018-01-30 21:15:09 +01:00
|
|
|
app.route('/share/:id', body(require('../pages/share')));
|
2017-11-08 00:54:42 +01:00
|
|
|
app.route('/download/:id', body(download));
|
|
|
|
app.route('/download/:id/:key', body(download));
|
2018-01-30 21:15:09 +01:00
|
|
|
app.route('/completed', body(require('../pages/completed')));
|
|
|
|
app.route('/unsupported/:reason', body(require('../pages/unsupported')));
|
|
|
|
app.route('/legal', body(require('../pages/legal')));
|
|
|
|
app.route('/error', body(require('../pages/error')));
|
|
|
|
app.route('/blank', body(require('../pages/blank')));
|
|
|
|
app.route('*', body(require('../pages/notFound')));
|
2017-08-24 23:54:02 +02:00
|
|
|
|
|
|
|
module.exports = app;
|