Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

🔥✨ Adapt image property changes #661

Merged
merged 2 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/gh-post-settings-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export default Component.extend(SettingsMenuMixin, {
},

setCoverImage(image) {
this.set('model.image', image);
this.set('model.featureImage', image);

if (this.get('model.isNew')) {
return;
Expand All @@ -313,7 +313,7 @@ export default Component.extend(SettingsMenuMixin, {
},

clearCoverImage() {
this.set('model.image', '');
this.set('model.featureImage', '');

if (this.get('model.isNew')) {
return;
Expand Down
4 changes: 2 additions & 2 deletions app/components/gh-posts-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default Component.extend({
return this.get('post.author.name') || this.get('post.author.email');
}),

authorAvatar: computed('post.author.image', function () {
return this.get('post.author.image') || `${this.get('ghostPaths.assetRoot')}/img/user-image.png`;
authorAvatar: computed('post.author.profileImage', function () {
return this.get('post.author.profileImage') || `${this.get('ghostPaths.assetRoot')}/img/user-image.png`;
}),

authorAvatarBackground: computed('authorAvatar', function () {
Expand Down
4 changes: 2 additions & 2 deletions app/components/gh-tag-settings-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ export default Component.extend({
},

setCoverImage(image) {
this.send('setProperty', 'image', image);
this.send('setProperty', 'featureImage', image);
},

clearCoverImage() {
this.send('setProperty', 'image', '');
this.send('setProperty', 'featureImage', '');
},

openMeta() {
Expand Down
11 changes: 6 additions & 5 deletions app/controllers/setup/two.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable camelcase */
import Controller from 'ember-controller';
import RSVP from 'rsvp';
import ValidationEngine from 'ghost-admin/mixins/validation-engine';
Expand Down Expand Up @@ -26,7 +27,7 @@ export default Controller.extend(ValidationEngine, {
blogTitle: null,
email: '',
flowErrors: '',
image: null,
profileImage: null,
name: null,
password: null,

Expand Down Expand Up @@ -94,14 +95,14 @@ export default Controller.extend(ValidationEngine, {
* @return {Ember.RSVP.Promise} A promise that takes care of both calls
*/
_sendImage(user) {
let image = this.get('image');
let image = this.get('profileImage');

return new Promise((resolve, reject) => {
image.formData = {};
return image.submit()
.done((response) => {
let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString());
user.image = response;
user.profile_image = response;

return this.get('ajax').put(usersUrl, {
data: {
Expand Down Expand Up @@ -215,7 +216,7 @@ export default Controller.extend(ValidationEngine, {
},

_afterAuthentication(result) {
if (this.get('image')) {
if (this.get('profileImage')) {
return this._sendImage(result.users[0])
.then(() => {

Expand Down Expand Up @@ -248,7 +249,7 @@ export default Controller.extend(ValidationEngine, {
},

setImage(image) {
this.set('image', image);
this.set('profileImage', image);
}
}
});
2 changes: 1 addition & 1 deletion app/controllers/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default Controller.extend(ValidationEngine, {
},

setImage(image) {
this.set('image', image);
this.set('profileImage', image);
}
}
});
8 changes: 4 additions & 4 deletions app/controllers/team/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export default Controller.extend({
return `${this.get('ghostPaths.assetRoot')}/img/user-image.png`;
}),

userImageBackground: computed('user.image', 'userDefault', function () {
let url = this.get('user.image') || this.get('userDefault');
userImageBackground: computed('user.profileImage', 'userDefault', function () {
let url = this.get('user.profileImage') || this.get('userDefault');
let safeUrl = Handlebars.Utils.escapeExpression(url);

return htmlSafe(`background-image: url(${safeUrl})`);
Expand All @@ -86,8 +86,8 @@ export default Controller.extend({
return `${this.get('ghostPaths.assetRoot')}/img/user-cover.png`;
}),

coverImageBackground: computed('user.cover', 'coverDefault', function () {
let url = this.get('user.cover') || this.get('coverDefault');
coverImageBackground: computed('user.coverImage', 'coverDefault', function () {
let url = this.get('user.coverImage') || this.get('coverDefault');
let safeUrl = Handlebars.Utils.escapeExpression(url);

return htmlSafe(`background-image: url(${safeUrl})`);
Expand Down
3 changes: 1 addition & 2 deletions app/models/post.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable camelcase */
import Ember from 'ember';
import computed, {equal, filterBy} from 'ember-computed';
import injectService from 'ember-service/inject';
Expand Down Expand Up @@ -81,7 +80,7 @@ export default Model.extend(Comparable, ValidationEngine, {
markdown: attr('string', {defaultValue: ''}),
mobiledoc: attr('json-string', {defaultValue: () => BLANK_DOC}),
html: attr('string'),
image: attr('string'),
featureImage: attr('string'),
featured: attr('boolean', {defaultValue: false}),
page: attr('boolean', {defaultValue: false}),
status: attr('string', {defaultValue: 'draft'}),
Expand Down
2 changes: 1 addition & 1 deletion app/models/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default Model.extend(ValidationEngine, {
title: attr('string'),
description: attr('string'),
logo: attr('string'),
cover: attr('string'),
cover_image: attr('string'),

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

icon: attr('string'),
defaultLang: attr('string'),
forceI18n: attr('boolean'),
Expand Down
2 changes: 1 addition & 1 deletion app/models/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default Model.extend(ValidationEngine, {
parent: attr(),
metaTitle: attr('string'),
metaDescription: attr('string'),
image: attr('string'),
featureImage: attr('string'),
visibility: attr('string', {defaultValue: 'public'}),
createdAtUTC: attr('moment-utc'),
updatedAtUTC: attr('moment-utc'),
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default Model.extend(ValidationEngine, {
name: attr('string'),
slug: attr('string'),
email: attr('string'),
image: attr('string'),
cover: attr('string'),
profileImage: attr('string'),
coverImage: attr('string'),
bio: attr('string'),
website: attr('string'),
location: attr('string'),
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/gh-post-settings-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<div class="settings-menu-content">
{{gh-image-uploader-with-preview
image=model.image
image=model.featureImage
text="Add post image"
update=(action "setCoverImage")
remove=(action "clearCoverImage")
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/gh-tag-settings-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
<div class="settings-menu-content">
{{gh-image-uploader-with-preview
image=tag.image
image=tag.featureImage
text="Add tag image"
update=(action "setCoverImage")
remove=(action "clearCoverImage")}}
Expand Down
6 changes: 3 additions & 3 deletions app/templates/settings/general.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@
<div class="gh-setting-desc">An optional large background image for your site</div>
</div>
<div class="gh-setting-action gh-setting-action-largeimg">
{{#if model.cover}}
<img class="blog-cover" src="{{model.cover}}" alt="cover photo" role="button" {{action "toggleUploadCoverModal"}}>
{{#if model.cover_image}}
<img class="blog-cover" src="{{model.cover_image}}" alt="cover photo" role="button" {{action "toggleUploadCoverModal"}}>
{{else}}
<button type="button" class="gh-btn" {{action "toggleUploadCoverModal"}}><span>Upload Image</span></button>
{{/if}}

{{#if showUploadCoverModal}}
{{gh-fullscreen-modal "upload-image"
model=(hash model=model imageProperty="cover")
model=(hash model=model imageProperty="cover_image")
close=(action "toggleUploadCoverModal")
modifier="action wide"}}
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions app/templates/team/user.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<button class="gh-btn gh-btn-default user-cover-edit" {{action "toggleUploadCoverModal"}}><span>Change Cover</span></button>
{{#if showUploadCoverModal}}
{{gh-fullscreen-modal "upload-image"
model=(hash model=user imageProperty="cover")
model=(hash model=user imageProperty="coverImage")
close=(action "toggleUploadCoverModal")
modifier="action wide"}}
{{/if}}
Expand All @@ -109,7 +109,7 @@
<button type="button" {{action "toggleUploadImageModal"}} class="edit-user-image">Edit Picture</button>
{{#if showUploadImageModal}}
{{gh-fullscreen-modal "upload-image"
model=(hash model=user imageProperty="image")
model=(hash model=user imageProperty="profileImage")
close=(action "toggleUploadImageModal")
modifier="action wide"}}
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion mirage/factories/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default Factory.extend({
slug(i) { return `post-${i}`; },
markdown(i) { return `Markdown for post ${i}.`; },
html(i) { return `<p>HTML for post ${i}.</p>`; },
image(i) { return `/content/images/2015/10/post-${i}.jpg`; },
featureImage(i) { return `/content/images/2015/10/post-${i}.jpg`; },
featured: false,
page: false,
status(i) { return faker.list.cycle('draft', 'published', 'scheduled')(i); },
Expand Down
2 changes: 1 addition & 1 deletion mirage/factories/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default Factory.extend({
createdBy: 1,
description(i) { return `Description for tag ${i}.`; },
visibility: 'public',
image(i) { return `/content/images/2015/10/tag-${i}.jpg`; },
featureImage(i) { return `/content/images/2015/10/tag-${i}.jpg`; },
metaDescription(i) { return `Meta description for tag ${i}.`; },
metaTitle(i) { return `Meta Title for tag ${i}`; },
name(i) { return `Tag ${i}`; },
Expand Down
4 changes: 2 additions & 2 deletions mirage/factories/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import {Factory} from 'ember-cli-mirage';
export default Factory.extend({
accessibility: null,
bio: null,
cover: null,
coverImage: null,
createdAt: '2015-09-02T13:41:50.000Z',
createdBy: null,
email(i) { return `user-${i}@example.com`; },
image: '//www.gravatar.com/avatar/3ae045bc198a157401827c8455cd7c99?s=250&d=mm&r=x',
profileImage: '//www.gravatar.com/avatar/3ae045bc198a157401827c8455cd7c99?s=250&d=mm&r=x',
language: 'en_US',
lastLogin: '2015-11-02T16:12:05.000Z',
location: null,
Expand Down
2 changes: 1 addition & 1 deletion mirage/fixtures/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default [
},
{
id: 4,
key: 'cover',
key: 'cover_image',
value: '/content/images/2014/Feb/cover.jpg',
type: 'blog',
created_at: '2013-11-25T14:48:11.000Z',
Expand Down