Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,4 @@ pip-log.txt

sftp-config.json
node_modules/
.gitconfig_local
32 changes: 30 additions & 2 deletions languages/de/glossary.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
{
"title": "Wörterbuch"
}
"title": "Wörterbuch",
"widgets": {
"header": "Wörterbuch-Seite (Kopfzeile)",
"left": "Wörterbuch-Seite (Links)",
"right": "Wörterbuch-Seite (Rechts)",
"footer": "Wörterbuch-Seite (Fußzeile)"
},
"admin": {
"general": "Allgemein",
"enabled": "Aktiviert",
"singleMatch": "Einzelne Übereinstimmung",
"caseSensitive": "Groß-/Kleinschreibung beachten",
"iconLabel": "Symbol neben Schlüsselwort anzeigen, leer lassen zum Deaktivieren",
"keywords": "Schlüsselwörter",
"uploadCsv": "CSV hochladen",
"deleteAll": "Alle löschen",
"addItem": "Element hinzufügen",
"edit": "Bearbeiten",
"delete": "Löschen",
"add": "Hinzufügen",
"confirmDeleteAll": "Sind Sie sicher, dass Sie alle Schlüsselwörter löschen möchten?",
"settingsSaved": "Einstellungen gespeichert",
"reloadMessage": "Bitte laden Sie NodeBB neu, um diese Einstellungen anzuwenden",
"form": {
"name": "Name",
"description": "Beschreibung",
"infoLabel": "Info (optional). Wird auf der /glossary Seite angezeigt"
}
}
}
32 changes: 30 additions & 2 deletions languages/en-GB/glossary.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
{
"title": "Glossary"
}
"title": "Glossary",
"widgets": {
"header": "Glossary Page (Header)",
"left": "Glossary Page (Left)",
"right": "Glossary Page (Right)",
"footer": "Glossary Page (Footer)"
},
"admin": {
"general": "General",
"enabled": "Enabled",
"singleMatch": "Single Match",
"caseSensitive": "Case Sensitive",
"iconLabel": "Icon to show next to keyword, leave empty to disable",
"keywords": "Keywords",
"uploadCsv": "Upload CSV",
"deleteAll": "Delete All",
"addItem": "Add Item",
"edit": "Edit",
"delete": "Delete",
"add": "Add",
"confirmDeleteAll": "Are you sure you want to delete all keywords?",
"settingsSaved": "Settings Saved",
"reloadMessage": "Please reload your NodeBB to apply these settings",
"form": {
"name": "Name",
"description": "Description",
"infoLabel": "Info (optional). Displayed on the /glossary page"
}
}
}
32 changes: 30 additions & 2 deletions languages/en-US/glossary.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
{
"title": "Glossary"
}
"title": "Glossary",
"widgets": {
"header": "Glossary Page (Header)",
"left": "Glossary Page (Left)",
"right": "Glossary Page (Right)",
"footer": "Glossary Page (Footer)"
},
"admin": {
"general": "General",
"enabled": "Enabled",
"singleMatch": "Single Match",
"caseSensitive": "Case Sensitive",
"iconLabel": "Icon to show next to keyword, leave empty to disable",
"keywords": "Keywords",
"uploadCsv": "Upload CSV",
"deleteAll": "Delete All",
"addItem": "Add Item",
"edit": "Edit",
"delete": "Delete",
"add": "Add",
"confirmDeleteAll": "Are you sure you want to delete all keywords?",
"settingsSaved": "Settings Saved",
"reloadMessage": "Please reload your NodeBB to apply these settings",
"form": {
"name": "Name",
"description": "Description",
"infoLabel": "Info (optional). Displayed on the /glossary page"
}
}
}
31 changes: 31 additions & 0 deletions languages/he/glossary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"title": "מילון מונחים",
"widgets": {
"header": "דף מילון מונחים (כותרת)",
"left": "דף מילון מונחים (שמאל)",
"right": "דף מילון מונחים (ימין)",
"footer": "דף מילון מונחים (תחתית)"
},
"admin": {
"general": "כללי",
"enabled": "מופעל",
"singleMatch": "התאמה בודדת",
"caseSensitive": "תלוי רישיות",
"iconLabel": "אייקון להצגה ליד מילת מפתח, השאר ריק לביטול",
"keywords": "מילות מפתח",
"uploadCsv": "העלאת CSV",
"deleteAll": "מחק הכל",
"addItem": "הוסף פריט",
"edit": "עריכה",
"delete": "מחיקה",
"add": "הוסף",
"confirmDeleteAll": "האם אתה בטוח שברצונך למחוק את כל מילות המפתח?",
"settingsSaved": "ההגדרות נשמרו",
"reloadMessage": "אנא טען מחדש את NodeBB כדי להחיל הגדרות אלו",
"form": {
"name": "שם",
"description": "תיאור",
"infoLabel": "מידע (אופציונלי). מוצג בדף /glossary"
}
}
}
32 changes: 30 additions & 2 deletions languages/tr/glossary.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
{
"title": "Sözlük"
}
"title": "Sözlük",
"widgets": {
"header": "Sözlük Sayfası (Üst)",
"left": "Sözlük Sayfası (Sol)",
"right": "Sözlük Sayfası (Sağ)",
"footer": "Sözlük Sayfası (Alt)"
},
"admin": {
"general": "Genel",
"enabled": "Etkin",
"singleMatch": "Tek Eşleşme",
"caseSensitive": "Büyük/Küçük Harf Duyarlı",
"iconLabel": "Anahtar kelimenin yanında gösterilecek simge, devre dışı bırakmak için boş bırakın",
"keywords": "Anahtar Kelimeler",
"uploadCsv": "CSV Yükle",
"deleteAll": "Tümünü Sil",
"addItem": "Öğe Ekle",
"edit": "Düzenle",
"delete": "Sil",
"add": "Ekle",
"confirmDeleteAll": "Tüm anahtar kelimeleri silmek istediğinizden emin misiniz?",
"settingsSaved": "Ayarlar Kaydedildi",
"reloadMessage": "Bu ayarları uygulamak için lütfen NodeBB'yi yeniden yükleyin",
"form": {
"name": "Ad",
"description": "Açıklama",
"infoLabel": "Bilgi (isteğe bağlı). /glossary sayfasında görüntülenir"
}
}
}
6 changes: 4 additions & 2 deletions lib/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ Controllers.renderGlossary = async function (req, res) {
});
};

Controllers.renderAdminPage = function (req, res/* , next */) {
Controllers.renderAdminPage = async function (req, res/* , next */) {
const translator = require.main.require('./src/translator');
const title = await translator.translate('[[glossary:title]]');
res.render('admin/plugins/glossary', {
title: 'Glossary',
title: title,
});
};

Expand Down
14 changes: 7 additions & 7 deletions library.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ plugin.init = async (params) => {
await loadSettings();
};

routeHelpers.setupPageRoute(router, '/glossary', controllers.renderGlossary);
routeHelpers.setupAdminPageRoute(router, '/admin/plugins/glossary', controllers.renderAdminPage);
routeHelpers.setupPageRoute(router, '/glossary', [], controllers.renderGlossary);
routeHelpers.setupAdminPageRoute(router, '/admin/plugins/glossary', [], controllers.renderAdminPage);
};

async function loadSettings() {
Expand Down Expand Up @@ -91,22 +91,22 @@ plugin.filterTeasersConfigureStripTags = function (hookData) {
plugin.defineWidgetAreas = async function (areas) {
areas = areas.concat([
{
name: 'Glossary Page (Header)',
name: '[[glossary:widgets.header]]',
template: 'glossary.tpl',
location: 'header',
},
{
name: 'Glossary Page (Left)',
name: '[[glossary:widgets.left]]',
template: 'glossary.tpl',
location: 'left',
},
{
name: 'Glossary Page (Right)',
name: '[[glossary:widgets.right]]',
template: 'glossary.tpl',
location: 'right',
},
{
name: 'Glossary Page (Footer)',
name: '[[glossary:widgets.footer]]',
template: 'glossary.tpl',
location: 'footer',
},
Expand All @@ -118,7 +118,7 @@ plugin.addAdminNavigation = (header) => {
header.plugins.push({
route: '/plugins/glossary',
icon: 'fa-info',
name: 'Glossary',
name: '[[glossary:title]]',
});

return header;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodebb-plugin-glossary",
"version": "1.1.0",
"version": "2.0.0",
"description": "A glossary plugin",
"main": "library.js",
"repository": {
Expand Down Expand Up @@ -34,7 +34,7 @@
},
"readmeFilename": "README.md",
"nbbpm": {
"compatibility": "^3.2.0"
"compatibility": "^4.0.0"
},
"dependencies": {
"csvtojson": "^2.0.10",
Expand Down
25 changes: 15 additions & 10 deletions static/lib/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
/* globals csv */

define('admin/plugins/glossary', [
'settings', 'settings/sorted-list', 'bootbox', 'benchpress', 'alerts',
], function (settings, sortedList, bootbox, benchpress, alerts) {
'settings', 'settings/sorted-list', 'bootbox', 'benchpress', 'alerts', 'translator',
], function (settings, sortedList, bootbox, benchpress, alerts, translator) {
var ACP = {};

ACP.init = function () {
settings.load('glossary', $('.glossary-settings'));
$('#save').on('click', saveSettings);

$('#upload-csv').on('click', function () {
$('#upload-csv').on('click', async function () {
const title = await translator.translate('[[glossary:admin.uploadCsv]]');
const addLabel = await translator.translate('[[glossary:admin.add]]');
const modal = bootbox.dialog({
title: 'Upload CSV',
title: title,
message: '<textarea id="csv-input" class="form-control"></textarea>',
buttons: {
submit: {
label: 'Add',
label: addLabel,
className: 'btn-primary',
callback: async function () {
const text = modal.find('#csv-input').val();
Expand All @@ -42,8 +44,9 @@ define('admin/plugins/glossary', [
return false;
});

$('#empty-glossary').on('click', function () {
bootbox.confirm('Are you sure you want to delete all keywords?', function (ok) {
$('#empty-glossary').on('click', async function () {
const confirmMsg = await translator.translate('[[glossary:admin.confirmDeleteAll]]');
bootbox.confirm(confirmMsg, function (ok) {
if (!ok) {
return;
}
Expand All @@ -59,13 +62,15 @@ define('admin/plugins/glossary', [
});
};

function saveSettings() {
async function saveSettings() {
const savedTitle = await translator.translate('[[glossary:admin.settingsSaved]]');
const savedMessage = await translator.translate('[[glossary:admin.reloadMessage]]');
settings.save('glossary', $('.glossary-settings'), function () {
alerts.alert({
type: 'success',
alert_id: 'glossary-saved',
title: 'Settings Saved',
message: 'Please reload your NodeBB to apply these settings',
title: savedTitle,
message: savedMessage,
clickfn: function () {
socket.emit('admin.reload');
},
Expand Down
16 changes: 13 additions & 3 deletions static/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
'use strict';

$(document).ready(function () {
$('#content').tooltip({
selector: '.glossary-wrapper',
container: '#content',
function initTooltips() {
const tooltipTriggerList = document.querySelectorAll('#content .glossary-wrapper');
tooltipTriggerList.forEach(function (el) {
if (!bootstrap.Tooltip.getInstance(el)) {
new bootstrap.Tooltip(el);
}
});
}

initTooltips();

$(window).on('action:posts.loaded action:ajaxify.end', function () {
initTooltips();
});
});
18 changes: 9 additions & 9 deletions templates/admin/plugins/glossary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
<div id="spy-container" class="col-12 col-md-8 px-0 mb-4" tabindex="0">
<form role="form" class="glossary-settings">
<div id="general" class="mb-4">
<h5 class="fw-bold tracking-tight settings-header">General</h5>
<h5 class="fw-bold tracking-tight settings-header">[[glossary:admin.general]]</h5>
<div class="mb-4">
<div class="form-check form-switch mb-3">
<input class="form-check-input" id="enabled" type="checkbox" name="enabled" />
<label class="form-check-label" for="enabled">Enabled</label>
<label class="form-check-label" for="enabled">[[glossary:admin.enabled]]</label>
</div>

<div class="form-check form-switch mb-3">
<input class="form-check-input" id="singleMatch" type="checkbox" name="singleMatch" />
<label class="form-check-label" for="singleMatch">Single Match</label>
<label class="form-check-label" for="singleMatch">[[glossary:admin.singleMatch]]</label>
</div>

<div class="form-check form-switch mb-3">
<input class="form-check-input" id="caseSensitive" type="checkbox" name="caseSensitive" />
<label class="form-check-label" for="caseSensitive">Case Sensitive</label>
<label class="form-check-label" for="caseSensitive">[[glossary:admin.caseSensitive]]</label>
</div>

<div>
<label class="form-label" for="icon">
Icon to show next to keyword, leave empty to disable
[[glossary:admin.iconLabel]]
</label>
<input class="form-control" type="text" name="icon" id="icon">
</div>
Expand All @@ -34,15 +34,15 @@
<hr/>

<div id="keywords">
<h5 class="fw-bold tracking-tight settings-header">Keywords</h5>
<h5 class="fw-bold tracking-tight settings-header">[[glossary:admin.keywords]]</h5>
<div>
<div class="mb-3">
<button id="upload-csv" class="btn btn-light btn-sm">Upload CSV</button>
<button id="empty-glossary" class="btn btn-danger btn-sm">Delete All</button>
<button id="upload-csv" class="btn btn-light btn-sm">[[glossary:admin.uploadCsv]]</button>
<button id="empty-glossary" class="btn btn-danger btn-sm">[[glossary:admin.deleteAll]]</button>
</div>
<div data-type="sorted-list" data-sorted-list="keywords" data-item-template="admin/plugins/glossary/partials/sorted-list/item" data-form-template="admin/plugins/glossary/partials/sorted-list/form">
<ul data-type="list" class="list-group mb-2"></ul>
<button type="button" data-type="add" class="btn btn-primary btn-sm">Add Item</button>
<button type="button" data-type="add" class="btn btn-primary btn-sm">[[glossary:admin.addItem]]</button>
</div>
</div>
</div>
Expand Down
Loading