diff --git a/.gitignore b/.gitignore index 9cdab09a61..0d6d3b803e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ projectFilesBackup .build .dist +.tmp /core/clientold/tpl/hbs-tpl.js /core/clientold/assets/css diff --git a/.npmignore b/.npmignore index 14da2fe851..cfa7144e9f 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,7 @@ !** .build .dist +.tmp docs/** _site/** content/images/** diff --git a/Gruntfile.js b/Gruntfile.js index d3df91718b..2eae8aa086 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -58,6 +58,12 @@ var path = require('path'), files: 'core/client/templates/**/*.hbs', tasks: ['emberTemplates'] }, + ember: { + files: [ + 'core/client/**/*.js' + ], + tasks: ['transpile', 'concat_sourcemap'] + }, sass: { files: ['<%= paths.adminOldAssets %>/sass/**/*'], tasks: ['sass:admin'] @@ -72,12 +78,6 @@ var path = require('path'), ], tasks: ['concat'] }, - 'concat-ember': { - files: [ - 'core/client/**/*.js' - ], - tasks: ['concat:dev-ember'] - }, livereload: { files: [ // Theme CSS @@ -311,9 +311,13 @@ var path = require('path'), // ### Config for grunt-ember-templates // Compiles handlebar templates for ember emberTemplates: { - compile: { + dev: { options: { - templateBasePath: /core\/client\/templates/ + templateBasePath: /core\/client\//, + templateFileExtensions: /\.hbs/, + templateRegistration: function (name, template) { + return grunt.config.process("define('ghost/") + name + "', ['exports'], function(__exports__){ __exports__['default'] = " + template + "; });"; + } }, files: { "core/built/scripts/templates-ember.js": "core/client/templates/**/*.hbs" @@ -321,6 +325,35 @@ var path = require('path'), } }, + // ### Config for grunt-es6-module-transpiler + // Compiles Ember es6 modules + transpile: { + client: { + type: 'amd', + moduleName: function (path) { + return 'ghost/' + path; + }, + files: [{ + expand: true, + cwd: 'core/client/', + src: ['**/*.js'], + dest: '.tmp/ember-transpiled/' + }] + } + }, + + // ### Config for grunt-es6-module-transpiler + // Compiles Ember es6 modules + concat_sourcemap: { + client: { + src: ['.tmp/ember-transpiled/**/*.js'], + dest: 'core/built/scripts/ghost-dev-ember.js', + options: { + sourcesContent: true + } + } + }, + // ### Config for grunt-groc // Generate documentation from code groc: { @@ -441,13 +474,11 @@ var path = require('path'), 'dev-ember': { files: { 'core/built/scripts/vendor-ember.js': [ + 'core/shared/vendor/loader.js', 'core/shared/vendor/jquery/jquery.js', 'core/shared/vendor/handlebars/handlebars.js', - 'core/shared/vendor/ember/ember.js' - ], - - 'core/built/scripts/ghost-dev-ember.js': [ - 'core/client/**/*.js' + 'core/shared/vendor/ember/ember.js', + 'core/shared/vendor/ember-resolver/dist/ember-resolver.js' ] } }, @@ -830,6 +861,7 @@ var path = require('path'), 'sass:admin', 'handlebars', 'concat', + 'emberBuild', 'express:dev', 'watch' ]); @@ -875,8 +907,11 @@ var path = require('path'), // Before running in production mode grunt.registerTask('prod', 'Build CSS, JS & templates for production', ['sass:compress', 'handlebars', 'concat', 'uglify']); + // All tasks related to building the Ember client code + grunt.registerTask('emberBuild', 'Build Ember JS & templates for development', ['emberTemplates:dev', 'transpile', 'concat_sourcemap']); + // When you just say 'grunt' - grunt.registerTask('default', 'Build CSS, JS & templates for development', ['update_submodules', 'sass:compress', 'handlebars', 'emberTemplates:compile', 'concat']); + grunt.registerTask('default', 'Build CSS, JS & templates for development', ['update_submodules', 'sass:compress', 'handlebars', 'concat', 'emberBuild']); }; module.exports = configureGrunt; diff --git a/bower.json b/bower.json index f07fdfc27b..8580aeb7d6 100644 --- a/bower.json +++ b/bower.json @@ -2,6 +2,10 @@ "name": "ghost", "dependencies": { "handlebars": "~1.1.2", + "ember": "~1.4.0", + "ember-resolver": "git://github.com/stefanpenner/ember-jj-abrams-resolver.git#9805033c178e7f857f801359664adb599444b430" + }, + "resolutions": { "ember": "~1.4.0" } } diff --git a/core/client/app.js b/core/client/app.js index b4c353615a..56c0cb68d1 100755 --- a/core/client/app.js +++ b/core/client/app.js @@ -1,6 +1,8 @@ /*global Ember */ -var App = Ember.Application.create({ +import Resolver from 'ember/resolver'; + +var App = Ember.Application.extend({ /** * These are debugging flags, they are useful during development */ @@ -9,6 +11,8 @@ var App = Ember.Application.create({ LOG_TRANSITIONS: true, LOG_TRANSITIONS_INTERNAL: true, LOG_VIEW_LOOKUPS: true, - rootElement: '#ember-app' // tells ember to inject this app into element with selector #ember-app + modulePrefix: 'ghost', // TODO: loaded via config + Resolver: Resolver['default'] }); +export default App; diff --git a/core/client/components/time-now.js b/core/client/components/time-now.js new file mode 100644 index 0000000000..951019aecc --- /dev/null +++ b/core/client/components/time-now.js @@ -0,0 +1,5 @@ +export default Ember.Component.extend({ + time: function() { + return new Date(); + }.property() +}); \ No newline at end of file diff --git a/core/client/controllers/.gitkeep b/core/client/controllers/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/core/client/controllers/application.js b/core/client/controllers/application.js new file mode 100644 index 0000000000..7d6cc131e6 --- /dev/null +++ b/core/client/controllers/application.js @@ -0,0 +1,3 @@ +export default Ember.Controller.extend({ + message: 'its a new beginning.' +}); \ No newline at end of file diff --git a/core/client/helpers/.gitkeep b/core/client/helpers/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/core/client/models/.gitkeep b/core/client/models/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/core/client/router.js b/core/client/router.js index 1133384526..76a432d973 100755 --- a/core/client/router.js +++ b/core/client/router.js @@ -1,9 +1,11 @@ -/*global App */ +/*global Ember */ -App.Router.map(function () { +// ensure we don't share routes between all Router instances +var Router = Ember.Router.extend(); + +Router.map(function () { 'use strict'; - this.resource('posts'); - this.resource('post', {path: 'post/:id'}, function () { - this.route('edit'); - }); + }); + +export default Router; diff --git a/core/client/routes/.gitkeep b/core/client/routes/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/core/client/templates/application.hbs b/core/client/templates/application.hbs index 7a1a31e653..5cf1ce3bf9 100755 --- a/core/client/templates/application.hbs +++ b/core/client/templates/application.hbs @@ -1,3 +1,5 @@