This repository has been archived by the owner on Dec 28, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
library.js
131 lines (109 loc) · 2.96 KB
/
library.js
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"use strict";
const striptags = require("striptags");
const meta = require.main.require("./src/meta");
const user = require.main.require("./src/user");
let library = {};
const renderAdmin = (req, res) => res.render("admin/plugins/oxide");
library.init = ({ router, middleware }, callback) => {
const app = router;
app.get("/admin/plugins/oxide", middleware.admin.buildHeader, renderAdmin);
app.get("/api/admin/plugins/oxide", renderAdmin);
callback();
};
library.addAdminNavigation = (header, callback) => {
header.plugins.push({
route: "/plugins/oxide",
icon: "fa-paint-brush",
name: "Oxide Theme",
});
callback(null, header);
};
library.getTeasers = (data, callback) => {
data.teasers.forEach((teaser) =>
teaser && teaser.content ? (teaser.content = striptags(teaser.content, ["img"])) : ""
);
callback(null, data);
};
library.defineWidgetAreas = (areas, callback) => {
const localAreas = [
{
name: "Categories Sidebar",
template: "categories.tpl",
location: "sidebar",
},
{
name: "Category Sidebar",
template: "category.tpl",
location: "sidebar",
},
{
name: "Topic Sidebar",
template: "topic.tpl",
location: "sidebar",
},
{
name: "Categories Header",
template: "categories.tpl",
location: "header",
},
{
name: "Category Header",
template: "category.tpl",
location: "header",
},
{
name: "Topic Header",
template: "topic.tpl",
location: "header",
},
{
name: "Categories Footer",
template: "categories.tpl",
location: "footer",
},
{
name: "Category Footer",
template: "category.tpl",
location: "footer",
},
{
name: "Topic Footer",
template: "topic.tpl",
location: "footer",
},
];
callback(null, [...areas, ...localAreas]);
};
library.getThemeConfig = (config, callback) => {
meta.settings.get("oxide", (err, settings) => {
if (err) return callback(err);
config.hideSubCategories = settings.hideSubCategories === "on";
config.hideCategoryLastPost = settings.hideCategoryLastPost === "on";
config.enableQuickReply = settings.enableQuickReply === "on";
config.enableShowTid = settings.enableShowTid === "on";
config.enableCategoryIcon = settings.enableCategoryIcon === "on";
config.enableShowUserAllGroupsInProfile = settings.enableShowUserAllGroupsInProfile === "on";
config.enableShowIpInUserProfile = settings.enableShowIpInUserProfile === "on";
config.enableDarkmodeIsDefault = settings.enableDarkmodeIsDefault === "on";
});
callback(null, config);
};
library.addUserToTopic = (data, callback) => {
const { user: reqUser } = data.req;
if (!reqUser) {
data.templateData.loggedInUser = {
uid: 0,
username: "[[global:guest]]",
picture: user.getDefaultAvatar(),
"icon:text": "?",
"icon:bgColor": "#aaa",
};
return callback(null, data);
}
user.getUserData(reqUser.uid, (err, userdata) => {
if (err) return callback(err);
data.templateData.loggedInUser = userdata;
callback(null, data);
});
};
module.exports = library;