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.

「いいね!」 2

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.

「いいね!」 4

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:

「いいね!」 3

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}}

リストの各トピックに対して、抜粋を取得するための追加リクエストを送信していますか?

残念ながら、その通りです。パフォーマンスに影響があることは承知していますが、決定権は私にはありません。ご理解いただけると思います。

きっと気に入るはずです

「いいね!」 5

ええっ!なんで隠れてるの?:smiley:

「いいね!」 2

管理者が設定をすべてクリックして読み飛ばすサポート問い合わせが非常に多いためです。つまり、API から提供される追加データを一切利用しないにもかかわらず、多くのインスタンスで過剰なペイロードが発生してしまいます。

まもなく、テーマで宣言的にこれらのシリアライザーの変更を有効化できるようになります

「いいね!」 5

このトピックは3184日後に自動的に閉じられました。返信はもう許可されていません。