Hide private data in pug when private mode is enabled
This commit is contained in:
parent
a69557f193
commit
3f14e23431
|
@ -218,6 +218,10 @@ router.get('/api.json', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const getFeed = async (acct: string) => {
|
const getFeed = async (acct: string) => {
|
||||||
|
const meta = await fetchMeta();
|
||||||
|
if (meta.privateMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { username, host } = Acct.parse(acct);
|
const { username, host } = Acct.parse(acct);
|
||||||
const user = await Users.findOneBy({
|
const user = await Users.findOneBy({
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
|
@ -290,6 +294,7 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
} else {
|
} else {
|
||||||
|
@ -333,6 +338,7 @@ router.get('/notes/:note', async (ctx, next) => {
|
||||||
summary: getNoteSummary(_note),
|
summary: getNoteSummary(_note),
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -370,6 +376,7 @@ router.get('/@:user/pages/:page', async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (['public'].includes(page.visibility)) {
|
if (['public'].includes(page.visibility)) {
|
||||||
|
@ -400,6 +407,7 @@ router.get('/clips/:clip', async (ctx, next) => {
|
||||||
profile,
|
profile,
|
||||||
avatarUrl: await Users.getAvatarUrl(await Users.findOneByOrFail({ id: clip.userId })),
|
avatarUrl: await Users.getAvatarUrl(await Users.findOneByOrFail({ id: clip.userId })),
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
|
privateMode: meta.privateMode,
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
@ -427,6 +435,7 @@ router.get('/gallery/:post', async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -451,6 +460,7 @@ router.get('/channels/:channel', async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -464,6 +474,10 @@ router.get('/channels/:channel', async (ctx, next) => {
|
||||||
|
|
||||||
router.get('/_info_card_', async ctx => {
|
router.get('/_info_card_', async ctx => {
|
||||||
const meta = await fetchMeta(true);
|
const meta = await fetchMeta(true);
|
||||||
|
if (meta.privateMode) {
|
||||||
|
ctx.status = 403;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ctx.remove('X-Frame-Options');
|
ctx.remove('X-Frame-Options');
|
||||||
|
|
||||||
|
@ -511,6 +525,7 @@ router.get('(.*)', async ctx => {
|
||||||
desc: meta.description,
|
desc: meta.description,
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,10 +51,12 @@ html
|
||||||
meta(name='description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
|
meta(name='description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
|
if privateMode
|
||||||
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:title' content= title || 'Misskey')
|
meta(property='og:title' content= title || 'Misskey')
|
||||||
meta(property='og:description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
|
meta(property='og:description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
|
||||||
meta(property='og:image' content= img)
|
meta(property='og:image' content= img)
|
||||||
|
|
||||||
style
|
style
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
extends ./base
|
extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const title = channel.name;
|
- const title = privateMode ? '非公開インスタンス' : channel.name;
|
||||||
- const url = `${config.url}/channels/${channel.id}`;
|
- const url = `${config.url}/channels/${channel.id}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
meta(name='description' content= channel.description)
|
unless privateMode
|
||||||
|
meta(name='description' content=channel.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:type' content='article')
|
unless privateMode
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:description' content= channel.description)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:url' content= url)
|
meta(property='og:description' content= channel.description)
|
||||||
meta(property='og:image' content= channel.bannerUrl)
|
meta(property='og:url' content= url)
|
||||||
|
meta(property='og:image' content= channel.bannerUrl)
|
||||||
|
|
|
@ -2,30 +2,33 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = clip.user;
|
- const user = clip.user;
|
||||||
- const title = clip.name;
|
- const title = privateMode ? '非公開インスタンス' : clip.name;
|
||||||
- const url = `${config.url}/clips/${clip.id}`;
|
- const url = `${config.url}/clips/${clip.id}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
meta(name='description' content= clip.description)
|
unless privateMode
|
||||||
|
meta(name='description' content= clip.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:type' content='article')
|
unless privateMode
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:description' content= clip.description)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:url' content= url)
|
meta(property='og:description' content= clip.description)
|
||||||
meta(property='og:image' content= avatarUrl)
|
meta(property='og:url' content= url)
|
||||||
|
meta(property='og:image' content= avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
if profile.noCrawle
|
unless privateMode
|
||||||
meta(name='robots' content='noindex')
|
if profile.noCrawle
|
||||||
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
meta(name='misskey:user-username' content=user.username)
|
meta(name='misskey:user-username' content=user.username)
|
||||||
meta(name='misskey:user-id' content=user.id)
|
meta(name='misskey:user-id' content=user.id)
|
||||||
meta(name='misskey:clip-id' content=clip.id)
|
meta(name='misskey:clip-id' content=clip.id)
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
if user.twitter
|
if user.twitter
|
||||||
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
||||||
|
|
|
@ -2,32 +2,35 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = post.user;
|
- const user = post.user;
|
||||||
- const title = post.title;
|
- const title = privateMode ? '非公開インスタンス' : post.title;
|
||||||
- const url = `${config.url}/gallery/${post.id}`;
|
- const url = `${config.url}/gallery/${post.id}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
meta(name='description' content= post.description)
|
unless privateMode
|
||||||
|
meta(name='description' content= post.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:type' content='article')
|
unless privateMode
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:description' content= post.description)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:url' content= url)
|
meta(property='og:description' content= post.description)
|
||||||
meta(property='og:image' content= post.files[0].thumbnailUrl)
|
meta(property='og:url' content= url)
|
||||||
|
meta(property='og:image' content= post.files[0].thumbnailUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
if user.host || profile.noCrawle
|
unless privateMode
|
||||||
meta(name='robots' content='noindex')
|
if user.host || profile.noCrawle
|
||||||
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
meta(name='misskey:user-username' content=user.username)
|
meta(name='misskey:user-username' content=user.username)
|
||||||
meta(name='misskey:user-id' content=user.id)
|
meta(name='misskey:user-id' content=user.id)
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
if user.twitter
|
if user.twitter
|
||||||
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
||||||
|
|
||||||
if !user.host
|
if !user.host
|
||||||
link(rel='alternate' href=url type='application/activity+json')
|
link(rel='alternate' href=url type='application/activity+json')
|
||||||
|
|
|
@ -2,7 +2,7 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = note.user;
|
- const user = note.user;
|
||||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
- const title = privateMode ? '非公開インスタンス' : (user.name ? `${user.name} (@${user.username})` : `@${user.username}`);
|
||||||
- const url = `${config.url}/notes/${note.id}`;
|
- const url = `${config.url}/notes/${note.id}`;
|
||||||
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
|
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
|
||||||
|
|
||||||
|
@ -10,33 +10,36 @@ block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
meta(name='description' content= summary)
|
unless privateMode
|
||||||
|
meta(name='description' content= summary)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:type' content='article')
|
unless privateMode
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:description' content= summary)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:url' content= url)
|
meta(property='og:description' content= summary)
|
||||||
meta(property='og:image' content= avatarUrl)
|
meta(property='og:url' content= url)
|
||||||
|
meta(property='og:image' content= avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
if user.host || isRenote || profile.noCrawle
|
unless privateMode
|
||||||
meta(name='robots' content='noindex')
|
if user.host || isRenote || profile.noCrawle
|
||||||
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
meta(name='misskey:user-username' content=user.username)
|
meta(name='misskey:user-username' content=user.username)
|
||||||
meta(name='misskey:user-id' content=user.id)
|
meta(name='misskey:user-id' content=user.id)
|
||||||
meta(name='misskey:note-id' content=note.id)
|
meta(name='misskey:note-id' content=note.id)
|
||||||
|
|
||||||
// todo
|
|
||||||
if user.twitter
|
|
||||||
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
|
||||||
|
|
||||||
if note.prev
|
// todo
|
||||||
link(rel='prev' href=`${config.url}/notes/${note.prev}`)
|
if user.twitter
|
||||||
if note.next
|
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
||||||
link(rel='next' href=`${config.url}/notes/${note.next}`)
|
|
||||||
|
|
||||||
if !user.host
|
if note.prev
|
||||||
link(rel='alternate' href=url type='application/activity+json')
|
link(rel='prev' href=`${config.url}/notes/${note.prev}`)
|
||||||
if note.uri
|
if note.next
|
||||||
link(rel='alternate' href=note.uri type='application/activity+json')
|
link(rel='next' href=`${config.url}/notes/${note.next}`)
|
||||||
|
|
||||||
|
if !user.host
|
||||||
|
link(rel='alternate' href=url type='application/activity+json')
|
||||||
|
if note.uri
|
||||||
|
link(rel='alternate' href=note.uri type='application/activity+json')
|
||||||
|
|
|
@ -2,30 +2,33 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = page.user;
|
- const user = page.user;
|
||||||
- const title = page.title;
|
- const title = privateMode ? '非公開インスタンス' : page.title;
|
||||||
- const url = `${config.url}/@${user.username}/${page.name}`;
|
- const url = `${config.url}/@${user.username}/${page.name}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
meta(name='description' content= page.summary)
|
unless privateMode
|
||||||
|
meta(name='description' content= page.summary)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:type' content='article')
|
unless privateMode
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:description' content= page.summary)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:url' content= url)
|
meta(property='og:description' content= page.summary)
|
||||||
meta(property='og:image' content= page.eyeCatchingImage ? page.eyeCatchingImage.thumbnailUrl : avatarUrl)
|
meta(property='og:url' content= url)
|
||||||
|
meta(property='og:image' content= page.eyeCatchingImage ? page.eyeCatchingImage.thumbnailUrl : avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
if profile.noCrawle
|
unless privateMode
|
||||||
meta(name='robots' content='noindex')
|
if profile.noCrawle
|
||||||
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
meta(name='misskey:user-username' content=user.username)
|
meta(name='misskey:user-username' content=user.username)
|
||||||
meta(name='misskey:user-id' content=user.id)
|
meta(name='misskey:user-id' content=user.id)
|
||||||
meta(name='misskey:page-id' content=page.id)
|
meta(name='misskey:page-id' content=page.id)
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
if user.twitter
|
if user.twitter
|
||||||
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
|
||||||
|
|
|
@ -1,39 +1,42 @@
|
||||||
extends ./base
|
extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
- const title = privateMode ? '非公開インスタンス' : (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)}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
meta(name='description' content= profile.description)
|
unless privateMode
|
||||||
|
meta(name='description' content= profile.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:type' content='blog')
|
unless privateMode
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:type' content='blog')
|
||||||
meta(property='og:description' content= profile.description)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:url' content= url)
|
meta(property='og:description' content= profile.description)
|
||||||
meta(property='og:image' content= avatarUrl)
|
meta(property='og:url' content= url)
|
||||||
|
meta(property='og:image' content= avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
if user.host || profile.noCrawle
|
unless privateMode
|
||||||
meta(name='robots' content='noindex')
|
if user.host || profile.noCrawle
|
||||||
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
meta(name='misskey:user-username' content=user.username)
|
meta(name='misskey:user-username' content=user.username)
|
||||||
meta(name='misskey:user-id' content=user.id)
|
meta(name='misskey:user-id' content=user.id)
|
||||||
|
|
||||||
if profile.twitter
|
if profile.twitter
|
||||||
meta(name='twitter:creator' content=`@${profile.twitter.screenName}`)
|
meta(name='twitter:creator' content=`@${profile.twitter.screenName}`)
|
||||||
|
|
||||||
if !sub
|
if !sub
|
||||||
if !user.host
|
if !user.host
|
||||||
link(rel='alternate' href=`${config.url}/users/${user.id}` type='application/activity+json')
|
link(rel='alternate' href=`${config.url}/users/${user.id}` type='application/activity+json')
|
||||||
if user.uri
|
if user.uri
|
||||||
link(rel='alternate' href=user.uri type='application/activity+json')
|
link(rel='alternate' href=user.uri type='application/activity+json')
|
||||||
if profile.url
|
if profile.url
|
||||||
link(rel='alternate' href=profile.url type='text/html')
|
link(rel='alternate' href=profile.url type='text/html')
|
||||||
|
|
||||||
each m in me
|
each m in me
|
||||||
link(rel='me' href=`${m}`)
|
link(rel='me' href=`${m}`)
|
||||||
|
|
Loading…
Reference in New Issue