mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
parent
4067bfe4c1
commit
9a62a38440
@ -67,21 +67,18 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
|||||||
.extend(Ember.PromiseProxyMixin)
|
.extend(Ember.PromiseProxyMixin)
|
||||||
.create(deferred);
|
.create(deferred);
|
||||||
}),
|
}),
|
||||||
/**
|
|
||||||
* The placeholder is the published date of the post,
|
publishedAtValue: Ember.computed('published_at', function () {
|
||||||
* or the current date if the pubdate has not been set.
|
|
||||||
*/
|
|
||||||
publishedAtPlaceholder: Ember.computed('publishedAtValue', function () {
|
|
||||||
var pubDate = this.get('published_at');
|
var pubDate = this.get('published_at');
|
||||||
if (pubDate) {
|
if (pubDate) {
|
||||||
return formatDate(pubDate);
|
return formatDate(pubDate);
|
||||||
}
|
}
|
||||||
return formatDate(moment());
|
return formatDate(moment());
|
||||||
}),
|
}),
|
||||||
publishedAtValue: boundOneWay('published_at', formatDate),
|
|
||||||
|
|
||||||
slugValue: boundOneWay('slug'),
|
slugValue: boundOneWay('slug'),
|
||||||
//Lazy load the slug generator for slugPlaceholder
|
|
||||||
|
//Lazy load the slug generator
|
||||||
slugGenerator: Ember.computed(function () {
|
slugGenerator: Ember.computed(function () {
|
||||||
return SlugGenerator.create({
|
return SlugGenerator.create({
|
||||||
ghostPaths: this.get('ghostPaths'),
|
ghostPaths: this.get('ghostPaths'),
|
||||||
@ -160,10 +157,15 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
|||||||
return placeholder;
|
return placeholder;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
seoURL: Ember.computed('slug', 'slugPlaceholder', function () {
|
seoURL: Ember.computed('slug', function () {
|
||||||
var blogUrl = this.get('config').blogUrl,
|
var blogUrl = this.get('config').blogUrl,
|
||||||
seoSlug = this.get('slug') ? this.get('slug') : this.get('slugPlaceholder'),
|
seoSlug = this.get('slug') ? this.get('slug') : '',
|
||||||
seoURL = blogUrl + '/' + seoSlug + '/';
|
seoURL = blogUrl + '/' + seoSlug;
|
||||||
|
|
||||||
|
// only append a slash to the URL if the slug exists
|
||||||
|
if (seoSlug) {
|
||||||
|
seoURL += '/';
|
||||||
|
}
|
||||||
|
|
||||||
if (seoURL.length > 70) {
|
if (seoURL.length > 70) {
|
||||||
seoURL = seoURL.substring(0, 70).trim();
|
seoURL = seoURL.substring(0, 70).trim();
|
||||||
@ -180,33 +182,20 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
|||||||
this.addObserver('titleScratch', this, 'titleObserver');
|
this.addObserver('titleScratch', this, 'titleObserver');
|
||||||
}
|
}
|
||||||
}.observes('model'),
|
}.observes('model'),
|
||||||
titleObserver: function () {
|
|
||||||
var debounceId;
|
|
||||||
|
|
||||||
if (this.get('isNew') && !this.get('title')) {
|
titleObserver: function () {
|
||||||
debounceId = Ember.run.debounce(this, 'generateAndSetSlug', ['slugPlaceholder'], 700);
|
var debounceId,
|
||||||
} else if (this.get('title') === '(Untitled)') {
|
title = this.get('title'),
|
||||||
|
slug = this.get('slug');
|
||||||
|
|
||||||
|
// generate a slug if a post is new and doesn't have a title yet or
|
||||||
|
// if the title is still '(Untitled)' and the slug is unaltered.
|
||||||
|
if ((this.get('isNew') && !title) || title === '(Untitled)' && /^untitled(-\d+){0,1}$/.test(slug)) {
|
||||||
debounceId = Ember.run.debounce(this, 'generateAndSetSlug', ['slug'], 700);
|
debounceId = Ember.run.debounce(this, 'generateAndSetSlug', ['slug'], 700);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('debounceId', debounceId);
|
this.set('debounceId', debounceId);
|
||||||
},
|
},
|
||||||
slugPlaceholder: Ember.computed(function (key, value) {
|
|
||||||
var slug = this.get('slug');
|
|
||||||
|
|
||||||
//If the post has a slug, that's its placeholder.
|
|
||||||
if (slug) {
|
|
||||||
return slug;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Otherwise, it's whatever value was set by the
|
|
||||||
// slugGenerator (below)
|
|
||||||
if (arguments.length > 1) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
//The title will stand in until the actual slug has been generated
|
|
||||||
return this.get('titleScratch');
|
|
||||||
}),
|
|
||||||
|
|
||||||
showErrors: function (errors) {
|
showErrors: function (errors) {
|
||||||
errors = Ember.isArray(errors) ? errors : [errors];
|
errors = Ember.isArray(errors) ? errors : [errors];
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="url">Post URL</label>
|
<label for="url">Post URL</label>
|
||||||
<span class="input-icon icon-link">
|
<span class="input-icon icon-link">
|
||||||
{{gh-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" focus-out="updateSlug" placeholder=slugPlaceholder selectOnClick="true" stopEnterKeyDownPropagation="true"}}
|
{{gh-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" focus-out="updateSlug" selectOnClick="true" stopEnterKeyDownPropagation="true"}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="post-setting-date">Publish Date</label>
|
<label for="post-setting-date">Publish Date</label>
|
||||||
<span class="input-icon icon-calendar">
|
<span class="input-icon icon-calendar">
|
||||||
{{gh-input class="post-setting-date" id="post-setting-date" value=publishedAtValue name="post-setting-date" focus-out="setPublishedAt" placeholder=publishedAtPlaceholder stopEnterKeyDownPropagation="true"}}
|
{{gh-input class="post-setting-date" id="post-setting-date" value=publishedAtValue name="post-setting-date" focus-out="setPublishedAt" stopEnterKeyDownPropagation="true"}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user