Get excerpt for regular topics

Hi,
I’m using Discourse API for get the latest topics for specific category(works great!):

http://haxe.org.il/c/15/l/latest.json?

but I want to get excerpt for all topics not just topics…
How can I do that?
Thanks,
Michael

There currently isn’t a get parameter to request excerpts, but it’s on the list of feature requests.

Hi.
It has been a few years, is it still impossible to do? I’m looking to display my lastest Discourse posts on a WP site and that would be an excellent feature.

Yeah this exists if you install this plugin:

Per:

https://github.com/discourse/discourse-tooltips/blob/master/app/controllers/discourse_tooltips/tooltip_previews_controller.rb

@codinghorror I wonder should we just roll in the functionality of discourse tooltip, it will help keep it more stable over time and helps a tiny bit in some desktop situations.

I am fairly strongly opposed, because hover means nothing on touch and we should not be relying on non-touch behaviors at all. And given that the world will be 99.9% smartphone usage soon.. it’s backwards thinking.

Hi,
I’ve installed and enabled this plugin. It works but I still don’t have the excerpts from other topics than pinned in top.json data.

I believe you need to do another request for the excerpts, like:

Hi, I know this is an old topic, but I am having the same issue.

My rss feed is working fine, but I rather use the Json one as it is more flexible.

So I have a php plugin that pulls discourse json feed ( latest, top, etc), everything works fine… expect the excerpt

Is there is reason why there is no post description on the Json feed? How can I fix this ?

Thanks.

안녕하세요, 저도 같은 문제를 겪었고, 필요한 데이터를 얻기 위해 다시 토픽을 가져오는 방식으로 해결했습니다. topic-list-item.js 컴포넌트에서 Ember.PromiseProxyMixin을 사용하여 이렇게 했습니다. 사용 방법은 여기서 확인하세요: Use Ember.PromiseProxyMixin in a theme

코드는 다음과 같이 보입니다:

// 요청 횟수를 줄이기 위해 커스텀 memoize 함수를 사용했습니다
const getTopic = memoize(id => ajax(`/t/${id}.json`).then(data => data));
// ...
// 컴포넌트 내부

  @discourseComputed("topic")
  topicPromise(topic) {
    return getTopic(topic.id);
  },

  @discourseComputed("topicPromise")
  topicProxy() {
    const promise = this.get("topicPromise");
    return promise && PromiseObject.create({ promise });
  },

  postStream: reads("topicProxy.content.post_stream"),

  @discourseComputed("postStream")
  excerpt(postStream) {
    if (!this.get("postStream")) return false;
    return `${stripHtml(postStream.posts[0].cooked).slice(0, 150)}...`;
  },

stripHtml은 첫 번째 게시글에서 HTML을 제거하기 위한 커스텀 함수입니다.

topic-list-item.hbs에는 다음과 같이 작성합니다.

  {{#if topicProxy.isFulfilled}}
    <div class="excerpt">
      {{#if excerpt}}
        {{html-safe excerpt}}
      {{/if}} 
    </div>
  {{/if}}

목록의 각 주제별로 발췌문을 가져오기 위해 추가 요청을 보내고 있는 건가요?

아쉽게도 그렇습니다. 성능에 영향을 미친다는 건 알지만, 결정은 내가 하는 게 아니거든요. 무슨 말인지 아시죠?

이거 좋아하실 거예요

아니, 왜 숨겨둔 거야?! :smiley:

관리자들이 설명서를 읽지 않고 모든 설정을 클릭하기 때문에 지원 관련 문의가 많이 발생하고 있습니다. 이로 인해 API에서 제공되는 추가 데이터를 전혀 사용하지 않는 많은 인스턴스들이 더 무거운 페이로드를 갖게 됩니다.

곧 테마가 선언적으로 이러한 직렬화 변경 사항을 활성화할 수 있게 될 것입니다.