Compare commits

..

25 Commits

Author SHA1 Message Date
9f2d8e1d51 10.39.0 2018-11-05 21:07:24 +09:00
0c98a90b75 [Client] カスタム絵文字にホバーしたときに拡大するエフェクトを追加 2018-11-05 21:04:19 +09:00
0047920c1a Merge pull request #3117 from syuilo/twemoji
Use Twemoji
2018-11-05 20:52:55 +09:00
e4bb534f20 Better emoji regexp 2018-11-05 20:49:17 +09:00
3fc04fcdc5 Improve readdability 2018-11-05 20:49:02 +09:00
e542dcac30 Fix test 2018-11-05 20:40:39 +09:00
a0b13505a0 Insert missing spaces 2018-11-05 20:15:09 +09:00
389f9bfea2 Add test 2018-11-05 20:14:49 +09:00
630a534cee Fix test 2018-11-05 20:10:28 +09:00
5744c391e6 Revert "Fix test fails"
This reverts commit b9b05a7401.
2018-11-05 20:10:00 +09:00
b9b05a7401 Fix test fails 2018-11-05 19:50:38 +09:00
359470a263 Fix bug 2018-11-05 19:40:09 +09:00
3fe934ee62 Better alt value 2018-11-05 19:33:28 +09:00
3abe632f06 Clean up 2018-11-05 19:29:50 +09:00
65961bc15b Refactoring & 設定でTwemojiを使うかどうか切り替えられるように 2018-11-05 19:20:35 +09:00
12f932d48a Update CI configuration (#3120)
* Update config.yml

* Add `npm prune` command

refs: https://misskey.xyz/notes/5bd9b87168b2a30045edb3aa

* Ensure package-lock.json exists
2018-11-05 17:38:57 +09:00
54e9147782 Refactoring codes
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171437187
2018-11-05 17:04:17 +09:00
31b7626d01 Make code better
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171423739
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171424596
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171425303
2018-11-05 16:19:14 +09:00
200ebefe92 Add support for unicode emojis
refs: https://github.com/syuilo/misskey/pull/3117#issuecomment-435745613
2018-11-05 15:15:37 +09:00
b7f10fdc10 Fix bug
refs: https://github.com/syuilo/misskey/pull/3117#discussion_r230624389
2018-11-05 13:24:54 +09:00
9719387bee Re-separate commits 2018-11-05 11:51:14 +09:00
dca110ebaa Separate commits
Flash Back 90's
2018-11-05 11:39:13 +09:00
136f23c7ad Merge branch 'develop' into twemoji 2018-11-05 11:21:34 +09:00
0963e6d6e1 Use Twemoji 2018-11-05 11:19:40 +09:00
4e7fbd8967 Implement /api/v1/custom_emojis 2018-11-05 10:42:46 +09:00
17 changed files with 185 additions and 72 deletions

View File

@ -23,6 +23,10 @@ jobs:
executor: default
steps:
- checkout
- run:
name: Ensure package-lock.json
command: |
[ ! -e package-lock.json ] && echo '{}' > package-lock.json
- restore_cache:
name: Restore npm package caches
keys:
@ -35,6 +39,7 @@ jobs:
name: Install Dependencies
command: |
npm install
npm prune
- run:
name: Configure
command: |
@ -50,8 +55,8 @@ jobs:
key: npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-lock-{{ checksum "package-lock.json" }}-ls-{{ checksum "ls" }}
paths:
- node_modules
- store_artifacts:
path: built
# - store_artifacts:
# path: built
- persist_to_workspace:
root: .
paths:
@ -98,7 +103,6 @@ jobs:
name: Build
command: |
docker build . | tee docker.log
tail -n 1 docker.log | read __Successfully __built tag
- when:
condition: <<parameters.with_deploy>>
steps:
@ -107,6 +111,7 @@ jobs:
command: |
if [ "$DOCKERHUB_USERNAME$DOCKERHUB_PASSWORD" ]
then
tail -n 1 docker.log | read __Successfully __built tag
docker tag $tag misskey/misskey
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
docker push misskey/misskey
@ -126,10 +131,13 @@ workflows:
without_redis: "true"
requires:
- build
- docker:
filters:
branches:
ignore: master
only: master
# - docker:
# filters:
# branches:
# ignore: master
- docker:
with_deploy: "true"
filters:

View File

@ -131,6 +131,7 @@ common:
show-full-acct: "ユーザー名のホストを省略しない"
reduce-motion: "UIの動きを減らす"
this-setting-is-this-device-only: "このデバイスのみ"
use-os-default-emojis: "OS標準の絵文字を使用"
do-not-use-in-production: 'これは開発ビルドです。本番環境で使用しないでください。'

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "10.38.8",
"clientVersion": "1.0.11537",
"version": "10.39.0",
"clientVersion": "1.0.11562",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,

View File

@ -14,7 +14,8 @@
</ol>
<ol class="emojis" ref="suggests" v-if="emojis.length > 0">
<li v-for="emoji in emojis" @click="complete(type, emoji.emoji)" @keydown="onKeydown" tabindex="-1">
<span class="emoji" v-if="emoji.url"><img :src="emoji.url" :alt="emoji.emoji"/></span>
<span class="emoji" v-if="emoji.isCustomEmoji"><img :src="emoji.url" :alt="emoji.emoji"/></span>
<span class="emoji" v-else-if="!useOsDefaultEmojis"><img :src="emoji.url" :alt="emoji.emoji"/></span>
<span class="emoji" v-else>{{ emoji.emoji }}</span>
<span class="name" v-html="emoji.name.replace(q, `<b>${q}</b>`)"></span>
<span class="alias" v-if="emoji.aliasOf">({{ emoji.aliasOf }})</span>
@ -33,6 +34,7 @@ type EmojiDef = {
name: string;
aliasOf?: string;
url?: string;
isCustomEmoji?: boolean;
};
const lib = Object.entries(emojilib.lib).filter((x: any) => {
@ -42,7 +44,8 @@ const lib = Object.entries(emojilib.lib).filter((x: any) => {
const emjdb: EmojiDef[] = lib.map((x: any) => ({
emoji: x[1].char,
name: x[0],
aliasOf: null
aliasOf: null,
url: `https://twemoji.maxcdn.com/2/svg/${x[1].char.codePointAt(0).toString(16)}.svg`
}));
lib.forEach((x: any) => {
@ -51,7 +54,8 @@ lib.forEach((x: any) => {
emjdb.push({
emoji: x[1].char,
name: k,
aliasOf: x[0]
aliasOf: x[0],
url: `https://twemoji.maxcdn.com/2/svg/${x[1].char.codePointAt(0).toString(16)}.svg`
});
});
}
@ -77,6 +81,10 @@ export default Vue.extend({
computed: {
items(): HTMLCollection {
return (this.$refs.suggests as Element).children;
},
useOsDefaultEmojis(): boolean {
return this.$store.state.device.useOsDefaultEmojis;
}
},
@ -107,7 +115,8 @@ export default Vue.extend({
emojiDefinitions.push({
name: x.name,
emoji: `:${x.name}:`,
url: x.url
url: x.url,
isCustomEmoji: true
});
if (x.aliases) {
@ -116,7 +125,8 @@ export default Vue.extend({
name: alias,
aliasOf: x.name,
emoji: `:${x.name}:`,
url: x.url
url: x.url,
isCustomEmoji: true
});
});
}

View File

@ -0,0 +1,81 @@
<template>
<img v-if="customEmoji" class="fvgwvorwhxigeolkkrcderjzcawqrscl custom" :src="url" :alt="alt" :title="alt"/>
<img v-else-if="char && !useOsDefaultEmojis" class="fvgwvorwhxigeolkkrcderjzcawqrscl" :src="url" :alt="alt" :title="alt"/>
<span v-else-if="char && useOsDefaultEmojis">{{ char }}</span>
<span v-else>:{{ name }}:</span>
</template>
<script lang="ts">
import Vue from 'vue';
import { lib } from 'emojilib';
export default Vue.extend({
props: {
name: {
type: String,
required: false
},
emoji: {
type: String,
required: false
},
customEmojis: {
required: false,
default: []
}
},
data() {
return {
url: null,
char: null,
customEmoji: null
}
},
computed: {
alt(): string {
return this.customEmoji ? `:${this.customEmoji.name}:` : this.char;
},
useOsDefaultEmojis(): boolean {
return this.$store.state.device.useOsDefaultEmojis;
}
},
created() {
if (this.name) {
const customEmoji = this.customEmojis.find(x => x.name == this.name);
if (customEmoji) {
this.customEmoji = customEmoji;
this.url = customEmoji.url;
} else {
const emoji = lib[this.name];
if (emoji) {
this.char = emoji.char;
}
}
} else {
this.char = this.emoji;
}
if (this.char) {
this.url = `https://twemoji.maxcdn.com/2/svg/${this.char.codePointAt(0).toString(16)}.svg`;
}
}
});
</script>
<style lang="stylus" scoped>
.fvgwvorwhxigeolkkrcderjzcawqrscl
height 1em
&.custom
height 2.5em
vertical-align middle
transition transform 0.2s ease
&:hover
transform scale(1.2)
</style>

View File

@ -39,6 +39,7 @@ import urlPreview from './url-preview.vue';
import twitterSetting from './twitter-setting.vue';
import githubSetting from './github-setting.vue';
import fileTypeIcon from './file-type-icon.vue';
import emoji from './emoji.vue';
import Reversi from './games/reversi/reversi.vue';
import welcomeTimeline from './welcome-timeline.vue';
import uiInput from './ui/input.vue';
@ -93,6 +94,7 @@ Vue.component('mk-url-preview', urlPreview);
Vue.component('mk-twitter-setting', twitterSetting);
Vue.component('mk-github-setting', githubSetting);
Vue.component('mk-file-type-icon', fileTypeIcon);
Vue.component('mk-emoji', emoji);
Vue.component('mk-reversi', Reversi);
Vue.component('mk-welcome-timeline', welcomeTimeline);
Vue.component('ui-input', uiInput);

View File

@ -1,5 +1,4 @@
import Vue, { VNode } from 'vue';
import * as emojilib from 'emojilib';
import { length } from 'stringz';
import parse from '../../../../../mfm/parse';
import getAcct from '../../../../../misc/acct/render';
@ -188,24 +187,15 @@ export default Vue.component('misskey-flavored-markdown', {
}
case 'emoji': {
//#region カスタム絵文字
if (this.customEmojis != null) {
const customEmoji = this.customEmojis.find(e => e.name == token.emoji || (e.aliases || []).includes(token.emoji));
if (customEmoji) {
return [createElement('img', {
attrs: {
src: customEmoji.url,
alt: token.emoji,
title: token.emoji,
style: 'height: 2.5em; vertical-align: middle;'
}
})];
return [createElement('mk-emoji', {
attrs: {
emoji: token.emoji,
name: token.name
},
props: {
customEmojis: this.customEmojis
}
}
//#endregion
const emoji = emojilib.lib[token.emoji];
return [createElement('span', emoji ? emoji.char : token.content)];
})];
}
case 'search': {

View File

@ -145,6 +145,7 @@ class Autocomplete {
} else {
// サジェスト要素作成
this.suggestion = new MkAutocomplete({
parent: this.vm,
propsData: {
textarea: this.textarea,
complete: this.complete,

View File

@ -115,6 +115,7 @@
<ui-switch v-model="reduceMotion">%i18n:common.reduce-motion%</ui-switch>
<ui-switch v-model="contrastedAcct">%i18n:@contrasted-acct%</ui-switch>
<ui-switch v-model="showFullAcct">%i18n:common.show-full-acct%</ui-switch>
<ui-switch v-model="useOsDefaultEmojis">%i18n:common.use-os-default-emojis%</ui-switch>
<ui-switch v-model="iLikeSushi">%i18n:common.i-like-sushi%</ui-switch>
</section>
<section>
@ -324,6 +325,11 @@ export default Vue.extend({
};
},
computed: {
useOsDefaultEmojis: {
get() { return this.$store.state.device.useOsDefaultEmojis; },
set(value) { this.$store.commit('device/set', { key: 'useOsDefaultEmojis', value }); }
},
reduceMotion: {
get() { return this.$store.state.device.reduceMotion; },
set(value) { this.$store.commit('device/set', { key: 'reduceMotion', value }); }

View File

@ -23,6 +23,7 @@
<ui-switch v-model="reduceMotion">%i18n:common.reduce-motion% (%i18n:common.this-setting-is-this-device-only%)</ui-switch>
<ui-switch v-model="contrastedAcct">%i18n:@contrasted-acct%</ui-switch>
<ui-switch v-model="showFullAcct">%i18n:common.show-full-acct%</ui-switch>
<ui-switch v-model="useOsDefaultEmojis">%i18n:common.use-os-default-emojis%</ui-switch>
<ui-switch v-model="iLikeSushi">%i18n:common.i-like-sushi%</ui-switch>
<ui-switch v-model="disableAnimatedMfm">%i18n:common.disable-animated-mfm%</ui-switch>
<ui-switch v-model="alwaysShowNsfw">%i18n:common.always-show-nsfw% (%i18n:common.this-setting-is-this-device-only%)</ui-switch>
@ -199,6 +200,11 @@ export default Vue.extend({
set(value) { this.$store.commit('device/set', { key: 'darkmode', value }); }
},
useOsDefaultEmojis: {
get() { return this.$store.state.device.useOsDefaultEmojis; },
set(value) { this.$store.commit('device/set', { key: 'useOsDefaultEmojis', value }); }
},
reduceMotion: {
get() { return this.$store.state.device.reduceMotion; },
set(value) { this.$store.commit('device/set', { key: 'reduceMotion', value }); }

View File

@ -62,7 +62,8 @@ const defaultDeviceSettings = {
deckColumnAlign: 'center',
mobileNotificationPosition: 'bottom',
deckTemporaryColumn: null,
deckDefault: false
deckDefault: false,
useOsDefaultEmojis: false
};
export default (os: MiOS) => new Vuex.Store({

View File

@ -5,16 +5,29 @@
export type TextElementEmoji = {
type: 'emoji';
content: string;
emoji: string;
emoji?: string;
name?: string;
};
const emojiRegex = /^[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}]/ug;
export default function(text: string) {
const match = text.match(/^:([a-zA-Z0-9+_-]+):/);
if (!match) return null;
const emoji = match[0];
return {
type: 'emoji',
content: emoji,
emoji: match[1]
} as TextElementEmoji;
const name = text.match(/^:([a-zA-Z0-9+_-]+):/);
if (name) {
return {
type: 'emoji',
content: name[0],
name: name[1]
} as TextElementEmoji;
}
const unicode = text.match(emojiRegex);
if (unicode) {
const [content] = unicode;
return {
type: 'emoji',
content,
emoji: content
} as TextElementEmoji;
}
return null;
}

View File

@ -62,15 +62,6 @@ export default async (job: bq.Job, done: any): Promise<void> => {
}) as IRemoteUser;
}
//#region Log
publishApLogStream({
direction: 'in',
activity: activity.type,
host: user.host,
actor: user.username
});
//#endregion
// Update activityの場合は、ここで署名検証/更新処理まで実施して終了
if (activity.type === 'Update') {
if (activity.object && activity.object.type === 'Person') {
@ -101,6 +92,15 @@ export default async (job: bq.Job, done: any): Promise<void> => {
done();
return;
}
//#region Log
publishApLogStream({
direction: 'in',
activity: activity.type,
host: user.host,
actor: user.username
});
//#endregion
// アクティビティを処理
try {

View File

@ -1,6 +0,0 @@
import parse from '../../../mfm/parse';
export default function(text: string) {
if (!text) return [];
return parse(text).filter(t => t.type === 'emoji').map(t => (t as any).emoji);
}

View File

@ -8,9 +8,7 @@ import Note, { INote } from '../../../models/note';
import User from '../../../models/user';
import toHtml from '../misc/get-note-html';
import parseMfm from '../../../mfm/parse';
import getEmojiNames from '../misc/get-emoji-names';
import Emoji, { IEmoji } from '../../../models/emoji';
import { unique } from '../../../prelude/array';
export default async function renderNote(note: INote, dive = true): Promise<any> {
const promisedFiles: Promise<IDriveFile[]> = note.fileIds
@ -110,8 +108,7 @@ export default async function renderNote(note: INote, dive = true): Promise<any>
const content = toHtml(Object.assign({}, note, { text }));
const emojiNames = unique(getEmojiNames(content));
const emojis = await getEmojis(emojiNames);
const emojis = await getEmojis(note.emojis);
const apemojis = emojis.map(emoji => renderEmoji(emoji));
const tag = [
@ -141,12 +138,10 @@ async function getEmojis(names: string[]): Promise<IEmoji[]> {
if (names == null || names.length < 1) return [];
const emojis = await Promise.all(
names.map(async name => {
return await Emoji.findOne({
name,
host: null
});
})
names.map(name => Emoji.findOne({
name,
host: null
}))
);
return emojis.filter(emoji => emoji != null);

View File

@ -456,8 +456,8 @@ function extractHashtags(tokens: ReturnType<typeof parse>): string[] {
function extractEmojis(tokens: ReturnType<typeof parse>): string[] {
// Extract emojis
const emojis = tokens
.filter(t => t.type == 'emoji')
.map(t => (t as TextElementEmoji).emoji)
.filter(t => t.type == 'emoji' && t.name)
.map(t => (t as TextElementEmoji).name)
.filter(emoji => emoji.length <= 100);
return unique(emojis);

View File

@ -16,7 +16,7 @@ describe('Text', () => {
{ type: 'text', content: ' '},
{ type: 'mention', content: '@hima_sub@namori.net', canonical: '@hima_sub@namori.net', username: 'hima_sub', host: 'namori.net' },
{ type: 'text', content: ' お腹ペコい ' },
{ type: 'emoji', content: ':cat:', emoji: 'cat'},
{ type: 'emoji', content: ':cat:', name: 'cat'},
{ type: 'text', content: ' '},
{ type: 'hashtag', content: '#yryr', hashtag: 'yryr' }
], tokens);
@ -182,15 +182,20 @@ describe('Text', () => {
it('emoji', () => {
const tokens1 = analyze(':cat:');
assert.deepEqual([
{ type: 'emoji', content: ':cat:', emoji: 'cat'}
{ type: 'emoji', content: ':cat:', name: 'cat' }
], tokens1);
const tokens2 = analyze(':cat::cat::cat:');
assert.deepEqual([
{ type: 'emoji', content: ':cat:', emoji: 'cat'},
{ type: 'emoji', content: ':cat:', emoji: 'cat'},
{ type: 'emoji', content: ':cat:', emoji: 'cat'}
{ type: 'emoji', content: ':cat:', name: 'cat' },
{ type: 'emoji', content: ':cat:', name: 'cat' },
{ type: 'emoji', content: ':cat:', name: 'cat' }
], tokens2);
const tokens3 = analyze('🍎');
assert.deepEqual([
{ type: 'emoji', content: '🍎', emoji: '🍎' }
], tokens3);
});
it('block code', () => {