Skip to content

Node.js based forum software built for the modern web

feat: add category selector to /world quick composer

Julian Lam2f5021e54730
diff --git a/install/data/defaults.json b/install/data/defaults.json
index 2636fa875c..a6b25a2732 100644
--- a/install/data/defaults.json
+++ b/install/data/defaults.json
@@ -208,5 +208,6 @@
"activitypubUserPruneDays": 7,
"activitypubFilter": 0,
"activitypubSummaryLimit": 500,
- "activitypubBreakString": "[...]"
+ "activitypubBreakString": "[...]",
+ "activitypubWorldDefaultCid": -1
}
diff --git a/install/package.json b/install/package.json
index 55d3247aba..ee1a0c15d6 100644
--- a/install/package.json
+++ b/install/package.json
@@ -108,10 +108,10 @@
"nodebb-plugin-spam-be-gone": "2.3.2",
"nodebb-plugin-web-push": "0.7.7",
"nodebb-rewards-essentials": "1.0.2",
- "nodebb-theme-harmony": "2.2.57",
+ "nodebb-theme-harmony": "2.2.58",
"nodebb-theme-lavender": "7.1.21",
"nodebb-theme-peace": "2.2.57",
- "nodebb-theme-persona": "14.2.31",
+ "nodebb-theme-persona": "14.2.32",
"nodebb-widget-essentials": "7.0.43",
"nodemailer": "8.0.2",
"nprogress": "0.2.0",
diff --git a/public/language/en-GB/admin/settings/activitypub.json b/public/language/en-GB/admin/settings/activitypub.json
index 0486870db1..64508849aa 100644
--- a/public/language/en-GB/admin/settings/activitypub.json
+++ b/public/language/en-GB/admin/settings/activitypub.json
@@ -50,5 +50,6 @@
"content.summary-limit": "Character count after which a summary is generated",
"content.summary-limit-help": "When content is federated out that exceeds this character count, a <code>summary</code> is generated, comprising of all complete sentences prior to this limit. (Default: 500)",
"content.break-string": "Note/Article Delimiter",
- "content.break-string-help": "This delimiter can be manually inserted by power users when composing new topics. It instructs NodeBB to use content up until that point as part of the <code>summary</code>. If this string is not used, then the character count fallback applies. (Default: <code>[...]</code>)"
+ "content.break-string-help": "This delimiter can be manually inserted by power users when composing new topics. It instructs NodeBB to use content up until that point as part of the <code>summary</code>. If this string is not used, then the character count fallback applies. (Default: <code>[...]</code>)",
+ "content.world-default-cid": "Default category ID for &quot;World&quot; page composer"
}
\ No newline at end of file
diff --git a/public/src/modules/quickreply.js b/public/src/modules/quickreply.js
index 9172ca3769..f081c59588 100644
--- a/public/src/modules/quickreply.js
+++ b/public/src/modules/quickreply.js
@@ -3,9 +3,11 @@
define('quickreply', [
'components', 'autocomplete', 'api',
'alerts', 'uploadHelpers', 'mousetrap', 'storage', 'hooks',
+ 'categorySelector',
], function (
components, autocomplete, api,
- alerts, uploadHelpers, mousetrap, storage, hooks
+ alerts, uploadHelpers, mousetrap, storage, hooks,
+ categorySelector,
) {
const QuickReply = {
_autocomplete: null,
@@ -17,6 +19,17 @@ define('quickreply', [
return;
}
+ if ($('[component="topic/quickreply/container"] [component="category-selector"]')) {
+ categorySelector.init($('[component="category-selector"]'), {
+ privilege: 'topics:create',
+ selectedCategory: ajaxify.data.selectedCategory,
+ onSelect: function (category) {
+ opts.body = opts.body || {};
+ opts.body.cid = category.cid;
+ },
+ });
+ }
+
const qrDraftId = ajaxify.data.tid ? `qr:draft:tid:${ajaxify.data.tid}` : `qr:draft:cid:${opts?.body?.cid || -1}`;
const data = {
element: element,
diff --git a/src/controllers/activitypub/topics.js b/src/controllers/activitypub/topics.js
index 775d738305..26008e416c 100644
--- a/src/controllers/activitypub/topics.js
+++ b/src/controllers/activitypub/topics.js
@@ -26,10 +26,11 @@ controller.list = async function (req, res) {
let start = Math.max(0, (page - 1) * topicsPerPage);
let stop = start + topicsPerPage - 1;
- const [userSettings, userPrivileges, isAdminOrGlobalMod] = await Promise.all([
+ const [userSettings, userPrivileges, isAdminOrGlobalMod, selectedCategory] = await Promise.all([
user.getSettings(req.uid),
privileges.categories.get('-1', req.uid),
user.isAdminOrGlobalMod(req.uid),
+ categories.getCategoryData(meta.config.activitypubWorldDefaultCid),
]);
const targetUid = await user.getUidByUserslug(req.query.author);
let cidQuery = {
@@ -48,6 +49,7 @@ controller.list = async function (req, res) {
delete data.children;
data.sort = req.query.sort;
data.privileges = userPrivileges;
+ data.selectedCategory = selectedCategory;
let tids;
let topicCount;
diff --git a/src/views/admin/federation/content.tpl b/src/views/admin/federation/content.tpl
index 3ee43fcf21..be584f6de2 100644
--- a/src/views/admin/federation/content.tpl
+++ b/src/views/admin/federation/content.tpl
@@ -20,6 +20,10 @@
[[admin/settings/activitypub:content.break-string-help]]
</div>
</div>
+ <div class="mb-3">
+ <label class="form-label" for="activitypubWorldDefaultCid">[[admin/settings/activitypub:content.world-default-cid]]</label>
+ <input type="text" id="activitypubWorldDefaultCid" name="activitypubWorldDefaultCid" data-field="activitypubWorldDefaultCid" title="[[admin/settings/activitypub:content.world-default-cid]]" class="form-control" />
+ </div>
</form>
</div>
</div>