Use string interpolation

This commit is contained in:
Aya Morisawa 2018-09-01 23:12:51 +09:00
parent 98ff6cdf91
commit 36e10e2bbf
40 changed files with 53 additions and 53 deletions

View file

@ -80,7 +80,7 @@ export default Vue.extend({
accepted() { accepted() {
this.state = 'accepted'; this.state = 'accepted';
if (this.session.app.callbackUrl) { if (this.session.app.callbackUrl) {
location.href = this.session.app.callbackUrl + '?token=' + this.session.token; location.href = `${this.session.app.callbackUrl}?token=${this.session.token}`;
} }
} }
} }

View file

@ -94,7 +94,7 @@
// Get salt query // Get salt query
const salt = localStorage.getItem('salt') const salt = localStorage.getItem('salt')
? '?salt=' + localStorage.getItem('salt') ? `?salt=${localStorage.getItem('salt')}`
: ''; : '';
// Load an app script // Load an app script

View file

@ -44,11 +44,11 @@ export default class Connection extends EventEmitter {
const query = params const query = params
? Object.keys(params) ? Object.keys(params)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k])) .map(k => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`)
.join('&') .join('&')
: null; : null;
this.socket = new ReconnectingWebsocket(`${wsUrl}/${endpoint}${query ? '?' + query : ''}`); this.socket = new ReconnectingWebsocket(`${wsUrl}/${endpoint}${query ? `?${query}` : ''}`);
this.socket.addEventListener('open', this.onOpen); this.socket.addEventListener('open', this.onOpen);
this.socket.addEventListener('close', this.onClose); this.socket.addEventListener('close', this.onClose);
this.socket.addEventListener('message', this.onMessage); this.socket.addEventListener('message', this.onMessage);

View file

@ -125,7 +125,7 @@ export default Vue.extend({
} }
if (this.type == 'user') { if (this.type == 'user') {
const cacheKey = 'autocomplete:user:' + this.q; const cacheKey = `autocomplete:user:${this.q}`;
const cache = sessionStorage.getItem(cacheKey); const cache = sessionStorage.getItem(cacheKey);
if (cache) { if (cache) {
const users = JSON.parse(cache); const users = JSON.parse(cache);
@ -148,7 +148,7 @@ export default Vue.extend({
this.hashtags = JSON.parse(localStorage.getItem('hashtags') || '[]'); this.hashtags = JSON.parse(localStorage.getItem('hashtags') || '[]');
this.fetching = false; this.fetching = false;
} else { } else {
const cacheKey = 'autocomplete:hashtag:' + this.q; const cacheKey = `autocomplete:hashtag:${this.q}`;
const cache = sessionStorage.getItem(cacheKey); const cache = sessionStorage.getItem(cacheKey);
if (cache) { if (cache) {
const hashtags = JSON.parse(cache); const hashtags = JSON.parse(cache);

View file

@ -57,7 +57,7 @@ export default Vue.extend({
} }
// Check internet connection // Check internet connection
fetch('https://google.com?rand=' + Math.random(), { fetch(`https://google.com?rand=${Math.random()}`, {
mode: 'no-cors' mode: 'no-cors'
}).then(() => { }).then(() => {
this.internet = true; this.internet = true;

View file

@ -170,7 +170,7 @@ export default Vue.extend({
return; return;
} }
fetch('/url?url=' + encodeURIComponent(this.url)).then(res => { fetch(`/url?url=${encodeURIComponent(this.url)}`).then(res => {
res.json().then(info => { res.json().then(info => {
if (info.url == null) return; if (info.url == null) return;
this.title = info.title; this.title = info.title;

View file

@ -191,7 +191,7 @@ class Autocomplete {
const acct = renderAcct(value); const acct = renderAcct(value);
// 挿入 // 挿入
this.text = trimmedBefore + '@' + acct + ' ' + after; this.text = `${trimmedBefore}@${acct} ${after}`;
// キャレットを戻す // キャレットを戻す
this.vm.$nextTick(() => { this.vm.$nextTick(() => {
@ -207,7 +207,7 @@ class Autocomplete {
const after = source.substr(caret); const after = source.substr(caret);
// 挿入 // 挿入
this.text = trimmedBefore + '#' + value + ' ' + after; this.text = `${trimmedBefore}#${value} ${after}`;
// キャレットを戻す // キャレットを戻す
this.vm.$nextTick(() => { this.vm.$nextTick(() => {

View file

@ -1,5 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
Vue.filter('notePage', note => { Vue.filter('notePage', note => {
return '/notes/' + note.id; return `/notes/${note.id}`;
}); });

View file

@ -11,5 +11,5 @@ Vue.filter('userName', user => {
}); });
Vue.filter('userPage', (user, path?) => { Vue.filter('userPage', (user, path?) => {
return '/@' + Vue.filter('acct')(user) + (path ? '/' + path : ''); return `/@${Vue.filter('acct')(user)}${(path ? `/${path}` : '')}`;
}); });

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="syxhndwprovvuqhmyvveewmbqayniwkv" v-if="!fetching" :data-darkmode="$store.state.device.darkmode"> <div class="syxhndwprovvuqhmyvveewmbqayniwkv" v-if="!fetching" :data-darkmode="$store.state.device.darkmode">
<div class="signed-in-as" v-html="'%i18n:@signed-in-as%'.replace('{}', '<b>' + myName + '</b>')"></div> <div class="signed-in-as" v-html="'%i18n:@signed-in-as%'.replace('{}', `<b>${myName}`)"></div>
<main> <main>
<div class="banner" :style="bannerStyle"></div> <div class="banner" :style="bannerStyle"></div>

View file

@ -163,7 +163,7 @@ export default Vue.extend({
}); });
break; break;
default: default:
alert('%i18n:@unhandled-error% ' + err); alert(`%i18n:@unhandled-error% ${err}`);
} }
}); });
} }

View file

@ -323,7 +323,7 @@ export default Vue.extend({
}); });
break; break;
default: default:
alert('%i18n:@unhandled-error% ' + err); alert(`%i18n:@unhandled-error% ${err}`);
} }
}); });
} }
@ -404,7 +404,7 @@ export default Vue.extend({
folder: folder folder: folder
}); });
} else { } else {
window.open(url + '/i/drive/folder/' + folder.id, window.open(`${url}/i/drive/folder/${folder.id}`,
'drive_window', 'drive_window',
'height=500, width=800'); 'height=500, width=800');
} }

View file

@ -48,7 +48,7 @@ export default Vue.extend({
const mouseY = e.clientY - rect.top; const mouseY = e.clientY - rect.top;
const xp = mouseX / this.$el.offsetWidth * 100; const xp = mouseX / this.$el.offsetWidth * 100;
const yp = mouseY / this.$el.offsetHeight * 100; const yp = mouseY / this.$el.offsetHeight * 100;
this.$el.style.backgroundPosition = xp + '% ' + yp + '%'; this.$el.style.backgroundPosition = `${xp}% ${yp}%';
this.$el.style.backgroundImage = `url("${this.image.url}")`; this.$el.style.backgroundImage = `url("${this.image.url}")`;
}, },

View file

@ -110,9 +110,9 @@ export default Vue.extend({
computed: { computed: {
draftId(): string { draftId(): string {
return this.renote return this.renote
? 'renote:' + this.renote.id ? `renote:${this.renote.id}`
: this.reply : this.reply
? 'reply:' + this.reply.id ? `reply:${this.reply.id}`
: 'note'; : 'note';
}, },
@ -313,7 +313,7 @@ export default Vue.extend({
this.geo = pos.coords; this.geo = pos.coords;
this.$emit('geo-attached', this.geo); this.$emit('geo-attached', this.geo);
}, err => { }, err => {
alert('%i18n:@error%: ' + err.message); alert(`%i18n:@error%: ${err.message}`);
}, { }, {
enableHighAccuracy: true enableHighAccuracy: true
}); });

View file

@ -31,7 +31,7 @@ export default Vue.extend({
const title = folder.name + ' | %i18n:@title%'; const title = folder.name + ' | %i18n:@title%';
// Rewrite URL // Rewrite URL
history.pushState(null, title, '/i/drive/folder/' + folder.id); history.pushState(null, title, `/i/drive/folder/${folder.id}`);
document.title = title; document.title = title;
} }

View file

@ -16,10 +16,10 @@ export default Vue.extend({
methods: { methods: {
nav(game, actualNav) { nav(game, actualNav) {
if (actualNav) { if (actualNav) {
this.$router.push('/reversi/' + game.id); this.$router.push(`/reversi/${game.id}`);
} else { } else {
// TODO: https://github.com/vuejs/vue-router/issues/703 // TODO: https://github.com/vuejs/vue-router/issues/703
this.$router.push('/reversi/' + game.id); this.$router.push(`/reversi/${game.id}`);
} }
} }
} }

View file

@ -46,7 +46,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
document.title = 'メッセージ: ' + getUserName(this.user); document.title = `メッセージ: ${getUserName(this.user)}`;
Progress.done(); Progress.done();
}); });

View file

@ -105,9 +105,9 @@ export default Vue.extend({
computed: { computed: {
draftId(): string { draftId(): string {
return this.renote return this.renote
? 'renote:' + this.renote.id ? `renote:${this.renote.id}`
: this.reply : this.reply
? 'reply:' + this.reply.id ? `reply:${this.reply.id}`
: 'note'; : 'note';
}, },
@ -229,7 +229,7 @@ export default Vue.extend({
navigator.geolocation.getCurrentPosition(pos => { navigator.geolocation.getCurrentPosition(pos => {
this.geo = pos.coords; this.geo = pos.coords;
}, err => { }, err => {
alert('%i18n:@error%: ' + err.message); alert(`%i18n:@error%: ${err.message}`);
}, { }, {
enableHighAccuracy: true enableHighAccuracy: true
}); });

View file

@ -82,7 +82,7 @@ export default Vue.extend({
search() { search() {
const query = window.prompt('%i18n:@search%'); const query = window.prompt('%i18n:@search%');
if (query == null || query == '') return; if (query == null || query == '') return;
this.$router.push('/search?q=' + encodeURIComponent(query)); this.$router.push(`/search?q=${encodeURIComponent(query)}`);
}, },
onReversiInvited() { onReversiInvited() {
this.hasGameInvitation = true; this.hasGameInvitation = true;

View file

@ -80,7 +80,7 @@ export default Vue.extend({
if (!silent) { if (!silent) {
// Rewrite URL // Rewrite URL
history.pushState(null, title, '/i/drive/folder/' + folder.id); history.pushState(null, title, `/i/drive/folder/${folder.id}`);
} }
document.title = title; document.title = title;
@ -93,7 +93,7 @@ export default Vue.extend({
if (!silent) { if (!silent) {
// Rewrite URL // Rewrite URL
history.pushState(null, title, '/i/drive/file/' + file.id); history.pushState(null, title, `/i/drive/file/${file.id}`);
} }
document.title = title; document.title = title;

View file

@ -49,7 +49,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
document.title = '%i18n:@followers-of%'.replace('{}', this.name) + ' | ' + (this as any).os.instanceName; document.title = `${'%i18n:@followers-of%'.replace('{}', this.name)} | ${(this as any).os.instanceName}`;
}); });
}, },
onLoaded() { onLoaded() {

View file

@ -48,7 +48,7 @@ export default Vue.extend({
this.user = user; this.user = user;
this.fetching = false; this.fetching = false;
document.title = '%i18n:@followers-of%'.replace('{}', this.name) + ' | ' + (this as any).os.instanceName; document.title = `${'%i18n:@followers-of%'.replace('{}', this.name)} | ${(this as any).os.instanceName}`;
}); });
}, },
onLoaded() { onLoaded() {

View file

@ -16,10 +16,10 @@ export default Vue.extend({
methods: { methods: {
nav(game, actualNav) { nav(game, actualNav) {
if (actualNav) { if (actualNav) {
this.$router.push('/reversi/' + game.id); this.$router.push(`/reversi/${game.id}`);
} else { } else {
// TODO: https://github.com/vuejs/vue-router/issues/703 // TODO: https://github.com/vuejs/vue-router/issues/703
this.$router.push('/reversi/' + game.id); this.$router.push(`/reversi/${game.id}`);
} }
} }
} }

View file

@ -2,7 +2,7 @@
<mk-ui> <mk-ui>
<span slot="header">%fa:cog%%i18n:@settings%</span> <span slot="header">%fa:cog%%i18n:@settings%</span>
<main :data-darkmode="$store.state.device.darkmode"> <main :data-darkmode="$store.state.device.darkmode">
<div class="signin-as" v-html="'%i18n:@signed-in-as%'.replace('{}', '<b>' + name + '</b>')"></div> <div class="signin-as" v-html="'%i18n:@signed-in-as%'.replace('{}', `<b>${name}</b>`)"></div>
<div> <div>
<x-profile/> <x-profile/>

View file

@ -43,7 +43,7 @@ export default Vue.extend({
title title
}); });
this.$router.push('/i/lists/' + list.id); this.$router.push(`/i/lists/${list.id}`);
}); });
} }
} }

View file

@ -107,7 +107,7 @@ export default Vue.extend({
this.fetching = false; this.fetching = false;
Progress.done(); Progress.done();
document.title = Vue.filter('userName')(this.user) + ' | ' + (this as any).os.instanceName; document.title = `${Vue.filter('userName')(this.user)} | ${(this as any).os.instanceName}`;
}); });
} }
} }

View file

@ -16,7 +16,7 @@ export default function() {
}); });
ev.on('requestNotesStatsLog', id => { ev.on('requestNotesStatsLog', id => {
ev.emit('notesStatsLog:' + id, log.toArray()); ev.emit(`notesStatsLog:${id}`, log.toArray());
}); });
process.on('exit', code => { process.on('exit', code => {

View file

@ -16,7 +16,7 @@ export default function() {
const log = new Deque<any>(); const log = new Deque<any>();
ev.on('requestServerStatsLog', x => { ev.on('requestServerStatsLog', x => {
ev.emit('serverStatsLog:' + x.id, log.toArray().slice(0, x.length || 50)); ev.emit(`serverStatsLog:${x.id}`, log.toArray().slice(0, x.length || 50));
}); });
async function tick() { async function tick() {

View file

@ -45,7 +45,7 @@ export default function(html: string): string {
if (part.length == 2) { if (part.length == 2) {
//#region ホスト名部分が省略されているので復元する //#region ホスト名部分が省略されているので復元する
const acct = txt + '@' + (new URL(href.value)).hostname; const acct = `${txt}@${(new URL(href.value)).hostname}`;
text += acct; text += acct;
break; break;
//#endregion //#endregion

View file

@ -44,8 +44,8 @@ const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers:
hashtag({ document }, { hashtag }) { hashtag({ document }, { hashtag }) {
const a = document.createElement('a'); const a = document.createElement('a');
a.href = config.url + '/tags/' + hashtag; a.href = `${config.url}/tags/${hashtag}`;
a.textContent = '#' + hashtag; a.textContent = `#${hashtag}`;
a.setAttribute('rel', 'tag'); a.setAttribute('rel', 'tag');
document.body.appendChild(a); document.body.appendChild(a);
}, },

View file

@ -26,7 +26,7 @@ export const replacement = (match: string, key: string) => {
arg == 'B' ? 'fab' : arg == 'B' ? 'fab' :
''; '';
} else if (arg.startsWith('.')) { } else if (arg.startsWith('.')) {
classes.push('fa-' + arg.substr(1)); classes.push(`fa-${arg.substr(1)}`);
} else if (arg.startsWith('-')) { } else if (arg.startsWith('-')) {
transform = arg.substr(1).split('|').join(' '); transform = arg.substr(1).split('|').join(' ');
} else { } else {

View file

@ -3,5 +3,5 @@ import config from '../../../config';
export default (tag: string) => ({ export default (tag: string) => ({
type: 'Hashtag', type: 'Hashtag',
href: `${config.url}/tags/${encodeURIComponent(tag)}`, href: `${config.url}/tags/${encodeURIComponent(tag)}`,
name: '#' + tag name: `#${tag}`
}); });

View file

@ -22,7 +22,7 @@ const router = new Router();
function inbox(ctx: Router.IRouterContext) { function inbox(ctx: Router.IRouterContext) {
let signature; let signature;
ctx.req.headers.authorization = 'Signature ' + ctx.req.headers.signature; ctx.req.headers.authorization = `Signature ${ctx.req.headers.signature}`;
try { try {
signature = httpSignature.parseRequest(ctx.req, { 'headers': [] }); signature = httpSignature.parseRequest(ctx.req, { 'headers': [] });

View file

@ -79,7 +79,7 @@ const files = glob.sync('**/*.js', {
}); });
const endpoints: IEndpoint[] = files.map(f => { const endpoints: IEndpoint[] = files.map(f => {
const ep = require('./endpoints/' + f); const ep = require(`./endpoints/${f}`);
return { return {
name: f.replace('.js', ''), name: f.replace('.js', ''),

View file

@ -16,7 +16,7 @@ export default function(request: websocket.request, connection: websocket.connec
switch (msg.type) { switch (msg.type) {
case 'requestLog': case 'requestLog':
ev.once('notesStatsLog:' + msg.id, statsLog => { ev.once(`notesStatsLog:${msg.id}`, statsLog => {
connection.send(JSON.stringify({ connection.send(JSON.stringify({
type: 'statsLog', type: 'statsLog',
body: statsLog body: statsLog

View file

@ -16,7 +16,7 @@ export default function(request: websocket.request, connection: websocket.connec
switch (msg.type) { switch (msg.type) {
case 'requestLog': case 'requestLog':
ev.once('serverStatsLog:' + msg.id, statsLog => { ev.once(`serverStatsLog:${msg.id}`, statsLog => {
connection.send(JSON.stringify({ connection.send(JSON.stringify({
type: 'statsLog', type: 'statsLog',
body: statsLog body: statsLog

View file

@ -196,7 +196,7 @@ router.get('/*/api/entities/*', async ctx => {
const lang = ctx.params[0]; const lang = ctx.params[0];
const entity = ctx.params[1]; const entity = ctx.params[1];
const x = yaml.safeLoad(fs.readFileSync(path.resolve(__dirname + '/../../../src/docs/api/entities/' + entity + '.yaml'), 'utf-8')) as any; const x = yaml.safeLoad(fs.readFileSync(path.resolve(`${__dirname}/../../../src/docs/api/entities/${entity}.yaml`), 'utf-8')) as any;
await ctx.render('../../../../src/docs/api/entities/view', Object.assign(await genVars(lang), { await ctx.render('../../../../src/docs/api/entities/view', Object.assign(await genVars(lang), {
id: `api/entities/${entity}`, id: `api/entities/${entity}`,

View file

@ -2,7 +2,7 @@ extends ../../../../src/client/app/base
block vars block vars
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`; - const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
- const url = config.url + '/@' + (user.host ? `${user.username}@${user.host}` : user.username); - const url = `${config.url}/@${(user.host ? `${user.username}@${user.host}` : user.username)}`;
- const img = user.avatarId ? `${config.drive_url}/${user.avatarId}` : null; - const img = user.avatarId ? `${config.drive_url}/${user.avatarId}` : null;
block title block title

View file

@ -40,7 +40,7 @@ async function save(path: string, name: string, type: string, hash: string, size
const thumbnailKey = `${config.drive.prefix}/${uuid.v4()}/${name}.thumbnail.jpg`; const thumbnailKey = `${config.drive.prefix}/${uuid.v4()}/${name}.thumbnail.jpg`;
const baseUrl = config.drive.baseUrl const baseUrl = config.drive.baseUrl
|| `${ config.drive.config.useSSL ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? ':' + config.drive.config.port : '' }/${ config.drive.bucket }`; || `${ config.drive.config.useSSL ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? `:${config.drive.config.port}` : '' }/${ config.drive.bucket }`;
await minio.putObject(config.drive.bucket, key, fs.createReadStream(path), size, { await minio.putObject(config.drive.bucket, key, fs.createReadStream(path), size, {
'Content-Type': type, 'Content-Type': type,

View file

@ -20,7 +20,7 @@ const constants = require('./src/const.json');
const locales = require('./locales'); const locales = require('./locales');
const meta = require('./package.json'); const meta = require('./package.json');
const version = meta.clientVersion + '-' + rndstr({ length: 8, chars: '0-9a-z' }); const version = `${meta.clientVersion}-${rndstr({ length: 8, chars: '0-9a-z' })}`;
const codename = meta.codename; const codename = meta.codename;
declare var global: { declare var global: {
@ -42,7 +42,7 @@ global['collapseSpacesReplacement'] = (html: string) => {
}; };
global['base64replacement'] = (_: any, key: string) => { global['base64replacement'] = (_: any, key: string) => {
return fs.readFileSync(__dirname + '/src/client/' + key, 'base64'); return fs.readFileSync(`${__dirname}/src/client/${key}`, 'base64');
}; };
global['i18nReplacement'] = i18nReplacement; global['i18nReplacement'] = i18nReplacement;