You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
882 B
JavaScript

"use strict";
var admin = {},
async = require('async'),
plugins = require('../plugins'),
db = require('../database');
admin.save = function(data, callback) {
var order = Object.keys(data),
items = data.map(function(item, idx) {
var data = {};
data[idx] = item;
return JSON.stringify(data);
});
async.waterfall([
function(next) {
db.delete('navigation:enabled', next);
},
function(next) {
db.sortedSetAdd('navigation:enabled', order, items, next);
}
], callback);
};
admin.get = function(callback) {
async.parallel({
enabled: require('./index').get,
available: getAvailable
}, callback);
};
function getAvailable(callback) {
var core = require('../../install/data/navigation.json').map(function(item) {
item.core = true;
return item;
});
plugins.fireHook('filter:navigation.available', core, callback);
}
module.exports = admin;