summaryrefslogtreecommitdiff
path: root/src/web/app
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-02-22 04:19:53 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-02-22 04:19:53 +0900
commit9820a691c154e7233b8327cedc7faa1f6c4e55e8 (patch)
treed62b2e92a3a1cfae3798cf8e676a2f740dabadb2 /src/web/app
parentMerge remote-tracking branch 'refs/remotes/origin/master' into no-build-requi... (diff)
downloadsharkey-9820a691c154e7233b8327cedc7faa1f6c4e55e8.tar.gz
sharkey-9820a691c154e7233b8327cedc7faa1f6c4e55e8.tar.bz2
sharkey-9820a691c154e7233b8327cedc7faa1f6c4e55e8.zip
well done
Diffstat (limited to 'src/web/app')
-rw-r--r--src/web/app/boot.js4
-rw-r--r--src/web/app/common/scripts/api.js2
-rw-r--r--src/web/app/common/scripts/config.js18
-rw-r--r--src/web/app/common/scripts/messaging-stream.js1
-rw-r--r--src/web/app/common/scripts/signout.js2
-rw-r--r--src/web/app/common/scripts/stream.js1
-rw-r--r--src/web/app/common/scripts/text-compiler.js1
-rw-r--r--src/web/app/common/tags/signup.tag20
-rw-r--r--src/web/app/desktop/scripts/update-avatar.js1
-rw-r--r--src/web/app/desktop/scripts/update-banner.js1
10 files changed, 45 insertions, 6 deletions
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 @@
</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 = () => {
diff --git a/src/web/app/desktop/scripts/update-avatar.js b/src/web/app/desktop/scripts/update-avatar.js
index c9bf866150..f3c4594ffd 100644
--- a/src/web/app/desktop/scripts/update-avatar.js
+++ b/src/web/app/desktop/scripts/update-avatar.js
@@ -1,4 +1,5 @@
const riot = require('riot');
+const CONFIG = require('../../common/scripts/config');
const dialog = require('./dialog');
const api = require('../../common/scripts/api');
diff --git a/src/web/app/desktop/scripts/update-banner.js b/src/web/app/desktop/scripts/update-banner.js
index 2ee918db89..51a107cf4c 100644
--- a/src/web/app/desktop/scripts/update-banner.js
+++ b/src/web/app/desktop/scripts/update-banner.js
@@ -1,4 +1,5 @@
const riot = require('riot');
+const CONFIG = require('../../common/scripts/config');
const dialog = require('./dialog');
const api = require('../../common/scripts/api');