Created
April 14, 2022 11:57
-
-
Save listenlight/14022344e54a12a31eae98b68c6803af to your computer and use it in GitHub Desktop.
Basic functionality for word count of replies to a topic, not counting author's posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plugins/wordcount/plugin.rb | |
after_initialize do | |
add_to_serializer(:topic_list_item, :word_count_of_replies) do | |
object.posts.where.not(user: object.user).sum(:word_count) | |
end | |
end | |
# topic-posts-column.hbr | |
<{{view.tagName}} class='num posts-map posts {{view.likesHeat}} topic-list-data' title='{{view.title}}'> | |
<button class="btn-link posts-map badge-posts {{view.likesHeat}}" aria-label="{{view.title}}"> | |
{{raw-plugin-outlet name="topic-list-before-reply-count"}} | |
{{number topic.replyCount noTitle="true" ariaLabel=view.title}} | |
# sample change, from "2" to "2 (220w)" | |
({{number topic.word_count_of_replies noTitle="true" ariaLabel="wordcount of replies"}}w) | |
</button> | |
</{{view.tagName}}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment