diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-11-23 05:43:00 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-11-23 05:43:00 +0900 |
| commit | 3f8ebac466ece8e9598432f3f574ec44e420c03b (patch) | |
| tree | 05114fce9728d6ce1deecc1f2eb8a903a22b0100 /src/web/app/common/scripts | |
| parent | :v: (diff) | |
| download | sharkey-3f8ebac466ece8e9598432f3f574ec44e420c03b.tar.gz sharkey-3f8ebac466ece8e9598432f3f574ec44e420c03b.tar.bz2 sharkey-3f8ebac466ece8e9598432f3f574ec44e420c03b.zip | |
なんかもうめっちゃ変えた
Closes #940
Diffstat (limited to 'src/web/app/common/scripts')
| -rw-r--r-- | src/web/app/common/scripts/api.ts | 4 | ||||
| -rw-r--r-- | src/web/app/common/scripts/check-for-update.ts | 6 | ||||
| -rw-r--r-- | src/web/app/common/scripts/config.ts | 27 | ||||
| -rw-r--r-- | src/web/app/common/scripts/signout.ts | 4 | ||||
| -rw-r--r-- | src/web/app/common/scripts/streaming/stream.ts | 5 | ||||
| -rw-r--r-- | src/web/app/common/scripts/text-compiler.ts | 5 |
6 files changed, 13 insertions, 38 deletions
diff --git a/src/web/app/common/scripts/api.ts b/src/web/app/common/scripts/api.ts index 5dcdb59710..e62447b0a0 100644 --- a/src/web/app/common/scripts/api.ts +++ b/src/web/app/common/scripts/api.ts @@ -2,7 +2,7 @@ * API Request */ -import CONFIG from './config'; +declare const _API_URL_: string; let spinner = null; let pending = 0; @@ -26,7 +26,7 @@ export default (i, endpoint, data = {}): Promise<{ [x: string]: any }> => { return new Promise((resolve, reject) => { // Send request - fetch(endpoint.indexOf('://') > -1 ? endpoint : `${CONFIG.apiUrl}/${endpoint}`, { + fetch(endpoint.indexOf('://') > -1 ? endpoint : `${_API_URL_}/${endpoint}`, { method: 'POST', body: JSON.stringify(data), credentials: endpoint === 'signin' ? 'include' : 'omit' diff --git a/src/web/app/common/scripts/check-for-update.ts b/src/web/app/common/scripts/check-for-update.ts index c1398ba54f..c447a517fa 100644 --- a/src/web/app/common/scripts/check-for-update.ts +++ b/src/web/app/common/scripts/check-for-update.ts @@ -1,12 +1,12 @@ import MiOS from '../mios'; -declare var VERSION: string; +declare const _VERSION_: string; export default async function(mios: MiOS) { const meta = await mios.getMeta(); - if (meta.version != VERSION) { + if (meta.version != _VERSION_) { localStorage.setItem('should-refresh', 'true'); - alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', VERSION)); + alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', _VERSION_)); } } diff --git a/src/web/app/common/scripts/config.ts b/src/web/app/common/scripts/config.ts deleted file mode 100644 index b4801a44de..0000000000 --- a/src/web/app/common/scripts/config.ts +++ /dev/null @@ -1,27 +0,0 @@ -const _url = new URL(location.href); - -const isRoot = _url.host == 'localhost' - ? true - : _url.host.split('.')[0] == 'misskey'; - -const host = isRoot ? _url.host : _url.host.substring(_url.host.indexOf('.') + 1, _url.host.length); -const scheme = _url.protocol; -const url = `${scheme}//${host}`; -const apiUrl = `${scheme}//api.${host}`; -const chUrl = `${scheme}//ch.${host}`; -const devUrl = `${scheme}//dev.${host}`; -const aboutUrl = `${scheme}//about.${host}`; -const statsUrl = `${scheme}//stats.${host}`; -const statusUrl = `${scheme}//status.${host}`; - -export default { - host, - scheme, - url, - apiUrl, - chUrl, - devUrl, - aboutUrl, - statsUrl, - statusUrl -}; diff --git a/src/web/app/common/scripts/signout.ts b/src/web/app/common/scripts/signout.ts index 6c95cfbc9c..2923196549 100644 --- a/src/web/app/common/scripts/signout.ts +++ b/src/web/app/common/scripts/signout.ts @@ -1,7 +1,7 @@ -import CONFIG from './config'; +declare const _HOST_: string; export default () => { localStorage.removeItem('me'); - document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; + document.cookie = `i=; domain=.${_HOST_}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; location.href = '/'; }; diff --git a/src/web/app/common/scripts/streaming/stream.ts b/src/web/app/common/scripts/streaming/stream.ts index 97ebdcdd74..770d77510f 100644 --- a/src/web/app/common/scripts/streaming/stream.ts +++ b/src/web/app/common/scripts/streaming/stream.ts @@ -1,6 +1,7 @@ +declare const _API_URL_: string; + import { EventEmitter } from 'eventemitter3'; import * as ReconnectingWebsocket from 'reconnecting-websocket'; -import CONFIG from '../config'; /** * Misskey stream connection @@ -24,7 +25,7 @@ export default class Connection extends EventEmitter { this.state = 'initializing'; this.buffer = []; - const host = CONFIG.apiUrl.replace('http', 'ws'); + const host = _API_URL_.replace('http', 'ws'); const query = params ? Object.keys(params) .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k])) diff --git a/src/web/app/common/scripts/text-compiler.ts b/src/web/app/common/scripts/text-compiler.ts index 8c65d6a068..e0ea47df26 100644 --- a/src/web/app/common/scripts/text-compiler.ts +++ b/src/web/app/common/scripts/text-compiler.ts @@ -1,6 +1,7 @@ +declare const _URL_: string; + import * as riot from 'riot'; import * as pictograph from 'pictograph'; -import CONFIG from './config'; const escape = text => text @@ -26,7 +27,7 @@ export default (tokens, shouldBreak) => { case 'link': return `<a class="link" href="${escape(token.url)}" target="_blank" title="${escape(token.url)}">${escape(token.title)}</a>`; case 'mention': - return `<a href="${CONFIG.url + '/' + escape(token.username)}" target="_blank" data-user-preview="${token.content}" ${me && me.username == token.username ? 'data-is-me' : ''}>${token.content}</a>`; + return `<a href="${_URL_ + '/' + escape(token.username)}" target="_blank" data-user-preview="${token.content}" ${me && me.username == token.username ? 'data-is-me' : ''}>${token.content}</a>`; case 'hashtag': // TODO return `<a>${escape(token.content)}</a>`; case 'code': |