-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user setting to hide/show deleted comments by default
- Loading branch information
1 parent
fb2f6c4
commit 761e3bf
Showing
7 changed files
with
239 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
var log4js = require('log4js'); | ||
var mongoose = require('mongoose'); | ||
var logger; | ||
|
||
module.exports.loadController = function (app, db) { | ||
logger = log4js.getLogger('systemjs.js'); | ||
|
||
saveSystemJSFunc(function pastvuPatch() { | ||
var startTime = Date.now(); | ||
|
||
// Показывать по умолчанию удаленные комментарии | ||
db.user_settings.save({ key: 'comment_show_deleted', val: false, vars: [true, false], desc: 'Показывать удаленные комментарии' }); | ||
|
||
return { message: 'FINISH in total ' + (Date.now() - startTime) / 1000 + 's' }; | ||
}); | ||
|
||
/** | ||
* Save function to db.system.js | ||
* @param func | ||
*/ | ||
function saveSystemJSFunc(func) { | ||
if (!func || !func.name) { | ||
logger.error('saveSystemJSFunc: function name is not defined'); | ||
} | ||
db.db.collection('system.js').save( | ||
{ | ||
_id: func.name, | ||
value: new mongoose.mongo.Code(func.toString()) | ||
}, | ||
function saveCallback(err) { | ||
if (err) { | ||
logger.error(err); | ||
} | ||
} | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.