2017-08-24 21:54:02 +00:00
|
|
|
const choo = require('choo');
|
2017-11-07 23:54:42 +00:00
|
|
|
const html = require('choo/html');
|
2017-08-24 21:54:02 +00:00
|
|
|
const download = require('./download');
|
2017-11-07 23:54:42 +00:00
|
|
|
const header = require('../templates/header');
|
|
|
|
const footer = require('../templates/footer');
|
|
|
|
const fxPromo = require('../templates/fxPromo');
|
2017-08-24 21:54:02 +00:00
|
|
|
|
|
|
|
const app = choo();
|
|
|
|
|
2018-01-24 18:23:13 +00:00
|
|
|
function banner(state, emit) {
|
|
|
|
if (state.promo && !state.route.startsWith('/unsupported/')) {
|
|
|
|
return fxPromo(state, emit);
|
|
|
|
}
|
2018-01-12 05:22:11 +00:00
|
|
|
}
|
|
|
|
|
2017-11-07 23:54:42 +00:00
|
|
|
function body(template) {
|
|
|
|
return function(state, emit) {
|
|
|
|
const b = html`<body>
|
2018-01-24 18:23:13 +00:00
|
|
|
${banner(state, emit)}
|
2017-11-07 23:54:42 +00:00
|
|
|
${header(state)}
|
|
|
|
<div class="all">
|
|
|
|
<noscript>
|
2018-01-24 18:23:13 +00:00
|
|
|
<h2>${state.translate('javascriptRequired')}</h2>
|
|
|
|
<p>
|
|
|
|
<a 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>
|
2017-11-07 23:54:42 +00:00
|
|
|
</noscript>
|
|
|
|
${template(state, emit)}
|
|
|
|
</div>
|
|
|
|
${footer(state)}
|
|
|
|
</body>`;
|
|
|
|
if (state.layout) {
|
2018-01-24 18:23:13 +00:00
|
|
|
// server side only
|
2017-11-07 23:54:42 +00:00
|
|
|
return state.layout(state, b);
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
app.route('/', body(require('./home')));
|
|
|
|
app.route('/share/:id', body(require('../templates/share')));
|
|
|
|
app.route('/download/:id', body(download));
|
|
|
|
app.route('/download/:id/:key', body(download));
|
|
|
|
app.route('/completed', body(require('../templates/completed')));
|
|
|
|
app.route('/unsupported/:reason', body(require('../templates/unsupported')));
|
|
|
|
app.route('/legal', body(require('../templates/legal')));
|
|
|
|
app.route('/error', body(require('../templates/error')));
|
|
|
|
app.route('/blank', body(require('../templates/blank')));
|
|
|
|
app.route('*', body(require('../templates/notFound')));
|
2017-08-24 21:54:02 +00:00
|
|
|
|
|
|
|
module.exports = app;
|