diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-04-24 22:38:24 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-24 22:38:24 +0900 |
| commit | fec3c70886c13a267814e7eba5d2dd9aa807687b (patch) | |
| tree | d88fcd2904b964a30a925be6e1b26e1e51ee329d /src/server/web | |
| parent | Tweak UI (diff) | |
| download | sharkey-fec3c70886c13a267814e7eba5d2dd9aa807687b.tar.gz sharkey-fec3c70886c13a267814e7eba5d2dd9aa807687b.tar.bz2 sharkey-fec3c70886c13a267814e7eba5d2dd9aa807687b.zip | |
Gallery (#7194)
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
Diffstat (limited to 'src/server/web')
| -rw-r--r-- | src/server/web/index.ts | 25 | ||||
| -rw-r--r-- | src/server/web/views/gallery-post.pug | 35 |
2 files changed, 59 insertions, 1 deletions
diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 1caab14cc2..c3b184088b 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -17,7 +17,7 @@ import packFeed from './feed'; import { fetchMeta } from '@/misc/fetch-meta'; import { genOpenapiSpec } from '../api/openapi/gen-spec'; import config from '@/config'; -import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips } from '../../models'; +import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '../../models'; import parseAcct from '@/misc/acct/parse'; import { getNoteSummary } from '@/misc/get-note-summary'; import { getConnection } from 'typeorm'; @@ -342,6 +342,29 @@ router.get('/clips/:clip', async ctx => { ctx.status = 404; }); +// Gallery post +router.get('/gallery/:post', async ctx => { + const post = await GalleryPosts.findOne(ctx.params.post); + + if (post) { + const _post = await GalleryPosts.pack(post); + const profile = await UserProfiles.findOneOrFail(post.userId); + const meta = await fetchMeta(); + await ctx.render('gallery-post', { + post: _post, + profile, + instanceName: meta.name || 'Misskey', + icon: meta.iconUrl + }); + + ctx.set('Cache-Control', 'public, max-age=180'); + + return; + } + + ctx.status = 404; +}); + // Channel router.get('/channels/:channel', async ctx => { const channel = await Channels.findOne({ diff --git a/src/server/web/views/gallery-post.pug b/src/server/web/views/gallery-post.pug new file mode 100644 index 0000000000..95bbb2437c --- /dev/null +++ b/src/server/web/views/gallery-post.pug @@ -0,0 +1,35 @@ +extends ./base + +block vars + - const user = post.user; + - const title = post.title; + - const url = `${config.url}/gallery/${post.id}`; + +block title + = `${title} | ${instanceName}` + +block desc + meta(name='description' content= post.description) + +block og + meta(property='og:type' content='article') + meta(property='og:title' content= title) + meta(property='og:description' content= post.description) + meta(property='og:url' content= url) + meta(property='og:image' content= post.files[0].thumbnailUrl) + +block meta + if user.host || profile.noCrawle + meta(name='robots' content='noindex') + + meta(name='misskey:user-username' content=user.username) + meta(name='misskey:user-id' content=user.id) + + meta(name='twitter:card' content='summary') + + // todo + if user.twitter + meta(name='twitter:creator' content=`@${user.twitter.screenName}`) + + if !user.host + link(rel='alternate' href=url type='application/activity+json') |