wip
This commit is contained in:
parent
9b56f4fca1
commit
f762ebec4e
|
@ -807,6 +807,27 @@ export class ClientServerService {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fastify.get<{ Params: { clip: string; } }>('/embed/clips/:clip', async (request, reply) => {
|
||||||
|
reply.removeHeader('X-Frame-Options');
|
||||||
|
|
||||||
|
const clip = await this.clipsRepository.findOneBy({
|
||||||
|
id: request.params.clip,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (clip == null) return;
|
||||||
|
|
||||||
|
const _clip = await this.clipEntityService.pack(clip);
|
||||||
|
|
||||||
|
reply.header('Cache-Control', 'public, max-age=3600');
|
||||||
|
return await reply.view('base-embed', {
|
||||||
|
title: this.meta.name ?? 'Misskey',
|
||||||
|
...await this.generateCommonPugData(this.meta),
|
||||||
|
embedCtx: htmlSafeJsonStringify({
|
||||||
|
clip: _clip,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
fastify.get('/embed/*', async (request, reply) => {
|
fastify.get('/embed/*', async (request, reply) => {
|
||||||
reply.removeHeader('X-Frame-Options');
|
reply.removeHeader('X-Frame-Options');
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<EmLoading v-if="loading"/>
|
<EmTimelineContainer v-if="clip" :showHeader="embedParams.header">
|
||||||
<EmTimelineContainer v-else-if="clip" :showHeader="embedParams.header">
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<div :class="$style.clipHeader">
|
<div :class="$style.clipHeader">
|
||||||
<div :class="$style.headerClipIconRoot">
|
<div :class="$style.headerClipIconRoot">
|
||||||
|
@ -42,6 +41,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import { ref, computed, shallowRef, inject } from 'vue';
|
import { ref, computed, shallowRef, inject } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { scrollToTop } from '@@/js/scroll.js';
|
import { scrollToTop } from '@@/js/scroll.js';
|
||||||
|
import { url, instanceName } from '@@/js/config.js';
|
||||||
|
import { isLink } from '@@/js/is-link.js';
|
||||||
|
import { defaultEmbedParams } from '@@/js/embed-page.js';
|
||||||
import type { Paging } from '@/components/EmPagination.vue';
|
import type { Paging } from '@/components/EmPagination.vue';
|
||||||
import EmLoading from '@/components/EmLoading.vue';
|
import EmLoading from '@/components/EmLoading.vue';
|
||||||
import EmNotes from '@/components/EmNotes.vue';
|
import EmNotes from '@/components/EmNotes.vue';
|
||||||
|
@ -50,9 +52,6 @@ import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
|
||||||
import { misskeyApi } from '@/misskey-api.js';
|
import { misskeyApi } from '@/misskey-api.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { serverMetadata } from '@/server-metadata.js';
|
import { serverMetadata } from '@/server-metadata.js';
|
||||||
import { url, instanceName } from '@@/js/config.js';
|
|
||||||
import { isLink } from '@@/js/is-link.js';
|
|
||||||
import { defaultEmbedParams } from '@@/js/embed-page.js';
|
|
||||||
import { DI } from '@/di.js';
|
import { DI } from '@/di.js';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
@ -68,7 +67,6 @@ const pagination = computed(() => ({
|
||||||
clipId: props.clipId,
|
clipId: props.clipId,
|
||||||
},
|
},
|
||||||
} as Paging));
|
} as Paging));
|
||||||
const loading = ref(true);
|
|
||||||
|
|
||||||
const notesEl = shallowRef<InstanceType<typeof EmNotes> | null>(null);
|
const notesEl = shallowRef<InstanceType<typeof EmNotes> | null>(null);
|
||||||
|
|
||||||
|
@ -81,14 +79,11 @@ function top(ev: MouseEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
misskeyApi('clips/show', {
|
const embedCtxEl = document.getElementById('misskey_embedCtx');
|
||||||
|
const embedCtx = (embedCtxEl && embedCtxEl.textContent) ? JSON.parse(embedCtxEl.textContent) : null;
|
||||||
|
// NOTE: devモードのときしか embedCtx が null になることは無い
|
||||||
|
clip.value = embedCtx != null ? embedCtx.clip : await misskeyApi('clips/show', {
|
||||||
clipId: props.clipId,
|
clipId: props.clipId,
|
||||||
}).then(res => {
|
|
||||||
clip.value = res;
|
|
||||||
loading.value = false;
|
|
||||||
}).catch(err => {
|
|
||||||
console.error(err);
|
|
||||||
loading.value = false;
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue