Get Ember Admin ready for production

Closes #3161
- Add a config.js file for the client which is used to configure
  Ember.Application during runtime. The correct version of config.js
  is copied into place by grunt via the copy:(dev|prod) task from
  either config-dev.js or config-prod.js.
- Serve minified and production versions of libraries where applicable
  including handlebars-runtime and ember-prod.
- Bundle third party libraries into vendor.min.js.
- Bundle Ghost's Ember app and templates into ghost.min.js
- Remove all fixture data and code from the client.
This commit is contained in:
Jason Williams 2014-07-17 22:34:21 +00:00
parent 6c5d1a6267
commit ddcb441268
11 changed files with 25 additions and 4912 deletions

View File

@ -1,3 +0,0 @@
var AppAdapter = DS.FixtureAdapter.extend({});
export default AppAdapter;

View File

@ -1,25 +1,18 @@
import Resolver from 'ember/resolver';
import initFixtures from 'ghost/fixtures/init';
import loadInitializers from 'ember/load-initializers';
import 'ghost/utils/link-view';
import 'ghost/utils/text-field';
import configureApp from 'ghost/config';
Ember.MODEL_FACTORY_INJECTIONS = true;
var App = Ember.Application.extend({
/**
* These are debugging flags, they are useful during development
*/
LOG_ACTIVE_GENERATION: true,
LOG_MODULE_RESOLVER: true,
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: true,
LOG_VIEW_LOOKUPS: true,
modulePrefix: 'ghost',
Resolver: Resolver['default']
});
initFixtures();
// Runtime configuration of Ember.Application
configureApp(App);
loadInitializers(App, 'ghost');

15
ghost/admin/config-dev.js Normal file
View File

@ -0,0 +1,15 @@
function configureApp(App) {
if (!App instanceof Ember.Application) {
return;
}
App.reopen({
LOG_ACTIVE_GENERATION: true,
LOG_MODULE_RESOLVER: true,
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: true,
LOG_VIEW_LOOKUPS: true
});
}
export default configureApp;

View File

@ -0,0 +1,7 @@
function configureApp(App) {
if (!App instanceof Ember.Application) {
return;
}
}
export default configureApp;

View File

@ -1,68 +0,0 @@
var apps = [
{
'id': 1,
'name': 'testApp',
'package': {
'name': 'testApp',
'version': '2.0.1',
'description': 'An example application showing how to filter jquery from ghost foot',
'author': 'Ghost Foundation',
'homepage': 'http://ghost.org',
'repository': {
'type': 'git',
'url': 'git://github.com/TryGhost/Example-Apps'
},
'licenses': [
{
'type': 'MIT',
'url': 'https://raw.github.com/TryGhost/Example-Apps/master/LICENSE'
}
],
'main': 'index.js',
'engines': {
'node': '0.10.*'
},
'engineStrict': true,
'dependencies': {
'ghost-app': '~0.0.2',
'lodash': '~2.4.1'
},
'devDependencies': {}
},
'active': true
},
{
'id': 2,
'name': 'testApp2',
'package': {
'name': 'testApp2',
'version': '0.1.1',
'description': 'An example application showing how to filter jquery from ghost foot',
'author': 'Ghost Foundation',
'homepage': 'http://ghost.org',
'repository': {
'type': 'git',
'url': 'git://github.com/TryGhost/Example-Apps'
},
'licenses': [
{
'type': 'MIT',
'url': 'https://raw.github.com/TryGhost/Example-Apps/master/LICENSE'
}
],
'main': 'index.js',
'engines': {
'node': '0.10.*'
},
'engineStrict': true,
'dependencies': {
'ghost-app': '~0.0.2',
'lodash': '~2.4.1'
},
'devDependencies': {}
},
'active': false
},
];
export default apps;

View File

@ -1,68 +0,0 @@
import postFixtures from 'ghost/fixtures/posts';
import userFixtures from 'ghost/fixtures/users';
import settingsFixtures from 'ghost/fixtures/settings';
import appFixtures from 'ghost/fixtures/apps';
var response = function (responseBody, status) {
status = status || 200;
var textStatus = (status === 200) ? 'success' : 'error';
return {
response: responseBody,
jqXHR: { status: status },
textStatus: textStatus
};
};
var user = function (status) {
return response(userFixtures.findBy('id', 1), status);
};
var post = function (id, status) {
return response(postFixtures.findBy('id', id), status);
};
var posts = function (status) {
return response({
'posts': postFixtures,
'page': 1,
'limit': 15,
'pages': 1,
'total': 2
}, status);
};
var settings = function (status) {
return response(settingsFixtures, status);
};
var apps = function (status) {
return response(appFixtures, status);
};
var defineFixtures = function (status) {
ic.ajax.defineFixture('/ghost/api/v0.1/posts', posts(status));
ic.ajax.defineFixture('/ghost/api/v0.1/posts/1', post(1, status));
ic.ajax.defineFixture('/ghost/api/v0.1/posts/2', post(2, status));
ic.ajax.defineFixture('/ghost/api/v0.1/posts/3', post(3, status));
ic.ajax.defineFixture('/ghost/api/v0.1/posts/4', post(4, status));
ic.ajax.defineFixture('/ghost/api/v0.1/slugs/post/test%20title/', response('generated-slug', status));
ic.ajax.defineFixture('/ghost/api/v0.1/users/me/', user(status));
ic.ajax.defineFixture('/ghost/changepw/', response({
msg: 'Password changed successfully'
}));
ic.ajax.defineFixture('/ghost/api/v0.1/forgotten/', response({
redirect: '/ghost/signin/'
}));
ic.ajax.defineFixture('/ghost/api/v0.1/reset/', response({
msg: 'Password changed successfully'
}));
ic.ajax.defineFixture('/ghost/api/v0.1/settings/?type=blog,theme,app', settings(status));
ic.ajax.defineFixture('/ghost/api/v0.1/apps', apps(status));
ic.ajax.defineFixture('/ghost/api/v0.1/apps/1', response({
response: 'success'
}));
};
export default defineFixtures;

View File

@ -1,132 +0,0 @@
Fixtures for the Ghost blogging platform, intended to be generated with http://www.json-generator.com/
The generator's index() starts a 0, remove first 'post' to match expected data format.
{
posts: [
'{{repeat(31)}}',
{
id: '{{index()}}',
uuid: '{{guid()}}',
status: '{{random("published", "draft")}}',
title: '{{lorem( integer(1, 10), "words")}}',
slug: function(tag, index){
return this.title.replace(/ /g, '-');
},
markdown: '{{lorem( integer(1, 10), "paragraphs")}}',
html: function(tag, index){
return "<p>" + this.markdown + "</p>";
},
image: null,
featured: '{{integer(0, 1)}}',
page: '{{integer(0, 1)}}',
language: "en_US",
meta_title: null,
meta_description: null,
author: {
id: '{{integer(1, 10)}}',
uuid: '{{guid()}}',
name: '{{firstName()}} {{surname()}}',
slug: function(tag, index){
return this.name.replace(/ /g, '-').toLocaleLowerCase();
},
email: '{{email()}}',
image: undefined,
cover: undefined,
bio: '{{lorem(5, 50, "words")}}',
website: "",
location: '{{lorem( integer(1, 3), "words")}}',
accessibility: undefined,
status: "active",
language: "en_US",
meta_title: undefined,
meta_description: undefined,
created_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
updated_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}'
},
created_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
created_by: {
id: '{{integer(1, 10)}}',
uuid: '{{guid()}}',
name: '{{firstName()}} {{surname()}}',
slug: function(tag, index){
return this.name.replace(/ /g, '-').toLocaleLowerCase();
},
email: '{{email()}}',
image: undefined,
cover: undefined,
bio: '{{lorem(5, 50, "words")}}',
website: "",
location: '{{lorem( integer(1, 3), "words")}}',
accessibility: undefined,
status: "active",
language: "en_US",
meta_title: undefined,
meta_description: undefined,
created_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
updated_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}'
},
updated_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
updated_by: {
id: '{{integer(1, 10)}}',
uuid: '{{guid()}}',
name: '{{firstName()}} {{surname()}}',
slug: function(tag, index){
return this.name.replace(/ /g, '-').toLocaleLowerCase();
},
email: '{{email()}}',
image: undefined,
cover: undefined,
bio: '{{lorem(5, 50, "words")}}',
website: "",
location: '{{lorem( integer(1, 3), "words")}}',
accessibility: undefined,
status: "active",
language: "en_US",
meta_title: undefined,
meta_description: undefined,
created_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
updated_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}'
},
published_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
published_by: {
id: '{{integer(1, 10)}}',
uuid: '{{guid()}}',
name: '{{firstName()}} {{surname()}}',
slug: function(tag, index){
return this.name.replace(/ /g, '-').toLocaleLowerCase();
},
email: '{{email()}}',
image: undefined,
cover: undefined,
bio: '{{lorem(5, 50, "words")}}',
website: "",
location: '{{lorem( integer(1, 3), "words")}}',
accessibility: undefined,
status: "active",
language: "en_US",
meta_title: undefined,
meta_description: undefined,
created_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
updated_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}'
},
tags: [
'{{repeat(0, 10)}}',
{
id: '{{integer(1, 100)}}',
uuid: '{{guid()}}',
name: '{{lorem( integer(1, 3), "words")}}',
slug: function(tag, index){
return this.name.replace(/ /g, '-').toLocaleLowerCase();
},
description: null,
parent_id: null,
meta_title: null,
meta_description: null,
created_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
created_by: '{{integer(0, 10)}}',
updated_at: '{{date(new Date(2012, 0, 1), new Date(), "YYYY-MM-ddThh:mm:ss.ff Z")}}',
updated_by: '{{integer(0, 10)}}'
}
]
}]
}

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
/* jshint ignore:start */
var settings = {
"title": "Ghost",
"description": "Just a blogging platform.",
"email": "ghost@tryghost.org",
"logo": "http://media-cache-ec0.pinimg.com/236x/be/35/06/be35065e6f9a613d4a7661a6f45d0831.jpg",
"cover": "http://i906.photobucket.com/albums/ac267/df853/bring_me_a_shrubbery_cat.jpg",
"defaultLang": "en_US",
"postsPerPage": "6",
"forceI18n": "true",
"permalinks": "/:slug/",
"activeTheme": "casper",
"activeApps": "[]",
"installedApps": "[]",
"availableThemes": [
{
"name": "casper",
"package": false,
"active": true
}
],
"availableApps": []
};
export default settings;
/* jshint ignore:end */

View File

@ -1,25 +0,0 @@
/* jshint ignore:start */
var users = [
{
"id": 1,
"uuid": "ba9c67e4-8046-4b8c-9349-0eed3cca7529",
"name": "some-user",
"slug": "some-user",
"email": "some@email.com",
"image": undefined,
"cover": undefined,
"bio": "Example bio",
"website": "",
"location": "Imaginationland",
"accessibility": undefined,
"status": "active",
"language": "en_US",
"meta_title": undefined,
"meta_description": undefined,
"created_at": "2014-02-15T20:02:25.000Z",
"updated_at": "2014-03-11T14:06:43.000Z"
}
];
export default users;
/* jshint ignore:end */

View File

@ -1,13 +0,0 @@
import appFixtures from 'ghost/fixtures/apps';
var App = DS.Model.extend({
name: DS.attr('string'),
package: DS.attr(),
active: DS.attr('boolean')
});
App.reopenClass({
FIXTURES: appFixtures
});
export default App;