upd: add tossface emojis as an option

This commit is contained in:
Marie 2024-01-04 20:42:25 +01:00
parent c8a7e27e70
commit 3c3c5e190a
No known key found for this signature in database
GPG Key ID: 56569BBE47D2C828
10 changed files with 39 additions and 4 deletions

3
.gitmodules vendored
View File

@ -4,3 +4,6 @@
[submodule "fluent-emojis"] [submodule "fluent-emojis"]
path = fluent-emojis path = fluent-emojis
url = https://github.com/misskey-dev/emojis.git url = https://github.com/misskey-dev/emojis.git
[submodule "tossface-emojis"]
path = tossface-emojis
url = https://git.joinsharkey.org/Sharkey/tossface-emojis.git

View File

@ -44,6 +44,7 @@ COPY --from=build /sharkey/packages/megalodon/node_modules ./packages/megalodon/
COPY --from=build /sharkey/packages/misskey-js/built ./packages/misskey-js/built COPY --from=build /sharkey/packages/misskey-js/built ./packages/misskey-js/built
COPY --from=build /sharkey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules COPY --from=build /sharkey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
COPY --from=build /sharkey/fluent-emojis ./fluent-emojis COPY --from=build /sharkey/fluent-emojis ./fluent-emojis
COPY --from=build /sharkey/tossface-emojis/dist ./tossface-emojis/dist
COPY --from=build /sharkey/sharkey-assets ./packages/frontend/assets COPY --from=build /sharkey/sharkey-assets ./packages/frontend/assets
COPY package.json ./package.json COPY package.json ./package.json

View File

@ -327,6 +327,21 @@ export class ClientServerService {
}); });
}); });
fastify.get<{ Params: { path: string } }>('/tossface/:path(.*)', async (request, reply) => {
const path = request.params.path;
if (!path.match(/^[0-9a-f-]+\.svg$/)) {
reply.code(404);
return;
}
reply.header('Content-Security-Policy', 'default-src \'none\'; style-src \'unsafe-inline\'');
return await reply.sendFile(path, `${_dirname}/../../../../../tossface-emojis/dist`, {
maxAge: ms('30 days'),
});
});
fastify.get<{ Params: { path: string } }>('/twemoji-badge/:path(.*)', async (request, reply) => { fastify.get<{ Params: { path: string } }>('/twemoji-badge/:path(.*)', async (request, reply) => {
const path = request.params.path; const path = request.params.path;

View File

@ -42,7 +42,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { markRaw, ref, shallowRef, computed, onUpdated, onMounted, onBeforeUnmount, nextTick, watch } from 'vue'; import { markRaw, ref, shallowRef, computed, onUpdated, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
import sanitizeHtml from 'sanitize-html'; import sanitizeHtml from 'sanitize-html';
import contains from '@/scripts/contains.js'; import contains from '@/scripts/contains.js';
import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base.js'; import { char2twemojiFilePath, char2fluentEmojiFilePath, char2tossfaceFilePath } from '@/scripts/emoji-base.js';
import { acct } from '@/filters/user.js'; import { acct } from '@/filters/user.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
@ -68,7 +68,7 @@ const lib = emojilist.filter(x => x.category !== 'flags');
const emojiDb = computed(() => { const emojiDb = computed(() => {
//#region Unicode Emoji //#region Unicode Emoji
const char2path = defaultStore.reactiveState.emojiStyle.value === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath; const char2path = defaultStore.reactiveState.emojiStyle.value === 'twemoji' ? char2twemojiFilePath : defaultStore.reactiveState.emojiStyle.value === 'tossface' ? char2tossfaceFilePath : char2fluentEmojiFilePath;
const unicodeEmojiDB: EmojiDef[] = lib.map(x => ({ const unicodeEmojiDB: EmojiDef[] = lib.map(x => ({
emoji: x.char, emoji: x.char,

View File

@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import { computed, inject } from 'vue'; import { computed, inject } from 'vue';
import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base.js'; import { char2twemojiFilePath, char2fluentEmojiFilePath, char2tossfaceFilePath } from '@/scripts/emoji-base.js';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { getEmojiName } from '@/scripts/emojilist.js'; import { getEmojiName } from '@/scripts/emojilist.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
@ -27,7 +27,7 @@ const props = defineProps<{
const react = inject<((name: string) => void) | null>('react', null); const react = inject<((name: string) => void) | null>('react', null);
const char2path = defaultStore.state.emojiStyle === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath; const char2path = defaultStore.state.emojiStyle === 'twemoji' ? char2twemojiFilePath : defaultStore.reactiveState.emojiStyle.value === 'tossface' ? char2tossfaceFilePath : char2fluentEmojiFilePath;
const useOsNativeEmojis = computed(() => defaultStore.state.emojiStyle === 'native'); const useOsNativeEmojis = computed(() => defaultStore.state.emojiStyle === 'native');
const url = computed(() => { const url = computed(() => {

View File

@ -146,6 +146,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="native">{{ i18n.ts.native }}</option> <option value="native">{{ i18n.ts.native }}</option>
<option value="fluentEmoji">Fluent Emoji</option> <option value="fluentEmoji">Fluent Emoji</option>
<option value="twemoji">Twemoji</option> <option value="twemoji">Twemoji</option>
<option value="tossface">Tossface</option>
</MkRadios> </MkRadios>
<div style="margin: 8px 0 0 0; font-size: 1.5em;"><Mfm :key="emojiStyle" text="🍮🍦🍭🍩🍰🍫🍬🥞🍪"/></div> <div style="margin: 8px 0 0 0; font-size: 1.5em;"><Mfm :key="emojiStyle" text="🍮🍦🍭🍩🍰🍫🍬🥞🍪"/></div>
</div> </div>

View File

@ -5,6 +5,7 @@
const twemojiSvgBase = '/twemoji'; const twemojiSvgBase = '/twemoji';
const fluentEmojiPngBase = '/fluent-emoji'; const fluentEmojiPngBase = '/fluent-emoji';
const tossfaceSvgBase = '/tossface';
export function char2twemojiFilePath(char: string): string { export function char2twemojiFilePath(char: string): string {
let codes = Array.from(char, x => x.codePointAt(0)?.toString(16)); let codes = Array.from(char, x => x.codePointAt(0)?.toString(16));
@ -23,3 +24,14 @@ export function char2fluentEmojiFilePath(char: string): string {
const fileName = codes.map(x => x!.padStart(4, '0')).join('-'); const fileName = codes.map(x => x!.padStart(4, '0')).join('-');
return `${fluentEmojiPngBase}/${fileName}.png`; return `${fluentEmojiPngBase}/${fileName}.png`;
} }
export function char2tossfaceFilePath(char: string): string {
let codes = Array.from(char, x => x.codePointAt(0)?.toString(16));
// Twemoji is the only emoji font which still supports the shibuya 50 emoji to this day
if (codes[0]?.startsWith('e50a')) return char2twemojiFilePath(char);
// Tossface does not use the fe0f modifier
codes = codes.filter(x => x !== 'fe0f');
codes = codes.filter(x => x && x.length);
const fileName = codes.join('-');
return `${tossfaceSvgBase}/${fileName}.svg`;
}

View File

@ -27,6 +27,7 @@ const devConfig = {
'/files': 'http://localhost:3000/', '/files': 'http://localhost:3000/',
'/twemoji': 'http://localhost:3000/', '/twemoji': 'http://localhost:3000/',
'/fluent-emoji': 'http://localhost:3000/', '/fluent-emoji': 'http://localhost:3000/',
'/tossface': 'http://localhost:3000/',
'/sw.js': 'http://localhost:3000/', '/sw.js': 'http://localhost:3000/',
'/streaming': { '/streaming': {
target: 'ws://localhost:3000/', target: 'ws://localhost:3000/',

View File

@ -71,6 +71,7 @@ export function getConfig(): UserConfig {
'/client-assets/': __dirname + '/assets/', '/client-assets/': __dirname + '/assets/',
'/static-assets/': __dirname + '/../backend/assets/', '/static-assets/': __dirname + '/../backend/assets/',
'/fluent-emojis/': __dirname + '/../../fluent-emojis/dist/', '/fluent-emojis/': __dirname + '/../../fluent-emojis/dist/',
'/tossface/': __dirname + '/../../tossface-emojis/dist/',
'/fluent-emoji/': __dirname + '/../../fluent-emojis/dist/', '/fluent-emoji/': __dirname + '/../../fluent-emojis/dist/',
}, },
}, },

1
tossface-emojis Submodule

@ -0,0 +1 @@
Subproject commit 3c0ac3f7bdd794cc334363bf834e58079ca00dd2