Merge branch 'master' of github.com:syuilo/misskey

This commit is contained in:
ha-dai 2017-11-30 13:24:41 +09:00
commit 105623e398
13 changed files with 171 additions and 17 deletions

View file

@ -2,6 +2,18 @@ ChangeLog (Release Notes)
========================= =========================
主に notable な changes を書いていきます 主に notable な changes を書いていきます
3230 (2017/11/28)
-----------------
* :v:
3219 (2017/11/28)
-----------------
* なんか
3212 (2017/11/27)
-----------------
* なんか
3201 (2017/11/23) 3201 (2017/11/23)
----------------- -----------------
* Twitterログインを実装 (#939) * Twitterログインを実装 (#939)

View file

@ -1,7 +1,7 @@
{ {
"name": "misskey", "name": "misskey",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"version": "0.0.3201", "version": "0.0.3230",
"license": "MIT", "license": "MIT",
"description": "A miniblog-based SNS", "description": "A miniblog-based SNS",
"bugs": "https://github.com/syuilo/misskey/issues", "bugs": "https://github.com/syuilo/misskey/issues",
@ -26,14 +26,14 @@
"@prezzemolo/zip": "0.0.3", "@prezzemolo/zip": "0.0.3",
"@types/bcryptjs": "2.4.1", "@types/bcryptjs": "2.4.1",
"@types/body-parser": "1.16.8", "@types/body-parser": "1.16.8",
"@types/chai": "4.0.5", "@types/chai": "4.0.6",
"@types/chai-http": "3.0.3", "@types/chai-http": "3.0.3",
"@types/compression": "0.0.35", "@types/compression": "0.0.35",
"@types/cookie": "0.3.1", "@types/cookie": "0.3.1",
"@types/cors": "2.8.3", "@types/cors": "2.8.3",
"@types/debug": "0.0.30", "@types/debug": "0.0.30",
"@types/deep-equal": "1.0.1", "@types/deep-equal": "1.0.1",
"@types/elasticsearch": "5.0.17", "@types/elasticsearch": "5.0.18",
"@types/event-stream": "3.3.33", "@types/event-stream": "3.3.33",
"@types/eventemitter3": "2.0.2", "@types/eventemitter3": "2.0.2",
"@types/express": "4.0.39", "@types/express": "4.0.39",
@ -48,9 +48,9 @@
"@types/inquirer": "0.0.35", "@types/inquirer": "0.0.35",
"@types/is-root": "1.0.0", "@types/is-root": "1.0.0",
"@types/is-url": "1.2.28", "@types/is-url": "1.2.28",
"@types/js-yaml": "3.10.0", "@types/js-yaml": "3.10.1",
"@types/mocha": "2.2.44", "@types/mocha": "2.2.44",
"@types/mongodb": "2.2.15", "@types/mongodb": "2.2.16",
"@types/monk": "1.0.6", "@types/monk": "1.0.6",
"@types/morgan": "1.7.35", "@types/morgan": "1.7.35",
"@types/ms": "0.7.30", "@types/ms": "0.7.30",
@ -60,7 +60,7 @@
"@types/proxy-addr": "2.0.0", "@types/proxy-addr": "2.0.0",
"@types/ratelimiter": "2.1.28", "@types/ratelimiter": "2.1.28",
"@types/redis": "2.8.1", "@types/redis": "2.8.1",
"@types/request": "2.0.7", "@types/request": "2.0.8",
"@types/rimraf": "2.0.2", "@types/rimraf": "2.0.2",
"@types/riot": "3.6.1", "@types/riot": "3.6.1",
"@types/seedrandom": "2.4.27", "@types/seedrandom": "2.4.27",
@ -69,7 +69,7 @@
"@types/uuid": "3.4.3", "@types/uuid": "3.4.3",
"@types/webpack": "3.8.1", "@types/webpack": "3.8.1",
"@types/webpack-stream": "3.2.8", "@types/webpack-stream": "3.2.8",
"@types/websocket": "0.0.34", "@types/websocket": "0.0.35",
"accesses": "2.5.0", "accesses": "2.5.0",
"animejs": "2.2.0", "animejs": "2.2.0",
"autwh": "0.0.1", "autwh": "0.0.1",
@ -92,7 +92,7 @@
"elasticsearch": "14.0.0", "elasticsearch": "14.0.0",
"escape-regexp": "0.0.1", "escape-regexp": "0.0.1",
"event-stream": "3.3.4", "event-stream": "3.3.4",
"eventemitter3": "2.0.3", "eventemitter3": "3.0.0",
"express": "4.16.2", "express": "4.16.2",
"file-type": "7.3.0", "file-type": "7.3.0",
"fuckadblock": "3.2.1", "fuckadblock": "3.2.1",
@ -113,7 +113,7 @@
"is-root": "1.0.0", "is-root": "1.0.0",
"is-url": "1.2.2", "is-url": "1.2.2",
"js-yaml": "3.10.0", "js-yaml": "3.10.0",
"mecab-async": "0.1.0", "mecab-async": "0.1.2",
"mocha": "4.0.1", "mocha": "4.0.1",
"moji": "0.5.1", "moji": "0.5.1",
"mongodb": "2.2.33", "mongodb": "2.2.33",
@ -153,8 +153,8 @@
"tmp": "0.0.33", "tmp": "0.0.33",
"ts-node": "3.3.0", "ts-node": "3.3.0",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.6.1", "typescript": "2.6.2",
"uglify-es": "3.1.10", "uglify-es": "3.2.0",
"uglifyjs-webpack-plugin": "1.1.1", "uglifyjs-webpack-plugin": "1.1.1",
"uuid": "3.1.0", "uuid": "3.1.0",
"vhost": "3.0.2", "vhost": "3.0.2",

View file

@ -45,7 +45,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
res({ res({
maintainer: config.maintainer, maintainer: config.maintainer,
version: version, version: version,
secure: config.https.enable, secure: config.https != null,
machine: os.hostname(), machine: os.hostname(),
os: os.platform(), os: os.platform(),
node: process.version, node: process.version,

View file

@ -69,4 +69,38 @@
script.setAttribute('async', 'true'); script.setAttribute('async', 'true');
script.setAttribute('defer', 'true'); script.setAttribute('defer', 'true');
head.appendChild(script); head.appendChild(script);
// 1秒経ってもスクリプトがロードされない場合はバージョンが古くて
// 404になっているせいかもしれないので、バージョンを確認して古ければ更新する
//
// 読み込まれたスクリプトからこのタイマーを解除できるように、
// グローバルにタイマーIDを代入しておく
window.mkBootTimer = window.setTimeout(async () => {
// Fetch meta
const res = await fetch(API + '/meta', {
method: 'POST',
cache: 'no-cache'
});
// Parse
const meta = await res.json();
// Compare versions
if (meta.version != VERSION) {
alert(
'Misskeyの新しいバージョンがあります。ページを再度読み込みします。' +
'\n\n' +
'New version of Misskey available. The page will be reloaded.');
// Clear cache (serive worker)
try {
navigator.serviceWorker.controller.postMessage('clear');
} catch (e) {
console.error(e);
}
// Force reload
location.reload(true);
}
}, 1000);
} }

View file

@ -29,7 +29,8 @@ export default (i, endpoint, data = {}): Promise<{ [x: string]: any }> => {
fetch(endpoint.indexOf('://') > -1 ? endpoint : `${_API_URL_}/${endpoint}`, { fetch(endpoint.indexOf('://') > -1 ? endpoint : `${_API_URL_}/${endpoint}`, {
method: 'POST', method: 'POST',
body: JSON.stringify(data), body: JSON.stringify(data),
credentials: endpoint === 'signin' ? 'include' : 'omit' credentials: endpoint === 'signin' ? 'include' : 'omit',
cache: 'no-cache'
}).then(res => { }).then(res => {
if (--pending === 0) spinner.parentNode.removeChild(spinner); if (--pending === 0) spinner.parentNode.removeChild(spinner);
if (res.status === 200) { if (res.status === 200) {

View file

@ -7,6 +7,14 @@ export default async function(mios: MiOS) {
if (meta.version != _VERSION_) { if (meta.version != _VERSION_) {
localStorage.setItem('should-refresh', 'true'); localStorage.setItem('should-refresh', 'true');
// Clear cache (serive worker)
try {
navigator.serviceWorker.controller.postMessage('clear');
} catch (e) {
console.error(e);
}
alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', _VERSION_)); alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', _VERSION_));
} }
} }

View file

@ -86,7 +86,9 @@
}); });
this.fetch = () => { this.fetch = () => {
fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.url}`).then(res => { fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.url}`, {
cache: 'no-cache'
}).then(res => {
res.json().then(feed => { res.json().then(feed => {
this.update({ this.update({
initializing: false, initializing: false,

View file

@ -19,6 +19,10 @@ require('./common/tags');
console.info(`Misskey v${_VERSION_} (葵 aoi)`); console.info(`Misskey v${_VERSION_} (葵 aoi)`);
// BootTimer解除
window.clearTimeout((window as any).mkBootTimer);
delete (window as any).mkBootTimer;
if (_HOST_ != 'localhost') { if (_HOST_ != 'localhost') {
document.domain = _HOST_; document.domain = _HOST_;
} }

View file

@ -4,9 +4,41 @@
import composeNotification from './common/scripts/compose-notification'; import composeNotification from './common/scripts/compose-notification';
// キャッシュするリソース
const cachee = [
'/'
];
// インストールされたとき // インストールされたとき
self.addEventListener('install', () => { self.addEventListener('install', ev => {
console.info('installed'); console.info('installed');
ev.waitUntil(Promise.all([
self.skipWaiting(), // Force activate
caches.open(_VERSION_).then(cache => cache.addAll(cachee)) // Cache
]));
});
// アクティベートされたとき
self.addEventListener('activate', ev => {
// Clean up old caches
ev.waitUntil(
caches.keys().then(keys => Promise.all(
keys
.filter(key => key != _VERSION_)
.map(key => caches.delete(key))
))
);
});
// リクエストが発生したとき
self.addEventListener('fetch', ev => {
ev.respondWith(
// キャッシュがあるか確認してあればそれを返す
caches.match(ev.request).then(response =>
response || fetch(ev.request)
)
);
}); });
// プッシュ通知を受け取ったとき // プッシュ通知を受け取ったとき
@ -31,3 +63,9 @@ self.addEventListener('push', ev => {
}); });
})); }));
}); });
self.addEventListener('message', ev => {
if (ev.data == 'clear') {
caches.keys().then(keys => keys.forEach(key => caches.delete(key)));
}
});

15
src/web/assets/404.js Normal file
View file

@ -0,0 +1,15 @@
const yn = window.confirm(
'サーバー上に存在しないスクリプトがリクエストされました。お使いのMisskeyのバージョンが古いことが原因の可能性があります。Misskeyを更新しますか');
if (yn) {
// Clear cache (serive worker)
try {
navigator.serviceWorker.controller.postMessage('clear');
} catch (e) {
console.error(e);
}
location.reload(true);
} else {
alert('問題が解決しない場合はサーバー管理者までお問い合せください。');
}

View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Misskeyのリカバリ</title>
<script>
const yn = window.confirm('キャッシュをクリアしますか?\n\nDo you want to clear caches?');
if (yn) {
try {
navigator.serviceWorker.controller.postMessage('clear');
navigator.serviceWorker.getRegistrations().then(registrations => {
registrations.forEach(registration => registration.unregister());
});
} catch (e) {
console.error(e);
}
localStorage.setItem('should-refresh', 'true');
alert('キャッシュをクリアしました。');
location.href = '/';
} else {
alert('問題が解決しない場合はサーバー管理者までお問い合せください。');
}
</script>
</head>
</html>

View file

@ -39,6 +39,12 @@ app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets
app.use('/assets', express.static(`${__dirname}/assets`, { app.use('/assets', express.static(`${__dirname}/assets`, {
maxAge: ms('7 days') maxAge: ms('7 days')
})); }));
app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/404.js`));
app.use('/assets', (req, res) => {
res.sendStatus(404);
});
app.use('/recover', (req, res) => res.sendFile(`${__dirname}/assets/recover.html`));
/** /**
* ServiceWroker * ServiceWroker

View file

@ -2,7 +2,7 @@ const StringReplacePlugin = require('string-replace-webpack-plugin');
import consts from './consts'; import consts from './consts';
import hoist from './hoist'; import hoist from './hoist';
//import minify from './minify'; import minify from './minify';
import banner from './banner'; import banner from './banner';
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
@ -16,7 +16,7 @@ export default (version, lang) => {
]; ];
if (isProduction) { if (isProduction) {
//plugins.push(minify()); plugins.push(minify());
} }
plugins.push(banner(version)); plugins.push(banner(version));