mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
c3ad1ae9e2
No Issue - Switches to the newer style of dependency injection. - Instead of injection Controllers via "needs," use Ember.inject.controller(). - Get rid of initializers that were only injecting objects into various factories. Converts these objects into Ember.Service objects and declaratively inject them where needed via Ember.inject.service(). The added benefit to this is that it's no longer a mystery where these properties/methods come from and it's straightforward to inject them where needed.
30 lines
898 B
JavaScript
30 lines
898 B
JavaScript
import Ember from 'ember';
|
|
/*
|
|
Example usage:
|
|
{{gh-url-preview prefix="tag" slug=theSlugValue tagName="p" classNames="description"}}
|
|
*/
|
|
var urlPreview = Ember.Component.extend({
|
|
classNames: 'ghost-url-preview',
|
|
prefix: null,
|
|
slug: null,
|
|
|
|
config: Ember.inject.service(),
|
|
|
|
url: Ember.computed('slug', function () {
|
|
// Get the blog URL and strip the scheme
|
|
var blogUrl = this.get('config.blogUrl'),
|
|
noSchemeBlogUrl = blogUrl.substr(blogUrl.indexOf('://') + 3), // Remove `http[s]://`
|
|
|
|
// Get the prefix and slug values
|
|
prefix = this.get('prefix') ? this.get('prefix') + '/' : '',
|
|
slug = this.get('slug') ? this.get('slug') + '/' : '',
|
|
|
|
// Join parts of the URL together with slashes
|
|
theUrl = noSchemeBlogUrl + '/' + prefix + slug;
|
|
|
|
return theUrl;
|
|
})
|
|
});
|
|
|
|
export default urlPreview;
|