Skip to content
forked from scripting/likes

A simple likes server for the web running in Node.

License

Notifications You must be signed in to change notification settings

brianleroux/likes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Likes

A simple Node-based server that manages likes across arbitrary web pages. Includes JavaScript code for clients that interfaces with the server.

This is the server behind the likes feature on Scripting News.

The demo app

Full source is provided for the demo app, of course. Please give it a try.

Ask questions. I want to nail this down as quickly as possible, so the sooner you spot problems the sooner they can be addressed.

There's a JavaScript API for the browser. Please review it. Try creating your own app. Follow the example of the demo app. I've tried to make it clear. If you have questions, ask. That'll help me fill out the docs.

The Hello World app

There's an even simpler demo app that's just enough to put up a bit of text with a like element adjacent to it. Here's the source.

Basic facts

We use Twitter for identity. We don't read anything from the user's Twitter account, or post anything to it, we use it to know who's doing the liking.

The server uses a SQL database to keep track of likes. Each like consists of three pieces of data, a URL, a screenname and a timestamp. If a user has liked a specific item there's a record in the database. If you unlike it, the record is removed.

The URLs are up to the application. In the demo app, we construct the URL for each item based on the URL of the page followed by # followed by the name of a color.

You are welcome to use my likes server. The client software defaults to using that server, but you can override it.

If you want to run your own server, you have to create an app with Twitter. This used to be open to everyone, but they're making it harder. It's understandable, they have to try to get troll farms under control. But it seems this is a legitimate use of Twitter identity.

What does a Like mean?

It's a way to tell the author that you saw what they wrote and found it likeable. It doesn't mean you necessarily agree. You're also registering your presence to other people who read the blog. It's a way to say hi to the author and others who read the blog. (From a post on Scripting News.)

API for the Node app

There are four calls, /toggle, /likes, /mylikes and /toplikes that provide the backend services your app needs.

  1. /toggle takes three params, and oauthToken, oauthSecret and the URL of the thing that you are either liking or unliking.

  2. /likes takes a URL and returns a list of users who have liked it. It doesn't require oAuth access info.

  3. /mylikes takes two params, and oauthToken, oauthSecret and returns an array of URLs the user has liked.

  4. /toplikes takes no params, and returns an array of most-liked items, in descending order.

Look in the body of handleHttpRequest in likes.js for all the calls it responds to.

Thejeshgn wrote docs for this API in an innovative way. Comment here.

About

A simple likes server for the web running in Node.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.9%
  • CSS 1.1%