mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
078f464197
covers 90% of #755 - moved ghost.settings to api.settings - moved ghost.notifications to api.notifications - split up api/index.js to notifications.js, posts.js, settings.js, tags.js and users.js - added instance.globals as temp workaround for blogglobals (Known issue: blog title and blog description are updated after restart only) - added webroot to config() to remove `var root = ...` - changed `e` and `url` helper to async - updated tests
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
var when = require('when'),
|
|
_ = require('underscore'),
|
|
// Holds the persistent notifications
|
|
notificationsStore = [],
|
|
notifications;
|
|
|
|
// ## Notifications
|
|
notifications = {
|
|
|
|
browse: function browse() {
|
|
return when(notificationsStore);
|
|
},
|
|
|
|
// #### Destroy
|
|
|
|
// **takes:** an identifier object ({id: id})
|
|
destroy: function destroy(i) {
|
|
notificationsStore = _.reject(notificationsStore, function (element) {
|
|
return element.id === i.id;
|
|
});
|
|
// **returns:** a promise for remaining notifications as a json object
|
|
return when(notificationsStore);
|
|
},
|
|
|
|
destroyAll: function destroyAll() {
|
|
notificationsStore = [];
|
|
return when(notificationsStore);
|
|
},
|
|
|
|
// #### Add
|
|
|
|
// **takes:** a notification object of the form
|
|
// ```
|
|
// msg = {
|
|
// type: 'error', // this can be 'error', 'success', 'warn' and 'info'
|
|
// message: 'This is an error', // A string. Should fit in one line.
|
|
// status: 'persistent', // or 'passive'
|
|
// id: 'auniqueid' // A unique ID
|
|
// };
|
|
// ```
|
|
add: function add(notification) {
|
|
// **returns:** a promise for all notifications as a json object
|
|
return when(notificationsStore.push(notification));
|
|
}
|
|
};
|
|
|
|
module.exports = notifications; |