Giter Site home page Giter Site logo

pumpkin's Introduction

Pumpkin

User moderated open commenting system

Usage

For pre-populating and/or testing, run the REST URLs provided in test_URLs.txt.

  • Clicking on the link of a topic will take you to that link.
  • Clicking on the topic title will show all replies to that topic
  • Clicking on "add reply" will allow you to add a reply to the parent
  • You can submit new topics through the form at the bottom

How it all works

The system uses an Object to store a sequence of topics. Each topic is the root of a tree-like structure. The children and subsequent branches are replies.

Topics All topics are stored in an object
Topic Topic is an object under topics with attributes: "id", "text", "link", "weight", "replies"
Replies All replies to a topic are stored in an object
Reply Reply is an object under replies with attributes: "id", "text", "votes", "weight", "replies", "children_ids"

API Endpoints

Get all topics - /topic/all

Attributes

Path /topic/all
HTTP Method GET

Parameters

None

Response

JSON of all topics and replies.

JSON format
Topic { "id": topic_id, "text": text, "link": link, "weight": 0, "replies": {} }
Reply { "id": reply_id, "text": text, "votes": 0, "weight": 0, "replies": {}, "children_ids": [] }

Example

Request $.get('http://127.0.0.1:30925/topic/all')
Response {"0":{"id":0,"text":"Cool search engine","link":"http://google.com","weight":0,
"replies":{"1":{"id":1,"text":"just a reply","votes":0,"weight":0,"replies":{},"children_ids":[]}}}}

Add new topic - /topic/add

Path /topic/add
HTTP Method POST

Parameters

text 140 character maximum text
link URL

Format: /topic/add?text=yourtext&link=yourlink

Response

JSON of topic added.

JSON format
Topic { "id": topic_id, "text": text, "link": link, "weight": 0, "replies": {} }

Example

Request $.post('http://127.0.0.1:30925/topic/add?text=yourtext&link=yourlink')
Response {"id":3,"text":"yourtext","link":"yourlink","weight":0,"replies":{}}

Get all replies for a specified topic - /topic/reply/all##

Path /topic/reply/all
HTTP Method GET

Parameters

topicid Valid existing topic ID

Format: /topic/reply/all?topicid=XX

Response

JSON of all replies for specified topic.

JSON format
Reply { "id": reply_id, "text": text, "votes": 0, "weight": 0, "replies": {}, "children_ids": [] }

Example

Request $.get('http://127.0.0.1:30925/topic/reply/all?topicid=0')
Response {"1":{"id":1,"text":"just a reply","votes":0,"weight":0,"replies":{},"children_ids":[]}}

Add a new reply - /topic/reply/add

Path /topic/reply/add
HTTP Method POST

Parameters

topicid Valid existing topic ID
parentid (optional) ID of reply this is in response to (ie. parent reply). Not needed for direct reply to topic.
text Reply content

Format: /topic/reply/add?topicid=XX&parentid=YY&text=ZZ

Response

JSON of all reply added.

JSON format
Reply { "id": reply_id, "text": text, "votes": 0, "weight": 0, "replies": {}, "children_ids": [] }

Example

Request $.post('http://127.0.0.1:30925/topic/reply/add?topicid=0&text=yourreplytext')
Response {"id":4,"text":"yourreplytext","votes":0,"weight":0,"replies":{},"children_ids":[]}

Vote for a reply - /topic/reply/upvote

Path /topic/reply/upvote
HTTP Method POST

Parameters

replyid ID of reply for which the vote is being registered

Format: /topic/reply/upvote?replyid=YY

Response

Plain text: success

JSON format
Reply { "id": reply_id, "text": text, "votes": 0, "weight": 0, "replies": {}, "children_ids": [] }

Example

Request $.post('http://127.0.0.1:30925/topic/reply/upvote?topicid=0&replyid=4')
Response success

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.