Skip to content

Commit

Permalink
Remove inline script from default.hbs
Browse files Browse the repository at this point in the history
no issue
- added config values as data attributes
- removed inline script
- removed current-user.js
  • Loading branch information
sebgie committed Jul 21, 2014
1 parent 2980035 commit 05b3606
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 59 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Expand Up @@ -269,7 +269,7 @@ var path = require('path'),
files: [{
expand: true,
cwd: 'core/client/',
src: ['**/*.js'],
src: ['**/*.js', '!loader.js'],
dest: '.tmp/ember-transpiled/'
}]
}
Expand All @@ -279,7 +279,7 @@ var path = require('path'),
// Compiles Ember es6 modules
concat_sourcemap: {
client: {
src: ['.tmp/ember-transpiled/**/*.js'],
src: ['.tmp/ember-transpiled/**/*.js', 'core/client/loader.js'],
dest: 'core/built/scripts/ghost-dev-ember.js',
options: {
sourcesContent: true
Expand Down
36 changes: 0 additions & 36 deletions core/client/initializers/current-user.js

This file was deleted.

5 changes: 4 additions & 1 deletion core/client/initializers/ghost-config.js
Expand Up @@ -2,7 +2,10 @@ var ConfigInitializer = {
name: 'config',

initialize: function (container, application) {
application.register('ghost:config', application.get('config'), {instantiate: false});
var apps = $('body').data('apps'),
fileStorage = $('body').data('filestorage');

application.register('ghost:config', {apps: apps, fileStorage: fileStorage}, {instantiate: false});

application.inject('route', 'config', 'ghost:config');
application.inject('controller', 'config', 'ghost:config');
Expand Down
4 changes: 4 additions & 0 deletions core/client/loader.js
@@ -0,0 +1,4 @@
// Loader to create the Ember.js application
/*global require */

window.App = require('ghost/app')['default'].create();
14 changes: 2 additions & 12 deletions core/server/controllers/admin.js
@@ -1,5 +1,4 @@
var config = require('../config'),
_ = require('lodash'),
var _ = require('lodash'),
when = require('when'),
api = require('../api'),
errors = require('../errors'),
Expand All @@ -12,18 +11,9 @@ adminControllers = {
// Method: GET
'index': function (req, res) {
/*jslint unparam:true*/
var userData,
// config we need on the frontend
frontConfig = {
apps: config().apps,
fileStorage: config().fileStorage
};

function renderIndex() {
res.render('default', {
user: userData,
config: JSON.stringify(frontConfig)
});
res.render('default');
}

updateCheck().then(function () {
Expand Down
4 changes: 4 additions & 0 deletions core/server/helpers/index.js
Expand Up @@ -782,6 +782,10 @@ registerHelpers = function (adminHbs, assetHash) {
registerAdminHelper('ghost_script_tags', coreHelpers.ghost_script_tags);

registerAdminHelper('asset', coreHelpers.asset);

registerAdminHelper('apps', coreHelpers.apps);

registerAdminHelper('file_storage', coreHelpers.file_storage);
};

module.exports = coreHelpers;
Expand Down
9 changes: 1 addition & 8 deletions core/server/views/default.hbs
Expand Up @@ -31,16 +31,9 @@
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:400,300,700" />
<link rel="stylesheet" href="{{asset "css/ghost-ui.min.css" ghost="true"}}" />
</head>
<body class="{{bodyClass}}">
<body class="{{bodyClass}}" data-apps="{{apps}}" data-filestorage="{{file_storage}}">

{{{ghost_script_tags}}}

<script>
window.ENV = {
{{#user}}user: {{{this}}},{{/user}}
config: {{{config}}}
};
window.App = require('ghost/app')['default'].create(window.ENV);
</script>
</body>
</html>

0 comments on commit 05b3606

Please sign in to comment.