Release 0.5.9
This commit is contained in:
1 parent
2851c7d936
commit
c3033479b5
32 files changed
+1598
-50
No files matched your search
@@ -11,12 +11,14 @@ import {
|
||||
savePiece,
|
||||
savePieceAsTemplate,
|
||||
setPieceArchived,
|
||||
setPieceFavorite,
|
||||
uploadPieceImage,
|
||||
type EditablePieceStatus,
|
||||
type PieceInput,
|
||||
type PieceSourceInput
|
||||
} from '#lib/server/content.js';
|
||||
import { renderMarkdown } from '#lib/server/markdown.js';
|
||||
import { listTools } from '#lib/server/tools.js';
|
||||
|
||||
function renderedFields(
|
||||
piece: Pick<
|
||||
@@ -57,6 +59,9 @@ function pieceInput(data: FormData): PieceInput {
|
||||
timecodeSeconds: timecode ? Number(timecode) : null
|
||||
});
|
||||
}
|
||||
const toolIds = data.getAll('toolId').map(String);
|
||||
const toolWorkUrls = data.getAll('toolWorkUrl').map(String);
|
||||
const toolNotes = data.getAll('toolNote').map(String);
|
||||
return {
|
||||
title: text(data, 'title'),
|
||||
outputTitle: text(data, 'outputTitle'),
|
||||
@@ -85,7 +90,12 @@ function pieceInput(data: FormData): PieceInput {
|
||||
presentationMetadataFetchedAtUtc: text(data, 'presentationMetadataFetchedAtUtc') || null,
|
||||
topicIds: data.getAll('topicIds').map(String),
|
||||
categoryIds: data.getAll('categoryIds').map(String),
|
||||
sources
|
||||
sources,
|
||||
tools: toolIds.map((toolId, index) => ({
|
||||
toolId,
|
||||
workUrl: toolWorkUrls[index] ?? '',
|
||||
note: toolNotes[index] ?? ''
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -126,6 +136,7 @@ export const load: PageServerLoad = ({ locals, params }) => {
|
||||
return {
|
||||
piece,
|
||||
taxonomy: getTaxonomy(),
|
||||
tools: listTools(true),
|
||||
templates: listPieceTemplates().filter((template) => template.id !== 'blank'),
|
||||
rendered: renderedFields(piece)
|
||||
};
|
||||
@@ -243,5 +254,15 @@ export const actions = {
|
||||
return fail(409, { intent: 'archive', error: saveError(cause).error });
|
||||
}
|
||||
redirect(303, '/archiv');
|
||||
},
|
||||
favorite: async ({ locals, params, request }) => {
|
||||
requireUser(locals.user);
|
||||
const data = await request.formData();
|
||||
try {
|
||||
setPieceFavorite(params.id, data.get('favorite') === '1');
|
||||
return { intent: 'favorite', success: true };
|
||||
} catch (cause) {
|
||||
return fail(404, { intent: 'favorite', error: saveError(cause).error });
|
||||
}
|
||||
}
|
||||
} satisfies Actions;
|
||||
Reference in new issue
Block a user