Документация: разделы и статьи в docs.html
- Добавлены 12 разделов документации: Журнал, Отчёты о занятиях, Ученики, Группы, Обратная связь, Короткие сообщения, Чаты, Фото, Файлы, Ссылки, Закладки, Заметки (каждый со вступительной статьёй) - Сид разделов в lib/docs.js (ensureDocsTables) и db/migration.sql -doc_images добавлен в sweepOrphanedUploads и BROKEN_IMAGE_SOURCES - Исправлен дубль docSectionIds в backup-restore.js - Роуты /api/docs/* в server.js - Страницы public/docs.html, public/docs-public.html, скрипты public/js/docs.js, public/js/docs-public.js, public/js/md.js
This commit is contained in:
+50
-3
@@ -19,14 +19,14 @@ const BACKUP_TABLES = [
|
||||
'lesson_reports', 'lesson_report_versions', 'audit_log', 'notifications',
|
||||
'notification_reads', 'banned_ips', 'chat_threads', 'chat_messages', 'chat_attachments',
|
||||
'short_messages', 'feedbacks', 'bookmarks', 'student_face_refs', 'photo_faces',
|
||||
'student_work_marks',
|
||||
'student_work_marks', 'doc_sections', 'doc_articles', 'doc_images',
|
||||
];
|
||||
const BACKUP_SEQUENCE_TABLES = [
|
||||
'groups', 'students', 'entries', 'project_files', 'branches', 'users', 'user_notes', 'group_photos',
|
||||
'entry_photos', 'modules', 'student_photos', 'share_links', 'photo_jobs', 'lesson_reports',
|
||||
'lesson_report_versions', 'audit_log', 'notifications', 'chat_threads', 'chat_messages',
|
||||
'chat_attachments', 'short_messages', 'feedbacks', 'bookmarks', 'student_face_refs', 'photo_faces',
|
||||
'student_work_marks',
|
||||
'student_work_marks', 'doc_sections', 'doc_articles', 'doc_images',
|
||||
];
|
||||
|
||||
function isSupportedBackupVersion(data) {
|
||||
@@ -623,6 +623,53 @@ function normalizeRestoreData(data) {
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
}));
|
||||
const docSections = (data.doc_sections || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
parent_id: x.parent_id == null ? null : reqInt(x.parent_id),
|
||||
title: optText(x.title, 200) || '',
|
||||
sort_order: optInt(x.sort_order, -10000000, 10000000) ?? 0,
|
||||
tutor_edit: x.tutor_edit === true,
|
||||
is_public: x.is_public === true,
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
})).filter(x => x.title);
|
||||
const docSectionIds = new Set(docSections.map(x => x.id));
|
||||
for (const section of docSections) {
|
||||
if (section.parent_id != null && (!docSectionIds.has(section.parent_id) || section.parent_id === section.id)) {
|
||||
section.parent_id = null;
|
||||
}
|
||||
}
|
||||
const docArticles = (data.doc_articles || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
section_id: reqInt(x.section_id),
|
||||
slug: optText(x.slug, 140) || '',
|
||||
title: optText(x.title, 200) || '',
|
||||
body: optText(x.body, 200000) || '',
|
||||
sort_order: optInt(x.sort_order, -10000000, 10000000) ?? 0,
|
||||
is_published: x.is_published !== false,
|
||||
is_public: x.is_public === true,
|
||||
author_id: x.author_id == null ? null : reqInt(x.author_id),
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
})).filter(x => x.slug && x.title && x.section_id);
|
||||
const usedDocSlugs = new Set();
|
||||
for (const article of docArticles) {
|
||||
let slug = article.slug;
|
||||
let suffix = 1;
|
||||
while (usedDocSlugs.has(slug)) {
|
||||
suffix += 1;
|
||||
slug = `${article.slug.slice(0, 130)}-${suffix}`;
|
||||
}
|
||||
article.slug = slug;
|
||||
usedDocSlugs.add(slug);
|
||||
}
|
||||
const docImages = (data.doc_images || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
article_id: x.article_id == null ? null : reqInt(x.article_id),
|
||||
path: optUploadPath(x.path, 300) || '',
|
||||
uploaded_by: x.uploaded_by == null ? null : reqInt(x.uploaded_by),
|
||||
created_at: optTs(x.created_at),
|
||||
})).filter(x => x.path);
|
||||
const faceRefs = (data.student_face_refs || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
student_id: reqInt(x.student_id),
|
||||
@@ -646,7 +693,7 @@ function normalizeRestoreData(data) {
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
})).filter(x => x.source_id && x.photo_path);
|
||||
return { groups, students, entries, project_files, settings, branches, users, user_branches, user_settings, user_notes, entry_photos, student_photos, group_photos, share_links, modules, photo_jobs, lesson_reports, lesson_report_versions, audit_log, notifications, notification_reads, banned_ips, chat_threads, chat_messages, chat_attachments, short_messages, feedbacks, bookmarks, student_face_refs: faceRefs, photo_faces: faceRows, student_work_marks };
|
||||
return { groups, students, entries, project_files, settings, branches, users, user_branches, user_settings, user_notes, entry_photos, student_photos, group_photos, share_links, modules, photo_jobs, lesson_reports, lesson_report_versions, audit_log, notifications, notification_reads, banned_ips, chat_threads, chat_messages, chat_attachments, short_messages, feedbacks, bookmarks, student_face_refs: faceRefs, photo_faces: faceRows, student_work_marks, doc_sections: docSections, doc_articles: docArticles, doc_images: docImages };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user