diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 04:19:53 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 04:19:53 +0900 |
| commit | 9820a691c154e7233b8327cedc7faa1f6c4e55e8 (patch) | |
| tree | d62b2e92a3a1cfae3798cf8e676a2f740dabadb2 /src/web/app/common | |
| parent | Merge remote-tracking branch 'refs/remotes/origin/master' into no-build-requi... (diff) | |
| download | sharkey-9820a691c154e7233b8327cedc7faa1f6c4e55e8.tar.gz sharkey-9820a691c154e7233b8327cedc7faa1f6c4e55e8.tar.bz2 sharkey-9820a691c154e7233b8327cedc7faa1f6c4e55e8.zip | |
well done
Diffstat (limited to 'src/web/app/common')
| -rw-r--r-- | src/web/app/common/scripts/api.js | 2 | ||||
| -rw-r--r-- | src/web/app/common/scripts/config.js | 18 | ||||
| -rw-r--r-- | src/web/app/common/scripts/messaging-stream.js | 1 | ||||
| -rw-r--r-- | src/web/app/common/scripts/signout.js | 2 | ||||
| -rw-r--r-- | src/web/app/common/scripts/stream.js | 1 | ||||
| -rw-r--r-- | src/web/app/common/scripts/text-compiler.js | 1 | ||||
| -rw-r--r-- | src/web/app/common/tags/signup.tag | 20 |
7 files changed, 40 insertions, 5 deletions
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 @@ </label> <label class="recaptcha"> <p class="caption"><i class="fa fa-toggle-on" if={ recaptchaed }></i><i class="fa fa-toggle-off" if={ !recaptchaed }></i>認証</p> - <div class="g-recaptcha" data-callback="onRecaptchaed" data-expired-callback="onRecaptchaExpired" data-sitekey={ CONFIG.recaptcha.siteKey }></div> + <div if={ recaptcha } class="g-recaptcha" data-callback="onRecaptchaed" data-expired-callback="onRecaptchaExpired" data-sitekey={ recaptcha.siteKey }></div> </label> <label class="agree-tou"> <input name="agree-tou" type="checkbox" autocomplete="off" required="required"/> @@ -193,10 +193,20 @@ }; this.on('mount', () => { - const head = document.getElementsByTagName('head')[0]; - const script = document.createElement('script'); - script.setAttribute('src', 'https://www.google.com/recaptcha/api.js'); - head.appendChild(script); + fetch('/config.json').then(res => { + res.json().then(conf => { + this.update({ + recaptcha: { + siteKey: conf.recaptcha.siteKey + } + }); + + const head = document.getElementsByTagName('head')[0]; + const script = document.createElement('script'); + script.setAttribute('src', 'https://www.google.com/recaptcha/api.js'); + head.appendChild(script); + }); + }); }); this.onChangeUsername = () => { |