diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-08-19 19:15:29 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-08-19 19:15:29 +0900 |
| commit | c9de5b65d4d234899725ba2c7f884041bd3d463b (patch) | |
| tree | 10cbf0f6845fc1648f1c35942b329b0f73a4a46c /src | |
| parent | Merge pull request #2348 from mei23/mei-0819-nsfw3 (diff) | |
| download | sharkey-c9de5b65d4d234899725ba2c7f884041bd3d463b.tar.gz sharkey-c9de5b65d4d234899725ba2c7f884041bd3d463b.tar.bz2 sharkey-c9de5b65d4d234899725ba2c7f884041bd3d463b.zip | |
wip
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/common/views/components/signup.vue | 23 | ||||
| -rw-r--r-- | src/client/app/config.ts | 43 | ||||
| -rw-r--r-- | src/server/api/endpoints/meta.ts | 7 |
3 files changed, 23 insertions, 50 deletions
diff --git a/src/client/app/common/views/components/signup.vue b/src/client/app/common/views/components/signup.vue index 1d33702159..810b850831 100644 --- a/src/client/app/common/views/components/signup.vue +++ b/src/client/app/common/views/components/signup.vue @@ -34,7 +34,7 @@ <p slot="text" v-if="passwordRetypeState == 'not-match'" style="color:#FF1161">%fa:exclamation-triangle .fw% %i18n:@password-not-matched%</p> </div> </ui-input> - <div v-if="recaptchaSitekey != null" class="g-recaptcha" :data-sitekey="recaptchaSitekey" style="margin: 16px 0;"></div> + <div v-if="meta && meta.recaptchaSitekey != null" class="g-recaptcha" :data-sitekey="meta.recaptchaSitekey" style="margin: 16px 0;"></div> <ui-button type="submit">%i18n:@create%</ui-button> </form> </template> @@ -42,7 +42,7 @@ <script lang="ts"> import Vue from 'vue'; const getPasswordStrength = require('syuilo-password-strength'); -import { host, url, recaptchaSitekey } from '../../../config'; +import { host, url } from '../../../config'; export default Vue.extend({ data() { @@ -53,7 +53,6 @@ export default Vue.extend({ retypedPassword: '', invitationCode: '', url, - recaptchaSitekey, usernameState: null, passwordStrength: '', passwordRetypeState: null, @@ -73,6 +72,12 @@ export default Vue.extend({ this.meta = meta; }); }, + mounted() { + const head = document.getElementsByTagName('head')[0]; + const script = document.createElement('script'); + script.setAttribute('src', 'https://www.google.com/recaptcha/api.js'); + head.appendChild(script); + }, methods: { onChangeUsername() { if (this.username == '') { @@ -123,7 +128,7 @@ export default Vue.extend({ username: this.username, password: this.password, invitationCode: this.invitationCode, - 'g-recaptcha-response': recaptchaSitekey != null ? (window as any).grecaptcha.getResponse() : null + 'g-recaptcha-response': this.meta.recaptchaSitekey != null ? (window as any).grecaptcha.getResponse() : null }).then(() => { (this as any).api('signin', { username: this.username, @@ -134,19 +139,11 @@ export default Vue.extend({ }).catch(() => { alert('%i18n:@some-error%'); - if (recaptchaSitekey != null) { + if (this.meta.recaptchaSitekey != null) { (window as any).grecaptcha.reset(); } }); } - }, - mounted() { - if (recaptchaSitekey != null) { - const head = document.getElementsByTagName('head')[0]; - const script = document.createElement('script'); - script.setAttribute('src', 'https://www.google.com/recaptcha/api.js'); - head.appendChild(script); - } } }); </script> diff --git a/src/client/app/config.ts b/src/client/app/config.ts index 04486ea230..76cd536a49 100644 --- a/src/client/app/config.ts +++ b/src/client/app/config.ts @@ -1,51 +1,22 @@ -declare const _HOST_: string; -declare const _HOSTNAME_: string; -declare const _URL_: string; -declare const _NAME_: string; -declare const _DESCRIPTION_: string; -declare const _API_URL_: string; -declare const _WS_URL_: string; -declare const _DOCS_URL_: string; -declare const _STATS_URL_: string; -declare const _STATUS_URL_: string; -declare const _DEV_URL_: string; -declare const _REPOSITORY_URL_: string; -declare const _FEEDBACK_URL_: string; declare const _LANG_: string; declare const _LANGS_: string; -declare const _RECAPTCHA_SITEKEY_: string; -declare const _SW_PUBLICKEY_: string; declare const _THEME_COLOR_: string; declare const _COPYRIGHT_: string; declare const _VERSION_: string; declare const _CODENAME_: string; declare const _LICENSE_: string; -declare const _GOOGLE_MAPS_API_KEY_: string; -declare const _WELCOME_BG_URL_: string; -declare const _TWITTER_INTEGRATION_: boolean; -export const host = _HOST_; -export const hostname = _HOSTNAME_; -export const url = _URL_; -export const name = _NAME_; -export const description = _DESCRIPTION_; -export const apiUrl = _API_URL_; -export const wsUrl = _WS_URL_; -export const docsUrl = _DOCS_URL_; -export const statsUrl = _STATS_URL_; -export const statusUrl = _STATUS_URL_; -export const devUrl = _DEV_URL_; -export const repositoryUrl = _REPOSITORY_URL_; -export const feedbackUrl = _FEEDBACK_URL_; +const address = new URL(location.href); + +export const host = address.host; +export const hostname = address.hostname; +export const url = address.origin; +export const apiUrl = url + '/api'; +export const wsUrl = url.replace('http://', 'ws://').replace('https://', 'wss://'); export const lang = _LANG_; export const langs = _LANGS_; -export const recaptchaSitekey = _RECAPTCHA_SITEKEY_; -export const swPublickey = _SW_PUBLICKEY_; export const themeColor = _THEME_COLOR_; export const copyright = _COPYRIGHT_; export const version = _VERSION_; export const codename = _CODENAME_; export const license = _LICENSE_; -export const googleMapsApiKey = _GOOGLE_MAPS_API_KEY_; -export const welcomeBgUrl = _WELCOME_BG_URL_; -export const twitterIntegration = _TWITTER_INTEGRATION_; diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 000a56024d..505ff60068 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -20,6 +20,9 @@ export default () => new Promise(async (res, rej) => { version: pkg.version, clientVersion: client.version, + name: config.name || 'Misskey', + description: config.description, + secure: config.https != null, machine: os.hostname(), os: os.platform(), @@ -29,6 +32,8 @@ export default () => new Promise(async (res, rej) => { cores: os.cpus().length }, broadcasts: meta.broadcasts, - disableRegistration: meta.disableRegistration + disableRegistration: meta.disableRegistration, + recaptchaSitekey: config.recaptcha.site_key, + swPublickey: config.sw.public_key }); }); |