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,
|
|
|
|
MAX_DOWNLOADS: 32,
|
|
|
|
MAX_EXPIRE_SECONDS: 604800
|
|
|
|
},
|
|
|
|
MAX_FILE_SIZE: 1024 * 1024 * 1024 * 2,
|
|
|
|
MAX_DOWNLOADS: 32,
|
|
|
|
MAX_EXPIRE_SECONDS: 604800,
|
|
|
|
MAX_FILES_PER_ARCHIVE: 32,
|
|
|
|
MAX_ARCHIVES_PER_USER: 32
|
|
|
|
};
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
import assets from '../common/assets';
|
|
|
|
import header from '../app/ui/header';
|
|
|
|
import locale from '../common/locales';
|
|
|
|
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-07-27 13:11:46 +00:00
|
|
|
|
2018-11-08 21:35:19 +00:00
|
|
|
if (navigator.userAgent === 'Send Android') {
|
|
|
|
assets.setPrefix('/android_asset');
|
|
|
|
}
|
|
|
|
|
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-11-08 23:12:07 +00:00
|
|
|
return html`
|
|
|
|
<body
|
|
|
|
class="flex flex-col items-center font-sans bg-blue-lightest md:h-screen md:bg-grey-lightest"
|
|
|
|
>
|
|
|
|
<a
|
|
|
|
id="hamburger"
|
|
|
|
class="absolute pin-t pin-r z-50"
|
|
|
|
href="#"
|
|
|
|
onclick="${clickPreferences}"
|
|
|
|
>
|
|
|
|
<img src="${assets.get('preferences.png')}" />
|
|
|
|
</a>
|
|
|
|
${header(state, emit)} ${main(state, emit)}
|
|
|
|
</body>
|
|
|
|
`;
|
2018-11-02 22:51:27 +00:00
|
|
|
|
|
|
|
function clickPreferences(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
emit('pushState', '/preferences');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
app.use((state, emitter) => {
|
|
|
|
state.translate = locale.getTranslator();
|
2018-11-08 21:35:19 +00:00
|
|
|
state.capabilities = {
|
|
|
|
account: true
|
|
|
|
}; //TODO
|
2018-11-14 19:20:32 +00:00
|
|
|
state.storage = storage;
|
|
|
|
state.user = new User(storage);
|
|
|
|
state.raven = Raven;
|
2018-11-08 21:35:19 +00:00
|
|
|
|
|
|
|
window.finishLogin = async function(accountInfo) {
|
|
|
|
await state.user.finishLogin(accountInfo);
|
|
|
|
emitter.emit('render');
|
|
|
|
};
|
2018-11-02 22:51:27 +00:00
|
|
|
|
|
|
|
// for debugging
|
|
|
|
window.appState = state;
|
|
|
|
window.appEmit = emitter.emit.bind(emitter);
|
|
|
|
});
|
|
|
|
app.route('/', body(home));
|
2018-11-14 19:20:32 +00:00
|
|
|
app.route('/upload', upload);
|
|
|
|
app.route('/share/:id', share);
|
|
|
|
app.route('/preferences', preferences);
|
|
|
|
app.route('/error', error);
|
2018-09-24 16:30:27 +00:00
|
|
|
//app.route('/debugging', require('./pages/debugging').default);
|
|
|
|
// add /api/filelist
|
2018-08-16 16:07:12 +00:00
|
|
|
app.mount('body');
|