load android ui in dev when browsing to /android (#919)
This commit is contained in:
parent
041c8ffdd2
commit
17ee4e0058
|
@ -27,5 +27,5 @@ app.route('/', require('./pages/home').default);
|
||||||
app.route('/upload', require('./pages/upload').default);
|
app.route('/upload', require('./pages/upload').default);
|
||||||
app.route('/share/:id', require('./pages/share').default);
|
app.route('/share/:id', require('./pages/share').default);
|
||||||
app.route('/preferences', require('./pages/preferences').default);
|
app.route('/preferences', require('./pages/preferences').default);
|
||||||
app.route('/android/app/src/main/assets', require('./pages/home').default);
|
app.route('/android', require('./pages/home').default);
|
||||||
app.mount('body');
|
app.mount('body');
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<title>Firefox Send</title>
|
<title>Firefox Send</title>
|
||||||
<link href="index.css" rel="stylesheet">
|
<link href="index.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script src="vendor.js"></script>
|
||||||
const EXPIRE_SECONDS = 86400;
|
<script src="android.js"></script>
|
||||||
</script>
|
|
||||||
<script src="vendor.js"></script>
|
|
||||||
<script src="android.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
const html = require('choo/html');
|
const html = require('choo/html');
|
||||||
|
|
||||||
export default function mainPage(state, emit) {
|
export default function mainPage(state, emit) {
|
||||||
if (window.location.pathname === '/android/app/src/main/assets/') {
|
|
||||||
// Hack: For debugging the android app in a web browser from
|
|
||||||
// http://0.0.0.0:8080/android/app/src/main/assets/ after running webpack
|
|
||||||
state.prefix = '/android/app/src/main/assets';
|
|
||||||
}
|
|
||||||
function clickPreferences(event) {
|
function clickPreferences(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
emit('pushState', '/preferences');
|
emit('pushState', '/preferences');
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const assets = require('../../common/assets');
|
const assets = require('../../common/assets');
|
||||||
const locales = require('../../common/locales');
|
const locales = require('../../common/locales');
|
||||||
const routes = require('../routes');
|
const routes = require('../routes');
|
||||||
|
@ -8,6 +10,11 @@ const expressWs = require('express-ws');
|
||||||
const morgan = require('morgan');
|
const morgan = require('morgan');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
|
|
||||||
|
const androidIndex = fs.readFileSync(
|
||||||
|
path.resolve(__dirname, '../../android/app/src/main/assets/index.html'),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = function(app, devServer) {
|
module.exports = function(app, devServer) {
|
||||||
const wsapp = express();
|
const wsapp = express();
|
||||||
expressWs(wsapp, null, { perMessageDeflate: false });
|
expressWs(wsapp, null, { perMessageDeflate: false });
|
||||||
|
@ -19,6 +26,15 @@ module.exports = function(app, devServer) {
|
||||||
app.use(morgan('dev', { stream: process.stderr }));
|
app.use(morgan('dev', { stream: process.stderr }));
|
||||||
routes(app);
|
routes(app);
|
||||||
tests(app);
|
tests(app);
|
||||||
|
app.get('/android', function(req, res) {
|
||||||
|
res.set('Content-Type', 'text/html');
|
||||||
|
res.send(
|
||||||
|
androidIndex
|
||||||
|
.replace('index.css', '/android_asset/index.css')
|
||||||
|
.replace('vendor.js', assets.get('vendor.js'))
|
||||||
|
.replace('android.js', assets.get('android.js'))
|
||||||
|
);
|
||||||
|
});
|
||||||
// webpack-dev-server routes haven't been added yet
|
// webpack-dev-server routes haven't been added yet
|
||||||
// so wait for next tick to add 404 handler
|
// so wait for next tick to add 404 handler
|
||||||
process.nextTick(() => app.use(pages.notfound));
|
process.nextTick(() => app.use(pages.notfound));
|
||||||
|
|
|
@ -183,6 +183,11 @@ const web = {
|
||||||
{
|
{
|
||||||
context: 'public',
|
context: 'public',
|
||||||
from: '*.*'
|
from: '*.*'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
context: 'android/app/src/main/assets',
|
||||||
|
from: '*.*',
|
||||||
|
to: 'android_asset'
|
||||||
}
|
}
|
||||||
]),
|
]),
|
||||||
new webpack.IgnorePlugin(/\.\.\/dist/), // used in common/*.js
|
new webpack.IgnorePlugin(/\.\.\/dist/), // used in common/*.js
|
||||||
|
|
Loading…
Reference in New Issue