feat: Page drafts

This commit is contained in:
ThatOneCalculator 2022-11-18 19:24:05 -08:00
parent 445def68e3
commit 331b8664f8
11 changed files with 26 additions and 4 deletions

View file

@ -85,6 +85,7 @@
- Link hover effect - Link hover effect
- Replace all `$ts` with i18n - Replace all `$ts` with i18n
- AVIF support - AVIF support
- Page drafts
- Obliteration of Ai-chan - Obliteration of Ai-chan
- [Make showing ads optional](https://github.com/misskey-dev/misskey/pull/8996) - [Make showing ads optional](https://github.com/misskey-dev/misskey/pull/8996)
- [Tapping avatar in mobile opens account modal](https://github.com/misskey-dev/misskey/pull/9056) - [Tapping avatar in mobile opens account modal](https://github.com/misskey-dev/misskey/pull/9056)

View file

@ -1,6 +1,6 @@
{ {
"name": "calckey", "name": "calckey",
"version": "12.119.0-calc.15-beta.8", "version": "12.119.0-calc.15-beta.9",
"codename": "aqua", "codename": "aqua",
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -40,6 +40,9 @@ export class Page {
@Column('boolean') @Column('boolean')
public alignCenter: boolean; public alignCenter: boolean;
@Column('boolean')
public isPublic: boolean;
@Column('boolean', { @Column('boolean', {
default: false, default: false,
}) })

View file

@ -65,6 +65,7 @@ export const PageRepository = db.getRepository(Page).extend({
content: page.content, content: page.content,
variables: page.variables, variables: page.variables,
title: page.title, title: page.title,
isPublic: page.isPublic,
name: page.name, name: page.name,
summary: page.summary, summary: page.summary,
hideTitleWhenPinned: page.hideTitleWhenPinned, hideTitleWhenPinned: page.hideTitleWhenPinned,

View file

@ -47,5 +47,9 @@ export const packedPageSchema = {
ref: 'UserLite', ref: 'UserLite',
optional: false, nullable: false, optional: false, nullable: false,
}, },
isPublic: {
type: 'boolean',
optional: false, nullable: false,
},
}, },
} as const; } as const;

View file

@ -53,6 +53,7 @@ export const paramDef = {
eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true }, eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' }, font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' },
alignCenter: { type: 'boolean', default: false }, alignCenter: { type: 'boolean', default: false },
isPublic: { type: 'boolean', default: true },
hideTitleWhenPinned: { type: 'boolean', default: false }, hideTitleWhenPinned: { type: 'boolean', default: false },
}, },
required: ['title', 'name', 'content', 'variables', 'script'], required: ['title', 'name', 'content', 'variables', 'script'],
@ -97,6 +98,7 @@ export default define(meta, paramDef, async (ps, user) => {
alignCenter: ps.alignCenter, alignCenter: ps.alignCenter,
hideTitleWhenPinned: ps.hideTitleWhenPinned, hideTitleWhenPinned: ps.hideTitleWhenPinned,
font: ps.font, font: ps.font,
isPublic: ps.isPublic,
})).then(x => Pages.findOneByOrFail(x.identifiers[0])); })).then(x => Pages.findOneByOrFail(x.identifiers[0]));
return await Pages.pack(page); return await Pages.pack(page);

View file

@ -67,5 +67,9 @@ export default define(meta, paramDef, async (ps, user) => {
throw new ApiError(meta.errors.noSuchPage); throw new ApiError(meta.errors.noSuchPage);
} }
if (!page.isPublic && (user == null || (page.userId !== user.id))) {
throw new ApiError(meta.errors.noSuchPage);
}
return await Pages.pack(page, user); return await Pages.pack(page, user);
}); });

View file

@ -60,6 +60,7 @@ export const paramDef = {
font: { type: 'string', enum: ['serif', 'sans-serif'] }, font: { type: 'string', enum: ['serif', 'sans-serif'] },
alignCenter: { type: 'boolean' }, alignCenter: { type: 'boolean' },
hideTitleWhenPinned: { type: 'boolean' }, hideTitleWhenPinned: { type: 'boolean' },
isPublic: { type: 'boolean' },
}, },
required: ['pageId', 'title', 'name', 'content', 'variables', 'script'], required: ['pageId', 'title', 'name', 'content', 'variables', 'script'],
} as const; } as const;
@ -104,6 +105,7 @@ export default define(meta, paramDef, async (ps, user) => {
content: ps.content, content: ps.content,
variables: ps.variables, variables: ps.variables,
script: ps.script, script: ps.script,
isPublic: ps.isPublic,
alignCenter: ps.alignCenter === undefined ? page.alignCenter : ps.alignCenter, alignCenter: ps.alignCenter === undefined ? page.alignCenter : ps.alignCenter,
hideTitleWhenPinned: ps.hideTitleWhenPinned === undefined ? page.hideTitleWhenPinned : ps.hideTitleWhenPinned, hideTitleWhenPinned: ps.hideTitleWhenPinned === undefined ? page.hideTitleWhenPinned : ps.hideTitleWhenPinned,
font: ps.font === undefined ? page.font : ps.font, font: ps.font === undefined ? page.font : ps.font,

View file

@ -34,7 +34,8 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, user) => { export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
.andWhere('page.userId = :userId', { userId: ps.userId }) .andWhere('page.userId = :userId', { userId: ps.userId })
.andWhere('page.visibility = \'public\''); .andWhere('page.visibility = \'public\'')
.andWhere('page.isPublic = true');
const pages = await query const pages = await query
.take(ps.limit) .take(ps.limit)

View file

@ -48,7 +48,7 @@ watch(() => props.clipId, async () => {
}); });
}, { }, {
immediate: true, immediate: true,
}); });
provide('currentClipPage', $$(clip)); provide('currentClipPage', $$(clip));

View file

@ -24,6 +24,7 @@
<template #label>{{ i18n.ts._pages.url }}</template> <template #label>{{ i18n.ts._pages.url }}</template>
</MkInput> </MkInput>
<MkSwitch v-model="isPublic" class="_formBlock">{{ i18n.ts._pages.isPublic }}</MkSwitch>
<MkSwitch v-model="alignCenter" class="_formBlock">{{ i18n.ts._pages.alignCenter }}</MkSwitch> <MkSwitch v-model="alignCenter" class="_formBlock">{{ i18n.ts._pages.alignCenter }}</MkSwitch>
<MkSelect v-model="font" class="_formBlock"> <MkSelect v-model="font" class="_formBlock">
@ -130,6 +131,7 @@ let eyeCatchingImageId = $ref(null);
let font = $ref('sans-serif'); let font = $ref('sans-serif');
let content = $ref([]); let content = $ref([]);
let alignCenter = $ref(false); let alignCenter = $ref(false);
let isPublic = $ref(true);
let hideTitleWhenPinned = $ref(false); let hideTitleWhenPinned = $ref(false);
let variables = $ref([]); let variables = $ref([]);
let hpml = $ref(null); let hpml = $ref(null);
@ -158,6 +160,7 @@ function getSaveOptions() {
script: script, script: script,
hideTitleWhenPinned: hideTitleWhenPinned, hideTitleWhenPinned: hideTitleWhenPinned,
alignCenter: alignCenter, alignCenter: alignCenter,
isPublic: isPublic,
content: content, content: content,
variables: variables, variables: variables,
eyeCatchingImageId: eyeCatchingImageId, eyeCatchingImageId: eyeCatchingImageId,
@ -393,6 +396,7 @@ async function init() {
script = page.script; script = page.script;
hideTitleWhenPinned = page.hideTitleWhenPinned; hideTitleWhenPinned = page.hideTitleWhenPinned;
alignCenter = page.alignCenter; alignCenter = page.alignCenter;
isPublic = page.isPublic;
content = page.content; content = page.content;
variables = page.variables; variables = page.variables;
eyeCatchingImageId = page.eyeCatchingImageId; eyeCatchingImageId = page.eyeCatchingImageId;
@ -401,7 +405,7 @@ async function init() {
content = [{ content = [{
id, id,
type: 'text', type: 'text',
text: 'Hello World!', text: '',
}]; }];
} }
} }