parent
1809800980
commit
3f8ebac466
46 changed files with 244 additions and 225 deletions
|
|
@ -3,11 +3,12 @@ import * as riot from 'riot';
|
|||
import signout from './scripts/signout';
|
||||
import Progress from './scripts/loading';
|
||||
import HomeStreamManager from './scripts/streaming/home-stream-manager';
|
||||
import CONFIG from './scripts/config';
|
||||
import api from './scripts/api';
|
||||
|
||||
declare var VERSION: string;
|
||||
declare var LANG: string;
|
||||
declare const _VERSION_: string;
|
||||
declare const _LANG_: string;
|
||||
declare const _API_URL_: string;
|
||||
declare const _SW_PUBLICKEY_: string;
|
||||
|
||||
/**
|
||||
* Misskey Operating System
|
||||
|
|
@ -113,7 +114,7 @@ export default class MiOS extends EventEmitter {
|
|||
}
|
||||
|
||||
// Fetch user
|
||||
fetch(`${CONFIG.apiUrl}/i`, {
|
||||
fetch(`${_API_URL_}/i`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
i: token
|
||||
|
|
@ -229,10 +230,15 @@ export default class MiOS extends EventEmitter {
|
|||
this.swRegistration = registration;
|
||||
|
||||
// Options of pushManager.subscribe
|
||||
// SEE: https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe#Parameters
|
||||
const opts = {
|
||||
// A boolean indicating that the returned push subscription
|
||||
// will only be used for messages whose effect is made visible to the user.
|
||||
userVisibleOnly: true
|
||||
userVisibleOnly: true,
|
||||
|
||||
// A public key your push server will use to send
|
||||
// messages to client apps via a push server.
|
||||
applicationServerKey: urlBase64ToUint8Array(_SW_PUBLICKEY_)
|
||||
};
|
||||
|
||||
// Subscribe push notification
|
||||
|
|
@ -257,7 +263,7 @@ export default class MiOS extends EventEmitter {
|
|||
});
|
||||
|
||||
// The path of service worker script
|
||||
const sw = `/sw.${VERSION}.${LANG}.js`;
|
||||
const sw = `/sw.${_VERSION_}.${_LANG_}.js`;
|
||||
|
||||
// Register service worker
|
||||
navigator.serviceWorker.register(sw).then(registration => {
|
||||
|
|
@ -310,3 +316,22 @@ export default class MiOS extends EventEmitter {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the URL safe base64 string to a Uint8Array
|
||||
* @param base64String base64 string
|
||||
*/
|
||||
function urlBase64ToUint8Array(base64String: string): Uint8Array {
|
||||
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
||||
const base64 = (base64String + padding)
|
||||
.replace(/\-/g, '+')
|
||||
.replace(/_/g, '/');
|
||||
|
||||
const rawData = window.atob(base64);
|
||||
const outputArray = new Uint8Array(rawData.length);
|
||||
|
||||
for (let i = 0; i < rawData.length; ++i) {
|
||||
outputArray[i] = rawData.charCodeAt(i);
|
||||
}
|
||||
return outputArray;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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_));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
@ -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 = '/';
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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]))
|
||||
|
|
|
|||
|
|
@ -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':
|
||||
|
|
|
|||
|
|
@ -170,8 +170,6 @@
|
|||
|
||||
</style>
|
||||
<script>
|
||||
import CONFIG from '../../common/scripts/config';
|
||||
|
||||
this.on('mount', () => {
|
||||
this.update({
|
||||
network: navigator.onLine
|
||||
|
|
@ -193,7 +191,7 @@
|
|||
});
|
||||
|
||||
// Check misskey server is available
|
||||
fetch(`${CONFIG.apiUrl}/meta`).then(() => {
|
||||
fetch(`${_API_URL_}/meta`).then(() => {
|
||||
this.update({
|
||||
end: true,
|
||||
server: true
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<h1>Misskeyとは?</h1>
|
||||
<p><ruby>Misskey<rt>みすきー</rt></ruby>は、<a href="http://syuilo.com" target="_blank">syuilo</a>が2014年くらいから<a href="https://github.com/syuilo/misskey" target="_blank">オープンソースで</a>開発・運営を行っている、ミニブログベースのSNSです。</p>
|
||||
<p>無料で誰でも利用でき、広告も掲載していません。</p>
|
||||
<p><a href={ CONFIG.aboutUrl } target="_blank">もっと知りたい方はこちら</a></p>
|
||||
<p><a href={ _ABOUT_URL_ } target="_blank">もっと知りたい方はこちら</a></p>
|
||||
</article>
|
||||
<style>
|
||||
:scope
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<mk-nav-links>
|
||||
<a href={ CONFIG.aboutUrl }>%i18n:common.tags.mk-nav-links.about%</a><i>・</i><a href={ CONFIG.statsUrl }>%i18n:common.tags.mk-nav-links.stats%</a><i>・</i><a href={ CONFIG.statusUrl }>%i18n:common.tags.mk-nav-links.status%</a><i>・</i><a href="http://zawazawa.jp/misskey/">%i18n:common.tags.mk-nav-links.wiki%</a><i>・</i><a href="https://github.com/syuilo/misskey/blob/master/DONORS.md">%i18n:common.tags.mk-nav-links.donors%</a><i>・</i><a href="https://github.com/syuilo/misskey">%i18n:common.tags.mk-nav-links.repository%</a><i>・</i><a href={ CONFIG.devUrl }>%i18n:common.tags.mk-nav-links.develop%</a><i>・</i><a href="https://twitter.com/misskey_xyz" target="_blank">Follow us on <i class="fa fa-twitter"></i></a>
|
||||
<a href={ _ABOUT_URL_ }>%i18n:common.tags.mk-nav-links.about%</a><i>・</i><a href={ _STATS_URL_ }>%i18n:common.tags.mk-nav-links.stats%</a><i>・</i><a href={ _STATUS_URL_ }>%i18n:common.tags.mk-nav-links.status%</a><i>・</i><a href="http://zawazawa.jp/misskey/">%i18n:common.tags.mk-nav-links.wiki%</a><i>・</i><a href="https://github.com/syuilo/misskey/blob/master/DONORS.md">%i18n:common.tags.mk-nav-links.donors%</a><i>・</i><a href="https://github.com/syuilo/misskey">%i18n:common.tags.mk-nav-links.repository%</a><i>・</i><a href={ _DEV_URL_ }>%i18n:common.tags.mk-nav-links.develop%</a><i>・</i><a href="https://twitter.com/misskey_xyz" target="_blank">Follow us on <i class="fa fa-twitter"></i></a>
|
||||
<style>
|
||||
:scope
|
||||
display inline
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<label class="username">
|
||||
<p class="caption"><i class="fa fa-at"></i>%i18n:common.tags.mk-signup.username%</p>
|
||||
<input ref="username" type="text" pattern="^[a-zA-Z0-9-]{3,20}$" placeholder="a~z、A~Z、0~9、-" autocomplete="off" required="required" onkeyup={ onChangeUsername }/>
|
||||
<p class="profile-page-url-preview" if={ refs.username.value != '' && username-state != 'invalidFormat' && username-state != 'minRange' && username-state != 'maxRange' }>{ CONFIG.url + '/' + refs.username.value }</p>
|
||||
<p class="profile-page-url-preview" if={ refs.username.value != '' && username-state != 'invalidFormat' && username-state != 'minRange' && username-state != 'maxRange' }>{ _URL_ + '/' + refs.username.value }</p>
|
||||
<p class="info" if={ usernameState == 'wait' } style="color:#999"><i class="fa fa-fw fa-spinner fa-pulse"></i>%i18n:common.tags.mk-signup.checking%</p>
|
||||
<p class="info" if={ usernameState == 'ok' } style="color:#3CB7B5"><i class="fa fa-fw fa-check"></i>%i18n:common.tags.mk-signup.available%</p>
|
||||
<p class="info" if={ usernameState == 'unavailable' } style="color:#FF1161"><i class="fa fa-fw fa-exclamation-triangle"></i>%i18n:common.tags.mk-signup.unavailable%</p>
|
||||
|
|
@ -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>%i18n:common.tags.mk-signup.recaptcha%</p>
|
||||
<div if={ recaptcha } class="g-recaptcha" data-callback="onRecaptchaed" data-expired-callback="onRecaptchaExpired" data-sitekey={ recaptcha.siteKey }></div>
|
||||
<div if={ recaptcha } class="g-recaptcha" data-callback="onRecaptchaed" data-expired-callback="onRecaptchaExpired" data-sitekey={ recaptcha.site_key }></div>
|
||||
</label>
|
||||
<label class="agree-tou">
|
||||
<input name="agree-tou" type="checkbox" autocomplete="off" required="required"/>
|
||||
|
|
@ -193,20 +193,16 @@
|
|||
};
|
||||
|
||||
this.on('mount', () => {
|
||||
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.update({
|
||||
recaptcha: {
|
||||
site_key: _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 = () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<mk-twitter-setting>
|
||||
<p>%i18n:common.tags.mk-twitter-setting.description%<a href={ CONFIG.aboutUrl + '/link-to-twitter' } target="_blank">%i18n:common.tags.mk-twitter-setting.detail%</a></p>
|
||||
<p>%i18n:common.tags.mk-twitter-setting.description%<a href={ _ABOUT_URL_ + '/link-to-twitter' } target="_blank">%i18n:common.tags.mk-twitter-setting.detail%</a></p>
|
||||
<p class="account" if={ I.twitter } title={ 'Twitter ID: ' + I.twitter.user_id }>%i18n:common.tags.mk-twitter-setting.connected-to%: <a href={ 'https://twitter.com/' + I.twitter.screen_name } target="_blank">@{ I.twitter.screen_name }</a></p>
|
||||
<p>
|
||||
<a href={ CONFIG.apiUrl + '/connect/twitter' } target="_blank" onclick={ connect }>{ I.twitter ? '%i18n:common.tags.mk-twitter-setting.reconnect%' : '%i18n:common.tags.mk-twitter-setting.connect%' }</a>
|
||||
<a href={ _API_URL_ + '/connect/twitter' } target="_blank" onclick={ connect }>{ I.twitter ? '%i18n:common.tags.mk-twitter-setting.reconnect%' : '%i18n:common.tags.mk-twitter-setting.connect%' }</a>
|
||||
<span if={ I.twitter }> or </span>
|
||||
<a href={ CONFIG.apiUrl + '/disconnect/twitter' } target="_blank" if={ I.twitter } onclick={ disconnect }>%i18n:common.tags.mk-twitter-setting.disconnect%</a>
|
||||
<a href={ _API_URL_ + '/disconnect/twitter' } target="_blank" if={ I.twitter } onclick={ disconnect }>%i18n:common.tags.mk-twitter-setting.disconnect%</a>
|
||||
</p>
|
||||
<p class="id" if={ I.twitter }>Twitter ID: { I.twitter.user_id }</p>
|
||||
<style>
|
||||
|
|
@ -25,8 +25,6 @@
|
|||
color #8899a6
|
||||
</style>
|
||||
<script>
|
||||
import CONFIG from '../scripts/config';
|
||||
|
||||
this.mixin('i');
|
||||
|
||||
this.form = null;
|
||||
|
|
@ -47,7 +45,7 @@
|
|||
|
||||
this.connect = e => {
|
||||
e.preventDefault();
|
||||
this.form = window.open(CONFIG.apiUrl + '/connect/twitter',
|
||||
this.form = window.open(_API_URL_ + '/connect/twitter',
|
||||
'twitter_connect_window',
|
||||
'height=570,width=520');
|
||||
return false;
|
||||
|
|
@ -55,7 +53,7 @@
|
|||
|
||||
this.disconnect = e => {
|
||||
e.preventDefault();
|
||||
window.open(CONFIG.apiUrl + '/disconnect/twitter',
|
||||
window.open(_API_URL_ + '/disconnect/twitter',
|
||||
'twitter_disconnect_window',
|
||||
'height=570,width=520');
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@
|
|||
if (folder) data.append('folder_id', folder);
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', this.CONFIG.apiUrl + '/drive/files/create', true);
|
||||
xhr.open('POST', _API_URL_ + '/drive/files/create', true);
|
||||
xhr.onload = e => {
|
||||
const driveFile = JSON.parse(e.target.response);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue