Identify and highlight post with the most likes in a given topic

(Christopher Heald) #1

I would like be able to uniquely style the post that has received the most likes in any given topic. From what I have read so far on meta, it looks like this would be best addressed - for now, at least - by a plugin that would add a CSS class to the most liked post.

I have looked through the Discourse source code, and I have looked at other plugins, but I can’t find anything that would help me to get started on this.

I’m not a Ruby person, but I know may way around jQuery and database queries. The logic would look something like this mash-up:

var post_id = (SELECT id FROM posts WHERE topic_id = current_topic_id ORDER BY like_count DESC LIMIT 1);
var post_class = "#post-cloak-" + post_id;

This would then allow CSS theming to target the most liked post.

I am more than willing to tackle this, but I would need some pointers as to where to start looking at how to hook into the listing of the posts in a topic.

Prospective Feature: Highlight Posts That Surpass Defined "Likes" Threshold