apidoc for "view comment"

This commit is contained in:
Joshua Gleitze 2016-06-03 10:28:51 +02:00
parent b2d9c80b5f
commit 1f804bcf8e

View File

@ -146,26 +146,14 @@ class API(object):
return True, "" return True, ""
# Common definitions for apidoc follow:
""" """
@api {post} /new create new @apiDefine plainParam
@apiGroup Comment @apiParam {number=0,1} [plain]
@apiUse csrf Iff set to `1`, the plain text entered by the user will be returned in the comments `text` attribute (instead of the rendered markdown).
"""
@apiParam {string} uri """
The uri of the thread to create the comment on. @apiDefine commentResponse
@apiParam {string} text
The comments raw text.
@apiParam {string} [author]
The comments authors name.
@apiParam {string} [email]
The comments authors email address.
@apiParam {string} [website]
The comments authors websites url.
@apiParam {number} [parent]
The parent comments id iff the new comment is a response to an existing comment.
@apiExample {curl} Create a reply to comment with id 15:
curl 'https://comments.example.com/new?uri=/thread/' -d '{"text": "Stop saying that! *isso*!", "author": "Max Rant", "email": "rant@example.com", "parent": 15}' -H 'Content-Type: application/json'
@apiSuccess {number} id @apiSuccess {number} id
The comments id (assigned by the server). The comments id (assigned by the server).
@ -188,6 +176,30 @@ class API(object):
UNIX timestamp of the time the comment was created (on the server). UNIX timestamp of the time the comment was created (on the server).
@apiSuccess {number} modified @apiSuccess {number} modified
UNIX timestamp of the time the comment was last modified (on the server). `null` if the comment was not yet modified. UNIX timestamp of the time the comment was last modified (on the server). `null` if the comment was not yet modified.
"""
"""
@api {post} /new create new
@apiGroup Comment
@apiUse csrf
@apiParam {string} uri
The uri of the thread to create the comment on.
@apiParam {string} text
The comments raw text.
@apiParam {string} [author]
The comments authors name.
@apiParam {string} [email]
The comments authors email address.
@apiParam {string} [website]
The comments authors websites url.
@apiParam {number} [parent]
The parent comments id iff the new comment is a response to an existing comment.
@apiExample {curl} Create a reply to comment with id 15:
curl 'https://comments.example.com/new?uri=/thread/' -d '{"text": "Stop saying that! *isso*!", "author": "Max Rant", "email": "rant@example.com", "parent": 15}' -H 'Content-Type: application/json'
@apiUse commentResponse
@apiSuccessExample Success after the above request: @apiSuccessExample Success after the above request:
{ {
@ -200,7 +212,7 @@ class API(object):
"modified": null, "modified": null,
"mode": 1, "mode": 1,
"hash": "e644f6ee43c0", "hash": "e644f6ee43c0",
"id": 10, "id": 23,
"likes": 0 "likes": 0
} }
""" """
@ -277,6 +289,33 @@ class API(object):
resp.headers.add("X-Set-Cookie", cookie("isso-%i" % rv["id"])) resp.headers.add("X-Set-Cookie", cookie("isso-%i" % rv["id"]))
return resp return resp
"""
@api {get} /id/:id view
@apiGroup Comment
@apiParam {number} id
The id of the comment to view.
@apiUse plainParam
@apiExample {curl} View the comment with id 4:
curl 'https://comments.example.com/id/4'
@apiUse commentResponse
@apiSuccessExample Example result:
{
"website": null,
"author": null,
"parent": null,
"created": 1464914341.312426,
"text": " <p>I want to use MySQL</p>",
"dislikes": 0,
"modified": null,
"mode": 1,
"id": 4,
"likes": 1
}
"""
def view(self, environ, request, id): def view(self, environ, request, id):
rv = self.comments.get(id) rv = self.comments.get(id)
@ -421,8 +460,7 @@ class API(object):
The URI of thread to get the comments from. The URI of thread to get the comments from.
@apiParam {number} [parent] @apiParam {number} [parent]
Return only comments that are children of the comment with the provided ID. Return only comments that are children of the comment with the provided ID.
@apiParam {number=0,1} [plain] @apiUse plainParam
Iff set to `1`, the plain text entered by the user will be returned in the comments `text` attribute (instead of the rendered markdown).
@apiParam {number} [limit] @apiParam {number} [limit]
The maximum number of returned top-level comments. Omit for unlimited results. The maximum number of returned top-level comments. Omit for unlimited results.
@apiParam {number} [nested_limit] @apiParam {number} [nested_limit]