forked from abramhindle/CMPUT404-project-socialdistribution
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example-article.json
329 lines (309 loc) · 13.1 KB
/
example-article.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
This file specifies what posts look like:
# This is not proper JSON, set editor to Spaces - 4 when editing this
# The following are ways URIs that can be used for post retrieval
#
# http://service/author/posts (posts that are visible to the currently authenticated user)
# or
# http://service/posts (all posts marked as public on the server)
# or
# http://service/author/{AUTHOR_ID}/posts (all posts made by {AUTHOR_ID} visible to the currently authenticated user)
# or
# http://service/posts/{POST_ID} access to a single post with id = {POST_ID}
# or
# http://service/posts/{post_id}/comments access to the comments in a post
#
# All of the previous URIs will get a list of posts like this:
# If a page is provided, return the results for that page, if no page is provided return page 0
# If a size is provided, return pages in this size up to the maximum set on the server. If no size is provided
# return the default page size
# Use same pagination style for all endpoints in this file
# Example:
# GET http://service/author/posts?page=4&size=50
# GET http://service/author/posts?page=4
{
"query": "posts",
# GET to http://service/posts
# number of posts
"count": 1023,
# Page size
"size": 50,
# Do not return next if last page
"next": "http://service/author/posts?page=5",
# Do not return previous if page is 0.
"previous": "http://service/author/posts?page=3",
# should be sorted newest(first) to oldest(last)
"posts":[
{
# title of a post
"title":"A post title about a post about web dev",
# where did you get this post from?
"source":"http://lastplaceigotthisfrom.com/posts/yyyyy",
# where is it actually from
"origin":"http://whereitcamefrom.com/posts/zzzzz",
# a brief description of the post
"description":"This post discusses stuff -- brief",
# The content type of the post
# assume either
# text/markdown
# text/plain
# application/base64
# image/png;base64 # this is an embedded png -- images are POSTS. So you might have a user make 2 posts if a post includes an image!
# image/jpeg;base64 # this is an embedded jpeg
# for HTML you will want to strip tags before displaying
"contentType":"text/plain",
"content":"Þā wæs on burgum Bēowulf Scyldinga, lēof lēod-cyning, longe þrāge folcum gefrǣge (fæder ellor hwearf, aldor of earde), oð þæt him eft onwōc hēah Healfdene; hēold þenden lifde, gamol and gūð-rēow, glæde Scyldingas. Þǣm fēower bearn forð-gerīmed in worold wōcun, weoroda rǣswan, Heorogār and Hrōðgār and Hālga til; hȳrde ic, þat Elan cwēn Ongenþēowes wæs Heaðoscilfinges heals-gebedde. Þā wæs Hrōðgāre here-spēd gyfen, wīges weorð-mynd, þæt him his wine-māgas georne hȳrdon, oð þæt sēo geogoð gewēox, mago-driht micel. Him on mōd bearn, þæt heal-reced hātan wolde, medo-ærn micel men gewyrcean, þone yldo bearn ǣfre gefrūnon, and þǣr on innan eall gedǣlan geongum and ealdum, swylc him god sealde, būton folc-scare and feorum gumena. Þā ic wīde gefrægn weorc gebannan manigre mǣgðe geond þisne middan-geard, folc-stede frætwan. Him on fyrste gelomp ǣdre mid yldum, þæt hit wearð eal gearo, heal-ærna mǣst; scōp him Heort naman, sē þe his wordes geweald wīde hæfde. Hē bēot ne ālēh, bēagas dǣlde, sinc æt symle. Sele hlīfade hēah and horn-gēap: heaðo-wylma bād, lāðan līges; ne wæs hit lenge þā gēn þæt se ecg-hete āðum-swerian 85 æfter wæl-nīðe wæcnan scolde. Þā se ellen-gǣst earfoðlīce þrāge geþolode, sē þe in þȳstrum bād, þæt hē dōgora gehwām drēam gehȳrde hlūdne in healle; þǣr wæs hearpan swēg, swutol sang scopes. Sægde sē þe cūðe frum-sceaft fīra feorran reccan",
# the author has an ID where by authors can be disambiguated
"author":{
# ID of the Author
"id":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
# the home host of the author
"host":"http://127.0.0.1:5454/",
# the display name of the author
"displayName":"Lara Croft",
# url to the authors profile
"url":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
# HATEOS url for Github API
"github": "http://github.com/laracroft"
},
# categories this post fits into (a list of strings
"categories":["web","tutorial"],
# comments about the post
# return a maximum number of comments
# total number of comments for this post
"count": 1023,
# page size
"size": 50,
# the first page of comments
"next": "http://service/posts/{post_id}/comments",
# You should return ~ 5 comments per post.
# should be sorted newest(first) to oldest(last)
"comments":[
{
"author":{
# ID of the Author (UUID)
"id":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
# url to the authors information
"url":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson",
# HATEOS url for Github API
"github": "http://github.com/gjohnson"
},
"comment":"Sick Olde English",
"contentType":"text/markdown",
# ISO 8601 TIMESTAMP
"published":"2015-03-09T13:07:04+00:00",
# ID of the Comment (UUID)
"id":"de305d54-75b4-431b-adb2-eb6b9e546013"
}
]
# ISO 8601 TIMESTAMP
"published":"2015-03-09T13:07:04+00:00",
# ID of the Post (UUID)
"id":"de305d54-75b4-431b-adb2-eb6b9e546013",
# visibility ["PUBLIC","FOAF","FRIENDS","PRIVATE","SERVERONLY"]
"visibility":"PUBLIC",
"visibleTo":[], # list of author URIs who can read the PRIVATE message
# for visibility PUBLIC means it is open to the wild web
# FOAF means it is only visible to Friends of A Friend
# If any of my friends are your friends I can see the post
# FRIENDS means if we're direct friends I can see the post
# PRIVATE means only you can see the post
# SERVERONLY means only those on your server (your home server) can see the post
# PRIVATE means only authors listed in "visibleTo" can see the post
"unlisted":false
# unlisted means it is public if you know the post name -- use this for images, it's so images don't show up in timelines
}
]
}
# Example
# http://service/posts/{post_id}/comments access to the comments in a post
# http://service/posts/{post_id}/comments?page=4
# http://service/posts/{post_id}/comments?page=4&size=40
{
"query": "comments",
# comments about the post
# return a maximum number of comments
# A list of posts
"count": 1023,
"size": 50,
# Do not return next if last page
"next": "http://service/posts/{post_id}/comments?page=5",
# Do not return previous if page is 0.
"previous": "http://service/posts/{post_id}/comments?page=3",
"comments":[{
"author":{
"id":"http://127.0.0.1:5454/8d919f29c12e8f97bcbbd34cc908f19ab9496989",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg"
},
"comment":"Sick Olde English",
"contentType":"text/markdown",
"published":"2015-03-09T13:07:04+00:00",
"id":"5471fe89-7697-4625-a06e-b3ad18577b72"
}]
}
# JSON post body of what you post to a posts' comemnts
# POST to http://service/posts/{POST_ID}/comments
{
"query": "addComment",
"post":"http://whereitcamefrom.com/posts/zzzzz",
"comment":{
"author":{
# ID of the Author
"id":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson",
# url to the authors information
"url":"http://127.0.0.1:5454/author/1d698d25ff008f7538453c120f581471",
# HATEOS url for Github API
"github": "http://github.com/gjohnson"
},
"comment":"Sick Olde English",
"contentType":"text/markdown",
# ISO 8601 TIMESTAMP
"published":"2015-03-09T13:07:04+00:00",
# ID of the Comment (UUID)
"id":"de305d54-75b4-431b-adb2-eb6b9e546013"
}
}
# Responds with
# 200 OK
{
"query": "addComment",
"success":true,
"message":"Comment Added"
}
# or if they don't have the visibility
# 403 Forbidden
{
"query": "addComment",
"success":false,
"message":"Comment not allowed"
}
# a reponse if friends or not
# ask a service GET http://service/author/<authorid>/friends/
responds with:
{
"query":"friends",
# Array of Author UUIDs
"authors":[
"http://host3/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://host2/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
]
}
# Ask if 2 authors are friends
# GET http://service/author/<authorid>/friends/<authorid2>
# STRIP the http:// and https:// from the URI in the restful query
# If you need a template (optional): GET http://service/author/<authorid1>/friends/<service2>/author/<authorid2>
# where authorid1 = de305d54-75b4-431b-adb2-eb6b9e546013 (actually author http://service/author/de305d54-75b4-431b-adb2-eb6b9e546013 )
# where authorid2 =
# GET http://service/author/de305d54-75b4-431b-adb2-eb6b9e546013/friends/127.0.0.1%3A5454%2Fauthor%2Fae345d54-75b4-431b-adb2-fb6b9e547891
# Please escape / of IDs with %2F e.g. urllib.parse.quote( "http://service/author/whatever" , safe='~()*!.\'')
# responds with:
{ "query":"friends",
# Array of Author UUIDs
"authors":[
"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891"
],
# boolean true or false
"friends": true
}
# ask a service if anyone in the list is a friend
# POST to http://service/author/<authorid>/friends
{
"query":"friends",
"author":"<authorid>",
# Array of Author ids
"authors": [
"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
"...",
"...",
"..."
]
}
# reponds with
{
"query":"friends",
"author":"<authorid>", # where <authorid> is the full URL of the author in question
# Array of Author ids who are friends
"authors": [
"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
"..."
]
}
# This is needed for FOAF calls, it asks the other server to decide to send us a
# post or not based on friends.
# one of Greg's friends has to be be LARA's friend
# Here GREG tries to get a post from LARA that's marked as FOAF visibility
# the server will query greg's server to ensure that he is friends with 7de and 11c
# then it will get the users from its own server and see if they are friends of Lara
# Then it will go to at least 1 of these friend's servers and verify that they are friends of Greg
# once it is verified via the 3 hosts that Greg is a friend, then greg will get the data for lara's post
# POST to http://service/posts/{POST_ID} , sending the body
{
"query":"getPost",
"postid":"{POST_ID}",
"url":"http://service/posts/{POST_ID}",
"author":{ # requestor
# UUID
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"host":"http://127.0.0.1:5454/",
"displayName":"Jerry Johnson",
# url to the authors information
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
# HATEOS
"github": "http://github.com/jjohnson"
},
# friends of author
"friends":[
"http://127.0.0.1:5454/author/7deee0684811f22b384ccb5991b2ca7e78abacde",
"http://127.0.0.1:5454/author/11c3783f15f7ade03430303573098f0d4d20797b",
]
}
# then this returns with the generic GET http://service/posts/{POST_ID}
# to make a friend request, POST to http://service/friendrequest
{
"query":"friendrequest",
"author": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg Johnson"
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
},
"friend": {
"id":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara Croft",
"url":"http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013",
}
}
# to unfriend simply do it locally
# Profile API calls
# GET http://service/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e
# Enables viewing of foreign author's profiles
#
# Response
{
"id":"http://service/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
"host":"http://127.0.0.1:5454/",
"displayName":"Lara",
"url":"http://127.0.0.1:5454/author/9de17f29c12e8f97bcbbd34cc908f1baba40658e",
"friends": [
{
"id":"http://127.0.0.1:5454/author/8d919f29c12e8f97bcbbd34cc908f19ab9496989",
"host":"http://127.0.0.1:5454/",
"displayName":"Greg",
"url": "http://127.0.0.1:5454/author/8d919f29c12e8f97bcbbd34cc908f19ab9496989"
}
],
# Optional attributes
"github": "http://github.com/lara",
"firstName": "Lara",
"lastName": "Smith",
"email": "[email protected]",
"bio": "Hi, I'm Lara"
}