hmans / pants

PANTS: Distributed Social Blogging.

Home Page:http://pants.social/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Likes" feature

hmans opened this issue · comments

Allow users to "like" posts. (A note about terminology: from "like", "fav" and "star", "like" is the one that simply works best for me, since you're expressing that you like a piece of content, and also since it's such a well-known activity, thanks to Facebook. "Fav" and "star" imply that you're marking something as a "favorite" or more important, which doesn't make a lot of sense in a social context. I was considering going with something more playful like "cheer", but once again, just the prevalence of "like" makes it the clear winner.)

The "Like" feature on #pants is interesting, as it also adds support for multiple different post types, with Likes simply being a different post type from normale text posts. When you Like something, what really happens behind the scenes is that you create a new post (of the new pants.like type), which is transferred to the liked content's owner via the same mechanism that otherwise transfers normal posts. pants.like posts are, of course, rendered in an entirely different fashion from normal posts.

Do this first:

  • Rewrite WebmentionHandler to do the following:
    • Find the link linking to target and analyze its attributes before deciding how to deal with the webmention
    • If source is a 404, delete existing posts and trash existing pings
  • Teach Pings to store additional microformat data; give them a type (like, mention, ...) for indieweb like/etc. tracking

Tasks:

  • Add a "Like" button to posts that, when clicked, creates a new pants.like post referencing the liked post
  • Prevent a user from creating multiple likes for the same post
  • Notify the liked post's site about the new pants.like post via webmention
  • When rendering a post, render its received likes
  • Deal with incoming non-#pants likes. (Store likes in their own model/column, after all?)
  • After unliking a post (= deleting the pants.like post), send another webmention to notify the OP
  • Ajaxify like/unlike actions
  • Use correct microformat when rendering a pants.like

Like counts:

  • Add number_of_likes column.
  • Render number of likes in post partial.
  • Update number_of_likes in Post#before_save callback.
  • Serve number_of_likes in post JSON.
  • Read number_of_likes from post JSON.

Cleanup/Polish:

  • Teach the network timeline to render likes notification-style (well, whatever this means)
  • Render Likes as a facepile?
  • Teach the blog (and ATOM feed) to only render pants.post posts
  • Smarten up "Replies" rendering
  • Nicer post action buttons/links
  • Figure out how to fix the Incoming Timeline (maybe better unified post actions?)

Just a quick heads-up (and also a note to my future self): there's already some good progress on this in the likes branch, but I reached a point where I realized that I need to refactor two (small) parts of Pants before wrapping this up:

  • The WebmentionHandler service class needs to change the way it works so it first looks for the link back to the target and then analyzes the nature of the link by looking at its rel attribute (instead of using the target itself to decide what to do, as it does now.)
  • The Ping class needs to get at least one additional attribute that stores the nature of the referenced URL (eg. like, reply, mention, and others.) This is because we're using stored Pings to display the reactions (replies, likes etc.) to a post, and I'd like to keep doing it this way because it saves me from setting up additional throw-away model classes.