"tag list" to choose from?
-
Is it possible to create whitelisted tags for the whole forum , and prevent new tags to be created by regular users?
So, everyone can only use tags that are pre-determined by the moderators/admins?
-
Yeah that's correct you would have to do them one by one in the UI. Alternatively if you are going to set all categories to the same 200 tags you can run the below script in your nodebb folder. Update the
tags
array to the the tags you wan't to allow. This script would delete all existing tag whitelists for all categories then set all categories to same list of allowed tags./* globals require, console, process */ 'use strict'; const nconf = require('nconf'); nconf.file({ file: 'config.json', }); nconf.defaults({ base_dir: __dirname, views_dir: './build/public/templates', upload_path: 'public/uploads', }); var db = require('./src/database'); // update to your own tags const tags = ['tag1', 'tag2', 'tag3']; db.init(function (err) { if (err) { console.log('NodeBB could not connect to your database. Error: ' + err.message); process.exit(); } setCategoryWhitelist(function (err) { if (err) { console.error(err); process.exit(); } console.log('done'); process.exit(); }); }); async function setCategoryWhitelist(callback) { const cids = await db.getSortedSetRange('categories:cid', 0, -1); // delete all existing tags await db.deleteAll(cids.map(cid => `cid:${cid}:tag:whitelist`)); // set new tag whitelist for all categories const bulkAdd = []; cids.forEach((cid) => { tags.forEach((tag, index) => { bulkAdd.push([`cid:${cid}:tag:whitelist`, index, tag]); }); }); await db.sortedSetAddBulk(bulkAdd); callback(); }
-
@baris said in "tag list" to choose from?:
Yes but you need to do it for each category, under
Tag whitelist
input.I think this requires inputting each tag separately, right? Is there an easy way to do this? Because I am talking about more than 200 tags... And I believe I have to input each tag in each category/sub-category separately, right?
-
Yeah that's correct you would have to do them one by one in the UI. Alternatively if you are going to set all categories to the same 200 tags you can run the below script in your nodebb folder. Update the
tags
array to the the tags you wan't to allow. This script would delete all existing tag whitelists for all categories then set all categories to same list of allowed tags./* globals require, console, process */ 'use strict'; const nconf = require('nconf'); nconf.file({ file: 'config.json', }); nconf.defaults({ base_dir: __dirname, views_dir: './build/public/templates', upload_path: 'public/uploads', }); var db = require('./src/database'); // update to your own tags const tags = ['tag1', 'tag2', 'tag3']; db.init(function (err) { if (err) { console.log('NodeBB could not connect to your database. Error: ' + err.message); process.exit(); } setCategoryWhitelist(function (err) { if (err) { console.error(err); process.exit(); } console.log('done'); process.exit(); }); }); async function setCategoryWhitelist(callback) { const cids = await db.getSortedSetRange('categories:cid', 0, -1); // delete all existing tags await db.deleteAll(cids.map(cid => `cid:${cid}:tag:whitelist`)); // set new tag whitelist for all categories const bulkAdd = []; cids.forEach((cid) => { tags.forEach((tag, index) => { bulkAdd.push([`cid:${cid}:tag:whitelist`, index, tag]); }); }); await db.sortedSetAddBulk(bulkAdd); callback(); }
-
-
-
@baris said in "tag list" to choose from?:
Yeah that's correct you would have to do them one by one in the UI. Alternatively if you are going to set all categories to the same 200 tags you can run the below script in your nodebb folder. Update the
tags
array to the the tags you wan't to allow. This script would delete all existing tag whitelists for all categories then set all categories to same list of allowed tags./* globals require, console, process */ 'use strict'; const nconf = require('nconf'); nconf.file({ file: 'config.json', }); nconf.defaults({ base_dir: __dirname, views_dir: './build/public/templates', upload_path: 'public/uploads', }); var db = require('./src/database'); // update to your own tags const tags = ['tag1', 'tag2', 'tag3']; db.init(function (err) { if (err) { console.log('NodeBB could not connect to your database. Error: ' + err.message); process.exit(); } setCategoryWhitelist(function (err) { if (err) { console.error(err); process.exit(); } console.log('done'); process.exit(); }); }); async function setCategoryWhitelist(callback) { const cids = await db.getSortedSetRange('categories:cid', 0, -1); // delete all existing tags await db.deleteAll(cids.map(cid => `cid:${cid}:tag:whitelist`)); // set new tag whitelist for all categories const bulkAdd = []; cids.forEach((cid) => { tags.forEach((tag, index) => { bulkAdd.push([`cid:${cid}:tag:whitelist`, index, tag]); }); }); await db.sortedSetAddBulk(bulkAdd); callback(); }
Hi Baris, can we use the same code for tag whitelisting in NodeBB 3.7 ?
-
@baris thanks, will the following issue change the code later on? or should I ask this after the commit
Allow case-sensitive tagging 路 Issue #12435 路 NodeBB/NodeBB
This is only tangentially related to ActivityPub, but is more closely aligned with accessibility. NodeBB currently lowercases tags, which I think might be because it's more easily searchable that way? Not sure. Not surprisingly, it means...
GitHub (github.com)