mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
Merge pull request #2281 from taras/ember
Merged into ember and added directory structure
This commit is contained in:
commit
daaf7a0e50
20 changed files with 375 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -29,6 +29,7 @@ projectFilesBackup
|
|||
|
||||
.build
|
||||
.dist
|
||||
.tmp
|
||||
|
||||
/core/clientold/tpl/hbs-tpl.js
|
||||
/core/clientold/assets/css
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
!**
|
||||
.build
|
||||
.dist
|
||||
.tmp
|
||||
docs/**
|
||||
_site/**
|
||||
content/images/**
|
||||
|
|
63
Gruntfile.js
63
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;
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
5
core/client/components/time-now.js
Normal file
5
core/client/components/time-now.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
export default Ember.Component.extend({
|
||||
time: function() {
|
||||
return new Date();
|
||||
}.property()
|
||||
});
|
0
core/client/controllers/.gitkeep
Normal file
0
core/client/controllers/.gitkeep
Normal file
3
core/client/controllers/application.js
Normal file
3
core/client/controllers/application.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export default Ember.Controller.extend({
|
||||
message: 'its a new beginning.'
|
||||
});
|
0
core/client/helpers/.gitkeep
Normal file
0
core/client/helpers/.gitkeep
Normal file
0
core/client/models/.gitkeep
Normal file
0
core/client/models/.gitkeep
Normal file
|
@ -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;
|
||||
|
|
0
core/client/routes/.gitkeep
Normal file
0
core/client/routes/.gitkeep
Normal file
|
@ -1,3 +1,5 @@
|
|||
<h2 id='title'>Welcome to Ghost on Ember.js</h2>
|
||||
|
||||
{{message}}
|
||||
|
||||
{{outlet}}
|
||||
|
|
1
core/client/templates/components/time-now.hbs
Normal file
1
core/client/templates/components/time-now.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
Time is now {{time}}
|
3
core/client/templates/index.hbs
Executable file
3
core/client/templates/index.hbs
Executable file
|
@ -0,0 +1,3 @@
|
|||
<em>This is the index route</em>
|
||||
|
||||
{{time-now}}
|
0
core/client/views/.gitkeep
Normal file
0
core/client/views/.gitkeep
Normal file
|
@ -32,10 +32,12 @@
|
|||
</head>
|
||||
<body class="{{bodyClass}}{{update_notification classOnly="true"}}">
|
||||
|
||||
<div id="ember-app"></div>
|
||||
|
||||
<script src="/ghost/scripts/vendor-ember.js"></script>
|
||||
<script src="/ghost/scripts/templates-ember.js"></script>
|
||||
<script src="/ghost/scripts/ghost-dev-ember.js"></script>
|
||||
|
||||
<script>
|
||||
window.App = require('ghost/app')['default'].create();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
211
core/shared/vendor/ember-resolver/dist/ember-resolver.js
vendored
Normal file
211
core/shared/vendor/ember-resolver/dist/ember-resolver.js
vendored
Normal file
|
@ -0,0 +1,211 @@
|
|||
// ==========================================================================
|
||||
// Project: Ember - JavaScript Application Framework
|
||||
// Copyright: Copyright 2013 Stefan Penner and Ember App Kit Contributors
|
||||
// License: Licensed under MIT license
|
||||
// See https://raw.github.com/stefanpenner/ember-jj-abrams-resolver/master/LICENSE
|
||||
// ==========================================================================
|
||||
|
||||
|
||||
// Version: 0.0.1
|
||||
|
||||
(function() {
|
||||
/*globals define registry requirejs */
|
||||
|
||||
define("ember/resolver",
|
||||
[],
|
||||
function() {
|
||||
"use strict";
|
||||
/*
|
||||
* This module defines a subclass of Ember.DefaultResolver that adds two
|
||||
* important features:
|
||||
*
|
||||
* 1) The resolver makes the container aware of es6 modules via the AMD
|
||||
* output. The loader's _seen is consulted so that classes can be
|
||||
* resolved directly via the module loader, without needing a manual
|
||||
* `import`.
|
||||
* 2) is able provide injections to classes that implement `extend`
|
||||
* (as is typical with Ember).
|
||||
*/
|
||||
|
||||
function classFactory(klass) {
|
||||
return {
|
||||
create: function (injections) {
|
||||
if (typeof klass.extend === 'function') {
|
||||
return klass.extend(injections);
|
||||
} else {
|
||||
return klass;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var underscore = Ember.String.underscore;
|
||||
var classify = Ember.String.classify;
|
||||
var get = Ember.get;
|
||||
|
||||
function parseName(fullName) {
|
||||
/*jshint validthis:true */
|
||||
|
||||
var nameParts = fullName.split(":"),
|
||||
type = nameParts[0], fullNameWithoutType = nameParts[1],
|
||||
name = fullNameWithoutType,
|
||||
namespace = get(this, 'namespace'),
|
||||
root = namespace;
|
||||
|
||||
return {
|
||||
fullName: fullName,
|
||||
type: type,
|
||||
fullNameWithoutType: fullNameWithoutType,
|
||||
name: name,
|
||||
root: root,
|
||||
resolveMethodName: "resolve" + classify(type)
|
||||
};
|
||||
}
|
||||
|
||||
function chooseModuleName(seen, moduleName) {
|
||||
var underscoredModuleName = Ember.String.underscore(moduleName);
|
||||
|
||||
if (moduleName !== underscoredModuleName && seen[moduleName] && seen[underscoredModuleName]) {
|
||||
throw new TypeError("Ambiguous module names: `" + moduleName + "` and `" + underscoredModuleName + "`");
|
||||
}
|
||||
|
||||
if (seen[moduleName]) {
|
||||
return moduleName;
|
||||
} else if (seen[underscoredModuleName]) {
|
||||
return underscoredModuleName;
|
||||
} else {
|
||||
var parts = moduleName.split('/'),
|
||||
lastPart = parts[parts.length - 1],
|
||||
partializedModuleName;
|
||||
|
||||
parts[parts.length - 1] = lastPart.replace(/^-/, '_');
|
||||
partializedModuleName = parts.join('/');
|
||||
|
||||
if (seen[partializedModuleName]) {
|
||||
Ember.deprecate('Modules should not contain underscores. ' +
|
||||
'Attempted to lookup "'+moduleName+'" which ' +
|
||||
'was not found. Please rename "'+partializedModuleName+'" '+
|
||||
'to "'+moduleName+'" instead.', false);
|
||||
|
||||
return partializedModuleName;
|
||||
} else {
|
||||
return moduleName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function logLookup(found, parsedName, moduleName) {
|
||||
if (Ember.ENV.LOG_MODULE_RESOLVER) {
|
||||
var symbol;
|
||||
|
||||
if (found) { symbol = '[✓]'; }
|
||||
else { symbol = '[ ]'; }
|
||||
|
||||
Ember.Logger.info(symbol, parsedName.fullName, new Array(40 - parsedName.fullName.length).join('.'), moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveOther(parsedName) {
|
||||
/*jshint validthis:true */
|
||||
|
||||
var moduleName, tmpModuleName, prefix, podPrefix, moduleRegistry;
|
||||
|
||||
prefix = this.namespace.modulePrefix;
|
||||
podPrefix = this.namespace.podModulePrefix || prefix;
|
||||
moduleRegistry = requirejs._eak_seen;
|
||||
|
||||
Ember.assert('module prefix must be defined', prefix);
|
||||
|
||||
var pluralizedType = parsedName.type + 's';
|
||||
var name = parsedName.fullNameWithoutType;
|
||||
|
||||
// lookup using POD formatting first
|
||||
tmpModuleName = podPrefix + '/' + name + '/' + parsedName.type;
|
||||
if (moduleRegistry[tmpModuleName]) {
|
||||
moduleName = tmpModuleName;
|
||||
}
|
||||
|
||||
// if not using POD format, use the custom prefix
|
||||
if (this.namespace[parsedName.type + 'Prefix']) {
|
||||
prefix = this.namespace[parsedName.type + 'Prefix'];
|
||||
}
|
||||
|
||||
// if router:main or adapter:main look for a module with just the type first
|
||||
tmpModuleName = prefix + '/' + parsedName.type;
|
||||
if (!moduleName && name === 'main' && moduleRegistry[tmpModuleName]) {
|
||||
moduleName = prefix + '/' + parsedName.type;
|
||||
}
|
||||
|
||||
// fallback if not type:main or POD format
|
||||
if (!moduleName) { moduleName = prefix + '/' + pluralizedType + '/' + name; }
|
||||
|
||||
// allow treat all dashed and all underscored as the same thing
|
||||
// supports components with dashes and other stuff with underscores.
|
||||
var normalizedModuleName = chooseModuleName(moduleRegistry, moduleName);
|
||||
|
||||
if (moduleRegistry[normalizedModuleName]) {
|
||||
var module = require(normalizedModuleName, null, null, true /* force sync */);
|
||||
|
||||
if (module && module['default']) { module = module['default']; }
|
||||
|
||||
if (module === undefined) {
|
||||
throw new Error(" Expected to find: '" + parsedName.fullName + "' within '" + normalizedModuleName + "' but got 'undefined'. Did you forget to `export default` within '" + normalizedModuleName + "'?");
|
||||
}
|
||||
|
||||
if (this.shouldWrapInClassFactory(module, parsedName)) {
|
||||
module = classFactory(module);
|
||||
}
|
||||
|
||||
logLookup(true, parsedName, moduleName);
|
||||
|
||||
return module;
|
||||
} else {
|
||||
logLookup(false, parsedName, moduleName);
|
||||
|
||||
return this._super(parsedName);
|
||||
}
|
||||
}
|
||||
// Ember.DefaultResolver docs:
|
||||
// https://github.com/emberjs/ember.js/blob/master/packages/ember-application/lib/system/resolver.js
|
||||
var Resolver = Ember.DefaultResolver.extend({
|
||||
resolveTemplate: resolveOther,
|
||||
resolveOther: resolveOther,
|
||||
makeToString: function(factory, fullName) {
|
||||
return '' + this.namespace.modulePrefix + '@' + fullName + ':';
|
||||
},
|
||||
parseName: parseName,
|
||||
shouldWrapInClassFactory: function(module, parsedName){
|
||||
return false;
|
||||
},
|
||||
normalize: function(fullName) {
|
||||
// replace `.` with `/` in order to make nested controllers work in the following cases
|
||||
// 1. `needs: ['posts/post']`
|
||||
// 2. `{{render "posts/post"}}`
|
||||
// 3. `this.render('posts/post')` from Route
|
||||
var split = fullName.split(':');
|
||||
if (split.length > 1) {
|
||||
return split[0] + ':' + Ember.String.dasherize(split[1].replace(/\./g, '/'));
|
||||
} else {
|
||||
return fullName;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Resolver['default'] = Resolver;
|
||||
return Resolver;
|
||||
});
|
||||
|
||||
define("resolver",
|
||||
["ember/resolver"],
|
||||
function (Resolver) {
|
||||
Ember.deprecate('Importing/requiring Ember Resolver as "resolver" is deprecated, please use "ember/resolver" instead');
|
||||
return Resolver;
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
})();
|
||||
|
75
core/shared/vendor/loader.js
vendored
Executable file
75
core/shared/vendor/loader.js
vendored
Executable file
|
@ -0,0 +1,75 @@
|
|||
var define, requireModule, require, requirejs;
|
||||
|
||||
(function() {
|
||||
var registry = {}, seen = {}, state = {};
|
||||
var FAILED = false;
|
||||
|
||||
define = function(name, deps, callback) {
|
||||
registry[name] = {
|
||||
deps: deps,
|
||||
callback: callback
|
||||
};
|
||||
};
|
||||
|
||||
requirejs = require = requireModule = function(name) {
|
||||
if (state[name] !== FAILED &&
|
||||
seen.hasOwnProperty(name)) {
|
||||
return seen[name];
|
||||
}
|
||||
|
||||
if (!registry.hasOwnProperty(name)) {
|
||||
throw new Error('Could not find module ' + name);
|
||||
}
|
||||
|
||||
var mod = registry[name];
|
||||
var deps = mod.deps;
|
||||
var callback = mod.callback;
|
||||
var reified = [];
|
||||
var exports;
|
||||
var value;
|
||||
var loaded = false;
|
||||
|
||||
seen[name] = { }; // enable run-time cycles
|
||||
|
||||
try {
|
||||
for (var i=0, l=deps.length; i<l; i++) {
|
||||
if (deps[i] === 'exports') {
|
||||
reified.push(exports = {});
|
||||
} else {
|
||||
reified.push(requireModule(resolve(deps[i], name)));
|
||||
}
|
||||
}
|
||||
|
||||
value = callback.apply(this, reified);
|
||||
loaded = true;
|
||||
} finally {
|
||||
if (!loaded) {
|
||||
state[name] = FAILED;
|
||||
}
|
||||
}
|
||||
return seen[name] = exports || value;
|
||||
};
|
||||
|
||||
function resolve(child, name) {
|
||||
if (child.charAt(0) !== '.') { return child; }
|
||||
|
||||
var parts = child.split('/');
|
||||
var parentBase = name.split('/').slice(0, -1);
|
||||
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
var part = parts[i];
|
||||
|
||||
if (part === '..') { parentBase.pop(); }
|
||||
else if (part === '.') { continue; }
|
||||
else { parentBase.push(part); }
|
||||
}
|
||||
|
||||
return parentBase.join('/');
|
||||
}
|
||||
|
||||
requirejs._eak_seen = registry;
|
||||
requirejs.clear = function(){
|
||||
requirejs._eak_seen = registry = {};
|
||||
seen = {};
|
||||
};
|
||||
})();
|
|
@ -62,6 +62,7 @@
|
|||
"grunt": "~0.4.1",
|
||||
"grunt-ember-templates": "~0.4.18",
|
||||
"grunt-cli": "~0.1.13",
|
||||
"grunt-concat-sourcemap": "~0.4.0",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
"grunt-contrib-compress": "~0.5.2",
|
||||
"grunt-contrib-concat": "~0.3.0",
|
||||
|
@ -70,6 +71,7 @@
|
|||
"grunt-contrib-sass": "~0.5.0",
|
||||
"grunt-contrib-uglify": "~0.2.5",
|
||||
"grunt-contrib-watch": "~0.5.3",
|
||||
"grunt-es6-module-transpiler": "~0.6.0",
|
||||
"grunt-express-server": "~0.4.11",
|
||||
"grunt-groc": "~0.4.0",
|
||||
"grunt-jslint": "~1.1.1",
|
||||
|
|
Loading…
Add table
Reference in a new issue