for example, I want to change the result on /latest.json endpoint,
and I found the controller is list_controller.rb,
is there a way to modify related functions through plugin?
j.jaffeux
(Joffrey Jaffeux)
8 בינואר, 2019, 2:37pm
2
There’s almost nothing a plugin can’t do. The question is generally more: is it a good idea ? is it maintainable?
What have you tried so far ?
A good starting point it to look at our all-the-plugins repo and search for similar patterns.
merefield
(Robert)
8 בינואר, 2019, 2:45pm
3
It’s best to look at an example, I believe you can amend the serialisers:
Consider this:
class TopicListItemSerializer < ListableTopicSerializer
include TopicTagsMixin
attributes :views,
:like_count,
:has_summary,
:archetype,
:last_poster_username,
:category_id,
:op_like_count,
:pinned_globally,
:bookmarked_post_numbers,
:liked_post_numbers,
:featured_link,
:featured_link_root_domain
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
has_many :participants, serializer: TopicPosterSerializer, embed: :objects
def posters
This file has been truncated. show original
With, for example, the Topic List Previews Plugin edits, from here:
https://github.com/angusmcleod/discourse-topic-previews/blob/master/serializers/topic_list_item_edits.rb
This appends a load of extra attributes. Try it and take a look.