mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-22 17:15:13 +00:00
Bye bye subdomains
This commit is contained in:
parent
d0c875c1e0
commit
f298fc6eb3
8 changed files with 81 additions and 74 deletions
|
@ -109,7 +109,6 @@ type Mixin = {
|
||||||
ws_url: string;
|
ws_url: string;
|
||||||
auth_url: string;
|
auth_url: string;
|
||||||
docs_url: string;
|
docs_url: string;
|
||||||
ch_url: string;
|
|
||||||
stats_url: string;
|
stats_url: string;
|
||||||
status_url: string;
|
status_url: string;
|
||||||
dev_url: string;
|
dev_url: string;
|
||||||
|
@ -135,12 +134,11 @@ export default function load() {
|
||||||
mixin.ws_scheme = mixin.scheme.replace('http', 'ws');
|
mixin.ws_scheme = mixin.scheme.replace('http', 'ws');
|
||||||
mixin.ws_url = `${mixin.ws_scheme}://${mixin.host}`;
|
mixin.ws_url = `${mixin.ws_scheme}://${mixin.host}`;
|
||||||
mixin.api_url = `${mixin.scheme}://${mixin.host}/api`;
|
mixin.api_url = `${mixin.scheme}://${mixin.host}/api`;
|
||||||
mixin.auth_url = `${mixin.scheme}://auth.${mixin.host}`;
|
mixin.auth_url = `${mixin.scheme}://${mixin.host}/auth`;
|
||||||
mixin.ch_url = `${mixin.scheme}://ch.${mixin.host}`;
|
mixin.dev_url = `${mixin.scheme}://${mixin.host}/dev`;
|
||||||
mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`;
|
mixin.docs_url = `${mixin.scheme}://${mixin.host}/docs`;
|
||||||
mixin.docs_url = `${mixin.scheme}://docs.${mixin.host}`;
|
mixin.stats_url = `${mixin.scheme}://${mixin.host}/stats`;
|
||||||
mixin.stats_url = `${mixin.scheme}://stats.${mixin.host}`;
|
mixin.status_url = `${mixin.scheme}://${mixin.host}/status`;
|
||||||
mixin.status_url = `${mixin.scheme}://status.${mixin.host}`;
|
|
||||||
mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`;
|
mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`;
|
||||||
|
|
||||||
return Object.assign(config, mixin);
|
return Object.assign(config, mixin);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import * as cluster from 'cluster';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import * as morgan from 'morgan';
|
import * as morgan from 'morgan';
|
||||||
import Accesses from 'accesses';
|
import Accesses from 'accesses';
|
||||||
import vhost = require('vhost');
|
|
||||||
|
|
||||||
import log from './log-request';
|
import log from './log-request';
|
||||||
import config from './conf';
|
import config from './conf';
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
// Get the current url information
|
// Get the current url information
|
||||||
const url = new URL(location.href);
|
const url = new URL(location.href);
|
||||||
|
|
||||||
// Extarct the (sub) domain part of the current url
|
//#region Detect app name
|
||||||
//
|
let app = null;
|
||||||
// e.g.
|
|
||||||
// misskey.alice => misskey
|
if (url.pathname == '/docs') app = 'docs';
|
||||||
// misskey.strawberry.pasta => misskey
|
if (url.pathname == '/dev') app = 'dev';
|
||||||
// dev.misskey.arisu.tachibana => dev
|
if (url.pathname == '/auth') app = 'auth';
|
||||||
let app = url.host === HOST ? 'misskey' : url.host.substr(0, -HOST.length);
|
//#endregion
|
||||||
|
|
||||||
// Detect the user language
|
// Detect the user language
|
||||||
// Note: The default language is English
|
// Note: The default language is English
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch desktop or mobile version
|
// Switch desktop or mobile version
|
||||||
if (app == 'misskey') {
|
if (app == null) {
|
||||||
app = isMobile ? 'mobile' : 'desktop';
|
app = isMobile ? 'mobile' : 'desktop';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
* Desktop Client
|
* Desktop Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import VueRouter from 'vue-router';
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
import './style.styl';
|
import './style.styl';
|
||||||
import '../../element.scss';
|
import '../../element.scss';
|
||||||
|
|
||||||
import init from '../init';
|
import init from '../init';
|
||||||
import fuckAdBlock from '../common/scripts/fuck-ad-block';
|
import fuckAdBlock from '../common/scripts/fuck-ad-block';
|
||||||
import HomeStreamManager from '../common/scripts/streaming/home-stream-manager';
|
import { HomeStreamManager } from '../common/scripts/streaming/home';
|
||||||
import composeNotification from '../common/scripts/compose-notification';
|
import composeNotification from '../common/scripts/compose-notification';
|
||||||
|
|
||||||
import chooseDriveFolder from './api/choose-drive-folder';
|
import chooseDriveFolder from './api/choose-drive-folder';
|
||||||
|
@ -41,8 +43,26 @@ init(async (launch) => {
|
||||||
require('./views/components');
|
require('./views/components');
|
||||||
require('./views/widgets');
|
require('./views/widgets');
|
||||||
|
|
||||||
|
// Init router
|
||||||
|
const router = new VueRouter({
|
||||||
|
mode: 'history',
|
||||||
|
routes: [
|
||||||
|
{ path: '/', name: 'index', component: MkIndex },
|
||||||
|
{ path: '/i/customize-home', component: MkHomeCustomize },
|
||||||
|
{ path: '/i/messaging/:username', component: MkMessagingRoom },
|
||||||
|
{ path: '/i/drive', component: MkDrive },
|
||||||
|
{ path: '/i/drive/folder/:folder', component: MkDrive },
|
||||||
|
{ path: '/selectdrive', component: MkSelectDrive },
|
||||||
|
{ path: '/search', component: MkSearch },
|
||||||
|
{ path: '/othello', component: MkOthello },
|
||||||
|
{ path: '/othello/:game', component: MkOthello },
|
||||||
|
{ path: '/@:user', component: MkUser },
|
||||||
|
{ path: '/@:user/:post', component: MkPost }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
// Launch the app
|
// Launch the app
|
||||||
const [app, os] = launch(os => ({
|
const [, os] = launch(router, os => ({
|
||||||
chooseDriveFolder,
|
chooseDriveFolder,
|
||||||
chooseDriveFile,
|
chooseDriveFile,
|
||||||
dialog,
|
dialog,
|
||||||
|
@ -71,21 +91,6 @@ init(async (launch) => {
|
||||||
registerNotifications(os.stream);
|
registerNotifications(os.stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Routing
|
|
||||||
app.$router.addRoutes([
|
|
||||||
{ path: '/', name: 'index', component: MkIndex },
|
|
||||||
{ path: '/i/customize-home', component: MkHomeCustomize },
|
|
||||||
{ path: '/i/messaging/:username', component: MkMessagingRoom },
|
|
||||||
{ path: '/i/drive', component: MkDrive },
|
|
||||||
{ path: '/i/drive/folder/:folder', component: MkDrive },
|
|
||||||
{ path: '/selectdrive', component: MkSelectDrive },
|
|
||||||
{ path: '/search', component: MkSearch },
|
|
||||||
{ path: '/othello', component: MkOthello },
|
|
||||||
{ path: '/othello/:game', component: MkOthello },
|
|
||||||
{ path: '/@:user', component: MkUser },
|
|
||||||
{ path: '/@:user/:post', component: MkPost }
|
|
||||||
]);
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
function registerNotifications(stream: HomeStreamManager) {
|
function registerNotifications(stream: HomeStreamManager) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
import VueRouter from 'vue-router';
|
||||||
import BootstrapVue from 'bootstrap-vue';
|
import BootstrapVue from 'bootstrap-vue';
|
||||||
import 'bootstrap/dist/css/bootstrap.css';
|
import 'bootstrap/dist/css/bootstrap.css';
|
||||||
import 'bootstrap-vue/dist/bootstrap-vue.css';
|
import 'bootstrap-vue/dist/bootstrap-vue.css';
|
||||||
|
@ -26,14 +27,18 @@ Vue.component('mk-ui', ui);
|
||||||
* init
|
* init
|
||||||
*/
|
*/
|
||||||
init(launch => {
|
init(launch => {
|
||||||
// Launch the app
|
// Init router
|
||||||
const [app] = launch();
|
const router = new VueRouter({
|
||||||
|
mode: 'history',
|
||||||
// Routing
|
base: '/dev/',
|
||||||
app.$router.addRoutes([
|
routes: [
|
||||||
{ path: '/', component: Index },
|
{ path: '/', component: Index },
|
||||||
{ path: '/apps', component: Apps },
|
{ path: '/apps', component: Apps },
|
||||||
{ path: '/app/new', component: AppNew },
|
{ path: '/app/new', component: AppNew },
|
||||||
{ path: '/app/:id', component: App },
|
{ path: '/app/:id', component: App },
|
||||||
]);
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// Launch the app
|
||||||
|
launch(router);
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,14 +91,14 @@ if (localStorage.getItem('should-refresh') == 'true') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MiOSを初期化してコールバックする
|
// MiOSを初期化してコールバックする
|
||||||
export default (callback: (launch: (api?: (os: MiOS) => API) => [Vue, MiOS]) => void, sw = false) => {
|
export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API) => [Vue, MiOS]) => void, sw = false) => {
|
||||||
const os = new MiOS(sw);
|
const os = new MiOS(sw);
|
||||||
|
|
||||||
os.init(() => {
|
os.init(() => {
|
||||||
// アプリ基底要素マウント
|
// アプリ基底要素マウント
|
||||||
document.body.innerHTML = '<div id="app"></div>';
|
document.body.innerHTML = '<div id="app"></div>';
|
||||||
|
|
||||||
const launch = (api?: (os: MiOS) => API) => {
|
const launch = (router: VueRouter, api?: (os: MiOS) => API) => {
|
||||||
os.apis = api ? api(os) : null;
|
os.apis = api ? api(os) : null;
|
||||||
|
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
|
@ -112,9 +112,7 @@ export default (callback: (launch: (api?: (os: MiOS) => API) => [Vue, MiOS]) =>
|
||||||
});
|
});
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
router: new VueRouter({
|
router,
|
||||||
mode: 'history'
|
|
||||||
}),
|
|
||||||
created() {
|
created() {
|
||||||
this.$watch('os.i', i => {
|
this.$watch('os.i', i => {
|
||||||
// キャッシュ更新
|
// キャッシュ更新
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* Mobile Client
|
* Mobile Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import VueRouter from 'vue-router';
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
import './style.styl';
|
import './style.styl';
|
||||||
import '../../element.scss';
|
import '../../element.scss';
|
||||||
|
@ -45,18 +47,10 @@ init((launch) => {
|
||||||
// http://qiita.com/junya/items/3ff380878f26ca447f85
|
// http://qiita.com/junya/items/3ff380878f26ca447f85
|
||||||
document.body.setAttribute('ontouchstart', '');
|
document.body.setAttribute('ontouchstart', '');
|
||||||
|
|
||||||
// Launch the app
|
// Init router
|
||||||
const [app] = launch(os => ({
|
const router = new VueRouter({
|
||||||
chooseDriveFolder,
|
mode: 'history',
|
||||||
chooseDriveFile,
|
routes: [
|
||||||
dialog,
|
|
||||||
input,
|
|
||||||
post: post(os),
|
|
||||||
notify
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Routing
|
|
||||||
app.$router.addRoutes([
|
|
||||||
{ path: '/', name: 'index', component: MkIndex },
|
{ path: '/', name: 'index', component: MkIndex },
|
||||||
{ path: '/signup', name: 'signup', component: MkSignup },
|
{ path: '/signup', name: 'signup', component: MkSignup },
|
||||||
{ path: '/i/settings', component: MkSettings },
|
{ path: '/i/settings', component: MkSettings },
|
||||||
|
@ -75,5 +69,16 @@ init((launch) => {
|
||||||
{ path: '/@:user/followers', component: MkFollowers },
|
{ path: '/@:user/followers', component: MkFollowers },
|
||||||
{ path: '/@:user/following', component: MkFollowing },
|
{ path: '/@:user/following', component: MkFollowing },
|
||||||
{ path: '/@:user/:post', component: MkPost }
|
{ path: '/@:user/:post', component: MkPost }
|
||||||
]);
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// Launch the app
|
||||||
|
launch(router, os => ({
|
||||||
|
chooseDriveFolder,
|
||||||
|
chooseDriveFile,
|
||||||
|
dialog,
|
||||||
|
input,
|
||||||
|
post: post(os),
|
||||||
|
notify
|
||||||
|
}));
|
||||||
}, true);
|
}, true);
|
||||||
|
|
|
@ -10,9 +10,6 @@ import * as express from 'express';
|
||||||
import * as bodyParser from 'body-parser';
|
import * as bodyParser from 'body-parser';
|
||||||
import * as favicon from 'serve-favicon';
|
import * as favicon from 'serve-favicon';
|
||||||
import * as compression from 'compression';
|
import * as compression from 'compression';
|
||||||
import vhost = require('vhost');
|
|
||||||
|
|
||||||
import config from '../conf';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init app
|
* Init app
|
||||||
|
@ -20,7 +17,7 @@ import config from '../conf';
|
||||||
const app = express();
|
const app = express();
|
||||||
app.disable('x-powered-by');
|
app.disable('x-powered-by');
|
||||||
|
|
||||||
app.use(vhost(`docs.${config.host}`, require('./docs/server')));
|
app.use('/docs', require('./docs/server'));
|
||||||
|
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
app.use(bodyParser.json({
|
app.use(bodyParser.json({
|
||||||
|
|
Loading…
Reference in a new issue