2018-11-08 21:35:19 +00:00
|
|
|
/* global window, navigator */
|
2018-07-27 13:11:46 +00:00
|
|
|
|
2018-09-06 22:56:04 +00:00
|
|
|
window.LIMITS = {
|
|
|
|
ANON: {
|
|
|
|
MAX_FILE_SIZE: 1024 * 1024 * 1024 * 2,
|
2019-01-08 21:46:48 +00:00
|
|
|
MAX_DOWNLOADS: 20,
|
|
|
|
MAX_EXPIRE_SECONDS: 86400
|
2018-09-06 22:56:04 +00:00
|
|
|
},
|
|
|
|
MAX_FILE_SIZE: 1024 * 1024 * 1024 * 2,
|
2019-01-08 21:46:48 +00:00
|
|
|
MAX_DOWNLOADS: 200,
|
2018-09-06 22:56:04 +00:00
|
|
|
MAX_EXPIRE_SECONDS: 604800,
|
2019-02-19 17:28:25 +00:00
|
|
|
MAX_FILES_PER_ARCHIVE: 64,
|
|
|
|
MAX_ARCHIVES_PER_USER: 16
|
2018-09-06 22:56:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
window.DEFAULTS = {
|
2018-09-25 18:36:23 +00:00
|
|
|
DOWNLOAD_COUNTS: [1, 2, 3, 4, 5, 20, 50, 100, 200],
|
|
|
|
EXPIRE_TIMES_SECONDS: [300, 3600, 86400, 604800],
|
2018-09-06 22:56:04 +00:00
|
|
|
EXPIRE_SECONDS: 3600
|
|
|
|
};
|
2018-07-27 13:11:46 +00:00
|
|
|
|
2018-11-14 19:20:32 +00:00
|
|
|
import choo from 'choo';
|
|
|
|
import html from 'choo/html';
|
|
|
|
import Raven from 'raven-js';
|
|
|
|
|
2018-11-19 20:10:57 +00:00
|
|
|
import { setApiUrlPrefix } from '../app/api';
|
2018-12-17 21:40:17 +00:00
|
|
|
import metrics from '../app/metrics';
|
2018-12-18 16:14:22 +00:00
|
|
|
//import assets from '../common/assets';
|
2019-01-08 20:46:16 +00:00
|
|
|
import Archive from '../app/archive';
|
2018-11-12 19:13:31 +00:00
|
|
|
import Header from '../app/ui/header';
|
2018-11-14 19:20:32 +00:00
|
|
|
import storage from '../app/storage';
|
|
|
|
import controller from '../app/controller';
|
|
|
|
import User from './user';
|
|
|
|
import intents from './stores/intents';
|
|
|
|
import home from './pages/home';
|
|
|
|
import upload from './pages/upload';
|
|
|
|
import share from './pages/share';
|
|
|
|
import preferences from './pages/preferences';
|
|
|
|
import error from './pages/error';
|
2018-11-20 14:50:59 +00:00
|
|
|
import { getTranslator } from '../app/locale';
|
2018-07-27 13:11:46 +00:00
|
|
|
|
2018-11-08 21:35:19 +00:00
|
|
|
if (navigator.userAgent === 'Send Android') {
|
2018-11-19 20:10:57 +00:00
|
|
|
setApiUrlPrefix('https://send2.dev.lcip.org');
|
2018-11-08 21:35:19 +00:00
|
|
|
}
|
|
|
|
|
2018-11-14 19:20:32 +00:00
|
|
|
const app = choo();
|
|
|
|
//app.use(state);
|
|
|
|
app.use(controller);
|
|
|
|
app.use(intents);
|
|
|
|
|
2018-11-02 22:51:27 +00:00
|
|
|
function body(main) {
|
|
|
|
return function(state, emit) {
|
2018-12-18 16:14:22 +00:00
|
|
|
/*
|
|
|
|
Disable the preferences menu for now since it is ugly and isn't
|
|
|
|
relevant to the beta
|
|
|
|
function clickPreferences(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
emit('pushState', '/preferences');
|
|
|
|
}
|
|
|
|
|
|
|
|
const menu = html`<a
|
|
|
|
id="hamburger"
|
|
|
|
class="absolute pin-t pin-r z-50"
|
|
|
|
href="#"
|
|
|
|
onclick="${clickPreferences}"
|
|
|
|
>
|
|
|
|
<img src="${assets.get('preferences.png')}" />
|
|
|
|
</a>`;
|
|
|
|
*/
|
2018-11-08 23:12:07 +00:00
|
|
|
return html`
|
|
|
|
<body
|
2019-02-11 21:48:06 +00:00
|
|
|
class="flex flex-col items-center font-sans bg-grey-lightest h-screen"
|
2018-11-08 23:12:07 +00:00
|
|
|
>
|
2018-11-12 19:13:31 +00:00
|
|
|
${state.cache(Header, 'header').render()} ${main(state, emit)}
|
2018-11-08 23:12:07 +00:00
|
|
|
</body>
|
|
|
|
`;
|
2018-11-02 22:51:27 +00:00
|
|
|
};
|
|
|
|
}
|
2018-11-20 14:50:59 +00:00
|
|
|
(async function start() {
|
|
|
|
const translate = await getTranslator('en-US');
|
2019-02-12 20:21:18 +00:00
|
|
|
app.use((state, emitter) => {
|
2018-11-20 14:50:59 +00:00
|
|
|
state.translate = translate;
|
|
|
|
state.capabilities = {
|
|
|
|
account: true
|
|
|
|
}; //TODO
|
2019-01-08 20:46:16 +00:00
|
|
|
state.archive = new Archive();
|
2018-11-20 14:50:59 +00:00
|
|
|
state.storage = storage;
|
|
|
|
state.user = new User(storage);
|
|
|
|
state.raven = Raven;
|
2018-11-02 22:51:27 +00:00
|
|
|
|
2018-11-20 14:50:59 +00:00
|
|
|
window.finishLogin = async function(accountInfo) {
|
|
|
|
await state.user.finishLogin(accountInfo);
|
2019-02-08 02:41:32 +00:00
|
|
|
await state.user.syncFileList();
|
|
|
|
emitter.emit('replaceState', '/');
|
2018-11-20 14:50:59 +00:00
|
|
|
};
|
2018-11-08 21:35:19 +00:00
|
|
|
|
2018-11-20 14:50:59 +00:00
|
|
|
// for debugging
|
|
|
|
window.appState = state;
|
|
|
|
window.appEmit = emitter.emit.bind(emitter);
|
|
|
|
});
|
2019-02-12 20:21:18 +00:00
|
|
|
app.use(metrics);
|
2018-11-20 14:50:59 +00:00
|
|
|
app.route('/', body(home));
|
|
|
|
app.route('/upload', upload);
|
|
|
|
app.route('/share/:id', share);
|
|
|
|
app.route('/preferences', preferences);
|
|
|
|
app.route('/error', error);
|
|
|
|
//app.route('/debugging', require('./pages/debugging').default);
|
|
|
|
// add /api/filelist
|
|
|
|
app.mount('body');
|
|
|
|
})();
|