mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-05 18:34:39 +03:00
Add a URL preview componant
Closes #4499 - Introduces a URL preview component - Added the component to tag settings and post settings - Adds a new CSS file for this component which makes sure the preview never wraps onto multiple lines
This commit is contained in:
parent
8ceb896e96
commit
7c310ad2df
18
core/client/assets/sass/components/url-preview.scss
Normal file
18
core/client/assets/sass/components/url-preview.scss
Normal file
@ -0,0 +1,18 @@
|
||||
// ------------------------------------------------------------
|
||||
// URL Preview
|
||||
//
|
||||
// Styles for the {{url-preview}} component
|
||||
//
|
||||
// * Overflow Ellipsis
|
||||
// ------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Overflow Ellipsis
|
||||
// --------------------------------------------------
|
||||
|
||||
.ghost-url-preview {
|
||||
width: 98%; // Makes sure the preview isnt wider than the input
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
@ -45,6 +45,7 @@
|
||||
@import "components/badges";
|
||||
@import "components/popovers";
|
||||
@import "components/settings-menu";
|
||||
@import "components/url-preview";
|
||||
|
||||
|
||||
//
|
||||
|
27
core/client/components/gh-url-preview.js
Normal file
27
core/client/components/gh-url-preview.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
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,
|
||||
theUrl: null,
|
||||
|
||||
generateUrl: 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;
|
||||
|
||||
this.set('the-url', theUrl);
|
||||
}.on('didInsertElement').observes('slug')
|
||||
});
|
||||
|
||||
export default urlPreview;
|
1
core/client/templates/components/gh-url-preview.hbs
Normal file
1
core/client/templates/components/gh-url-preview.hbs
Normal file
@ -0,0 +1 @@
|
||||
{{the-url}}
|
@ -14,6 +14,7 @@
|
||||
<span class="input-icon icon-link">
|
||||
{{gh-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" focus-out="updateSlug" selectOnClick="true" stopEnterKeyDownPropagation="true"}}
|
||||
</span>
|
||||
{{gh-url-preview slug=slugValue tagName="p" classNames="description"}}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -16,8 +16,9 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Slug</label>{{!--@TODO show full url preview, not just slug--}}
|
||||
<label>Slug</label>
|
||||
{{gh-input type="text" value=activeTagSlugScratch focus-out="saveActiveTagSlug"}}
|
||||
{{gh-url-preview prefix="tag" slug=activeTagSlugScratch tagName="p" classNames="description"}}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
Loading…
Reference in New Issue
Block a user