From 9820a691c154e7233b8327cedc7faa1f6c4e55e8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Feb 2017 04:19:53 +0900 Subject: [PATCH] well done --- README.md | 4 ++-- src/web/app/boot.js | 4 +++- src/web/app/common/scripts/api.js | 2 ++ src/web/app/common/scripts/config.js | 18 +++++++++++++++++ .../app/common/scripts/messaging-stream.js | 1 + src/web/app/common/scripts/signout.js | 2 ++ src/web/app/common/scripts/stream.js | 1 + src/web/app/common/scripts/text-compiler.js | 1 + src/web/app/common/tags/signup.tag | 20 ++++++++++++++----- src/web/app/desktop/scripts/update-avatar.js | 1 + src/web/app/desktop/scripts/update-banner.js | 1 + src/web/server.ts | 11 ++++++++++ 12 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 src/web/app/common/scripts/config.js diff --git a/README.md b/README.md index 52666390e2..32b86f8dc6 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,7 @@ and more! You can touch with your own eyes at https://misskey.xyz/. 2. `git clone git://github.com/syuilo/misskey.git` 3. `cd misskey` 4. `npm install` -5. `npm run config` -6. `npm run build` +5. `npm run build` GLHF! @@ -92,6 +91,7 @@ If you want to run misskey in production mode, add `--env NODE_ENV=production` l Note that `$(pwd)` is the working directory. ## Launch +(初回起動時はまず `npm run config` してください) `sudo npm start` ## Debugging :bug: diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 5fc7524626..d39e46861c 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -17,11 +17,13 @@ require('./common/tags'); "use strict"; +const CONFIG = require('./common/scripts/config'); + document.domain = CONFIG.host; // Set global configration riot.mixin({ - CONFIG: CONFIG + CONFIG }); // ↓ iOS待ちPolyfill (SEE: http://caniuse.com/#feat=fetch) diff --git a/src/web/app/common/scripts/api.js b/src/web/app/common/scripts/api.js index b549fe47b9..be72f863d6 100644 --- a/src/web/app/common/scripts/api.js +++ b/src/web/app/common/scripts/api.js @@ -2,6 +2,8 @@ * API Request */ +const CONFIG = require('./config'); + let spinner = null; let pending = 0; diff --git a/src/web/app/common/scripts/config.js b/src/web/app/common/scripts/config.js new file mode 100644 index 0000000000..5123402414 --- /dev/null +++ b/src/web/app/common/scripts/config.js @@ -0,0 +1,18 @@ +const url = new URL(location.href); + +const isRoot = 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 apiUrl = `${scheme}//api.${host}`; +const devUrl = `${scheme}//dev.${host}`; +const aboutUrl = `${scheme}//about.${host}`; + +module.exports = { + host, + scheme, + apiUrl, + devUrl, + aboutUrl, + themeColor: '#f76d6c' +}; diff --git a/src/web/app/common/scripts/messaging-stream.js b/src/web/app/common/scripts/messaging-stream.js index 2c00c24024..0c8ce3c9d2 100644 --- a/src/web/app/common/scripts/messaging-stream.js +++ b/src/web/app/common/scripts/messaging-stream.js @@ -1,5 +1,6 @@ const ReconnectingWebSocket = require('reconnecting-websocket'); const riot = require('riot'); +const CONFIG = require('./config'); class Connection { constructor(me, otherparty) { diff --git a/src/web/app/common/scripts/signout.js b/src/web/app/common/scripts/signout.js index cd752423da..7242ebc5b0 100644 --- a/src/web/app/common/scripts/signout.js +++ b/src/web/app/common/scripts/signout.js @@ -1,3 +1,5 @@ +const CONFIG = require('./config'); + module.exports = () => { localStorage.removeItem('me'); document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; diff --git a/src/web/app/common/scripts/stream.js b/src/web/app/common/scripts/stream.js index 34ddc8447d..fd7bac7faa 100644 --- a/src/web/app/common/scripts/stream.js +++ b/src/web/app/common/scripts/stream.js @@ -1,5 +1,6 @@ const ReconnectingWebSocket = require('reconnecting-websocket'); const riot = require('riot'); +const CONFIG = require('./config'); module.exports = me => { let state = 'initializing'; diff --git a/src/web/app/common/scripts/text-compiler.js b/src/web/app/common/scripts/text-compiler.js index 62e70463ad..c9eb73e870 100644 --- a/src/web/app/common/scripts/text-compiler.js +++ b/src/web/app/common/scripts/text-compiler.js @@ -1,5 +1,6 @@ const riot = require('riot'); const nyaize = require('nyaize').default; +const CONFIG = require('./config'); const escape = function(text) { return text diff --git a/src/web/app/common/tags/signup.tag b/src/web/app/common/tags/signup.tag index f0358e2328..a70399a872 100644 --- a/src/web/app/common/tags/signup.tag +++ b/src/web/app/common/tags/signup.tag @@ -30,7 +30,7 @@