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