This repository has been archived by the owner on Nov 4, 2021. It is now read-only.
forked from pitaj/nodebb-plugin-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
86 lines (77 loc) · 2.4 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import 'source-map-support/register';
import init from './init';
import { parsePost, parseRaw, postSummary, topicTeaser } from './parseFilters';
import { postSave } from './postSave';
import { privilegesList, privilegesGroupsList, privilegesListHuman } from './privileges';
import { deleteEvent, restoreEvent, purgeEvent } from './event';
import './sockets';
import { initialize as initTranslatorModule } from './translatorModule';
import {
action__post_delete,
action__post_purge,
action__post_restore,
filter__admin_header_build,
filter__composer_formatting,
filter__navigation_available,
filter__sanitize_config,
} from './hooks';
const { Translator } = require.main?.require('./public/src/modules/translator');
initTranslatorModule(Translator);
const addNavigation: filter__navigation_available = async (navs) => {
navs.push({
route: '/calendar',
title: '\\[\\[calendar:calendar\\]\\]',
iconClass: 'fa-calendar',
textClass: 'visible-xs-inline',
text: '\\[\\[calendar:calendar\\]\\]',
});
return navs;
};
const adminMenu: filter__admin_header_build = async (header) => {
header.plugins.push({
route: '/plugins/calendar',
icon: 'fa-calendar',
name: 'Calendar',
});
return header;
};
const composerFormatting: filter__composer_formatting = async (data) => {
data.options.push({
name: 'plugin-calendar-event',
className: 'fa fa-calendar-o plugin-calendar-composer-edit-event',
title: '[[calendar:edit_event]]',
});
return data;
};
/* eslint-disable no-param-reassign */
const sanitizeConfig: filter__sanitize_config = async (config) => {
config.allowedTags.push('input');
config.allowedAttributes.input = ['class', 'title', 'type'];
// in case we're on an older NodeBB version
config.allowedClasses = config.allowedClasses || {};
config.allowedClasses.input = ['form-control'];
return config;
};
/* eslint-enable no-param-reassign */
const postDelete: action__post_delete = (data) => { deleteEvent(data); };
const postRestore: action__post_restore = (data) => { restoreEvent(data); };
const postPurge: action__post_purge = (data) => { purgeEvent(data); };
export {
init,
addNavigation,
adminMenu,
parsePost,
parseRaw,
postSummary,
topicTeaser,
postSave as postCreate,
postSave as postEdit,
privilegesList,
privilegesGroupsList,
privilegesListHuman,
composerFormatting,
sanitizeConfig,
postDelete,
postRestore,
postPurge,
};