Skip to content

Commit 0efb501

Browse files
committed
Use real objects where it makes sense
1 parent 3bd2c7d commit 0efb501

File tree

7 files changed

+193
-112
lines changed

7 files changed

+193
-112
lines changed

content/reference/meta/entities.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Ranges specified by entities may be adjacent, but may not overlap.
1515

1616
<div class="alert alert-info"><b>Note:</b> <code>pos</code> and <code>len</code> fields are given as UTF-32 code points. Many string implementations (in particular, Cocoa's NSString class and Javascript's strings) use UTF-16 or UCS-2 encoding internally, and thus the indices given will not map directly to UTF-16 code points if encoded with surrogate pairs, e.g., emoji characters.</div>
1717

18-
All of the following examples are about the following post:
18+
All of the following examples are about the following text:
1919

2020
> @berg FIRST post on this new site #newsocialnetwork
2121

content/reference/resources/channel/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ A Channel is a user created stream of Messages. It controls access to the messag
1313

1414
## Example Channel object
1515

16-
<%= json(:CHANNEL_WITH_MARKER) do |h|
16+
<%= json(:channel) do |h|
17+
h["marker"] = "...marker object..."
1718
h["writers"]["user_ids"] = ["2", "3"]
1819
end %>
1920

content/reference/resources/post/lifecycle.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ If you want to test how your text will be processed you can use the [text proces
2828

2929
#### Example
3030

31-
<%= curl_example(:post, "posts", :first_post, {:data => "text=%40berg+FIRST+post+on+this+new+site+%23newsocialnetwork", :content_type => nil}) %>
31+
<%= curl_example(:post, "posts", :post, {:data => "text=join.app.net getting ready for the world w/ @dalton @berg @voidfiles @jhubball @aaronblyth @andrew @vinitlee @mark @mintz @barmstrong @laughingman @mikegreenspan @ben #joinus", :content_type => nil}) %>
3232

3333
#### Example (JSON Data)
3434

3535
<% data = {
36-
"text" => "@berg FIRST post on this new site #newsocialnetwork",
36+
"text" => "join.app.net getting ready for the world w/ @dalton @berg @voidfiles @jhubball @aaronblyth @andrew @vinitlee @mark @mintz @barmstrong @laughingman @mikegreenspan @ben #joinus",
3737
"annotations" => [{
3838
"type" => "net.app.core.geolocation",
3939
"value" => {
@@ -42,7 +42,7 @@ If you want to test how your text will be processed you can use the [text proces
4242
}
4343
}]
4444
} %>
45-
<%= curl_example(:post, "posts?include_post_annoations=1", :first_post, {:data => data}) do |h|
45+
<%= curl_example(:post, "posts?include_post_annoations=1", :post, {:data => data}) do |h|
4646
h["data"]["annotations"] = data["annotations"]
4747
end %>
4848

content/reference/resources/post/search.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Returns [Post](/reference/resources/post/) objects which match a given search qu
6464

6565
#### Example
6666

67-
<%= curl_example(:get, "posts/search?hashtags=newsocialnetwork&mentions=berg&is_directed=1&count=-1", :post, {:response => :paginated}) do |h|
67+
<%= curl_example(:get, "posts/search?hashtags=joinus&mentions=berg&count=-1", :post, {:response => :paginated}) do |h|
6868
h["meta"]["count"] = 1
6969
h["data"][0]["pagination_id"] = "10000"
70-
end %>
70+
end %>

content/reference/resources/post/streams.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ Return the 20 most recent [Posts](/reference/resources/post/) for a specific has
101101

102102
#### Example
103103

104-
<%= curl_example(:get, "posts/tag/newsocialnetwork", :post, {:response => :paginated}) %>
104+
<%= curl_example(:get, "posts/tag/joinus", :post, {:response => :paginated}) %>

content/reference/resources/user/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A User is the central object of the App.net APIs. User objects have usernames, f
1818
{
1919
"type" => "net.app.core.directory.blog",
2020
"value" => {
21-
"url" => "http://myawesomeblog.com"
21+
"url" => "http://daltoncaldwell.com/"
2222
}
2323
}
2424
]

lib/sample_objects.rb

+183-103
Original file line numberDiff line numberDiff line change
@@ -163,56 +163,55 @@ def paginated_response(key, &block)
163163
}
164164

165165
USER_SELF = {
166-
"id" => "1",
167-
"username" => "mthurman",
168-
"name" => "Mark Thurman",
169-
"description" => {
170-
"text" => "Hi, I'm Mark Thurman and I'm teaching you about the @appdotnet Stream #API.",
171-
"html" => "Hi, I'm Mark Thurman and I'm <a href=\"https://github.com/appdotnet/api_spec\" rel=\"nofollow\">teaching you</a> about the <span itemprop=\"mention\" data-mention-name=\"appdotnet\" data-mention-id=\"3\">@appdotnet</span> Stream #<span itemprop=\"hashtag\" data-hashtag-name=\"api\">API</span>.",
172-
"entities" => {
173-
"mentions" => [{
174-
"name" => "appdotnet",
175-
"id" => "3",
176-
"pos" => 52,
177-
"len" => 10
178-
}],
179-
"hashtags" => [{
180-
"name" => "api",
181-
"pos" => 70,
182-
"len" => 4
183-
}],
184-
"links" => [{
185-
"text" => "teaching you",
186-
"url" => "https://github.com/appdotnet/api-spec",
187-
"pos" => 29,
188-
"len" => 12
189-
}]
190-
}
191-
},
192-
"timezone" => "US/Pacific",
193-
"locale" => "en_US",
194166
"avatar_image" => {
195-
"height" => 200,
196-
"width" => 200,
197-
"url" => "https://example.com/avatar_image.jpg",
198-
"is_default" => false
167+
"height" => 138,
168+
"is_default" => false,
169+
"url" => "https://d2rfichhc2fb9n.cloudfront.net/image/5/IE7DNB7N4XE9OjQuP16-9zaPU1x7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvODgvNjgvNDAvODg2ODQwMDAwMDAwMDAwMC5qcGciLCJvIjoiIn0",
170+
"width" => 138
171+
},
172+
"canonical_url" => "https://alpha.app.net/dalton",
173+
"counts" => {
174+
"followers" => 16833,
175+
"following" => 666,
176+
"posts" => 13284,
177+
"stars" => 8301
199178
},
200179
"cover_image" => {
201-
"width" => 960,
202-
"height" => 264,
203-
"url" => "https://example.com/cover_image.jpg",
204-
"is_default" => false
180+
"height" => 456,
181+
"is_default" => false,
182+
"url" => "https://d2rfichhc2fb9n.cloudfront.net/image/5/iV3sRFel7xEjDK7hCB9R0xgIFAF7InMiOiJzMyIsImIiOiJhZG4tdXNlci1hc3NldHMiLCJrIjoiYXNzZXRzL3VzZXIvNDIvMDAvMDAvNDIwMDAwMDAwMDAwMDAwMC5wbmciLCJvIjoiIn0",
183+
"width" => 1103
205184
},
206-
"type" => "human",
207-
"created_at" => "2012-07-16T17:23:34Z",
208-
"counts" => {
209-
"following" => 100,
210-
"followers" => 200,
211-
"posts" => 24,
212-
"stars" => 76
185+
"created_at" => "2012-08-03T01:17:14Z",
186+
"description" => {
187+
"entities" => {
188+
"hashtags" => [],
189+
"links" => [
190+
{
191+
"len" => 7,
192+
"pos" => 12,
193+
"text" => "App.net",
194+
"url" => "http://App.net"
195+
},
196+
{
197+
"len" => 18,
198+
"pos" => 27,
199+
"text" => "daltoncaldwell.com",
200+
"url" => "http://daltoncaldwell.com"
201+
}
202+
],
203+
"mentions" => []
204+
},
205+
"html" => "<span itemscope=\"https://app.net/schemas/Post\">Founder/CEO <a href=\"http://App.net\">App.net</a> <br>Blog => <a href=\"http://daltoncaldwell.com\">daltoncaldwell.com</a></span>",
206+
"text" => "Founder/CEO App.net \nBlog => daltoncaldwell.com"
213207
},
214-
"verified_domain" => "example.com",
215-
"canonical_url" => "https://alpha.app.net/mthurman"
208+
"id" => "1",
209+
"locale" => "en_US",
210+
"name" => "Dalton Caldwell",
211+
"timezone" => "America/Los_Angeles",
212+
"type" => "human",
213+
"username" => "dalton",
214+
"verified_domain" => "daltoncaldwell.com",
216215
}
217216

218217
USER = USER_SELF.merge({
@@ -289,49 +288,123 @@ def paginated_response(key, &block)
289288
"you_muted" => false,
290289
}
291290

292-
CHANNEL_WITH_MARKER = CHANNEL.merge({
293-
"marker" => "...marker object..."
294-
})
295-
296291
POST = {
297-
"id" => "1",
298-
"user" => "...user object...",
299-
"created_at" => "2012-07-16T17:25:47Z",
300-
"text" => "@berg FIRST post on this new site #newsocialnetwork",
301-
"html" => "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"mention\" data-mention-name=\"berg\" data-mention-id=\"2\">@berg</span> FIRST post on <a href=\"https://join.app.net\" rel=\"nofollow\">this new site</a> <span itemprop=\"hashtag\" data-hashtag-name=\"newsocialnetwork\">#newsocialnetwork</span>.</span>",
302-
"source" => {
303-
"name" => "Clientastic for iOS",
304-
"link" => "http://app.net",
305-
"client_id" => "udxGzAVBdXwGtkHmvswR5MbMEeVnq6n4"
292+
"canonical_url" => "https://alpha.app.net/mthurman/post/1",
293+
"created_at" => "2012-08-03T03:59:06Z",
294+
"entities" => {
295+
"hashtags" => [
296+
{
297+
"len" => 7,
298+
"name" => "joinus",
299+
"pos" => 167
300+
}
301+
],
302+
"links" => [
303+
{
304+
"len" => 12,
305+
"pos" => 0,
306+
"text" => "join.app.net",
307+
"url" => "http://join.app.net"
308+
}
309+
],
310+
"mentions" => [
311+
{
312+
"id" => "1",
313+
"len" => 7,
314+
"name" => "dalton",
315+
"pos" => 44
316+
},
317+
{
318+
"id" => "2",
319+
"len" => 5,
320+
"name" => "berg",
321+
"pos" => 52
322+
},
323+
{
324+
"id" => "3",
325+
"len" => 10,
326+
"name" => "voidfiles",
327+
"pos" => 58
328+
},
329+
{
330+
"id" => "4",
331+
"len" => 9,
332+
"name" => "jhubball",
333+
"pos" => 69
334+
},
335+
{
336+
"id" => "5",
337+
"len" => 11,
338+
"name" => "aaronblyth",
339+
"pos" => 79
340+
},
341+
{
342+
"id" => "6",
343+
"len" => 7,
344+
"name" => "andrew",
345+
"pos" => 91
346+
},
347+
{
348+
"id" => "7",
349+
"len" => 9,
350+
"name" => "vinitlee",
351+
"pos" => 99
352+
},
353+
{
354+
"id" => "9",
355+
"len" => 5,
356+
"name" => "mark",
357+
"pos" => 109
358+
},
359+
{
360+
"id" => "10",
361+
"len" => 6,
362+
"name" => "mintz",
363+
"pos" => 115
364+
},
365+
{
366+
"id" => "11",
367+
"len" => 11,
368+
"name" => "barmstrong",
369+
"pos" => 122
370+
},
371+
{
372+
"id" => "12",
373+
"len" => 12,
374+
"name" => "laughingman",
375+
"pos" => 134
376+
},
377+
{
378+
"id" => "13",
379+
"len" => 14,
380+
"name" => "mikegreenspan",
381+
"pos" => 147
382+
},
383+
{
384+
"id" => "14",
385+
"len" => 4,
386+
"name" => "ben",
387+
"pos" => 162
388+
}
389+
]
306390
},
391+
"html" => "<span itemscope=\"https://app.net/schemas/Post\"><a href=\"http://join.app.net\">join.app.net</a> getting ready for the world w/ <span data-mention-id=\"1\" data-mention-name=\"dalton\" itemprop=\"mention\">@dalton</span> <span data-mention-id=\"2\" data-mention-name=\"berg\" itemprop=\"mention\">@berg</span> <span data-mention-id=\"3\" data-mention-name=\"voidfiles\" itemprop=\"mention\">@voidfiles</span> <span data-mention-id=\"4\" data-mention-name=\"jhubball\" itemprop=\"mention\">@jhubball</span> <span data-mention-id=\"5\" data-mention-name=\"aaronblyth\" itemprop=\"mention\">@aaronblyth</span> <span data-mention-id=\"6\" data-mention-name=\"andrew\" itemprop=\"mention\">@andrew</span> <span data-mention-id=\"7\" data-mention-name=\"vinitlee\" itemprop=\"mention\">@vinitlee</span> <span data-mention-id=\"9\" data-mention-name=\"mark\" itemprop=\"mention\">@mark</span> <span data-mention-id=\"10\" data-mention-name=\"mintz\" itemprop=\"mention\">@mintz</span> <span data-mention-id=\"11\" data-mention-name=\"barmstrong\" itemprop=\"mention\">@barmstrong</span> <span data-mention-id=\"12\" data-mention-name=\"laughingman\" itemprop=\"mention\">@laughingman</span> <span data-mention-id=\"13\" data-mention-name=\"mikegreenspan\" itemprop=\"mention\">@mikegreenspan</span> <span data-mention-id=\"14\" data-mention-name=\"ben\" itemprop=\"mention\">@ben</span> <span data-hashtag-name=\"joinus\" itemprop=\"hashtag\">#joinus</span></span>",
392+
"id" => "1",
307393
"machine_only" => false,
394+
"num_replies" => 11,
395+
"num_reposts" => 5,
396+
"num_stars" => 53,
308397
"reply_to" => nil,
309-
"thread_id" => "1",
310-
"canonical_url" => "https://alpha.app.net/mthurman/post/1",
311-
"num_replies" => 0,
312-
"num_reposts" => 0,
313-
"num_stars" => 0,
314-
"entities" => {
315-
"mentions" => [{
316-
"name" => "berg",
317-
"id" => "2",
318-
"pos" => 0,
319-
"len" => 5
320-
}],
321-
"hashtags" => [{
322-
"name" => "newsocialnetwork",
323-
"pos" => 34,
324-
"len" => 17
325-
}],
326-
"links" => [{
327-
"text" => "this new site",
328-
"url" => "https://join.app.net",
329-
"pos" => 20,
330-
"len" => 13
331-
}]
398+
"source" => {
399+
"client_id" => "caYWDBvjwt2e9HWMm6qyKS6KcATHUkzQ",
400+
"link" => "https://alpha.app.net",
401+
"name" => "Alpha"
332402
},
403+
"text" => "join.app.net getting ready for the world w/ @dalton @berg @voidfiles @jhubball @aaronblyth @andrew @vinitlee @mark @mintz @barmstrong @laughingman @mikegreenspan @ben #joinus",
404+
"thread_id" => "1",
405+
"user" => "...user object...",
333406
"you_reposted" => false,
334-
"you_starred" => false,
407+
"you_starred" => false
335408
}
336409

337410
FULL_POST = POST.merge({
@@ -353,34 +426,41 @@ def paginated_response(key, &block)
353426
# since posts have text, html, entities, instead of always having to override in the block, provide more options here if we care
354427
# about what the text is
355428

356-
# No user defined link here
357-
FIRST_POST = POST.merge({
358-
"html" => "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"mention\" data-mention-name=\"berg\" data-mention-id=\"2\">@berg</span> FIRST post on this new site <span itemprop=\"hashtag\" data-hashtag-name=\"newsocialnetwork\">#newsocialnetwork</span>.</span>",
359-
"entities" => POST["entities"].merge({
360-
"links" => []
361-
})
362-
})
363-
364429
# A reply to POST
365430
POST_REPLY = POST.merge({
431+
"canonical_url" => "https://alpha.app.net/voidfiles/post/2",
432+
"created_at" => "2012-08-03T04:00:20Z",
433+
"entities" => {
434+
"hashtags" => [],
435+
"links" => [],
436+
"mentions" => [
437+
{
438+
"id" => "8",
439+
"is_leading" => true,
440+
"len" => 9,
441+
"name" => "mthurman",
442+
"pos" => 0
443+
}
444+
]
445+
},
446+
"html" => "<span itemscope=\"https://app.net/schemas/Post\"><span data-mention-id=\"8\" data-mention-name=\"mthurman\" itemprop=\"mention\">@mthurman</span> oh, I'm ready.</span>",
366447
"id" => "2",
367-
"canonical_url" => "https://alpha.app.net/berg/post/2",
448+
"machine_only" => false,
449+
"num_replies" => 0,
450+
"num_reposts" => 0,
451+
"num_stars" => 2,
368452
"reply_to" => "1",
453+
"source" => {
454+
"client_id" => "caYWDBvjwt2e9HWMm6qyKS6KcATHUkzQ",
455+
"link" => "https://alpha.app.net",
456+
"name" => "Alpha"
457+
},
458+
"text" => "@mthurman oh, I'm ready.",
369459
"thread_id" => "1",
370-
"text" => "@mthurman stop trolling",
371-
"html" => "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"mention\" data-mention-name=\"mthurman\" data-mention-id=\"1\">@mthurman</span> stop trolling</span>",
372-
"entities" => {
373-
"mentions" => [{
374-
"name" => "mthurman",
375-
"id" => "2",
376-
"pos" => 0,
377-
"len" => 9
378-
}],
379-
"hashtags" => [],
380-
"links" => []
381-
}
460+
"user" => "...user object...",
382461
})
383462

463+
# These aren't real posts anymore past this point
384464
# Building up to REPOST which is a repost of a REPOST_OF (which is just POST with fewer entities)
385465
REPOST_OF = POST.merge({
386466
"text" => "a really insightful post that must be shared with the world",

0 commit comments

Comments
 (0)