summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-18 00:02:41 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-18 00:02:53 +0900
commit5ad77e8a3a7d3771559b02ea5c3e445ff2983533 (patch)
treed6fbaa72a612baadee18e24c9ebc7e6a1fa3eb54 /src
parent7.7.3 (diff)
downloadsharkey-5ad77e8a3a7d3771559b02ea5c3e445ff2983533.tar.gz
sharkey-5ad77e8a3a7d3771559b02ea5c3e445ff2983533.tar.bz2
sharkey-5ad77e8a3a7d3771559b02ea5c3e445ff2983533.zip
nanka iroiro
Diffstat (limited to 'src')
-rw-r--r--src/api/endpoints/meta.ts6
-rw-r--r--src/version.ts12
-rw-r--r--src/web/app/auth/view.pug5
-rw-r--r--src/web/app/base.pug10
-rw-r--r--src/web/app/boot.js20
-rw-r--r--src/web/app/client/script.js15
-rw-r--r--src/web/app/dev/view.pug3
7 files changed, 56 insertions, 15 deletions
diff --git a/src/api/endpoints/meta.ts b/src/api/endpoints/meta.ts
index ea2a8206ad..0cbeaae820 100644
--- a/src/api/endpoints/meta.ts
+++ b/src/api/endpoints/meta.ts
@@ -2,7 +2,7 @@
* Module dependencies
*/
import prominence from 'prominence';
-import git from 'git-last-commit';
+import getVersion from '../../version';
import config from '../../conf';
/**
@@ -39,11 +39,11 @@ import config from '../../conf';
* @return {Promise<any>}
*/
module.exports = (params) => new Promise(async (res, rej) => {
- const commit = await prominence(git).getLastCommit();
+ const version = await getVersion.then();
res({
maintainer: config.maintainer,
- commit: commit.shortHash,
+ version: version,
secure: config.https.enable
});
});
diff --git a/src/version.ts b/src/version.ts
new file mode 100644
index 0000000000..1022ab83b3
--- /dev/null
+++ b/src/version.ts
@@ -0,0 +1,12 @@
+import prominence = require('prominence');
+import git = require('git-last-commit');
+
+const getVersion = new Promise<string>(async resolve => {
+ const commit = await prominence(git).getLastCommit();
+
+ const version = commit.shortHash;
+
+ resolve(version);
+});
+
+export default getVersion;
diff --git a/src/web/app/auth/view.pug b/src/web/app/auth/view.pug
index 94ec12a9af..03ec4e6f72 100644
--- a/src/web/app/auth/view.pug
+++ b/src/web/app/auth/view.pug
@@ -1,6 +1,5 @@
extends ../base
block head
- meta(name='viewport', content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no')
- link(rel='stylesheet', href='/resources/auth/style.css')
- script(src='/resources/auth/script.js', async, defer)
+ meta(name='viewport' content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no')
+ script(src=`/resources/auth/script.${version}.js` async defer)
diff --git a/src/web/app/base.pug b/src/web/app/base.pug
index e65726fba5..90fb7b24a2 100644
--- a/src/web/app/base.pug
+++ b/src/web/app/base.pug
@@ -2,17 +2,17 @@ doctype html
!= '\r\n<!-- Thank you for using Misskey! @syuilo -->\r\n'
-html(lang='ja', dir='ltr')
+html(lang='ja' dir='ltr')
head
meta(charset='utf-8')
- meta(name='application-name', content='Misskey')
- meta(name='theme-color', content= themeColor)
- meta(name='referrer', content='origin')
+ meta(name='application-name' content='Misskey')
+ meta(name='theme-color' content=themeColor)
+ meta(name='referrer' content='origin')
title Misskey
style
include ./../../../built/web/resources/init.css
- script(src='https://use.fontawesome.com/22aba0df4f.js', async)
+ script(src='https://use.fontawesome.com/22aba0df4f.js' async)
block head
body
diff --git a/src/web/app/boot.js b/src/web/app/boot.js
index 6741a44231..4d008ad66f 100644
--- a/src/web/app/boot.js
+++ b/src/web/app/boot.js
@@ -49,6 +49,26 @@ try {
Storage.prototype.setItem = () => { }; // noop
}
+// クライアントを更新すべきならする
+if (localStorage.getItem('should-refresh') == 'true') {
+ localStorage.removeItem('should-refresh');
+ location.reload(true);
+}
+
+// 更新チェック
+setTimeout(() => {
+ fetch(CONFIG.apiUrl + '/meta', {
+ method: 'POST'
+ }).then(res => {
+ res.json().then(meta => {
+ if (meta.version != VERSION) {
+ localStorage.setItem('should-refresh', 'true');
+ alert('Misskeyの新しいバージョンがあります。ページを再度読み込みすると更新が適用されます。');
+ }
+ });
+ });
+}, 3000);
+
// ユーザーをフェッチしてコールバックする
module.exports = callback => {
// Get cached account data
diff --git a/src/web/app/client/script.js b/src/web/app/client/script.js
index dcd6bb16f2..ffc9c892cd 100644
--- a/src/web/app/client/script.js
+++ b/src/web/app/client/script.js
@@ -1,18 +1,29 @@
+/**
+ * MISSKEY ENTRY POINT
+ */
(() => {
const head = document.getElementsByTagName('head')[0];
+
+ // Detect user agent
const ua = navigator.userAgent.toLowerCase();
const isMobile = /mobile|iphone|ipad|android/.test(ua);
isMobile ? mountMobile() : mountDesktop();
+ /**
+ * Mount the desktop app
+ */
function mountDesktop() {
const script = document.createElement('script');
- script.setAttribute('src', '/resources/desktop/script.js');
+ script.setAttribute('src', `/resources/desktop/script.${VERSION}.js`);
script.setAttribute('async', 'true');
script.setAttribute('defer', 'true');
head.appendChild(script);
}
+ /**
+ * Mount the mobile app
+ */
function mountMobile() {
const meta = document.createElement('meta');
meta.setAttribute('name', 'viewport');
@@ -20,7 +31,7 @@
head.appendChild(meta);
const script = document.createElement('script');
- script.setAttribute('src', '/resources/mobile/script.js');
+ script.setAttribute('src', `/resources/mobile/script.${VERSION}.js`);
script.setAttribute('async', 'true');
script.setAttribute('defer', 'true');
head.appendChild(script);
diff --git a/src/web/app/dev/view.pug b/src/web/app/dev/view.pug
index 5b426bcbd1..8d21c7e714 100644
--- a/src/web/app/dev/view.pug
+++ b/src/web/app/dev/view.pug
@@ -1,5 +1,4 @@
extends ../base
block head
- link(rel='stylesheet', href='/resources/dev/style.css')
- script(src='/resources/dev/script.js', async, defer)
+ script(src=`/resources/dev/script.${version}.js` async defer)