Update Ember to 1.10.0

No issue.
- Ember@1.10.0
- Update grunt-ember-templates to version that supports HTMLBars.
- Update Gruntfile.js to compile templates with HTMLBars.
- Convert Handlebars code to its HTMLBars equivalent.
This commit is contained in:
Jason Williams 2015-02-09 15:57:50 +00:00
parent a110b3741f
commit 2a91a1071e
17 changed files with 93 additions and 36 deletions

View File

@ -380,6 +380,9 @@ var _ = require('lodash'),
emberTemplates: { emberTemplates: {
dev: { dev: {
options: { options: {
templateCompilerPath: 'bower_components/ember/ember-template-compiler.js',
handlebarsPath: 'bower_components/handlebars/handlebars.js',
templateNamespace: 'HTMLBars',
templateBasePath: /core\/client\//, templateBasePath: /core\/client\//,
templateFileExtensions: /\.hbs/, templateFileExtensions: /\.hbs/,
templateRegistration: function (name, template) { templateRegistration: function (name, template) {
@ -395,6 +398,9 @@ var _ = require('lodash'),
prod: { prod: {
options: { options: {
templateCompilerPath: 'bower_components/ember/ember-template-compiler.js',
handlebarsPath: 'bower_components/handlebars/handlebars.js',
templateNamespace: 'HTMLBars',
templateBasePath: /core\/client\//, templateBasePath: /core\/client\//,
templateFileExtensions: /\.hbs/, templateFileExtensions: /\.hbs/,
templateRegistration: function (name, template) { templateRegistration: function (name, template) {
@ -571,8 +577,7 @@ var _ = require('lodash'),
src: [ src: [
'bower_components/loader.js/loader.js', 'bower_components/loader.js/loader.js',
'bower_components/jquery/dist/jquery.js', 'bower_components/jquery/dist/jquery.js',
'bower_components/handlebars/handlebars.js', 'bower_components/ember/ember.debug.js',
'bower_components/ember/ember.js',
'bower_components/ember-data/ember-data.js', 'bower_components/ember-data/ember-data.js',
'bower_components/ember-resolver/dist/ember-resolver.js', 'bower_components/ember-resolver/dist/ember-resolver.js',
'bower_components/ic-ajax/dist/globals/main.js', 'bower_components/ic-ajax/dist/globals/main.js',
@ -608,7 +613,6 @@ var _ = require('lodash'),
src: [ src: [
'bower_components/loader.js/loader.js', 'bower_components/loader.js/loader.js',
'bower_components/jquery/dist/jquery.js', 'bower_components/jquery/dist/jquery.js',
'bower_components/handlebars/handlebars.runtime.js',
'bower_components/ember/ember.prod.js', 'bower_components/ember/ember.prod.js',
'bower_components/ember-data/ember-data.prod.js', 'bower_components/ember-data/ember-data.prod.js',
'bower_components/ember-resolver/dist/ember-resolver.js', 'bower_components/ember-resolver/dist/ember-resolver.js',

View File

@ -4,7 +4,7 @@
"codemirror": "4.0.1", "codemirror": "4.0.1",
"Countable": "2.0.2", "Countable": "2.0.2",
"device": "git://github.com/matthewhudson/device.js#5347a275b66020a0d4dfe9aad81a488f8cce448d", "device": "git://github.com/matthewhudson/device.js#5347a275b66020a0d4dfe9aad81a488f8cce448d",
"ember": "1.9.0", "ember": "1.10.0",
"ember-data": "1.0.0-beta.14.1", "ember-data": "1.0.0-beta.14.1",
"ember-load-initializers": "git://github.com/stefanpenner/ember-load-initializers.git#0.0.1", "ember-load-initializers": "git://github.com/stefanpenner/ember-load-initializers.git#0.0.1",
"ember-resolver": "git://github.com/stefanpenner/ember-jj-abrams-resolver.git#181251821cf513bb58d3e192faa13245a816f75e", "ember-resolver": "git://github.com/stefanpenner/ember-jj-abrams-resolver.git#181251821cf513bb58d3e192faa13245a816f75e",

View File

@ -3,6 +3,10 @@ import uploader from 'ghost/assets/lib/uploader';
var PostImageUploader = Ember.Component.extend({ var PostImageUploader = Ember.Component.extend({
classNames: ['image-uploader', 'js-post-image-upload'], classNames: ['image-uploader', 'js-post-image-upload'],
imageSource: Ember.computed('image', function () {
return this.get('image') || '';
}),
setup: function () { setup: function () {
var $this = this.$(), var $this = this.$(),
self = this; self = this;

View File

@ -126,7 +126,7 @@ var PostSettingsMenuController = Ember.Controller.extend(SettingsMenuMixin, {
if (metaTitle.length > 70) { if (metaTitle.length > 70) {
metaTitle = metaTitle.substring(0, 70).trim(); metaTitle = metaTitle.substring(0, 70).trim();
metaTitle = Ember.Handlebars.Utils.escapeExpression(metaTitle); metaTitle = Ember.Handlebars.Utils.escapeExpression(metaTitle);
metaTitle = new Ember.Handlebars.SafeString(metaTitle + '…'); metaTitle = Ember.String.htmlSafe(metaTitle + '…');
} }
return metaTitle; return metaTitle;
@ -162,7 +162,7 @@ var PostSettingsMenuController = Ember.Controller.extend(SettingsMenuMixin, {
// Limit to 156 characters // Limit to 156 characters
placeholder = placeholder.substring(0, 156).trim(); placeholder = placeholder.substring(0, 156).trim();
placeholder = Ember.Handlebars.Utils.escapeExpression(placeholder); placeholder = Ember.Handlebars.Utils.escapeExpression(placeholder);
placeholder = new Ember.Handlebars.SafeString(placeholder + '…'); placeholder = Ember.String.htmlSafe(placeholder + '…');
} }
return placeholder; return placeholder;
@ -180,7 +180,7 @@ var PostSettingsMenuController = Ember.Controller.extend(SettingsMenuMixin, {
if (seoURL.length > 70) { if (seoURL.length > 70) {
seoURL = seoURL.substring(0, 70).trim(); seoURL = seoURL.substring(0, 70).trim();
seoURL = new Ember.Handlebars.SafeString(seoURL + '…'); seoURL = Ember.String.htmlSafe(seoURL + '…');
} }
return seoURL; return seoURL;

View File

@ -234,7 +234,7 @@ var PostTagsInputController = Ember.Controller.extend({
suggestion = Ember.Object.create(); suggestion = Ember.Object.create();
highlightedName = tagName.replace(regex, '<mark>$1</mark>'); highlightedName = tagName.replace(regex, '<mark>$1</mark>');
highlightedName = new Ember.Handlebars.SafeString(highlightedName); highlightedName = Ember.String.htmlSafe(highlightedName);
suggestion.set('tag', matchingTag); suggestion.set('tag', matchingTag);
suggestion.set('highlightedName', highlightedName); suggestion.set('highlightedName', highlightedName);

View File

@ -1,6 +1,14 @@
var SettingsGeneralController = Ember.Controller.extend({ var SettingsGeneralController = Ember.Controller.extend({
selectedTheme: null, selectedTheme: null,
logoImageSource: Ember.computed('model.logo', function () {
return this.get('model.logo') || '';
}),
coverImageSource: Ember.computed('model.cover', function () {
return this.get('model.cover') || '';
}),
isDatedPermalinks: Ember.computed('model.permalinks', function (key, value) { isDatedPermalinks: Ember.computed('model.permalinks', function (key, value) {
// setter // setter
if (arguments.length > 1) { if (arguments.length > 1) {

View File

@ -52,7 +52,7 @@ var TagsController = Ember.ArrayController.extend(PaginationMixin, SettingsMenuM
if (metaTitle && metaTitle.length > 70) { if (metaTitle && metaTitle.length > 70) {
metaTitle = metaTitle.substring(0, 70).trim(); metaTitle = metaTitle.substring(0, 70).trim();
metaTitle = Ember.Handlebars.Utils.escapeExpression(metaTitle); metaTitle = Ember.Handlebars.Utils.escapeExpression(metaTitle);
metaTitle = new Ember.Handlebars.SafeString(metaTitle + '&hellip;'); metaTitle = Ember.String.htmlSafe(metaTitle + '&hellip;');
} }
return metaTitle; return metaTitle;
@ -70,7 +70,7 @@ var TagsController = Ember.ArrayController.extend(PaginationMixin, SettingsMenuM
if (seoURL.length > 70) { if (seoURL.length > 70) {
seoURL = seoURL.substring(0, 70).trim(); seoURL = seoURL.substring(0, 70).trim();
seoURL = new Ember.Handlebars.SafeString(seoURL + '&hellip;'); seoURL = Ember.String.htmlSafe(seoURL + '&hellip;');
} }
return seoURL; return seoURL;
@ -84,7 +84,7 @@ var TagsController = Ember.ArrayController.extend(PaginationMixin, SettingsMenuM
if (metaDescription && metaDescription.length > 156) { if (metaDescription && metaDescription.length > 156) {
metaDescription = metaDescription.substring(0, 156).trim(); metaDescription = metaDescription.substring(0, 156).trim();
metaDescription = Ember.Handlebars.Utils.escapeExpression(metaDescription); metaDescription = Ember.Handlebars.Utils.escapeExpression(metaDescription);
metaDescription = new Ember.Handlebars.SafeString(metaDescription + '&hellip;'); metaDescription = Ember.String.htmlSafe(metaDescription + '&hellip;');
} }
return metaDescription; return metaDescription;

View File

@ -1,5 +1,5 @@
var blogUrl = Ember.Handlebars.makeBoundHelper(function () { var blogUrl = Ember.HTMLBars.makeBoundHelper(function () {
return new Ember.Handlebars.SafeString(this.get('config.blogUrl')); return Ember.String.htmlSafe(this.get('config.blogUrl'));
}); });
export default blogUrl; export default blogUrl;

View File

@ -1,6 +1,14 @@
var countCharacters = Ember.Handlebars.makeBoundHelper(function (content) { var countCharacters = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
var el = document.createElement('span'), var el = document.createElement('span'),
length = content ? content.length : 0; length,
content;
if (!arr || !arr.length) {
return;
}
content = arr[0] || '';
length = content.length;
el.className = 'word-count'; el.className = 'word-count';
@ -12,7 +20,7 @@ var countCharacters = Ember.Handlebars.makeBoundHelper(function (content) {
el.innerHTML = 200 - length; el.innerHTML = 200 - length;
return new Ember.Handlebars.SafeString(el.outerHTML); return Ember.String.htmlSafe(el.outerHTML);
}); });
export default countCharacters; export default countCharacters;

View File

@ -1,6 +1,16 @@
var countDownCharacters = Ember.Handlebars.makeBoundHelper(function (content, maxCharacters) { var countDownCharacters = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
var el = document.createElement('span'), var el = document.createElement('span'),
length = content ? content.length : 0; content,
maxCharacters,
length;
if (!arr || arr.length < 2) {
return;
}
content = arr[0] || '';
maxCharacters = arr[1];
length = content.length;
el.className = 'word-count'; el.className = 'word-count';
@ -12,7 +22,7 @@ var countDownCharacters = Ember.Handlebars.makeBoundHelper(function (content, ma
el.innerHTML = length; el.innerHTML = length;
return new Ember.Handlebars.SafeString(el.outerHTML); return Ember.String.htmlSafe(el.outerHTML);
}); });
export default countDownCharacters; export default countDownCharacters;

View File

@ -1,11 +1,20 @@
import counter from 'ghost/utils/word-count'; import counter from 'ghost/utils/word-count';
var countWords = Ember.Handlebars.makeBoundHelper(function (markdown) { var countWords = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
if (!arr || !arr.length) {
return;
}
var markdown,
count;
markdown = arr[0] || '';
if (/^\s*$/.test(markdown)) { if (/^\s*$/.test(markdown)) {
return '0 words'; return '0 words';
} }
var count = counter(markdown || ''); count = counter(markdown);
return count + (count === 1 ? ' word' : ' words'); return count + (count === 1 ? ' word' : ' words');
}); });

View File

@ -1,8 +1,12 @@
/* global Handlebars, html_sanitize*/ /* global html_sanitize*/
import cajaSanitizers from 'ghost/utils/caja-sanitizers'; import cajaSanitizers from 'ghost/utils/caja-sanitizers';
var formatHTML = Ember.Handlebars.makeBoundHelper(function (html) { var formatHTML = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
var escapedhtml = html || ''; if (!arr || !arr.length) {
return;
}
var escapedhtml = arr[0] || '';
// replace script and iFrame // replace script and iFrame
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
@ -15,7 +19,7 @@ var formatHTML = Ember.Handlebars.makeBoundHelper(function (html) {
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id); escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
return new Handlebars.SafeString(escapedhtml); return Ember.String.htmlSafe(escapedhtml);
}); });
export default formatHTML; export default formatHTML;

View File

@ -1,4 +1,4 @@
/* global Showdown, Handlebars, html_sanitize*/ /* global Showdown, html_sanitize*/
import cajaSanitizers from 'ghost/utils/caja-sanitizers'; import cajaSanitizers from 'ghost/utils/caja-sanitizers';
var showdown, var showdown,
@ -6,11 +6,16 @@ var showdown,
showdown = new Showdown.converter({extensions: ['ghostimagepreview', 'ghostgfm', 'footnotes', 'highlight']}); showdown = new Showdown.converter({extensions: ['ghostimagepreview', 'ghostgfm', 'footnotes', 'highlight']});
formatMarkdown = Ember.Handlebars.makeBoundHelper(function (markdown) { formatMarkdown = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
var escapedhtml = ''; if (!arr || !arr.length) {
return;
}
var escapedhtml = '',
markdown = arr[0] || '';
// convert markdown to HTML // convert markdown to HTML
escapedhtml = showdown.makeHtml(markdown || ''); escapedhtml = showdown.makeHtml(markdown);
// replace script and iFrame // replace script and iFrame
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
@ -23,7 +28,7 @@ formatMarkdown = Ember.Handlebars.makeBoundHelper(function (markdown) {
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id); escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
return new Handlebars.SafeString(escapedhtml); return Ember.String.htmlSafe(escapedhtml);
}); });
export default formatMarkdown; export default formatMarkdown;

View File

@ -1,5 +1,10 @@
/* global moment */ var formatTimeago = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
var formatTimeago = Ember.Handlebars.makeBoundHelper(function (timeago) { if (!arr || !arr.length) {
return;
}
var timeago = arr[0];
return moment(timeago).fromNow(); return moment(timeago).fromNow();
// stefanpenner says cool for small number of timeagos. // stefanpenner says cool for small number of timeagos.
// For large numbers moment sucks => single Ember.Object based clock better // For large numbers moment sucks => single Ember.Object based clock better

View File

@ -47,7 +47,7 @@ function ghostPathsHelper(path, url) {
base = base + url; base = base + url;
} }
return new Ember.Handlebars.SafeString(base); return Ember.String.htmlSafe(base);
} }
export default ghostPathsHelper; export default ghostPathsHelper;

View File

@ -1,6 +1,6 @@
<span class="media"> <span class="media">
<span class="hidden">Image Upload</span> <span class="hidden">Image Upload</span>
</span> </span>
<img class="js-upload-target" {{bind-attr src=image}}> <img class="js-upload-target" {{bind-attr src=imageSource}} />
<div class="description">{{description}}<strong></strong></div> <div class="description">{{description}}<strong></strong></div>
<input data-url="upload" class="js-fileupload main fileupload" type="file" name="uploadimage"> <input data-url="upload" class="js-fileupload main fileupload" type="file" name="uploadimage">

View File

@ -86,7 +86,7 @@
"grunt-contrib-uglify": "~0.6.0", "grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-watch": "~0.6.1", "grunt-contrib-watch": "~0.6.1",
"grunt-docker": "~0.0.8", "grunt-docker": "~0.0.8",
"grunt-ember-templates": "~0.5.0-alpha", "grunt-ember-templates": "dgeb/grunt-ember-templates#88594c6",
"grunt-es6-module-transpiler": "~0.6.0", "grunt-es6-module-transpiler": "~0.6.0",
"grunt-express-server": "~0.4.19", "grunt-express-server": "~0.4.19",
"grunt-jscs": "~1.2.0", "grunt-jscs": "~1.2.0",