diff --git a/install/package.json b/install/package.json index 6b28d05bb5..107a92b2b8 100644 --- a/install/package.json +++ b/install/package.json @@ -60,12 +60,12 @@ "mousetrap": "^1.6.1", "mubsub": "^1.4.0", "nconf": "^0.9.1", - "nodebb-plugin-composer-default": "6.0.11", + "nodebb-plugin-composer-default": "6.0.12", "nodebb-plugin-dbsearch": "2.0.9", "nodebb-plugin-emoji": "2.1.0", "nodebb-plugin-emoji-android": "2.0.0", "nodebb-plugin-markdown": "8.3.0", - "nodebb-plugin-mentions": "2.2.2", + "nodebb-plugin-mentions": "2.2.3", "nodebb-plugin-soundpack-default": "1.0.0", "nodebb-plugin-spam-be-gone": "0.5.1", "nodebb-rewards-essentials": "0.0.11", @@ -73,7 +73,7 @@ "nodebb-theme-persona": "7.2.20", "nodebb-theme-slick": "1.1.4", "nodebb-theme-vanilla": "8.1.9", - "nodebb-widget-essentials": "4.0.1", + "nodebb-widget-essentials": "4.0.2", "nodemailer": "4.4.1", "passport": "^0.4.0", "passport-local": "1.0.0", diff --git a/public/language/en-GB/admin/extend/widgets.json b/public/language/en-GB/admin/extend/widgets.json index 477bb15e56..025f48b327 100644 --- a/public/language/en-GB/admin/extend/widgets.json +++ b/public/language/en-GB/admin/extend/widgets.json @@ -2,6 +2,7 @@ "available": "Available Widgets", "explanation": "Select a widget from the dropdown menu and then drag and drop it into a template's widget area on the left.", "none-installed": "No widgets found! Activate the essential widgets plugin in the plugins control panel.", + "clone-from": "Clone widgets from", "containers.available": "Available Containers", "containers.explanation": "Drag and drop on top of any active widget", "containers.none": "None", @@ -14,6 +15,8 @@ "alert.confirm-delete": "Are you sure you wish to delete this widget?", "alert.updated": "Widgets Updated", - "alert.update-success": "Successfully updated widgets" + "alert.update-success": "Successfully updated widgets", + "alert.clone-success": "Successfully cloned widgets", + "error.select-clone": "Please select a page to clone from" } \ No newline at end of file diff --git a/public/language/zh-CN/modules.json b/public/language/zh-CN/modules.json index 484962b740..cab48a8174 100644 --- a/public/language/zh-CN/modules.json +++ b/public/language/zh-CN/modules.json @@ -18,7 +18,7 @@ "chat.seven_days": "7天", "chat.thirty_days": "30天", "chat.three_months": "3个月", - "chat.delete_message_confirm": "确认删除此消息吗?", + "chat.delete_message_confirm": "你确定删除此消息吗?", "chat.add-users-to-room": "向此聊天室中添加成员", "chat.confirm-chat-with-dnd-user": "该用户将其状态设置为DnD(请勿打扰)。 你还想和他们聊天吗?", "composer.compose": "编写帮助", diff --git a/public/less/admin/admin.less b/public/less/admin/admin.less index d7cd7e6ae4..e5bff2c1f3 100644 --- a/public/less/admin/admin.less +++ b/public/less/admin/admin.less @@ -19,6 +19,7 @@ @import "./appearance/themes"; @import "./extend/plugins"; @import "./extend/rewards"; +@import "./extend/widgets"; @import "./advanced/database"; @import "./advanced/logs"; @import "./advanced/errors"; diff --git a/public/less/admin/appearance/themes.less b/public/less/admin/appearance/themes.less index 4fed5205b2..f69222999b 100644 --- a/public/less/admin/appearance/themes.less +++ b/public/less/admin/appearance/themes.less @@ -38,8 +38,14 @@ background-size: contain; } - .mdl-card__supporting-text h2 { - margin-bottom: 15px; + .mdl-card__supporting-text { + font-size: 1.5rem; + margin: 0 auto; + + .mdl-card__title-text { + display: inline-block; + margin-bottom: 15px; + } } } diff --git a/public/less/admin/extend/widgets.less b/public/less/admin/extend/widgets.less new file mode 100644 index 0000000000..8316030446 --- /dev/null +++ b/public/less/admin/extend/widgets.less @@ -0,0 +1,19 @@ +.page-extend-widgets { + [component="clone"] { + display: flex; + align-items: stretch; + align-content: stretch; + + [component="clone/button"] { + flex-grow: 1; + text-align: left; + } + + .dropdown-menu { + max-height: 300px; + overflow-y: scroll; + min-width: 250px; + border-radius: 0; + } + } +} \ No newline at end of file diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index f6d02ab420..15414207c0 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -25,6 +25,7 @@ define('admin/extend/widgets', ['jqueryui'], function () { $('#widget-selector').trigger('change'); loadWidgetData(); + setupCloneButton(); }; function prepareWidgets() { @@ -224,5 +225,51 @@ define('admin/extend/widgets', ['jqueryui'], function () { }); } + function setupCloneButton() { + var clone = $('[component="clone"]'); + var cloneBtn = $('[component="clone/button"]'); + + clone.find('.dropdown-menu li').on('click', function () { + var template = $(this).find('a').text(); + cloneBtn.translateHtml('[[admin/extend/widgets:clone-from]] ' + template + ''); + cloneBtn.attr('data-template', template); + }); + + cloneBtn.on('click', function () { + var template = cloneBtn.attr('data-template'); + if (!template) { + return app.alertError('[[admin/extend/widgets:error.select-clone]]'); + } + + var currentTemplate = $('#active-widgets .active.tab-pane[data-template] .area'); + var templateToClone = $('#active-widgets .tab-pane[data-template="' + template + '"] .area'); + + var currentAreas = currentTemplate.map(function () { + return $(this).attr('data-location'); + }).get(); + + var areasToClone = templateToClone.map(function () { + var location = $(this).attr('data-location'); + return currentAreas.indexOf(location) !== -1 ? location : undefined; + }).get().filter(function (i) { return i; }); + + function clone(location) { + $('#active-widgets .tab-pane[data-template="' + template + '"] [data-location="' + location + '"]').each(function () { + $(this).find('[data-widget]').each(function () { + var widget = $(this).clone(true); + $('#active-widgets .active.tab-pane[data-template]:not([data-template="global"]) [data-location="' + location + '"] .widget-area').append(widget); + }); + }); + } + + for (var i = 0, ii = areasToClone.length; i < ii; i++) { + var location = areasToClone[i]; + clone(location); + } + + app.alertSuccess('[[admin/extend/widgets:alert.clone-success]]'); + }); + } + return Widgets; }); diff --git a/public/src/admin/general/navigation.js b/public/src/admin/general/navigation.js index 9e44ac0468..8987c1aa23 100644 --- a/public/src/admin/general/navigation.js +++ b/public/src/admin/general/navigation.js @@ -67,7 +67,8 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'benchpress', 'j data.enabled = false; data.index = (parseInt($('#enabled').children().last().attr('data-index'), 10) || 0) + 1; - + data.title = translator.escape(data.title); + data.text = translator.escape(data.text); Benchpress.parse('admin/general/navigation', 'navigation', { navigation: [data] }, function (li) { translator.translate(li, function (li) { li = $(translator.unescape(li)); diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index d11cb0aacd..5eca32fd4e 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -279,7 +279,7 @@ module.exports = function (db, module) { callback = callback || helpers.noop; value = parseInt(value, 10); if (!key || isNaN(value)) { - return callback(); + return callback(null, null); } var data = {}; diff --git a/src/database/redis/hash.js b/src/database/redis/hash.js index 1a9388f0a2..6f3c799027 100644 --- a/src/database/redis/hash.js +++ b/src/database/redis/hash.js @@ -117,14 +117,18 @@ module.exports = function (redisClient, module) { }; module.incrObjectField = function (key, field, callback) { - redisClient.hincrby(key, field, 1, callback); + module.incrObjectFieldBy(key, field, 1, callback); }; module.decrObjectField = function (key, field, callback) { - redisClient.hincrby(key, field, -1, callback); + module.incrObjectFieldBy(key, field, -1, callback); }; module.incrObjectFieldBy = function (key, field, value, callback) { + value = parseInt(value, 10); + if (!key || isNaN(value)) { + return callback(null, null); + } redisClient.hincrby(key, field, value, callback); }; }; diff --git a/src/topics/suggested.js b/src/topics/suggested.js index 830631d302..0c6ae1a661 100644 --- a/src/topics/suggested.js +++ b/src/topics/suggested.js @@ -24,8 +24,8 @@ module.exports = function (Topics) { }, next); }, function (results, next) { - var tids = results.tagTids.concat(results.searchTids).concat(results.categoryTids); - tids = _.uniq(tids).filter(function (_tid) { + var tids = _.shuffle(_.uniq(results.tagTids.concat(results.searchTids).concat(results.categoryTids))); + tids = tids.filter(function (_tid) { return parseInt(_tid, 10) !== parseInt(tid, 10); }); @@ -59,10 +59,10 @@ module.exports = function (Topics) { function getSearchTids(tid, callback) { async.waterfall([ function (next) { - Topics.getTopicField(tid, 'title', next); + Topics.getTopicFields(tid, ['title', 'cid'], next); }, - function (title, next) { - search.searchQuery('topic', title, [], [], next); + function (topicData, next) { + search.searchQuery('topic', topicData.title, [topicData.cid], [], next); }, ], callback); } diff --git a/src/views/admin/appearance/skins.tpl b/src/views/admin/appearance/skins.tpl index 6e87580557..4b0b89323b 100644 --- a/src/views/admin/appearance/skins.tpl +++ b/src/views/admin/appearance/skins.tpl @@ -1,5 +1,5 @@