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

Commit

Permalink
🎨 use formats query param (#718)
Browse files Browse the repository at this point in the history
refs TryGhost/Ghost#8275
- ask Ghost for `mobiledoc` and `plaintext`
- Ghost returns `html` by default
- use plaintext for `{{subText}}` for posts overview
  • Loading branch information
kirrg001 authored and kevinansfield committed May 30, 2017
1 parent 7eefbba commit 221ca16
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
11 changes: 3 additions & 8 deletions app/components/gh-posts-list-item.js
Expand Up @@ -40,19 +40,14 @@ export default Component.extend({

// HACK: this is intentionally awful due to time constraints
// TODO: find a better way to get an excerpt! :)
subText: computed('post.{html,metaDescription}', function () {
let html = this.get('post.html');
subText: computed('post.{plaintext,metaDescription}', function () {
let text = this.get('post.plaintext');
let metaDescription = this.get('post.metaDescription');
let text;

if (!isBlank(metaDescription)) {
text = metaDescription;
} else {
let $html = $(`<div>${html}</div>`);
text = $html.text();
}

return htmlSafe(`${text.slice(0, 80)}&hellip;`);
return `${text.slice(0, 80)}...`;
}),

didReceiveAttrs() {
Expand Down
1 change: 1 addition & 0 deletions app/models/post.js
Expand Up @@ -82,6 +82,7 @@ export default Model.extend(Comparable, ValidationEngine, {
featureImage: attr('string'),
featured: attr('boolean', {defaultValue: false}),
page: attr('boolean', {defaultValue: false}),
plaintext: attr('string'),
status: attr('string', {defaultValue: 'draft'}),
language: attr('string', {defaultValue: 'en_US'}),
metaTitle: attr('string'),
Expand Down
3 changes: 2 additions & 1 deletion app/routes/editor/edit.js
Expand Up @@ -16,7 +16,8 @@ export default AuthenticatedRoute.extend(base, {
let query = {
id: params.post_id,
status: 'all',
staticPages: 'all'
staticPages: 'all',
formats: 'mobiledoc,plaintext'
};
/* eslint-enable camelcase */

Expand Down
2 changes: 2 additions & 0 deletions app/routes/posts.js
Expand Up @@ -55,6 +55,8 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
queryParams.order = params.order;
}

queryParams.formats = 'mobiledoc,plaintext';

let perPage = this.get('perPage');
let paginationSettings = assign({perPage, startingPage: 1}, queryParams);

Expand Down
1 change: 1 addition & 0 deletions mirage/factories/post.js
Expand Up @@ -7,6 +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>`; },
plaintext(i) { return `Plaintext for post ${i}.`; },
featureImage(i) { return `/content/images/2015/10/post-${i}.jpg`; },
featured: false,
page: false,
Expand Down

0 comments on commit 221ca16

Please sign in to comment.