mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-01 18:27:29 +00:00
nanka iroiro
This commit is contained in:
parent
6927ffa979
commit
5ad77e8a3a
10 changed files with 155 additions and 93 deletions
27
gulpfile.ts
27
gulpfile.ts
|
@ -19,13 +19,16 @@ import * as chalk from 'chalk';
|
||||||
import imagemin = require('gulp-imagemin');
|
import imagemin = require('gulp-imagemin');
|
||||||
import * as rename from 'gulp-rename';
|
import * as rename from 'gulp-rename';
|
||||||
import * as mocha from 'gulp-mocha';
|
import * as mocha from 'gulp-mocha';
|
||||||
|
import * as replace from 'gulp-replace';
|
||||||
|
import getVersion from './src/version';
|
||||||
|
|
||||||
const env = process.env.NODE_ENV;
|
const env = process.env.NODE_ENV;
|
||||||
const isProduction = env === 'production';
|
const isProduction = env === 'production';
|
||||||
const isDebug = !isProduction;
|
const isDebug = !isProduction;
|
||||||
|
|
||||||
if (isDebug) {
|
if (isDebug) {
|
||||||
console.log(chalk.yellow.bold('!!!WARNING!!! NODE_ENV is not "production". (built script compessing will not be performed.)'));
|
console.warn(chalk.yellow.bold('WARNING! NODE_ENV is not "production".'));
|
||||||
|
console.warn(chalk.yellow.bold(' built script compessing will not be performed.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const constants = require('./src/const.json');
|
const constants = require('./src/const.json');
|
||||||
|
@ -126,15 +129,21 @@ gulp.task('build:client', [
|
||||||
'copy:client'
|
'copy:client'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
gulp.task('build:client:scripts', () =>
|
gulp.task('build:client:scripts', done => {
|
||||||
|
getVersion.then(version => {
|
||||||
|
require('./webpack.config').then(webpackOptions => {
|
||||||
es.merge(
|
es.merge(
|
||||||
webpack(require('./webpack.config'), require('webpack'))
|
webpack(webpackOptions, require('webpack'))
|
||||||
.pipe(gulp.dest('./built/web/resources/')) as any,
|
.pipe(gulp.dest('./built/web/resources/')) as any,
|
||||||
gulp.src('./src/web/app/client/script.js')
|
gulp.src('./src/web/app/client/script.js')
|
||||||
|
.pipe(replace('VERSION', JSON.stringify(version)))
|
||||||
//.pipe(isProduction ? uglify() : gutil.noop())
|
//.pipe(isProduction ? uglify() : gutil.noop())
|
||||||
.pipe(gulp.dest('./built/web/resources/client/')) as any
|
.pipe(gulp.dest('./built/web/resources/client/')) as any
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('build:client:styles', () =>
|
gulp.task('build:client:styles', () =>
|
||||||
gulp.src('./src/web/app/init.css')
|
gulp.src('./src/web/app/init.css')
|
||||||
|
@ -163,12 +172,16 @@ gulp.task('build:client:pug', [
|
||||||
'copy:client',
|
'copy:client',
|
||||||
'build:client:scripts',
|
'build:client:scripts',
|
||||||
'build:client:styles'
|
'build:client:styles'
|
||||||
], () =>
|
], done => {
|
||||||
|
getVersion.then(version => {
|
||||||
gulp.src('./src/web/app/*/view.pug')
|
gulp.src('./src/web/app/*/view.pug')
|
||||||
.pipe(pug({
|
.pipe(pug({
|
||||||
locals: {
|
locals: {
|
||||||
|
version: version,
|
||||||
themeColor: constants.themeColor
|
themeColor: constants.themeColor
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest('./built/web/app/'))
|
.pipe(gulp.dest('./built/web/app/'));
|
||||||
);
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
12
package.json
12
package.json
|
@ -36,13 +36,14 @@
|
||||||
"@types/express": "4.0.35",
|
"@types/express": "4.0.35",
|
||||||
"@types/glob": "5.0.30",
|
"@types/glob": "5.0.30",
|
||||||
"@types/gm": "1.17.30",
|
"@types/gm": "1.17.30",
|
||||||
"@types/gulp-tslint": "3.6.31",
|
|
||||||
"@types/gulp-rename": "0.0.32",
|
|
||||||
"@types/gulp-mocha": "0.0.30",
|
|
||||||
"@types/gulp": "4.0.2",
|
"@types/gulp": "4.0.2",
|
||||||
|
"@types/gulp-mocha": "0.0.30",
|
||||||
|
"@types/gulp-rename": "0.0.32",
|
||||||
|
"@types/gulp-replace": "0.0.30",
|
||||||
|
"@types/gulp-tslint": "3.6.31",
|
||||||
"@types/gulp-typescript": "0.0.32",
|
"@types/gulp-typescript": "0.0.32",
|
||||||
"@types/gulp-util": "3.0.31",
|
|
||||||
"@types/gulp-uglify": "0.0.30",
|
"@types/gulp-uglify": "0.0.30",
|
||||||
|
"@types/gulp-util": "3.0.31",
|
||||||
"@types/inquirer": "0.0.32",
|
"@types/inquirer": "0.0.32",
|
||||||
"@types/is-root": "1.0.0",
|
"@types/is-root": "1.0.0",
|
||||||
"@types/is-url": "1.2.28",
|
"@types/is-url": "1.2.28",
|
||||||
|
@ -65,8 +66,8 @@
|
||||||
"@types/websocket": "0.0.33",
|
"@types/websocket": "0.0.33",
|
||||||
"autwh": "0.0.1",
|
"autwh": "0.0.1",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"cafy": "2.3.0",
|
|
||||||
"body-parser": "1.17.1",
|
"body-parser": "1.17.1",
|
||||||
|
"cafy": "2.3.0",
|
||||||
"chai": "3.5.0",
|
"chai": "3.5.0",
|
||||||
"chai-http": "3.0.0",
|
"chai-http": "3.0.0",
|
||||||
"chalk": "1.1.3",
|
"chalk": "1.1.3",
|
||||||
|
@ -95,6 +96,7 @@
|
||||||
"gulp-mocha": "4.1.0",
|
"gulp-mocha": "4.1.0",
|
||||||
"gulp-pug": "3.3.0",
|
"gulp-pug": "3.3.0",
|
||||||
"gulp-rename": "1.2.2",
|
"gulp-rename": "1.2.2",
|
||||||
|
"gulp-replace": "0.5.4",
|
||||||
"gulp-tslint": "7.1.0",
|
"gulp-tslint": "7.1.0",
|
||||||
"gulp-typescript": "3.1.6",
|
"gulp-typescript": "3.1.6",
|
||||||
"gulp-uglify": "2.1.0",
|
"gulp-uglify": "2.1.0",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Module dependencies
|
* Module dependencies
|
||||||
*/
|
*/
|
||||||
import prominence from 'prominence';
|
import prominence from 'prominence';
|
||||||
import git from 'git-last-commit';
|
import getVersion from '../../version';
|
||||||
import config from '../../conf';
|
import config from '../../conf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,11 +39,11 @@ import config from '../../conf';
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
module.exports = (params) => new Promise(async (res, rej) => {
|
module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
const commit = await prominence(git).getLastCommit();
|
const version = await getVersion.then();
|
||||||
|
|
||||||
res({
|
res({
|
||||||
maintainer: config.maintainer,
|
maintainer: config.maintainer,
|
||||||
commit: commit.shortHash,
|
version: version,
|
||||||
secure: config.https.enable
|
secure: config.https.enable
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
12
src/version.ts
Normal file
12
src/version.ts
Normal file
|
@ -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;
|
|
@ -1,6 +1,5 @@
|
||||||
extends ../base
|
extends ../base
|
||||||
|
|
||||||
block head
|
block head
|
||||||
meta(name='viewport', content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no')
|
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.${version}.js` async defer)
|
||||||
script(src='/resources/auth/script.js', async, defer)
|
|
||||||
|
|
|
@ -2,17 +2,17 @@ doctype html
|
||||||
|
|
||||||
!= '\r\n<!-- Thank you for using Misskey! @syuilo -->\r\n'
|
!= '\r\n<!-- Thank you for using Misskey! @syuilo -->\r\n'
|
||||||
|
|
||||||
html(lang='ja', dir='ltr')
|
html(lang='ja' dir='ltr')
|
||||||
|
|
||||||
head
|
head
|
||||||
meta(charset='utf-8')
|
meta(charset='utf-8')
|
||||||
meta(name='application-name', content='Misskey')
|
meta(name='application-name' content='Misskey')
|
||||||
meta(name='theme-color', content= themeColor)
|
meta(name='theme-color' content=themeColor)
|
||||||
meta(name='referrer', content='origin')
|
meta(name='referrer' content='origin')
|
||||||
title Misskey
|
title Misskey
|
||||||
style
|
style
|
||||||
include ./../../../built/web/resources/init.css
|
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
|
block head
|
||||||
|
|
||||||
body
|
body
|
||||||
|
|
|
@ -49,6 +49,26 @@ try {
|
||||||
Storage.prototype.setItem = () => { }; // noop
|
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 => {
|
module.exports = callback => {
|
||||||
// Get cached account data
|
// Get cached account data
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
|
/**
|
||||||
|
* MISSKEY ENTRY POINT
|
||||||
|
*/
|
||||||
(() => {
|
(() => {
|
||||||
const head = document.getElementsByTagName('head')[0];
|
const head = document.getElementsByTagName('head')[0];
|
||||||
|
|
||||||
|
// Detect user agent
|
||||||
const ua = navigator.userAgent.toLowerCase();
|
const ua = navigator.userAgent.toLowerCase();
|
||||||
const isMobile = /mobile|iphone|ipad|android/.test(ua);
|
const isMobile = /mobile|iphone|ipad|android/.test(ua);
|
||||||
|
|
||||||
isMobile ? mountMobile() : mountDesktop();
|
isMobile ? mountMobile() : mountDesktop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mount the desktop app
|
||||||
|
*/
|
||||||
function mountDesktop() {
|
function mountDesktop() {
|
||||||
const script = document.createElement('script');
|
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('async', 'true');
|
||||||
script.setAttribute('defer', 'true');
|
script.setAttribute('defer', 'true');
|
||||||
head.appendChild(script);
|
head.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mount the mobile app
|
||||||
|
*/
|
||||||
function mountMobile() {
|
function mountMobile() {
|
||||||
const meta = document.createElement('meta');
|
const meta = document.createElement('meta');
|
||||||
meta.setAttribute('name', 'viewport');
|
meta.setAttribute('name', 'viewport');
|
||||||
|
@ -20,7 +31,7 @@
|
||||||
head.appendChild(meta);
|
head.appendChild(meta);
|
||||||
|
|
||||||
const script = document.createElement('script');
|
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('async', 'true');
|
||||||
script.setAttribute('defer', 'true');
|
script.setAttribute('defer', 'true');
|
||||||
head.appendChild(script);
|
head.appendChild(script);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
extends ../base
|
extends ../base
|
||||||
|
|
||||||
block head
|
block head
|
||||||
link(rel='stylesheet', href='/resources/dev/style.css')
|
script(src=`/resources/dev/script.${version}.js` async defer)
|
||||||
script(src='/resources/dev/script.js', async, defer)
|
|
||||||
|
|
|
@ -4,11 +4,15 @@
|
||||||
|
|
||||||
import * as webpack from 'webpack';
|
import * as webpack from 'webpack';
|
||||||
const StringReplacePlugin = require('string-replace-webpack-plugin');
|
const StringReplacePlugin = require('string-replace-webpack-plugin');
|
||||||
|
import getVersion from './src/version';
|
||||||
const constants = require('./src/const.json');
|
const constants = require('./src/const.json');
|
||||||
|
|
||||||
const env = process.env.NODE_ENV;
|
const env = process.env.NODE_ENV;
|
||||||
const isProduction = env === 'production';
|
const isProduction = env === 'production';
|
||||||
|
|
||||||
|
module.exports = new Promise(async resolve => {
|
||||||
|
const version = await getVersion.then();
|
||||||
|
|
||||||
const pack: webpack.Configuration = {
|
const pack: webpack.Configuration = {
|
||||||
entry: {
|
entry: {
|
||||||
'desktop': './src/web/app/desktop/script.js',
|
'desktop': './src/web/app/desktop/script.js',
|
||||||
|
@ -58,6 +62,7 @@ const pack: webpack.Configuration = {
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
|
VERSION: JSON.stringify(version),
|
||||||
CONFIG: {
|
CONFIG: {
|
||||||
themeColor: JSON.stringify(constants.themeColor)
|
themeColor: JSON.stringify(constants.themeColor)
|
||||||
}
|
}
|
||||||
|
@ -65,7 +70,7 @@ const pack: webpack.Configuration = {
|
||||||
new StringReplacePlugin()
|
new StringReplacePlugin()
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
filename: '[name]/script.js'
|
filename: `[name]/script.${version}.js`
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,4 +78,5 @@ if (isProduction) {
|
||||||
//pack.plugins.push(new webpack.optimize.UglifyJsPlugin());
|
//pack.plugins.push(new webpack.optimize.UglifyJsPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = pack;
|
resolve(pack);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue