2014-07-21 22:00:54 +04:00
var _ = require ( 'lodash' ) ,
2014-07-09 08:17:30 +04:00
api = require ( '../api' ) ,
2014-05-09 14:11:29 +04:00
errors = require ( '../errors' ) ,
2014-01-03 19:50:03 +04:00
updateCheck = require ( '../update-check' ) ,
2014-09-03 08:27:37 +04:00
config = require ( '../config' ) ,
2014-07-01 03:26:08 +04:00
adminControllers ;
2013-05-29 04:10:39 +04:00
2013-06-25 15:43:15 +04:00
adminControllers = {
2014-07-01 03:26:08 +04:00
// Route: index
// Path: /ghost/
// Method: GET
2015-05-30 23:18:26 +03:00
index : function index ( req , res ) {
2014-02-27 03:15:31 +04:00
/*jslint unparam:true*/
2014-05-09 09:00:10 +04:00
2014-02-25 14:51:12 +04:00
function renderIndex ( ) {
2015-05-30 23:18:26 +03:00
return api . configuration . browse ( ) . then ( function then ( data ) {
var apiConfig = _ . omit ( data . configuration , function omit ( value ) {
2014-11-27 23:50:15 +03:00
return _ . contains ( [ 'environment' , 'database' , 'mail' , 'version' ] , value . key ) ;
} ) ;
res . render ( 'default' , {
skip _google _fonts : config . isPrivacyDisabled ( 'useGoogleFonts' ) ,
configuration : apiConfig
} ) ;
2014-09-03 08:27:37 +04:00
} ) ;
2014-02-25 14:51:12 +04:00
}
2015-05-30 23:18:26 +03:00
updateCheck ( ) . then ( function then ( ) {
2014-07-09 08:17:30 +04:00
return updateCheck . showUpdateNotification ( ) ;
2015-05-30 23:18:26 +03:00
} ) . then ( function then ( updateVersion ) {
2014-08-06 03:48:44 +04:00
if ( ! updateVersion ) {
2014-08-17 10:17:23 +04:00
return ;
2014-07-09 08:17:30 +04:00
}
var notification = {
2015-04-29 23:54:53 +03:00
type : 'upgrade' ,
location : 'settings-about-upgrade' ,
2014-07-09 08:17:30 +04:00
dismissible : false ,
status : 'persistent' ,
2015-04-29 23:54:53 +03:00
message : 'Ghost ' + updateVersion + ' is available! Hot Damn. <a href="http://support.ghost.org/how-to-upgrade/" target="_blank">Click here</a> to upgrade.'
2014-07-09 08:17:30 +04:00
} ;
2015-05-30 23:18:26 +03:00
return api . notifications . browse ( { context : { internal : true } } ) . then ( function then ( results ) {
2014-09-10 08:06:24 +04:00
if ( ! _ . some ( results . notifications , { message : notification . message } ) ) {
return api . notifications . add ( { notifications : [ notification ] } , { context : { internal : true } } ) ;
2014-07-09 08:17:30 +04:00
}
} ) ;
2015-05-30 23:18:26 +03:00
} ) . finally ( function noMatterWhat ( ) {
2014-07-09 08:17:30 +04:00
renderIndex ( ) ;
} ) . catch ( errors . logError ) ;
2013-06-25 15:43:15 +04:00
}
} ;
2013-05-11 20:44:25 +04:00
2013-08-09 05:22:49 +04:00
module . exports = adminControllers ;