1package vocab 2 3import ( 4 "time" 5) 6 7const example1 = `{ 8 "@context": "https://www.w3.org/ns/activitystreams", 9 "type": "Object", 10 "id": "http://www.test.example/object/1", 11 "name": "A Simple, non-specific object" 12}` 13 14var example1Type = &Object{} 15 16func init() { 17 example1Type.AppendType("Object") 18 example1Type.SetId(MustParseURL("http://www.test.example/object/1")) 19 example1Type.AppendNameString("A Simple, non-specific object") 20} 21 22const example2 = `{ 23 "@context": "https://www.w3.org/ns/activitystreams", 24 "type": "Link", 25 "href": "http://example.org/abc", 26 "hreflang": "en", 27 "mediaType": "text/html", 28 "name": "An example link" 29}` 30 31var example2Type = &Link{} 32 33func init() { 34 href := MustParseURL("http://example.org/abc") 35 example2Type.AppendType("Link") 36 example2Type.SetHref(href) 37 example2Type.SetHreflang("en") 38 example2Type.SetMediaType("text/html") 39 example2Type.AppendNameString("An example link") 40} 41 42const example3 = `{ 43 "@context": "https://www.w3.org/ns/activitystreams", 44 "type": "Activity", 45 "summary": "Sally did something to a note", 46 "actor": { 47 "type": "Person", 48 "name": "Sally" 49 }, 50 "object": { 51 "type": "Note", 52 "name": "A Note" 53 } 54}` 55 56var example3Type = &Activity{} 57 58func init() { 59 actor := &Person{} 60 actor.AppendType("Person") 61 actor.AppendNameString("Sally") 62 object := &Note{} 63 object.AppendType("Note") 64 object.AppendNameString("A Note") 65 example3Type.AppendType("Activity") 66 example3Type.AppendSummaryString("Sally did something to a note") 67 example3Type.AppendActorObject(actor) 68 example3Type.AppendObject(object) 69} 70 71const example4 = `{ 72 "@context": "https://www.w3.org/ns/activitystreams", 73 "type": "Travel", 74 "summary": "Sally went to work", 75 "actor": { 76 "type": "Person", 77 "name": "Sally" 78 }, 79 "target": { 80 "type": "Place", 81 "name": "Work" 82 } 83}` 84 85var example4Type = &Travel{} 86 87func init() { 88 person := &Person{} 89 person.AppendType("Person") 90 person.AppendNameString("Sally") 91 place := &Place{} 92 place.AppendType("Place") 93 place.AppendNameString("Work") 94 example4Type.AppendType("Travel") 95 example4Type.AppendSummaryString("Sally went to work") 96 example4Type.AppendActorObject(person) 97 example4Type.AppendTargetObject(place) 98} 99 100const example5 = `{ 101 "@context": "https://www.w3.org/ns/activitystreams", 102 "summary": "Sally's notes", 103 "type": "Collection", 104 "totalItems": 2, 105 "items": [ 106 { 107 "type": "Note", 108 "name": "A Simple Note" 109 }, 110 { 111 "type": "Note", 112 "name": "Another Simple Note" 113 } 114 ] 115}` 116 117var example5Type = &Collection{} 118 119func init() { 120 note1 := &Note{} 121 note1.AppendType("Note") 122 note1.AppendNameString("A Simple Note") 123 note2 := &Note{} 124 note2.AppendType("Note") 125 note2.AppendNameString("Another Simple Note") 126 example5Type.AppendType("Collection") 127 example5Type.AppendSummaryString("Sally's notes") 128 example5Type.SetTotalItems(2) 129 example5Type.AppendItemsObject(note1) 130 example5Type.AppendItemsObject(note2) 131} 132 133const example6 = `{ 134 "@context": "https://www.w3.org/ns/activitystreams", 135 "summary": "Sally's notes", 136 "type": "OrderedCollection", 137 "totalItems": 2, 138 "orderedItems": [ 139 { 140 "type": "Note", 141 "name": "A Simple Note" 142 }, 143 { 144 "type": "Note", 145 "name": "Another Simple Note" 146 } 147 ] 148}` 149 150var example6Type = &OrderedCollection{} 151 152func init() { 153 note1 := &Note{} 154 note1.AppendType("Note") 155 note1.AppendNameString("A Simple Note") 156 note2 := &Note{} 157 note2.AppendType("Note") 158 note2.AppendNameString("Another Simple Note") 159 example6Type.AppendType("OrderedCollection") 160 example6Type.AppendSummaryString("Sally's notes") 161 example6Type.SetTotalItems(2) 162 example6Type.AppendOrderedItemsObject(note1) 163 example6Type.AppendOrderedItemsObject(note2) 164} 165 166const example7 = `{ 167 "@context": "https://www.w3.org/ns/activitystreams", 168 "summary": "Page 1 of Sally's notes", 169 "type": "CollectionPage", 170 "id": "http://example.org/foo?page=1", 171 "partOf": "http://example.org/foo", 172 "items": [ 173 { 174 "type": "Note", 175 "name": "A Simple Note" 176 }, 177 { 178 "type": "Note", 179 "name": "Another Simple Note" 180 } 181 ] 182}` 183 184var example7Type = &CollectionPage{} 185 186func init() { 187 note1 := &Note{} 188 note1.AppendType("Note") 189 note1.AppendNameString("A Simple Note") 190 note2 := &Note{} 191 note2.AppendType("Note") 192 note2.AppendNameString("Another Simple Note") 193 link := MustParseURL("http://example.org/foo") 194 example7Type.AppendType("CollectionPage") 195 example7Type.AppendSummaryString("Page 1 of Sally's notes") 196 example7Type.SetId(MustParseURL("http://example.org/foo?page=1")) 197 example7Type.SetPartOfIRI(link) 198 example7Type.AppendItemsObject(note1) 199 example7Type.AppendItemsObject(note2) 200} 201 202const example8 = `{ 203 "@context": "https://www.w3.org/ns/activitystreams", 204 "summary": "Page 1 of Sally's notes", 205 "type": "OrderedCollectionPage", 206 "id": "http://example.org/foo?page=1", 207 "partOf": "http://example.org/foo", 208 "orderedItems": [ 209 { 210 "type": "Note", 211 "name": "A Simple Note" 212 }, 213 { 214 "type": "Note", 215 "name": "Another Simple Note" 216 } 217 ] 218}` 219 220var example8Type = &OrderedCollectionPage{} 221 222func init() { 223 note1 := &Note{} 224 note1.AppendType("Note") 225 note1.AppendNameString("A Simple Note") 226 note2 := &Note{} 227 note2.AppendType("Note") 228 note2.AppendNameString("Another Simple Note") 229 link := MustParseURL("http://example.org/foo") 230 example8Type.AppendType("OrderedCollectionPage") 231 example8Type.AppendSummaryString("Page 1 of Sally's notes") 232 example8Type.SetId(MustParseURL("http://example.org/foo?page=1")) 233 example8Type.SetPartOfIRI(link) 234 example8Type.AppendOrderedItemsObject(note1) 235 example8Type.AppendOrderedItemsObject(note2) 236} 237 238const example9 = `{ 239 "@context": "https://www.w3.org/ns/activitystreams", 240 "summary": "Sally accepted an invitation to a party", 241 "type": "Accept", 242 "actor": { 243 "type": "Person", 244 "name": "Sally" 245 }, 246 "object": { 247 "type": "Invite", 248 "actor": "http://john.example.org", 249 "object": { 250 "type": "Event", 251 "name": "Going-Away Party for Jim" 252 } 253 } 254}` 255 256var example9Type = &Accept{} 257 258func init() { 259 person := &Person{} 260 person.AppendType("Person") 261 person.AppendNameString("Sally") 262 event := &Event{} 263 event.AppendType("Event") 264 event.AppendNameString("Going-Away Party for Jim") 265 link := MustParseURL("http://john.example.org") 266 invite := &Invite{} 267 invite.AppendType("Invite") 268 invite.AppendActorIRI(link) 269 invite.AppendObject(event) 270 example9Type.AppendType("Accept") 271 example9Type.AppendSummaryString("Sally accepted an invitation to a party") 272 example9Type.AppendActorObject(person) 273 example9Type.AppendObject(invite) 274} 275 276const example10 = `{ 277 "@context": "https://www.w3.org/ns/activitystreams", 278 "summary": "Sally accepted Joe into the club", 279 "type": "Accept", 280 "actor": { 281 "type": "Person", 282 "name": "Sally" 283 }, 284 "object": { 285 "type": "Person", 286 "name": "Joe" 287 }, 288 "target": { 289 "type": "Group", 290 "name": "The Club" 291 } 292}` 293 294var example10Type = &Accept{} 295 296func init() { 297 person := &Person{} 298 person.AppendType("Person") 299 person.AppendNameString("Sally") 300 object := &Person{} 301 object.AppendType("Person") 302 object.AppendNameString("Joe") 303 target := &Group{} 304 target.AppendType("Group") 305 target.AppendNameString("The Club") 306 example10Type.AppendType("Accept") 307 example10Type.AppendSummaryString("Sally accepted Joe into the club") 308 example10Type.AppendActorObject(person) 309 example10Type.AppendObject(object) 310 example10Type.AppendTargetObject(target) 311} 312 313const example11 = `{ 314 "@context": "https://www.w3.org/ns/activitystreams", 315 "summary": "Sally tentatively accepted an invitation to a party", 316 "type": "TentativeAccept", 317 "actor": { 318 "type": "Person", 319 "name": "Sally" 320 }, 321 "object": { 322 "type": "Invite", 323 "actor": "http://john.example.org", 324 "object": { 325 "type": "Event", 326 "name": "Going-Away Party for Jim" 327 } 328 } 329}` 330 331var example11Type = &TentativeAccept{} 332 333func init() { 334 person := &Person{} 335 person.AppendType("Person") 336 person.AppendNameString("Sally") 337 event := &Event{} 338 event.AppendType("Event") 339 event.AppendNameString("Going-Away Party for Jim") 340 link := MustParseURL("http://john.example.org") 341 invite := &Invite{} 342 invite.AppendType("Invite") 343 invite.AppendActorIRI(link) 344 invite.AppendObject(event) 345 example11Type.AppendType("TentativeAccept") 346 example11Type.AppendSummaryString("Sally tentatively accepted an invitation to a party") 347 example11Type.AppendActorObject(person) 348 example11Type.AppendObject(invite) 349} 350 351const example12 = `{ 352 "@context": "https://www.w3.org/ns/activitystreams", 353 "summary": "Sally added an object", 354 "type": "Add", 355 "actor": { 356 "type": "Person", 357 "name": "Sally" 358 }, 359 "object": "http://example.org/abc" 360}` 361 362var example12Type = &Add{} 363 364func init() { 365 person := &Person{} 366 person.AppendType("Person") 367 person.AppendNameString("Sally") 368 link := MustParseURL("http://example.org/abc") 369 example12Type.AppendType("Add") 370 example12Type.AppendSummaryString("Sally added an object") 371 example12Type.AppendActorObject(person) 372 example12Type.AppendObjectIRI(link) 373} 374 375const example13 = `{ 376 "@context": "https://www.w3.org/ns/activitystreams", 377 "summary": "Sally added a picture of her cat to her cat picture collection", 378 "type": "Add", 379 "actor": { 380 "type": "Person", 381 "name": "Sally" 382 }, 383 "object": { 384 "type": "Image", 385 "name": "A picture of my cat", 386 "url": "http://example.org/img/cat.png" 387 }, 388 "origin": { 389 "type": "Collection", 390 "name": "Camera Roll" 391 }, 392 "target": { 393 "type": "Collection", 394 "name": "My Cat Pictures" 395 } 396}` 397 398var example13Type = &Add{} 399 400func init() { 401 person := &Person{} 402 person.AppendType("Person") 403 person.AppendNameString("Sally") 404 link := MustParseURL("http://example.org/img/cat.png") 405 object := &Image{} 406 object.AppendType("Image") 407 object.AppendNameString("A picture of my cat") 408 object.AppendUrlAnyURI(link) 409 origin := &Collection{} 410 origin.AppendType("Collection") 411 origin.AppendNameString("Camera Roll") 412 target := &Collection{} 413 target.AppendType("Collection") 414 target.AppendNameString("My Cat Pictures") 415 example13Type.AppendType("Add") 416 example13Type.AppendSummaryString("Sally added a picture of her cat to her cat picture collection") 417 example13Type.AppendActorObject(person) 418 example13Type.AppendObject(object) 419 example13Type.AppendOriginObject(origin) 420 example13Type.AppendTargetObject(target) 421} 422 423const example14 = `{ 424 "@context": "https://www.w3.org/ns/activitystreams", 425 "summary": "Sally arrived at work", 426 "type": "Arrive", 427 "actor": { 428 "type": "Person", 429 "name": "Sally" 430 }, 431 "location": { 432 "type": "Place", 433 "name": "Work" 434 }, 435 "origin": { 436 "type": "Place", 437 "name": "Home" 438 } 439}` 440 441var example14Type = &Arrive{} 442 443func init() { 444 person := &Person{} 445 person.AppendType("Person") 446 person.AppendNameString("Sally") 447 location := &Place{} 448 location.AppendType("Place") 449 location.AppendNameString("Work") 450 origin := &Place{} 451 origin.AppendType("Place") 452 origin.AppendNameString("Home") 453 example14Type.AppendType("Arrive") 454 example14Type.AppendSummaryString("Sally arrived at work") 455 example14Type.AppendActorObject(person) 456 example14Type.AppendLocationObject(location) 457 example14Type.AppendOriginObject(origin) 458} 459 460const example15 = `{ 461 "@context": "https://www.w3.org/ns/activitystreams", 462 "summary": "Sally created a note", 463 "type": "Create", 464 "actor": { 465 "type": "Person", 466 "name": "Sally" 467 }, 468 "object": { 469 "type": "Note", 470 "name": "A Simple Note", 471 "content": "This is a simple note" 472 } 473}` 474 475var example15Type = &Create{} 476 477func init() { 478 actor := &Person{} 479 actor.AppendType("Person") 480 actor.AppendNameString("Sally") 481 object := &Note{} 482 object.AppendType("Note") 483 object.AppendNameString("A Simple Note") 484 object.AppendContentString("This is a simple note") 485 example15Type.AppendType("Create") 486 example15Type.AppendSummaryString("Sally created a note") 487 example15Type.AppendActorObject(actor) 488 example15Type.AppendObject(object) 489} 490 491const example16 = `{ 492 "@context": "https://www.w3.org/ns/activitystreams", 493 "summary": "Sally deleted a note", 494 "type": "Delete", 495 "actor": { 496 "type": "Person", 497 "name": "Sally" 498 }, 499 "object": "http://example.org/notes/1", 500 "origin": { 501 "type": "Collection", 502 "name": "Sally's Notes" 503 } 504}` 505 506var example16Type = &Delete{} 507 508func init() { 509 actor := &Person{} 510 actor.AppendType("Person") 511 actor.AppendNameString("Sally") 512 origin := &Collection{} 513 origin.AppendType("Collection") 514 origin.AppendNameString("Sally's Notes") 515 link := MustParseURL("http://example.org/notes/1") 516 example16Type.AppendType("Delete") 517 example16Type.AppendSummaryString("Sally deleted a note") 518 example16Type.AppendActorObject(actor) 519 example16Type.AppendObjectIRI(link) 520 example16Type.AppendOriginObject(origin) 521} 522 523const example17 = `{ 524 "@context": "https://www.w3.org/ns/activitystreams", 525 "summary": "Sally followed John", 526 "type": "Follow", 527 "actor": { 528 "type": "Person", 529 "name": "Sally" 530 }, 531 "object": { 532 "type": "Person", 533 "name": "John" 534 } 535}` 536 537var example17Type = &Follow{} 538 539func init() { 540 actor := &Person{} 541 actor.AppendType("Person") 542 actor.AppendNameString("Sally") 543 object := &Person{} 544 object.AppendType("Person") 545 object.AppendNameString("John") 546 example17Type.AppendType("Follow") 547 example17Type.AppendSummaryString("Sally followed John") 548 example17Type.AppendActorObject(actor) 549 example17Type.AppendObject(object) 550} 551 552const example18 = `{ 553 "@context": "https://www.w3.org/ns/activitystreams", 554 "summary": "Sally ignored a note", 555 "type": "Ignore", 556 "actor": { 557 "type": "Person", 558 "name": "Sally" 559 }, 560 "object": "http://example.org/notes/1" 561}` 562 563var example18Type = &Ignore{} 564 565func init() { 566 actor := &Person{} 567 actor.AppendType("Person") 568 actor.AppendNameString("Sally") 569 link := MustParseURL("http://example.org/notes/1") 570 example18Type.AppendType("Ignore") 571 example18Type.AppendSummaryString("Sally ignored a note") 572 example18Type.AppendActorObject(actor) 573 example18Type.AppendObjectIRI(link) 574} 575 576const example19 = `{ 577 "@context": "https://www.w3.org/ns/activitystreams", 578 "summary": "Sally joined a group", 579 "type": "Join", 580 "actor": { 581 "type": "Person", 582 "name": "Sally" 583 }, 584 "object": { 585 "type": "Group", 586 "name": "A Simple Group" 587 } 588}` 589 590var example19Type = &Join{} 591 592func init() { 593 actor := &Person{} 594 actor.AppendType("Person") 595 actor.AppendNameString("Sally") 596 object := &Group{} 597 object.AppendType("Group") 598 object.AppendNameString("A Simple Group") 599 example19Type.AppendType("Join") 600 example19Type.AppendSummaryString("Sally joined a group") 601 example19Type.AppendActorObject(actor) 602 example19Type.AppendObject(object) 603 604} 605 606const example20 = `{ 607 "@context": "https://www.w3.org/ns/activitystreams", 608 "summary": "Sally left work", 609 "type": "Leave", 610 "actor": { 611 "type": "Person", 612 "name": "Sally" 613 }, 614 "object": { 615 "type": "Place", 616 "name": "Work" 617 } 618}` 619 620var example20Type = &Leave{} 621 622func init() { 623 actor := &Person{} 624 actor.AppendType("Person") 625 actor.AppendNameString("Sally") 626 object := &Place{} 627 object.AppendType("Place") 628 object.AppendNameString("Work") 629 example20Type.AppendType("Leave") 630 example20Type.AppendSummaryString("Sally left work") 631 example20Type.AppendActorObject(actor) 632 example20Type.AppendObject(object) 633} 634 635const example21 = `{ 636 "@context": "https://www.w3.org/ns/activitystreams", 637 "summary": "Sally left a group", 638 "type": "Leave", 639 "actor": { 640 "type": "Person", 641 "name": "Sally" 642 }, 643 "object": { 644 "type": "Group", 645 "name": "A Simple Group" 646 } 647}` 648 649var example21Type = &Leave{} 650 651func init() { 652 actor := &Person{} 653 actor.AppendType("Person") 654 actor.AppendNameString("Sally") 655 object := &Group{} 656 object.AppendType("Group") 657 object.AppendNameString("A Simple Group") 658 example21Type.AppendType("Leave") 659 example21Type.AppendSummaryString("Sally left a group") 660 example21Type.AppendActorObject(actor) 661 example21Type.AppendObject(object) 662} 663 664const example22 = `{ 665 "@context": "https://www.w3.org/ns/activitystreams", 666 "summary": "Sally liked a note", 667 "type": "Like", 668 "actor": { 669 "type": "Person", 670 "name": "Sally" 671 }, 672 "object": "http://example.org/notes/1" 673}` 674 675var example22Type = &Like{} 676 677func init() { 678 actor := &Person{} 679 actor.AppendType("Person") 680 actor.AppendNameString("Sally") 681 link := MustParseURL("http://example.org/notes/1") 682 example22Type.AppendType("Like") 683 example22Type.AppendSummaryString("Sally liked a note") 684 example22Type.AppendActorObject(actor) 685 example22Type.AppendObjectIRI(link) 686} 687 688const example23 = `{ 689 "@context": "https://www.w3.org/ns/activitystreams", 690 "summary": "Sally offered 50% off to Lewis", 691 "type": "Offer", 692 "actor": { 693 "type": "Person", 694 "name": "Sally" 695 }, 696 "object": { 697 "type": "http://www.types.example/ProductOffer", 698 "name": "50% Off!" 699 }, 700 "target": { 701 "type": "Person", 702 "name": "Lewis" 703 } 704}` 705 706var example23Type = &Offer{} 707 708func init() { 709 actor := &Person{} 710 actor.AppendType("Person") 711 actor.AppendNameString("Sally") 712 object := make(map[string]interface{}) 713 object["type"] = "http://www.types.example/ProductOffer" 714 object["name"] = "50% Off!" 715 target := &Person{} 716 target.AppendType("Person") 717 target.AppendNameString("Lewis") 718 example23Type.AppendType("Offer") 719 example23Type.AppendSummaryString("Sally offered 50% off to Lewis") 720 example23Type.AppendActorObject(actor) 721 example23Type.SetUnknownObject(object) 722 example23Type.AppendTargetObject(target) 723} 724 725const example24 = `{ 726 "@context": "https://www.w3.org/ns/activitystreams", 727 "summary": "Sally invited John and Lisa to a party", 728 "type": "Invite", 729 "actor": { 730 "type": "Person", 731 "name": "Sally" 732 }, 733 "object": { 734 "type": "Event", 735 "name": "A Party" 736 }, 737 "target": [ 738 { 739 "type": "Person", 740 "name": "John" 741 }, 742 { 743 "type": "Person", 744 "name": "Lisa" 745 } 746 ] 747}` 748 749var example24Type = &Invite{} 750 751func init() { 752 actor := &Person{} 753 actor.AppendType("Person") 754 actor.AppendNameString("Sally") 755 object := &Event{} 756 object.AppendType("Event") 757 object.AppendNameString("A Party") 758 target1 := &Person{} 759 target1.AppendType("Person") 760 target1.AppendNameString("John") 761 target2 := &Person{} 762 target2.AppendType("Person") 763 target2.AppendNameString("Lisa") 764 example24Type.AppendType("Invite") 765 example24Type.AppendSummaryString("Sally invited John and Lisa to a party") 766 example24Type.AppendActorObject(actor) 767 example24Type.AppendObject(object) 768 example24Type.AppendTargetObject(target1) 769 example24Type.AppendTargetObject(target2) 770} 771 772const example25 = `{ 773 "@context": "https://www.w3.org/ns/activitystreams", 774 "summary": "Sally rejected an invitation to a party", 775 "type": "Reject", 776 "actor": { 777 "type": "Person", 778 "name": "Sally" 779 }, 780 "object": { 781 "type": "Invite", 782 "actor": "http://john.example.org", 783 "object": { 784 "type": "Event", 785 "name": "Going-Away Party for Jim" 786 } 787 } 788}` 789 790var example25Type = &Reject{} 791 792func init() { 793 actor := &Person{} 794 actor.AppendType("Person") 795 actor.AppendNameString("Sally") 796 link := MustParseURL("http://john.example.org") 797 inviteObject := &Event{} 798 inviteObject.AppendType("Event") 799 inviteObject.AppendNameString("Going-Away Party for Jim") 800 object := &Invite{} 801 object.AppendType("Invite") 802 object.AppendActorIRI(link) 803 object.AppendObject(inviteObject) 804 example25Type.AppendType("Reject") 805 example25Type.AppendSummaryString("Sally rejected an invitation to a party") 806 example25Type.AppendActorObject(actor) 807 example25Type.AppendObject(object) 808} 809 810const example26 = `{ 811 "@context": "https://www.w3.org/ns/activitystreams", 812 "summary": "Sally tentatively rejected an invitation to a party", 813 "type": "TentativeReject", 814 "actor": { 815 "type": "Person", 816 "name": "Sally" 817 }, 818 "object": { 819 "type": "Invite", 820 "actor": "http://john.example.org", 821 "object": { 822 "type": "Event", 823 "name": "Going-Away Party for Jim" 824 } 825 } 826}` 827 828var example26Type = &TentativeReject{} 829 830func init() { 831 actor := &Person{} 832 actor.AppendType("Person") 833 actor.AppendNameString("Sally") 834 link := MustParseURL("http://john.example.org") 835 inviteObject := &Event{} 836 inviteObject.AppendType("Event") 837 inviteObject.AppendNameString("Going-Away Party for Jim") 838 object := &Invite{} 839 object.AppendType("Invite") 840 object.AppendActorIRI(link) 841 object.AppendObject(inviteObject) 842 example26Type.AppendType("TentativeReject") 843 example26Type.AppendSummaryString("Sally tentatively rejected an invitation to a party") 844 example26Type.AppendActorObject(actor) 845 example26Type.AppendObject(object) 846} 847 848const example27 = `{ 849 "@context": "https://www.w3.org/ns/activitystreams", 850 "summary": "Sally removed a note from her notes folder", 851 "type": "Remove", 852 "actor": { 853 "type": "Person", 854 "name": "Sally" 855 }, 856 "object": "http://example.org/notes/1", 857 "target": { 858 "type": "Collection", 859 "name": "Notes Folder" 860 } 861}` 862 863var example27Type = &Remove{} 864 865func init() { 866 actor := &Person{} 867 actor.AppendType("Person") 868 actor.AppendNameString("Sally") 869 link := MustParseURL("http://example.org/notes/1") 870 target := &Collection{} 871 target.AppendType("Collection") 872 target.AppendNameString("Notes Folder") 873 example27Type.AppendType("Remove") 874 example27Type.AppendSummaryString("Sally removed a note from her notes folder") 875 example27Type.AppendActorObject(actor) 876 example27Type.AppendObjectIRI(link) 877 example27Type.AppendTargetObject(target) 878} 879 880const example28 = `{ 881 "@context": "https://www.w3.org/ns/activitystreams", 882 "summary": "The moderator removed Sally from a group", 883 "type": "Remove", 884 "actor": { 885 "type": "http://example.org/Role", 886 "name": "The Moderator" 887 }, 888 "object": { 889 "type": "Person", 890 "name": "Sally" 891 }, 892 "origin": { 893 "type": "Group", 894 "name": "A Simple Group" 895 } 896}` 897 898var example28Type = &Remove{} 899 900func init() { 901 actor := make(map[string]interface{}) 902 actor["type"] = "http://example.org/Role" 903 actor["name"] = "The Moderator" 904 object := &Person{} 905 object.AppendType("Person") 906 object.AppendNameString("Sally") 907 origin := &Group{} 908 origin.AppendType("Group") 909 origin.AppendNameString("A Simple Group") 910 example28Type.AppendType("Remove") 911 example28Type.AppendSummaryString("The moderator removed Sally from a group") 912 example28Type.SetUnknownActor(actor) 913 example28Type.AppendObject(object) 914 example28Type.AppendOriginObject(origin) 915} 916 917const example29 = `{ 918 "@context": "https://www.w3.org/ns/activitystreams", 919 "summary": "Sally retracted her offer to John", 920 "type": "Undo", 921 "actor": "http://sally.example.org", 922 "object": { 923 "type": "Offer", 924 "actor": "http://sally.example.org", 925 "object": "http://example.org/posts/1", 926 "target": "http://john.example.org" 927 } 928}` 929 930var example29Type = &Undo{} 931 932func init() { 933 link := MustParseURL("http://sally.example.org") 934 objectLink := MustParseURL("http://example.org/posts/1") 935 targetLink := MustParseURL("http://john.example.org") 936 object := &Offer{} 937 object.AppendType("Offer") 938 object.AppendActorIRI(link) 939 object.AppendObjectIRI(objectLink) 940 object.AppendTargetIRI(targetLink) 941 example29Type.AppendType("Undo") 942 example29Type.AppendSummaryString("Sally retracted her offer to John") 943 example29Type.AppendActorIRI(link) 944 example29Type.AppendObject(object) 945} 946 947const example30 = `{ 948 "@context": "https://www.w3.org/ns/activitystreams", 949 "summary": "Sally updated her note", 950 "type": "Update", 951 "actor": { 952 "type": "Person", 953 "name": "Sally" 954 }, 955 "object": "http://example.org/notes/1" 956}` 957 958var example30Type = &Update{} 959 960func init() { 961 actor := &Person{} 962 actor.AppendType("Person") 963 actor.AppendNameString("Sally") 964 link := MustParseURL("http://example.org/notes/1") 965 example30Type.AppendType("Update") 966 example30Type.AppendSummaryString("Sally updated her note") 967 example30Type.AppendActorObject(actor) 968 example30Type.AppendObjectIRI(link) 969} 970 971const example31 = `{ 972 "@context": "https://www.w3.org/ns/activitystreams", 973 "summary": "Sally read an article", 974 "type": "View", 975 "actor": { 976 "type": "Person", 977 "name": "Sally" 978 }, 979 "object": { 980 "type": "Article", 981 "name": "What You Should Know About Activity Streams" 982 } 983}` 984 985var example31Type = &View{} 986 987func init() { 988 actor := &Person{} 989 actor.AppendType("Person") 990 actor.AppendNameString("Sally") 991 object := &Article{} 992 object.AppendType("Article") 993 object.AppendNameString("What You Should Know About Activity Streams") 994 example31Type.AppendType("View") 995 example31Type.AppendSummaryString("Sally read an article") 996 example31Type.AppendActorObject(actor) 997 example31Type.AppendObject(object) 998} 999 1000const example32 = `{ 1001 "@context": "https://www.w3.org/ns/activitystreams", 1002 "summary": "Sally listened to a piece of music", 1003 "type": "Listen", 1004 "actor": { 1005 "type": "Person", 1006 "name": "Sally" 1007 }, 1008 "object": "http://example.org/music.mp3" 1009}` 1010 1011var example32Type = &Listen{} 1012 1013func init() { 1014 actor := &Person{} 1015 actor.AppendType("Person") 1016 actor.AppendNameString("Sally") 1017 link := MustParseURL("http://example.org/music.mp3") 1018 example32Type.AppendType("Listen") 1019 example32Type.AppendSummaryString("Sally listened to a piece of music") 1020 example32Type.AppendActorObject(actor) 1021 example32Type.AppendObjectIRI(link) 1022} 1023 1024const example33 = `{ 1025 "@context": "https://www.w3.org/ns/activitystreams", 1026 "summary": "Sally read a blog post", 1027 "type": "Read", 1028 "actor": { 1029 "type": "Person", 1030 "name": "Sally" 1031 }, 1032 "object": "http://example.org/posts/1" 1033}` 1034 1035var example33Type = &Read{} 1036 1037func init() { 1038 actor := &Person{} 1039 actor.AppendType("Person") 1040 actor.AppendNameString("Sally") 1041 link := MustParseURL("http://example.org/posts/1") 1042 example33Type.AppendType("Read") 1043 example33Type.AppendSummaryString("Sally read a blog post") 1044 example33Type.AppendActorObject(actor) 1045 example33Type.AppendObjectIRI(link) 1046} 1047 1048const example34 = `{ 1049 "@context": "https://www.w3.org/ns/activitystreams", 1050 "summary": "Sally moved a post from List A to List B", 1051 "type": "Move", 1052 "actor": { 1053 "type": "Person", 1054 "name": "Sally" 1055 }, 1056 "object": "http://example.org/posts/1", 1057 "target": { 1058 "type": "Collection", 1059 "name": "List B" 1060 }, 1061 "origin": { 1062 "type": "Collection", 1063 "name": "List A" 1064 } 1065}` 1066 1067var example34Type = &Move{} 1068 1069func init() { 1070 actor := &Person{} 1071 actor.AppendType("Person") 1072 actor.AppendNameString("Sally") 1073 link := MustParseURL("http://example.org/posts/1") 1074 target := &Collection{} 1075 target.AppendType("Collection") 1076 target.AppendNameString("List B") 1077 origin := &Collection{} 1078 origin.AppendType("Collection") 1079 origin.AppendNameString("List A") 1080 example34Type.AppendType("Move") 1081 example34Type.AppendSummaryString("Sally moved a post from List A to List B") 1082 example34Type.AppendActorObject(actor) 1083 example34Type.AppendObjectIRI(link) 1084 example34Type.AppendTargetObject(target) 1085 example34Type.AppendOriginObject(origin) 1086} 1087 1088const example35 = `{ 1089 "@context": "https://www.w3.org/ns/activitystreams", 1090 "summary": "Sally went home from work", 1091 "type": "Travel", 1092 "actor": { 1093 "type": "Person", 1094 "name": "Sally" 1095 }, 1096 "target": { 1097 "type": "Place", 1098 "name": "Home" 1099 }, 1100 "origin": { 1101 "type": "Place", 1102 "name": "Work" 1103 } 1104}` 1105 1106var example35Type = &Travel{} 1107 1108func init() { 1109 actor := &Person{} 1110 actor.AppendType("Person") 1111 actor.AppendNameString("Sally") 1112 target := &Place{} 1113 target.AppendType("Place") 1114 target.AppendNameString("Home") 1115 origin := &Place{} 1116 origin.AppendType("Place") 1117 origin.AppendNameString("Work") 1118 example35Type.AppendType("Travel") 1119 example35Type.AppendSummaryString("Sally went home from work") 1120 example35Type.AppendActorObject(actor) 1121 example35Type.AppendTargetObject(target) 1122 example35Type.AppendOriginObject(origin) 1123} 1124 1125const example36 = `{ 1126 "@context": "https://www.w3.org/ns/activitystreams", 1127 "summary": "Sally announced that she had arrived at work", 1128 "type": "Announce", 1129 "actor": { 1130 "type": "Person", 1131 "id": "http://sally.example.org", 1132 "name": "Sally" 1133 }, 1134 "object": { 1135 "type": "Arrive", 1136 "actor": "http://sally.example.org", 1137 "location": { 1138 "type": "Place", 1139 "name": "Work" 1140 } 1141 } 1142}` 1143 1144var example36Type = &Announce{} 1145 1146func init() { 1147 link := MustParseURL("http://sally.example.org") 1148 actor := &Person{} 1149 actor.AppendType("Person") 1150 actor.AppendNameString("Sally") 1151 actor.SetId(link) 1152 loc := &Place{} 1153 loc.AppendType("Place") 1154 loc.AppendNameString("Work") 1155 object := &Arrive{} 1156 object.AppendType("Arrive") 1157 object.AppendActorIRI(link) 1158 object.AppendLocationObject(loc) 1159 example36Type.AppendType("Announce") 1160 example36Type.AppendSummaryString("Sally announced that she had arrived at work") 1161 example36Type.AppendActorObject(actor) 1162 example36Type.AppendObject(object) 1163} 1164 1165const example37 = `{ 1166 "@context": "https://www.w3.org/ns/activitystreams", 1167 "summary": "Sally blocked Joe", 1168 "type": "Block", 1169 "actor": "http://sally.example.org", 1170 "object": "http://joe.example.org" 1171}` 1172 1173var example37Type = &Block{} 1174 1175func init() { 1176 link := MustParseURL("http://sally.example.org") 1177 objLink := MustParseURL("http://joe.example.org") 1178 example37Type.AppendType("Block") 1179 example37Type.AppendSummaryString("Sally blocked Joe") 1180 example37Type.AppendActorIRI(link) 1181 example37Type.AppendObjectIRI(objLink) 1182} 1183 1184const example38 = `{ 1185 "@context": "https://www.w3.org/ns/activitystreams", 1186 "summary": "Sally flagged an inappropriate note", 1187 "type": "Flag", 1188 "actor": "http://sally.example.org", 1189 "object": { 1190 "type": "Note", 1191 "content": "An inappropriate note" 1192 } 1193}` 1194 1195var example38Type = &Flag{} 1196 1197func init() { 1198 link := MustParseURL("http://sally.example.org") 1199 object := &Note{} 1200 object.AppendType("Note") 1201 object.AppendContentString("An inappropriate note") 1202 example38Type.AppendType("Flag") 1203 example38Type.AppendSummaryString("Sally flagged an inappropriate note") 1204 example38Type.AppendActorIRI(link) 1205 example38Type.AppendObject(object) 1206} 1207 1208const example39 = `{ 1209 "@context": "https://www.w3.org/ns/activitystreams", 1210 "summary": "Sally disliked a post", 1211 "type": "Dislike", 1212 "actor": "http://sally.example.org", 1213 "object": "http://example.org/posts/1" 1214}` 1215 1216var example39Type = &Dislike{} 1217 1218func init() { 1219 link := MustParseURL("http://sally.example.org") 1220 objLink := MustParseURL("http://example.org/posts/1") 1221 example39Type.AppendType("Dislike") 1222 example39Type.AppendSummaryString("Sally disliked a post") 1223 example39Type.AppendActorIRI(link) 1224 example39Type.AppendObjectIRI(objLink) 1225} 1226 1227const example40 = `{ 1228 "@context": "https://www.w3.org/ns/activitystreams", 1229 "type": "Question", 1230 "name": "What is the answer?", 1231 "oneOf": [ 1232 { 1233 "type": "Note", 1234 "name": "Option A" 1235 }, 1236 { 1237 "type": "Note", 1238 "name": "Option B" 1239 } 1240 ] 1241}` 1242 1243var example40Type = &Question{} 1244 1245func init() { 1246 note1 := &Note{} 1247 note1.AppendType("Note") 1248 note1.AppendNameString("Option A") 1249 note2 := &Note{} 1250 note2.AppendType("Note") 1251 note2.AppendNameString("Option B") 1252 example40Type.AppendType("Question") 1253 example40Type.AppendNameString("What is the answer?") 1254 example40Type.AppendOneOfObject(note1) 1255 example40Type.AppendOneOfObject(note2) 1256} 1257 1258const example41 = `{ 1259 "@context": "https://www.w3.org/ns/activitystreams", 1260 "type": "Question", 1261 "name": "What is the answer?", 1262 "closed": "2016-05-10T00:00:00Z" 1263}` 1264 1265var example41Type = &Question{} 1266 1267func init() { 1268 t, err := time.Parse(time.RFC3339, "2016-05-10T00:00:00Z") 1269 if err != nil { 1270 panic(err) 1271 } 1272 example41Type.AppendType("Question") 1273 example41Type.AppendNameString("What is the answer?") 1274 example41Type.AppendClosedDateTime(t) 1275} 1276 1277const example42 = `{ 1278 "@context": "https://www.w3.org/ns/activitystreams", 1279 "type": "Application", 1280 "name": "Exampletron 3000" 1281}` 1282 1283var example42Type = &Application{} 1284 1285func init() { 1286 example42Type.AppendType("Application") 1287 example42Type.AppendNameString("Exampletron 3000") 1288} 1289 1290const example43 = `{ 1291 "@context": "https://www.w3.org/ns/activitystreams", 1292 "type": "Group", 1293 "name": "Big Beards of Austin" 1294}` 1295 1296var example43Type = &Group{} 1297 1298func init() { 1299 example43Type.AppendType("Group") 1300 example43Type.AppendNameString("Big Beards of Austin") 1301} 1302 1303const example44 = `{ 1304 "@context": "https://www.w3.org/ns/activitystreams", 1305 "type": "Organization", 1306 "name": "Example Co." 1307}` 1308 1309var example44Type = &Organization{} 1310 1311func init() { 1312 example44Type.AppendType("Organization") 1313 example44Type.AppendNameString("Example Co.") 1314} 1315 1316const example45 = `{ 1317 "@context": "https://www.w3.org/ns/activitystreams", 1318 "type": "Person", 1319 "name": "Sally Smith" 1320}` 1321 1322var example45Type = &Person{} 1323 1324func init() { 1325 example45Type.AppendType("Person") 1326 example45Type.AppendNameString("Sally Smith") 1327} 1328 1329const example46 = `{ 1330 "@context": "https://www.w3.org/ns/activitystreams", 1331 "type": "Service", 1332 "name": "Acme Web Service" 1333}` 1334 1335var example46Type = &Service{} 1336 1337func init() { 1338 example46Type.AppendType("Service") 1339 example46Type.AppendNameString("Acme Web Service") 1340} 1341 1342const example47 = `{ 1343 "@context": "https://www.w3.org/ns/activitystreams", 1344 "summary": "Sally is an acquaintance of John", 1345 "type": "Relationship", 1346 "subject": { 1347 "type": "Person", 1348 "name": "Sally" 1349 }, 1350 "relationship": "http://purl.org/vocab/relationship/acquaintanceOf", 1351 "object": { 1352 "type": "Person", 1353 "name": "John" 1354 } 1355}` 1356 1357var example47Type = &Relationship{} 1358 1359func init() { 1360 subject := &Person{} 1361 subject.AppendType("Person") 1362 subject.AppendNameString("Sally") 1363 object := &Person{} 1364 object.AppendType("Person") 1365 object.AppendNameString("John") 1366 rel := MustParseURL("http://purl.org/vocab/relationship/acquaintanceOf") 1367 example47Type.AppendType("Relationship") 1368 example47Type.AppendSummaryString("Sally is an acquaintance of John") 1369 example47Type.SetSubjectObject(subject) 1370 example47Type.AppendObject(object) 1371 example47Type.SetRelationshipIRI(rel) 1372} 1373 1374const example48 = `{ 1375 "@context": "https://www.w3.org/ns/activitystreams", 1376 "type": "Article", 1377 "name": "What a Crazy Day I Had", 1378 "content": "<div>... you will never believe ...</div>", 1379 "attributedTo": "http://sally.example.org" 1380}` 1381 1382var example48Type = &Article{} 1383 1384func init() { 1385 att := MustParseURL("http://sally.example.org") 1386 example48Type.AppendType("Article") 1387 example48Type.AppendNameString("What a Crazy Day I Had") 1388 example48Type.AppendAttributedToIRI(att) 1389 example48Type.AppendContentString("<div>... you will never believe ...</div>") 1390} 1391 1392const example49 = `{ 1393 "@context": "https://www.w3.org/ns/activitystreams", 1394 "type": "Document", 1395 "name": "4Q Sales Forecast", 1396 "url": "http://example.org/4q-sales-forecast.pdf" 1397}` 1398 1399var example49Type = &Document{} 1400 1401func init() { 1402 l := MustParseURL("http://example.org/4q-sales-forecast.pdf") 1403 example49Type.AppendType("Document") 1404 example49Type.AppendNameString("4Q Sales Forecast") 1405 example49Type.AppendUrlAnyURI(l) 1406} 1407 1408const example50 = `{ 1409 "@context": "https://www.w3.org/ns/activitystreams", 1410 "type": "Audio", 1411 "name": "Interview With A Famous Technologist", 1412 "url": { 1413 "type": "Link", 1414 "href": "http://example.org/podcast.mp3", 1415 "mediaType": "audio/mp3" 1416 } 1417}` 1418 1419var example50Type = &Audio{} 1420 1421func init() { 1422 l := MustParseURL("http://example.org/podcast.mp3") 1423 link := &Link{} 1424 link.AppendType("Link") 1425 link.SetHref(l) 1426 link.SetMediaType("audio/mp3") 1427 example50Type.AppendType("Audio") 1428 example50Type.AppendNameString("Interview With A Famous Technologist") 1429 example50Type.AppendUrlLink(link) 1430} 1431 1432const example51 = `{ 1433 "@context": "https://www.w3.org/ns/activitystreams", 1434 "type": "Image", 1435 "name": "Cat Jumping on Wagon", 1436 "url": [ 1437 { 1438 "type": "Link", 1439 "href": "http://example.org/image.jpeg", 1440 "mediaType": "image/jpeg" 1441 }, 1442 { 1443 "type": "Link", 1444 "href": "http://example.org/image.png", 1445 "mediaType": "image/png" 1446 } 1447 ] 1448}` 1449 1450var example51Type = &Image{} 1451 1452func init() { 1453 l1 := MustParseURL("http://example.org/image.jpeg") 1454 l2 := MustParseURL("http://example.org/image.png") 1455 link1 := &Link{} 1456 link1.AppendType("Link") 1457 link1.SetHref(l1) 1458 link1.SetMediaType("image/jpeg") 1459 link2 := &Link{} 1460 link2.AppendType("Link") 1461 link2.SetHref(l2) 1462 link2.SetMediaType("image/png") 1463 example51Type.AppendType("Image") 1464 example51Type.AppendNameString("Cat Jumping on Wagon") 1465 example51Type.AppendUrlLink(link1) 1466 example51Type.AppendUrlLink(link2) 1467} 1468 1469const example52 = `{ 1470 "@context": "https://www.w3.org/ns/activitystreams", 1471 "type": "Video", 1472 "name": "Puppy Plays With Ball", 1473 "url": "http://example.org/video.mkv", 1474 "duration": "PT2H" 1475}` 1476 1477var example52Type = &Video{} 1478 1479func init() { 1480 l := MustParseURL("http://example.org/video.mkv") 1481 example52Type.AppendType("Video") 1482 example52Type.AppendNameString("Puppy Plays With Ball") 1483 example52Type.AppendUrlAnyURI(l) 1484 example52Type.SetDuration(time.Hour * 2) 1485} 1486 1487const example53 = `{ 1488 "@context": "https://www.w3.org/ns/activitystreams", 1489 "type": "Note", 1490 "name": "A Word of Warning", 1491 "content": "Looks like it is going to rain today. Bring an umbrella!" 1492}` 1493 1494var example53Type = &Note{} 1495 1496func init() { 1497 example53Type.AppendType("Note") 1498 example53Type.AppendNameString("A Word of Warning") 1499 example53Type.AppendContentString("Looks like it is going to rain today. Bring an umbrella!") 1500} 1501 1502const example54 = `{ 1503 "@context": "https://www.w3.org/ns/activitystreams", 1504 "type": "Page", 1505 "name": "Omaha Weather Report", 1506 "url": "http://example.org/weather-in-omaha.html" 1507}` 1508 1509var example54Type = &Page{} 1510 1511func init() { 1512 l := MustParseURL("http://example.org/weather-in-omaha.html") 1513 example54Type.AppendType("Page") 1514 example54Type.AppendNameString("Omaha Weather Report") 1515 example54Type.AppendUrlAnyURI(l) 1516} 1517 1518const example55 = `{ 1519 "@context": "https://www.w3.org/ns/activitystreams", 1520 "type": "Event", 1521 "name": "Going-Away Party for Jim", 1522 "startTime": "2014-12-31T23:00:00-08:00", 1523 "endTime": "2015-01-01T06:00:00-08:00" 1524}` 1525 1526var example55Type = &Event{} 1527 1528func init() { 1529 t1, err := time.Parse(time.RFC3339, "2014-12-31T23:00:00-08:00") 1530 if err != nil { 1531 panic(err) 1532 } 1533 t2, err := time.Parse(time.RFC3339, "2015-01-01T06:00:00-08:00") 1534 if err != nil { 1535 panic(err) 1536 } 1537 example55Type.AppendType("Event") 1538 example55Type.AppendNameString("Going-Away Party for Jim") 1539 example55Type.SetStartTime(t1) 1540 example55Type.SetEndTime(t2) 1541} 1542 1543const example56 = `{ 1544 "@context": "https://www.w3.org/ns/activitystreams", 1545 "type": "Place", 1546 "name": "Work" 1547}` 1548 1549var example56Type = &Place{} 1550 1551func init() { 1552 example56Type.AppendType("Place") 1553 example56Type.AppendNameString("Work") 1554} 1555 1556const example57 = `{ 1557 "@context": "https://www.w3.org/ns/activitystreams", 1558 "type": "Place", 1559 "name": "Fresno Area", 1560 "latitude": 36.75, 1561 "longitude": 119.7667, 1562 "radius": 15, 1563 "units": "miles" 1564}` 1565 1566var example57Type = &Place{} 1567 1568func init() { 1569 example57Type.AppendType("Place") 1570 example57Type.AppendNameString("Fresno Area") 1571 example57Type.SetLatitude(36.75) 1572 example57Type.SetLongitude(119.7667) 1573 example57Type.SetRadius(15) 1574 example57Type.SetUnitsUnitsValue("miles") 1575} 1576 1577const example58 = `{ 1578 "@context": "https://www.w3.org/ns/activitystreams", 1579 "summary": "Mention of Joe by Carrie in her note", 1580 "type": "Mention", 1581 "href": "http://example.org/joe", 1582 "name": "Joe" 1583}` 1584 1585var example58Type = &Mention{} 1586 1587func init() { 1588 l := MustParseURL("http://example.org/joe") 1589 example58Type.AppendType("Mention") 1590 example58Type.AppendSummaryString("Mention of Joe by Carrie in her note") 1591 example58Type.SetHref(l) 1592 example58Type.AppendNameString("Joe") 1593} 1594 1595const example59 = `{ 1596 "@context": "https://www.w3.org/ns/activitystreams", 1597 "type": "Profile", 1598 "summary": "Sally's Profile", 1599 "describes": { 1600 "type": "Person", 1601 "name": "Sally Smith" 1602 } 1603}` 1604 1605var example59Type = &Profile{} 1606 1607func init() { 1608 person := &Person{} 1609 person.AppendType("Person") 1610 person.AppendNameString("Sally Smith") 1611 example59Type.AppendType("Profile") 1612 example59Type.AppendSummaryString("Sally's Profile") 1613 example59Type.SetDescribes(person) 1614} 1615 1616// Note that the @context is missing from the spec! 1617const example60 = `{ 1618 "@context": "https://www.w3.org/ns/activitystreams", 1619 "type": "OrderedCollection", 1620 "totalItems": 3, 1621 "name": "Vacation photos 2016", 1622 "orderedItems": [ 1623 { 1624 "type": "Image", 1625 "id": "http://image.example/1" 1626 }, 1627 { 1628 "type": "Tombstone", 1629 "formerType": "Image", 1630 "id": "http://image.example/2", 1631 "deleted": "2016-03-17T00:00:00Z" 1632 }, 1633 { 1634 "type": "Image", 1635 "id": "http://image.example/3" 1636 } 1637 ] 1638}` 1639 1640var example60Type = &OrderedCollection{} 1641 1642func init() { 1643 t, err := time.Parse(time.RFC3339, "2016-03-17T00:00:00Z") 1644 if err != nil { 1645 panic(err) 1646 } 1647 image1 := &Image{} 1648 image1.AppendType("Image") 1649 image1.SetId(MustParseURL("http://image.example/1")) 1650 tombstone := &Tombstone{} 1651 tombstone.AppendType("Tombstone") 1652 tombstone.AppendFormerTypeString("Image") 1653 tombstone.SetId(MustParseURL("http://image.example/2")) 1654 tombstone.SetDeleted(t) 1655 image2 := &Image{} 1656 image2.AppendType("Image") 1657 image2.SetId(MustParseURL("http://image.example/3")) 1658 example60Type.AppendType("OrderedCollection") 1659 example60Type.SetTotalItems(3) 1660 example60Type.AppendNameString("Vacation photos 2016") 1661 example60Type.AppendOrderedItemsObject(image1) 1662 example60Type.AppendOrderedItemsObject(tombstone) 1663 example60Type.AppendOrderedItemsObject(image2) 1664} 1665 1666const example61 = `{ 1667 "@context": "https://www.w3.org/ns/activitystreams", 1668 "name": "Foo", 1669 "id": "http://example.org/foo" 1670}` 1671 1672var example61Type = &Unknown{} 1673 1674func init() { 1675 example61Type.SetField("id", "http://example.org/foo") 1676 example61Type.SetField("name", "Foo") 1677} 1678 1679const example62 = `{ 1680 "@context": "https://www.w3.org/ns/activitystreams", 1681 "summary": "A foo", 1682 "type": "http://example.org/Foo" 1683}` 1684 1685var example62Type = &Unknown{} 1686 1687func init() { 1688 example62Type.SetField("type", "http://example.org/Foo") 1689 example62Type.SetField("summary", "A foo") 1690} 1691 1692const example63 = `{ 1693 "@context": "https://www.w3.org/ns/activitystreams", 1694 "summary": "Sally offered the Foo object", 1695 "type": "Offer", 1696 "actor": "http://sally.example.org", 1697 "object": "http://example.org/foo" 1698}` 1699 1700var example63Type = &Offer{} 1701 1702func init() { 1703 l := MustParseURL("http://sally.example.org") 1704 o := MustParseURL("http://example.org/foo") 1705 example63Type.AppendType("Offer") 1706 example63Type.AppendSummaryString("Sally offered the Foo object") 1707 example63Type.AppendActorIRI(l) 1708 example63Type.AppendObjectIRI(o) 1709} 1710 1711const example64 = `{ 1712 "@context": "https://www.w3.org/ns/activitystreams", 1713 "summary": "Sally offered the Foo object", 1714 "type": "Offer", 1715 "actor": { 1716 "type": "Person", 1717 "id": "http://sally.example.org", 1718 "summary": "Sally" 1719 }, 1720 "object": "http://example.org/foo" 1721}` 1722 1723var example64Type = &Offer{} 1724 1725func init() { 1726 actor := &Person{} 1727 actor.AppendType("Person") 1728 actor.SetId(MustParseURL("http://sally.example.org")) 1729 actor.AppendSummaryString("Sally") 1730 o := MustParseURL("http://example.org/foo") 1731 example64Type.AppendType("Offer") 1732 example64Type.AppendSummaryString("Sally offered the Foo object") 1733 example64Type.AppendActorObject(actor) 1734 example64Type.AppendObjectIRI(o) 1735} 1736 1737const example65 = `{ 1738 "@context": "https://www.w3.org/ns/activitystreams", 1739 "summary": "Sally and Joe offered the Foo object", 1740 "type": "Offer", 1741 "actor": [ 1742 "http://joe.example.org", 1743 { 1744 "type": "Person", 1745 "id": "http://sally.example.org", 1746 "name": "Sally" 1747 } 1748 ], 1749 "object": "http://example.org/foo" 1750}` 1751 1752var example65Type = &Offer{} 1753 1754func init() { 1755 actor := &Person{} 1756 actor.AppendType("Person") 1757 actor.SetId(MustParseURL("http://sally.example.org")) 1758 actor.AppendNameString("Sally") 1759 o := MustParseURL("http://example.org/foo") 1760 l := MustParseURL("http://joe.example.org") 1761 example65Type.AppendType("Offer") 1762 example65Type.AppendSummaryString("Sally and Joe offered the Foo object") 1763 example65Type.AppendObjectIRI(o) 1764 example65Type.AppendActorIRI(l) 1765 example65Type.AppendActorObject(actor) 1766} 1767 1768// NOTE: Changed to not be an array value for "attachment" to keep in line with other examples in spec! 1769const example66 = `{ 1770 "@context": "https://www.w3.org/ns/activitystreams", 1771 "type": "Note", 1772 "name": "Have you seen my cat?", 1773 "attachment": { 1774 "type": "Image", 1775 "content": "This is what he looks like.", 1776 "url": "http://example.org/cat.jpeg" 1777 } 1778}` 1779 1780var example66Type = &Note{} 1781 1782func init() { 1783 l := MustParseURL("http://example.org/cat.jpeg") 1784 image := &Image{} 1785 image.AppendType("Image") 1786 image.AppendContentString("This is what he looks like.") 1787 image.AppendUrlAnyURI(l) 1788 example66Type.AppendType("Note") 1789 example66Type.AppendNameString("Have you seen my cat?") 1790 example66Type.AppendAttachmentObject(image) 1791} 1792 1793// NOTE: Changed to not be an array value for "attributedTo" to keep in line with other examples in spec! 1794const example67 = `{ 1795 "@context": "https://www.w3.org/ns/activitystreams", 1796 "type": "Image", 1797 "name": "My cat taking a nap", 1798 "url": "http://example.org/cat.jpeg", 1799 "attributedTo": { 1800 "type": "Person", 1801 "name": "Sally" 1802 } 1803}` 1804 1805var example67Type = &Image{} 1806 1807func init() { 1808 l := MustParseURL("http://example.org/cat.jpeg") 1809 person := &Person{} 1810 person.AppendType("Person") 1811 person.AppendNameString("Sally") 1812 example67Type.AppendType("Image") 1813 example67Type.AppendNameString("My cat taking a nap") 1814 example67Type.AppendUrlAnyURI(l) 1815 example67Type.AppendAttributedToObject(person) 1816} 1817 1818const example68 = `{ 1819 "@context": "https://www.w3.org/ns/activitystreams", 1820 "type": "Image", 1821 "name": "My cat taking a nap", 1822 "url": "http://example.org/cat.jpeg", 1823 "attributedTo": [ 1824 "http://joe.example.org", 1825 { 1826 "type": "Person", 1827 "name": "Sally" 1828 } 1829 ] 1830}` 1831 1832var example68Type = &Image{} 1833 1834func init() { 1835 l := MustParseURL("http://example.org/cat.jpeg") 1836 a := MustParseURL("http://joe.example.org") 1837 person := &Person{} 1838 person.AppendType("Person") 1839 person.AppendNameString("Sally") 1840 example68Type.AppendType("Image") 1841 example68Type.AppendNameString("My cat taking a nap") 1842 example68Type.AppendUrlAnyURI(l) 1843 example68Type.AppendAttributedToIRI(a) 1844 example68Type.AppendAttributedToObject(person) 1845} 1846 1847const example69 = `{ 1848 "@context": "https://www.w3.org/ns/activitystreams", 1849 "name": "Holiday announcement", 1850 "type": "Note", 1851 "content": "Thursday will be a company-wide holiday. Enjoy your day off!", 1852 "audience": { 1853 "type": "http://example.org/Organization", 1854 "name": "ExampleCo LLC" 1855 } 1856}` 1857 1858var example69Type = &Note{} 1859 1860func init() { 1861 audience := make(map[string]interface{}) 1862 audience["type"] = "http://example.org/Organization" 1863 audience["name"] = "ExampleCo LLC" 1864 example69Type.AppendType("Note") 1865 example69Type.AppendNameString("Holiday announcement") 1866 example69Type.AppendContentString("Thursday will be a company-wide holiday. Enjoy your day off!") 1867 example69Type.AddUnknown("audience", audience) 1868} 1869 1870// NOTE: Changed to not be an array value for "bcc" to keep in line with other examples in spec! 1871const example70 = `{ 1872 "@context": "https://www.w3.org/ns/activitystreams", 1873 "summary": "Sally offered a post to John", 1874 "type": "Offer", 1875 "actor": "http://sally.example.org", 1876 "object": "http://example.org/posts/1", 1877 "target": "http://john.example.org", 1878 "bcc": "http://joe.example.org" 1879}` 1880 1881var example70Type = &Offer{} 1882 1883func init() { 1884 o := MustParseURL("http://example.org/posts/1") 1885 a := MustParseURL("http://sally.example.org") 1886 t := MustParseURL("http://john.example.org") 1887 b := MustParseURL("http://joe.example.org") 1888 example70Type.AppendType("Offer") 1889 example70Type.AppendSummaryString("Sally offered a post to John") 1890 example70Type.AppendActorIRI(a) 1891 example70Type.AppendObjectIRI(o) 1892 example70Type.AppendTargetIRI(t) 1893 example70Type.AppendBccIRI(b) 1894} 1895 1896// NOTE: Changed to not be an array value for "bto" to keep in line with other examples in spec! 1897const example71 = `{ 1898 "@context": "https://www.w3.org/ns/activitystreams", 1899 "summary": "Sally offered a post to John", 1900 "type": "Offer", 1901 "actor": "http://sally.example.org", 1902 "object": "http://example.org/posts/1", 1903 "target": "http://john.example.org", 1904 "bto": "http://joe.example.org" 1905}` 1906 1907var example71Type = &Offer{} 1908 1909func init() { 1910 o := MustParseURL("http://example.org/posts/1") 1911 a := MustParseURL("http://sally.example.org") 1912 t := MustParseURL("http://john.example.org") 1913 b := MustParseURL("http://joe.example.org") 1914 example71Type.AppendType("Offer") 1915 example71Type.AppendSummaryString("Sally offered a post to John") 1916 example71Type.AppendActorIRI(a) 1917 example71Type.AppendObjectIRI(o) 1918 example71Type.AppendTargetIRI(t) 1919 example71Type.AppendBtoIRI(b) 1920} 1921 1922// NOTE: Changed to not be an array value for "cc" to keep in line with other examples in spec! 1923const example72 = `{ 1924 "@context": "https://www.w3.org/ns/activitystreams", 1925 "summary": "Sally offered a post to John", 1926 "type": "Offer", 1927 "actor": "http://sally.example.org", 1928 "object": "http://example.org/posts/1", 1929 "target": "http://john.example.org", 1930 "cc": "http://joe.example.org" 1931}` 1932 1933var example72Type = &Offer{} 1934 1935func init() { 1936 o := MustParseURL("http://example.org/posts/1") 1937 a := MustParseURL("http://sally.example.org") 1938 t := MustParseURL("http://john.example.org") 1939 b := MustParseURL("http://joe.example.org") 1940 example72Type.AppendType("Offer") 1941 example72Type.AppendSummaryString("Sally offered a post to John") 1942 example72Type.AppendActorIRI(a) 1943 example72Type.AppendObjectIRI(o) 1944 example72Type.AppendTargetIRI(t) 1945 example72Type.AppendCcIRI(b) 1946} 1947 1948const example73 = `{ 1949 "@context": "https://www.w3.org/ns/activitystreams", 1950 "summary": "Activities in context 1", 1951 "type": "Collection", 1952 "items": [ 1953 { 1954 "type": "Offer", 1955 "actor": "http://sally.example.org", 1956 "object": "http://example.org/posts/1", 1957 "target": "http://john.example.org", 1958 "context": "http://example.org/contexts/1" 1959 }, 1960 { 1961 "type": "Like", 1962 "actor": "http://joe.example.org", 1963 "object": "http://example.org/posts/2", 1964 "context": "http://example.org/contexts/1" 1965 } 1966 ] 1967}` 1968 1969var example73Type = &Collection{} 1970 1971func init() { 1972 oa := MustParseURL("http://sally.example.org") 1973 oo := MustParseURL("http://example.org/posts/1") 1974 ot := MustParseURL("http://john.example.org") 1975 oc := MustParseURL("http://example.org/contexts/1") 1976 offer := &Offer{} 1977 offer.AppendType("Offer") 1978 offer.AppendActorIRI(oa) 1979 offer.AppendObjectIRI(oo) 1980 offer.AppendTargetIRI(ot) 1981 offer.AppendContextIRI(oc) 1982 la := MustParseURL("http://joe.example.org") 1983 lo := MustParseURL("http://example.org/posts/2") 1984 lc := MustParseURL("http://example.org/contexts/1") 1985 like := &Like{} 1986 like.AppendType("Like") 1987 like.AppendActorIRI(la) 1988 like.AppendObjectIRI(lo) 1989 like.AppendContextIRI(lc) 1990 example73Type.AppendType("Collection") 1991 example73Type.AppendSummaryString("Activities in context 1") 1992 example73Type.AppendItemsObject(offer) 1993 example73Type.AppendItemsObject(like) 1994} 1995 1996const example74 = `{ 1997 "@context": "https://www.w3.org/ns/activitystreams", 1998 "summary": "Sally's blog posts", 1999 "type": "Collection", 2000 "totalItems": 3, 2001 "current": "http://example.org/collection", 2002 "items": [ 2003 "http://example.org/posts/1", 2004 "http://example.org/posts/2", 2005 "http://example.org/posts/3" 2006 ] 2007}` 2008 2009var example74Type = &Collection{} 2010 2011func init() { 2012 c := MustParseURL("http://example.org/collection") 2013 i1 := MustParseURL("http://example.org/posts/1") 2014 i2 := MustParseURL("http://example.org/posts/2") 2015 i3 := MustParseURL("http://example.org/posts/3") 2016 example74Type.AppendType("Collection") 2017 example74Type.SetTotalItems(3) 2018 example74Type.AppendSummaryString("Sally's blog posts") 2019 example74Type.SetCurrentIRI(c) 2020 example74Type.AppendItemsIRI(i1) 2021 example74Type.AppendItemsIRI(i2) 2022 example74Type.AppendItemsIRI(i3) 2023} 2024 2025const example75 = `{ 2026 "@context": "https://www.w3.org/ns/activitystreams", 2027 "summary": "Sally's blog posts", 2028 "type": "Collection", 2029 "totalItems": 3, 2030 "current": { 2031 "type": "Link", 2032 "summary": "Most Recent Items", 2033 "href": "http://example.org/collection" 2034 }, 2035 "items": [ 2036 "http://example.org/posts/1", 2037 "http://example.org/posts/2", 2038 "http://example.org/posts/3" 2039 ] 2040}` 2041 2042var example75Type = &Collection{} 2043 2044func init() { 2045 i1 := MustParseURL("http://example.org/posts/1") 2046 i2 := MustParseURL("http://example.org/posts/2") 2047 i3 := MustParseURL("http://example.org/posts/3") 2048 href := MustParseURL("http://example.org/collection") 2049 link := &Link{} 2050 link.AppendType("Link") 2051 link.AppendSummaryString("Most Recent Items") 2052 link.SetHref(href) 2053 example75Type.AppendType("Collection") 2054 example75Type.SetTotalItems(3) 2055 example75Type.AppendSummaryString("Sally's blog posts") 2056 example75Type.SetCurrentLink(link) 2057 example75Type.AppendItemsIRI(i1) 2058 example75Type.AppendItemsIRI(i2) 2059 example75Type.AppendItemsIRI(i3) 2060} 2061 2062const example76 = `{ 2063 "@context": "https://www.w3.org/ns/activitystreams", 2064 "summary": "Sally's blog posts", 2065 "type": "Collection", 2066 "totalItems": 3, 2067 "first": "http://example.org/collection?page=0" 2068}` 2069 2070var example76Type = &Collection{} 2071 2072func init() { 2073 f := MustParseURL("http://example.org/collection?page=0") 2074 example76Type.AppendType("Collection") 2075 example76Type.SetTotalItems(3) 2076 example76Type.AppendSummaryString("Sally's blog posts") 2077 example76Type.SetFirstIRI(f) 2078} 2079 2080const example77 = `{ 2081 "@context": "https://www.w3.org/ns/activitystreams", 2082 "summary": "Sally's blog posts", 2083 "type": "Collection", 2084 "totalItems": 3, 2085 "first": { 2086 "type": "Link", 2087 "summary": "First Page", 2088 "href": "http://example.org/collection?page=0" 2089 } 2090}` 2091 2092var example77Type = &Collection{} 2093 2094func init() { 2095 href := MustParseURL("http://example.org/collection?page=0") 2096 link := &Link{} 2097 link.AppendType("Link") 2098 link.AppendSummaryString("First Page") 2099 link.SetHref(href) 2100 example77Type.AppendType("Collection") 2101 example77Type.SetTotalItems(3) 2102 example77Type.AppendSummaryString("Sally's blog posts") 2103 example77Type.SetFirstLink(link) 2104} 2105 2106const example78 = `{ 2107 "@context": "https://www.w3.org/ns/activitystreams", 2108 "summary": "A simple note", 2109 "type": "Note", 2110 "content": "This is all there is.", 2111 "generator": { 2112 "type": "Application", 2113 "name": "Exampletron 3000" 2114 } 2115}` 2116 2117var example78Type = &Note{} 2118 2119func init() { 2120 app := &Application{} 2121 app.AppendType("Application") 2122 app.AppendNameString("Exampletron 3000") 2123 example78Type.AppendType("Note") 2124 example78Type.AppendSummaryString("A simple note") 2125 example78Type.AppendContentString("This is all there is.") 2126 example78Type.AppendGeneratorObject(app) 2127} 2128 2129const example79 = `{ 2130 "@context": "https://www.w3.org/ns/activitystreams", 2131 "summary": "A simple note", 2132 "type": "Note", 2133 "content": "This is all there is.", 2134 "icon": { 2135 "type": "Image", 2136 "name": "Note icon", 2137 "url": "http://example.org/note.png", 2138 "width": 16, 2139 "height": 16 2140 } 2141}` 2142 2143var example79Type = &Note{} 2144 2145func init() { 2146 u := MustParseURL("http://example.org/note.png") 2147 image := &Image{} 2148 image.AppendType("Image") 2149 image.AppendNameString("Note icon") 2150 image.AppendUrlAnyURI(u) 2151 image.SetWidth(16) 2152 image.SetHeight(16) 2153 example79Type.AppendType("Note") 2154 example79Type.AppendSummaryString("A simple note") 2155 example79Type.AppendContentString("This is all there is.") 2156 example79Type.AppendIconImage(image) 2157} 2158 2159const example80 = `{ 2160 "@context": "https://www.w3.org/ns/activitystreams", 2161 "summary": "A simple note", 2162 "type": "Note", 2163 "content": "A simple note", 2164 "icon": [ 2165 { 2166 "type": "Image", 2167 "summary": "Note (16x16)", 2168 "url": "http://example.org/note1.png", 2169 "width": 16, 2170 "height": 16 2171 }, 2172 { 2173 "type": "Image", 2174 "summary": "Note (32x32)", 2175 "url": "http://example.org/note2.png", 2176 "width": 32, 2177 "height": 32 2178 } 2179 ] 2180}` 2181 2182var example80Type = &Note{} 2183 2184func init() { 2185 u1 := MustParseURL("http://example.org/note1.png") 2186 u2 := MustParseURL("http://example.org/note2.png") 2187 image1 := &Image{} 2188 image1.AppendType("Image") 2189 image1.AppendSummaryString("Note (16x16)") 2190 image1.AppendUrlAnyURI(u1) 2191 image1.SetWidth(16) 2192 image1.SetHeight(16) 2193 image2 := &Image{} 2194 image2.AppendType("Image") 2195 image2.AppendSummaryString("Note (32x32)") 2196 image2.AppendUrlAnyURI(u2) 2197 image2.SetWidth(32) 2198 image2.SetHeight(32) 2199 example80Type.AppendType("Note") 2200 example80Type.AppendSummaryString("A simple note") 2201 example80Type.AppendContentString("A simple note") 2202 example80Type.AppendIconImage(image1) 2203 example80Type.AppendIconImage(image2) 2204} 2205 2206const example81 = `{ 2207 "@context": "https://www.w3.org/ns/activitystreams", 2208 "name": "A simple note", 2209 "type": "Note", 2210 "content": "This is all there is.", 2211 "image": { 2212 "type": "Image", 2213 "name": "A Cat", 2214 "url": "http://example.org/cat.png" 2215 } 2216}` 2217 2218var example81Type = &Note{} 2219 2220func init() { 2221 u := MustParseURL("http://example.org/cat.png") 2222 image := &Image{} 2223 image.AppendType("Image") 2224 image.AppendNameString("A Cat") 2225 image.AppendUrlAnyURI(u) 2226 example81Type.AppendType("Note") 2227 example81Type.AppendNameString("A simple note") 2228 example81Type.AppendContentString("This is all there is.") 2229 example81Type.AppendImageImage(image) 2230} 2231 2232const example82 = `{ 2233 "@context": "https://www.w3.org/ns/activitystreams", 2234 "name": "A simple note", 2235 "type": "Note", 2236 "content": "This is all there is.", 2237 "image": [ 2238 { 2239 "type": "Image", 2240 "name": "Cat 1", 2241 "url": "http://example.org/cat1.png" 2242 }, 2243 { 2244 "type": "Image", 2245 "name": "Cat 2", 2246 "url": "http://example.org/cat2.png" 2247 } 2248 ] 2249}` 2250 2251var example82Type = &Note{} 2252 2253func init() { 2254 u1 := MustParseURL("http://example.org/cat1.png") 2255 u2 := MustParseURL("http://example.org/cat2.png") 2256 image1 := &Image{} 2257 image1.AppendType("Image") 2258 image1.AppendNameString("Cat 1") 2259 image1.AppendUrlAnyURI(u1) 2260 image2 := &Image{} 2261 image2.AppendType("Image") 2262 image2.AppendNameString("Cat 2") 2263 image2.AppendUrlAnyURI(u2) 2264 example82Type.AppendType("Note") 2265 example82Type.AppendNameString("A simple note") 2266 example82Type.AppendContentString("This is all there is.") 2267 example82Type.AppendImageImage(image1) 2268 example82Type.AppendImageImage(image2) 2269} 2270 2271const example83 = `{ 2272 "@context": "https://www.w3.org/ns/activitystreams", 2273 "summary": "A simple note", 2274 "type": "Note", 2275 "content": "This is all there is.", 2276 "inReplyTo": { 2277 "summary": "Previous note", 2278 "type": "Note", 2279 "content": "What else is there?" 2280 } 2281}` 2282 2283var example83Type = &Note{} 2284 2285func init() { 2286 note := &Note{} 2287 note.AppendType("Note") 2288 note.AppendSummaryString("Previous note") 2289 note.AppendContentString("What else is there?") 2290 example83Type.AppendType("Note") 2291 example83Type.AppendSummaryString("A simple note") 2292 example83Type.AppendContentString("This is all there is.") 2293 example83Type.AppendInReplyToObject(note) 2294} 2295 2296const example84 = `{ 2297 "@context": "https://www.w3.org/ns/activitystreams", 2298 "summary": "A simple note", 2299 "type": "Note", 2300 "content": "This is all there is.", 2301 "inReplyTo": "http://example.org/posts/1" 2302}` 2303 2304var example84Type = &Note{} 2305 2306func init() { 2307 u := MustParseURL("http://example.org/posts/1") 2308 example84Type.AppendType("Note") 2309 example84Type.AppendSummaryString("A simple note") 2310 example84Type.AppendContentString("This is all there is.") 2311 example84Type.AppendInReplyToIRI(u) 2312} 2313 2314const example85 = `{ 2315 "@context": "https://www.w3.org/ns/activitystreams", 2316 "summary": "Sally listened to a piece of music on the Acme Music Service", 2317 "type": "Listen", 2318 "actor": { 2319 "type": "Person", 2320 "name": "Sally" 2321 }, 2322 "object": "http://example.org/foo.mp3", 2323 "instrument": { 2324 "type": "Service", 2325 "name": "Acme Music Service" 2326 } 2327}` 2328 2329var example85Type = &Listen{} 2330 2331func init() { 2332 u := MustParseURL("http://example.org/foo.mp3") 2333 actor := &Person{} 2334 actor.AppendType("Person") 2335 actor.AppendNameString("Sally") 2336 service := &Service{} 2337 service.AppendType("Service") 2338 service.AppendNameString("Acme Music Service") 2339 example85Type.AppendType("Listen") 2340 example85Type.AppendSummaryString("Sally listened to a piece of music on the Acme Music Service") 2341 example85Type.AppendActorObject(actor) 2342 example85Type.AppendObjectIRI(u) 2343 example85Type.AppendInstrumentObject(service) 2344} 2345 2346const example86 = `{ 2347 "@context": "https://www.w3.org/ns/activitystreams", 2348 "summary": "A collection", 2349 "type": "Collection", 2350 "totalItems": 3, 2351 "last": "http://example.org/collection?page=1" 2352}` 2353 2354var example86Type = &Collection{} 2355 2356func init() { 2357 u := MustParseURL("http://example.org/collection?page=1") 2358 example86Type.AppendType("Collection") 2359 example86Type.SetTotalItems(3) 2360 example86Type.AppendSummaryString("A collection") 2361 example86Type.SetLastIRI(u) 2362} 2363 2364const example87 = `{ 2365 "@context": "https://www.w3.org/ns/activitystreams", 2366 "summary": "A collection", 2367 "type": "Collection", 2368 "totalItems": 5, 2369 "last": { 2370 "type": "Link", 2371 "summary": "Last Page", 2372 "href": "http://example.org/collection?page=1" 2373 } 2374}` 2375 2376var example87Type = &Collection{} 2377 2378func init() { 2379 u := MustParseURL("http://example.org/collection?page=1") 2380 link := &Link{} 2381 link.AppendType("Link") 2382 link.AppendSummaryString("Last Page") 2383 link.SetHref(u) 2384 example87Type.AppendType("Collection") 2385 example87Type.AppendSummaryString("A collection") 2386 example87Type.SetTotalItems(5) 2387 example87Type.SetLastLink(link) 2388} 2389 2390const example88 = `{ 2391 "@context": "https://www.w3.org/ns/activitystreams", 2392 "type": "Person", 2393 "name": "Sally", 2394 "location": { 2395 "name": "Over the Arabian Sea, east of Socotra Island Nature Sanctuary", 2396 "type": "Place", 2397 "longitude": 12.34, 2398 "latitude": 56.78, 2399 "altitude": 90, 2400 "units": "m" 2401 } 2402}` 2403 2404var example88Type = &Person{} 2405 2406func init() { 2407 place := &Place{} 2408 place.AppendType("Place") 2409 place.AppendNameString("Over the Arabian Sea, east of Socotra Island Nature Sanctuary") 2410 place.SetLongitude(12.34) 2411 place.SetLatitude(56.78) 2412 place.SetAltitude(90) 2413 place.SetUnitsUnitsValue("m") 2414 example88Type.AppendType("Person") 2415 example88Type.AppendNameString("Sally") 2416 example88Type.AppendLocationObject(place) 2417} 2418 2419const example89 = `{ 2420 "@context": "https://www.w3.org/ns/activitystreams", 2421 "summary": "Sally's notes", 2422 "type": "Collection", 2423 "totalItems": 2, 2424 "items": [ 2425 { 2426 "type": "Note", 2427 "name": "Reminder for Going-Away Party" 2428 }, 2429 { 2430 "type": "Note", 2431 "name": "Meeting 2016-11-17" 2432 } 2433 ] 2434}` 2435 2436var example89Type = &Collection{} 2437 2438func init() { 2439 note1 := &Note{} 2440 note1.AppendType("Note") 2441 note1.AppendNameString("Reminder for Going-Away Party") 2442 note2 := &Note{} 2443 note2.AppendType("Note") 2444 note2.AppendNameString("Meeting 2016-11-17") 2445 example89Type.AppendType("Collection") 2446 example89Type.AppendSummaryString("Sally's notes") 2447 example89Type.SetTotalItems(2) 2448 example89Type.AppendItemsObject(note1) 2449 example89Type.AppendItemsObject(note2) 2450} 2451 2452const example90 = `{ 2453 "@context": "https://www.w3.org/ns/activitystreams", 2454 "summary": "Sally's notes", 2455 "type": "OrderedCollection", 2456 "totalItems": 2, 2457 "orderedItems": [ 2458 { 2459 "type": "Note", 2460 "name": "Meeting 2016-11-17" 2461 }, 2462 { 2463 "type": "Note", 2464 "name": "Reminder for Going-Away Party" 2465 } 2466 ] 2467}` 2468 2469var example90Type = &OrderedCollection{} 2470 2471func init() { 2472 note1 := &Note{} 2473 note1.AppendType("Note") 2474 note1.AppendNameString("Meeting 2016-11-17") 2475 note2 := &Note{} 2476 note2.AppendType("Note") 2477 note2.AppendNameString("Reminder for Going-Away Party") 2478 example90Type.AppendType("OrderedCollection") 2479 example90Type.AppendSummaryString("Sally's notes") 2480 example90Type.SetTotalItems(2) 2481 example90Type.AppendOrderedItemsObject(note1) 2482 example90Type.AppendOrderedItemsObject(note2) 2483} 2484 2485const example91 = `{ 2486 "@context": "https://www.w3.org/ns/activitystreams", 2487 "type": "Question", 2488 "name": "What is the answer?", 2489 "oneOf": [ 2490 { 2491 "type": "Note", 2492 "name": "Option A" 2493 }, 2494 { 2495 "type": "Note", 2496 "name": "Option B" 2497 } 2498 ] 2499}` 2500 2501var example91Type = &Question{} 2502 2503func init() { 2504 note1 := &Note{} 2505 note1.AppendType("Note") 2506 note1.AppendNameString("Option A") 2507 note2 := &Note{} 2508 note2.AppendType("Note") 2509 note2.AppendNameString("Option B") 2510 example91Type.AppendType("Question") 2511 example91Type.AppendNameString("What is the answer?") 2512 example91Type.AppendOneOfObject(note1) 2513 example91Type.AppendOneOfObject(note2) 2514} 2515 2516const example92 = `{ 2517 "@context": "https://www.w3.org/ns/activitystreams", 2518 "type": "Question", 2519 "name": "What is the answer?", 2520 "anyOf": [ 2521 { 2522 "type": "Note", 2523 "name": "Option A" 2524 }, 2525 { 2526 "type": "Note", 2527 "name": "Option B" 2528 } 2529 ] 2530}` 2531 2532var example92Type = &Question{} 2533 2534func init() { 2535 note1 := &Note{} 2536 note1.AppendType("Note") 2537 note1.AppendNameString("Option A") 2538 note2 := &Note{} 2539 note2.AppendType("Note") 2540 note2.AppendNameString("Option B") 2541 example92Type.AppendType("Question") 2542 example92Type.AppendNameString("What is the answer?") 2543 example92Type.AppendAnyOfObject(note1) 2544 example92Type.AppendAnyOfObject(note2) 2545} 2546 2547const example93 = `{ 2548 "@context": "https://www.w3.org/ns/activitystreams", 2549 "type": "Question", 2550 "name": "What is the answer?", 2551 "closed": "2016-05-10T00:00:00Z" 2552}` 2553 2554var example93Type = &Question{} 2555 2556func init() { 2557 t, err := time.Parse(time.RFC3339, "2016-05-10T00:00:00Z") 2558 if err != nil { 2559 panic(err) 2560 } 2561 example93Type.AppendType("Question") 2562 example93Type.AppendNameString("What is the answer?") 2563 example93Type.AppendClosedDateTime(t) 2564} 2565 2566const example94 = `{ 2567 "@context": "https://www.w3.org/ns/activitystreams", 2568 "summary": "Sally moved a post from List A to List B", 2569 "type": "Move", 2570 "actor": "http://sally.example.org", 2571 "object": "http://example.org/posts/1", 2572 "target": { 2573 "type": "Collection", 2574 "name": "List B" 2575 }, 2576 "origin": { 2577 "type": "Collection", 2578 "name": "List A" 2579 } 2580}` 2581 2582var example94Type = &Move{} 2583 2584func init() { 2585 a := MustParseURL("http://sally.example.org") 2586 o := MustParseURL("http://example.org/posts/1") 2587 target := &Collection{} 2588 target.AppendType("Collection") 2589 target.AppendNameString("List B") 2590 origin := &Collection{} 2591 origin.AppendType("Collection") 2592 origin.AppendNameString("List A") 2593 example94Type.AppendType("Move") 2594 example94Type.AppendSummaryString("Sally moved a post from List A to List B") 2595 example94Type.AppendActorIRI(a) 2596 example94Type.AppendObjectIRI(o) 2597 example94Type.AppendTargetObject(target) 2598 example94Type.AppendOriginObject(origin) 2599} 2600 2601const example95 = `{ 2602 "@context": "https://www.w3.org/ns/activitystreams", 2603 "summary": "Page 2 of Sally's blog posts", 2604 "type": "CollectionPage", 2605 "next": "http://example.org/collection?page=2", 2606 "items": [ 2607 "http://example.org/posts/1", 2608 "http://example.org/posts/2", 2609 "http://example.org/posts/3" 2610 ] 2611}` 2612 2613var example95Type = &CollectionPage{} 2614 2615func init() { 2616 i := MustParseURL("http://example.org/collection?page=2") 2617 u1 := MustParseURL("http://example.org/posts/1") 2618 u2 := MustParseURL("http://example.org/posts/2") 2619 u3 := MustParseURL("http://example.org/posts/3") 2620 example95Type.AppendType("CollectionPage") 2621 example95Type.AppendSummaryString("Page 2 of Sally's blog posts") 2622 example95Type.SetNextIRI(i) 2623 example95Type.AppendItemsIRI(u1) 2624 example95Type.AppendItemsIRI(u2) 2625 example95Type.AppendItemsIRI(u3) 2626} 2627 2628const example96 = `{ 2629 "@context": "https://www.w3.org/ns/activitystreams", 2630 "summary": "Page 2 of Sally's blog posts", 2631 "type": "CollectionPage", 2632 "next": { 2633 "type": "Link", 2634 "name": "Next Page", 2635 "href": "http://example.org/collection?page=2" 2636 }, 2637 "items": [ 2638 "http://example.org/posts/1", 2639 "http://example.org/posts/2", 2640 "http://example.org/posts/3" 2641 ] 2642}` 2643 2644var example96Type = &CollectionPage{} 2645 2646func init() { 2647 href := MustParseURL("http://example.org/collection?page=2") 2648 u1 := MustParseURL("http://example.org/posts/1") 2649 u2 := MustParseURL("http://example.org/posts/2") 2650 u3 := MustParseURL("http://example.org/posts/3") 2651 link := &Link{} 2652 link.AppendType("Link") 2653 link.AppendNameString("Next Page") 2654 link.SetHref(href) 2655 example96Type.AppendType("CollectionPage") 2656 example96Type.AppendSummaryString("Page 2 of Sally's blog posts") 2657 example96Type.SetNextLink(link) 2658 example96Type.AppendItemsIRI(u1) 2659 example96Type.AppendItemsIRI(u2) 2660 example96Type.AppendItemsIRI(u3) 2661} 2662 2663const example97 = `{ 2664 "@context": "https://www.w3.org/ns/activitystreams", 2665 "summary": "Sally liked a post", 2666 "type": "Like", 2667 "actor": "http://sally.example.org", 2668 "object": "http://example.org/posts/1" 2669}` 2670 2671var example97Type = &Like{} 2672 2673func init() { 2674 a := MustParseURL("http://sally.example.org") 2675 o := MustParseURL("http://example.org/posts/1") 2676 example97Type.AppendType("Like") 2677 example97Type.AppendSummaryString("Sally liked a post") 2678 example97Type.AppendActorIRI(a) 2679 example97Type.AppendObjectIRI(o) 2680} 2681 2682const example98 = `{ 2683 "@context": "https://www.w3.org/ns/activitystreams", 2684 "type": "Like", 2685 "actor": "http://sally.example.org", 2686 "object": { 2687 "type": "Note", 2688 "content": "A simple note" 2689 } 2690}` 2691 2692var example98Type = &Like{} 2693 2694func init() { 2695 a := MustParseURL("http://sally.example.org") 2696 note := &Note{} 2697 note.AppendType("Note") 2698 note.AppendContentString("A simple note") 2699 example98Type.AppendType("Like") 2700 example98Type.AppendActorIRI(a) 2701 example98Type.AppendObject(note) 2702} 2703 2704const example99 = `{ 2705 "@context": "https://www.w3.org/ns/activitystreams", 2706 "summary": "Sally liked a note", 2707 "type": "Like", 2708 "actor": "http://sally.example.org", 2709 "object": [ 2710 "http://example.org/posts/1", 2711 { 2712 "type": "Note", 2713 "summary": "A simple note", 2714 "content": "That is a tree." 2715 } 2716 ] 2717}` 2718 2719var example99Type = &Like{} 2720 2721func init() { 2722 a := MustParseURL("http://sally.example.org") 2723 o := MustParseURL("http://example.org/posts/1") 2724 note := &Note{} 2725 note.AppendType("Note") 2726 note.AppendSummaryString("A simple note") 2727 note.AppendContentString("That is a tree.") 2728 example99Type.AppendType("Like") 2729 example99Type.AppendSummaryString("Sally liked a note") 2730 example99Type.AppendActorIRI(a) 2731 example99Type.AppendObjectIRI(o) 2732 example99Type.AppendObject(note) 2733} 2734 2735const example100 = `{ 2736 "@context": "https://www.w3.org/ns/activitystreams", 2737 "summary": "Page 1 of Sally's blog posts", 2738 "type": "CollectionPage", 2739 "prev": "http://example.org/collection?page=1", 2740 "items": [ 2741 "http://example.org/posts/1", 2742 "http://example.org/posts/2", 2743 "http://example.org/posts/3" 2744 ] 2745}` 2746 2747var example100Type = &CollectionPage{} 2748 2749func init() { 2750 p := MustParseURL("http://example.org/collection?page=1") 2751 u1 := MustParseURL("http://example.org/posts/1") 2752 u2 := MustParseURL("http://example.org/posts/2") 2753 u3 := MustParseURL("http://example.org/posts/3") 2754 example100Type.AppendType("CollectionPage") 2755 example100Type.AppendSummaryString("Page 1 of Sally's blog posts") 2756 example100Type.SetPrevIRI(p) 2757 example100Type.AppendItemsIRI(u1) 2758 example100Type.AppendItemsIRI(u2) 2759 example100Type.AppendItemsIRI(u3) 2760} 2761 2762const example101 = `{ 2763 "@context": "https://www.w3.org/ns/activitystreams", 2764 "summary": "Page 1 of Sally's blog posts", 2765 "type": "CollectionPage", 2766 "prev": { 2767 "type": "Link", 2768 "name": "Previous Page", 2769 "href": "http://example.org/collection?page=1" 2770 }, 2771 "items": [ 2772 "http://example.org/posts/1", 2773 "http://example.org/posts/2", 2774 "http://example.org/posts/3" 2775 ] 2776}` 2777 2778var example101Type = &CollectionPage{} 2779 2780func init() { 2781 p := MustParseURL("http://example.org/collection?page=1") 2782 u1 := MustParseURL("http://example.org/posts/1") 2783 u2 := MustParseURL("http://example.org/posts/2") 2784 u3 := MustParseURL("http://example.org/posts/3") 2785 link := &Link{} 2786 link.AppendType("Link") 2787 link.AppendNameString("Previous Page") 2788 link.SetHref(p) 2789 example101Type.AppendType("CollectionPage") 2790 example101Type.AppendSummaryString("Page 1 of Sally's blog posts") 2791 example101Type.SetPrevLink(link) 2792 example101Type.AppendItemsIRI(u1) 2793 example101Type.AppendItemsIRI(u2) 2794 example101Type.AppendItemsIRI(u3) 2795} 2796 2797// NOTE: The 'url' field has added the 'type' property 2798const example102 = `{ 2799 "@context": "https://www.w3.org/ns/activitystreams", 2800 "type": "Video", 2801 "name": "Cool New Movie", 2802 "duration": "PT2H30M", 2803 "preview": { 2804 "type": "Video", 2805 "name": "Trailer", 2806 "duration": "PT1M", 2807 "url": { 2808 "type": "Link", 2809 "href": "http://example.org/trailer.mkv", 2810 "mediaType": "video/mkv" 2811 } 2812 } 2813}` 2814 2815var example102Type = &Video{} 2816 2817func init() { 2818 u := MustParseURL("http://example.org/trailer.mkv") 2819 link := &Link{} 2820 link.AppendType("Link") 2821 link.SetMediaType("video/mkv") 2822 link.SetHref(u) 2823 video := &Video{} 2824 video.AppendType("Video") 2825 video.AppendNameString("Trailer") 2826 video.SetDuration(time.Minute) 2827 video.AppendUrlLink(link) 2828 example102Type.AppendType("Video") 2829 example102Type.AppendNameString("Cool New Movie") 2830 example102Type.SetDuration(time.Hour*2 + time.Minute*30) 2831 example102Type.AppendPreviewObject(video) 2832} 2833 2834const example103 = `{ 2835 "@context": "https://www.w3.org/ns/activitystreams", 2836 "summary": "Sally checked that her flight was on time", 2837 "type": ["Activity", "http://www.verbs.example/Check"], 2838 "actor": "http://sally.example.org", 2839 "object": "http://example.org/flights/1", 2840 "result": { 2841 "type": "http://www.types.example/flightstatus", 2842 "name": "On Time" 2843 } 2844}` 2845 2846var example103Type = &Activity{} 2847 2848func init() { 2849 o := MustParseURL("http://example.org/flights/1") 2850 a := MustParseURL("http://sally.example.org") 2851 status := make(map[string]interface{}) 2852 status["type"] = "http://www.types.example/flightstatus" 2853 status["name"] = "On Time" 2854 example103Type.AppendType("Activity") 2855 example103Type.AppendType("http://www.verbs.example/Check") 2856 example103Type.AppendSummaryString("Sally checked that her flight was on time") 2857 example103Type.AppendActorIRI(a) 2858 example103Type.AppendObjectIRI(o) 2859 example103Type.AddUnknown("result", status) 2860} 2861 2862// NOTE: Changed to not be an array value for "items" to keep in line with other examples in spec! 2863const example104 = `{ 2864 "@context": "https://www.w3.org/ns/activitystreams", 2865 "summary": "A simple note", 2866 "type": "Note", 2867 "id": "http://www.test.example/notes/1", 2868 "content": "I am fine.", 2869 "replies": { 2870 "type": "Collection", 2871 "totalItems": 1, 2872 "items": { 2873 "summary": "A response to the note", 2874 "type": "Note", 2875 "content": "I am glad to hear it.", 2876 "inReplyTo": "http://www.test.example/notes/1" 2877 } 2878 } 2879}` 2880 2881var example104Type = &Note{} 2882 2883func init() { 2884 i := MustParseURL("http://www.test.example/notes/1") 2885 note := &Note{} 2886 note.AppendType("Note") 2887 note.AppendSummaryString("A response to the note") 2888 note.AppendContentString("I am glad to hear it.") 2889 note.AppendInReplyToIRI(i) 2890 replies := &Collection{} 2891 replies.AppendType("Collection") 2892 replies.SetTotalItems(1) 2893 replies.AppendItemsObject(note) 2894 example104Type.AppendType("Note") 2895 example104Type.AppendSummaryString("A simple note") 2896 example104Type.SetId(MustParseURL("http://www.test.example/notes/1")) 2897 example104Type.AppendContentString("I am fine.") 2898 example104Type.SetReplies(replies) 2899} 2900 2901// NOTE: Changed to not be an array value for "tag" to keep in line with other examples in spec! 2902const example105 = `{ 2903 "@context": "https://www.w3.org/ns/activitystreams", 2904 "type": "Image", 2905 "summary": "Picture of Sally", 2906 "url": "http://example.org/sally.jpg", 2907 "tag": { 2908 "type": "Person", 2909 "id": "http://sally.example.org", 2910 "name": "Sally" 2911 } 2912}` 2913 2914var example105Type = &Image{} 2915 2916func init() { 2917 u := MustParseURL("http://example.org/sally.jpg") 2918 person := &Person{} 2919 person.AppendType("Person") 2920 person.SetId(MustParseURL("http://sally.example.org")) 2921 person.AppendNameString("Sally") 2922 example105Type.AppendType("Image") 2923 example105Type.AppendSummaryString("Picture of Sally") 2924 example105Type.AppendUrlAnyURI(u) 2925 example105Type.AppendTagObject(person) 2926} 2927 2928const example106 = `{ 2929 "@context": "https://www.w3.org/ns/activitystreams", 2930 "summary": "Sally offered the post to John", 2931 "type": "Offer", 2932 "actor": "http://sally.example.org", 2933 "object": "http://example.org/posts/1", 2934 "target": "http://john.example.org" 2935}` 2936 2937var example106Type = &Offer{} 2938 2939func init() { 2940 a := MustParseURL("http://sally.example.org") 2941 o := MustParseURL("http://example.org/posts/1") 2942 t := MustParseURL("http://john.example.org") 2943 example106Type.AppendType("Offer") 2944 example106Type.AppendSummaryString("Sally offered the post to John") 2945 example106Type.AppendActorIRI(a) 2946 example106Type.AppendObjectIRI(o) 2947 example106Type.AppendTargetIRI(t) 2948} 2949 2950const example107 = `{ 2951 "@context": "https://www.w3.org/ns/activitystreams", 2952 "summary": "Sally offered the post to John", 2953 "type": "Offer", 2954 "actor": "http://sally.example.org", 2955 "object": "http://example.org/posts/1", 2956 "target": { 2957 "type": "Person", 2958 "name": "John" 2959 } 2960}` 2961 2962var example107Type = &Offer{} 2963 2964func init() { 2965 a := MustParseURL("http://sally.example.org") 2966 o := MustParseURL("http://example.org/posts/1") 2967 person := &Person{} 2968 person.AppendType("Person") 2969 person.AppendNameString("John") 2970 example107Type.AppendType("Offer") 2971 example107Type.AppendSummaryString("Sally offered the post to John") 2972 example107Type.AppendActorIRI(a) 2973 example107Type.AppendObjectIRI(o) 2974 example107Type.AppendTargetObject(person) 2975} 2976 2977// NOTE: Changed to not be an array value for "to" to keep in line with other examples in spec! 2978const example108 = `{ 2979 "@context": "https://www.w3.org/ns/activitystreams", 2980 "summary": "Sally offered the post to John", 2981 "type": "Offer", 2982 "actor": "http://sally.example.org", 2983 "object": "http://example.org/posts/1", 2984 "target": "http://john.example.org", 2985 "to": "http://joe.example.org" 2986}` 2987 2988var example108Type = &Offer{} 2989 2990func init() { 2991 a := MustParseURL("http://sally.example.org") 2992 o := MustParseURL("http://example.org/posts/1") 2993 t := MustParseURL("http://john.example.org") 2994 z := MustParseURL("http://joe.example.org") 2995 example108Type.AppendType("Offer") 2996 example108Type.AppendSummaryString("Sally offered the post to John") 2997 example108Type.AppendActorIRI(a) 2998 example108Type.AppendObjectIRI(o) 2999 example108Type.AppendTargetIRI(t) 3000 example108Type.AppendToIRI(z) 3001} 3002 3003const example109 = `{ 3004 "@context": "https://www.w3.org/ns/activitystreams", 3005 "type": "Document", 3006 "name": "4Q Sales Forecast", 3007 "url": "http://example.org/4q-sales-forecast.pdf" 3008}` 3009 3010var example109Type = &Document{} 3011 3012func init() { 3013 u := MustParseURL("http://example.org/4q-sales-forecast.pdf") 3014 example109Type.AppendType("Document") 3015 example109Type.AppendNameString("4Q Sales Forecast") 3016 example109Type.AppendUrlAnyURI(u) 3017} 3018 3019const example110 = `{ 3020 "@context": "https://www.w3.org/ns/activitystreams", 3021 "type": "Document", 3022 "name": "4Q Sales Forecast", 3023 "url": { 3024 "type": "Link", 3025 "href": "http://example.org/4q-sales-forecast.pdf" 3026 } 3027}` 3028 3029var example110Type = &Document{} 3030 3031func init() { 3032 u := MustParseURL("http://example.org/4q-sales-forecast.pdf") 3033 link := &Link{} 3034 link.AppendType("Link") 3035 link.SetHref(u) 3036 example110Type.AppendType("Document") 3037 example110Type.AppendNameString("4Q Sales Forecast") 3038 example110Type.AppendUrlLink(link) 3039} 3040 3041const example111 = `{ 3042 "@context": "https://www.w3.org/ns/activitystreams", 3043 "type": "Document", 3044 "name": "4Q Sales Forecast", 3045 "url": [ 3046 { 3047 "type": "Link", 3048 "href": "http://example.org/4q-sales-forecast.pdf", 3049 "mediaType": "application/pdf" 3050 }, 3051 { 3052 "type": "Link", 3053 "href": "http://example.org/4q-sales-forecast.html", 3054 "mediaType": "text/html" 3055 } 3056 ] 3057}` 3058 3059var example111Type = &Document{} 3060 3061func init() { 3062 u1 := MustParseURL("http://example.org/4q-sales-forecast.pdf") 3063 u2 := MustParseURL("http://example.org/4q-sales-forecast.html") 3064 link1 := &Link{} 3065 link1.AppendType("Link") 3066 link1.SetHref(u1) 3067 link1.SetMediaType("application/pdf") 3068 link2 := &Link{} 3069 link2.AppendType("Link") 3070 link2.SetHref(u2) 3071 link2.SetMediaType("text/html") 3072 example111Type.AppendType("Document") 3073 example111Type.AppendNameString("4Q Sales Forecast") 3074 example111Type.AppendUrlLink(link1) 3075 example111Type.AppendUrlLink(link2) 3076} 3077 3078const example112 = `{ 3079 "@context": "https://www.w3.org/ns/activitystreams", 3080 "name": "Liu Gu Lu Cun, Pingdu, Qingdao, Shandong, China", 3081 "type": "Place", 3082 "latitude": 36.75, 3083 "longitude": 119.7667, 3084 "accuracy": 94.5 3085}` 3086 3087var example112Type = &Place{} 3088 3089func init() { 3090 example112Type.AppendType("Place") 3091 example112Type.AppendNameString("Liu Gu Lu Cun, Pingdu, Qingdao, Shandong, China") 3092 example112Type.SetLatitude(36.75) 3093 example112Type.SetLongitude(119.7667) 3094 example112Type.SetAccuracy(94.5) 3095} 3096 3097const example113 = `{ 3098 "@context": "https://www.w3.org/ns/activitystreams", 3099 "type": "Place", 3100 "name": "Fresno Area", 3101 "altitude": 15.0, 3102 "latitude": 36.75, 3103 "longitude": 119.7667, 3104 "units": "miles" 3105}` 3106 3107var example113Type = &Place{} 3108 3109func init() { 3110 example113Type.AppendType("Place") 3111 example113Type.AppendNameString("Fresno Area") 3112 example113Type.SetAltitude(15.0) 3113 example113Type.SetLatitude(36.75) 3114 example113Type.SetLongitude(119.7667) 3115 example113Type.SetUnitsUnitsValue("miles") 3116} 3117 3118const example114 = `{ 3119 "@context": "https://www.w3.org/ns/activitystreams", 3120 "summary": "A simple note", 3121 "type": "Note", 3122 "content": "A <em>simple</em> note" 3123}` 3124 3125var example114Type = &Note{} 3126 3127func init() { 3128 example114Type.AppendType("Note") 3129 example114Type.AppendSummaryString("A simple note") 3130 example114Type.AppendContentString("A <em>simple</em> note") 3131} 3132 3133const example115 = `{ 3134 "@context": "https://www.w3.org/ns/activitystreams", 3135 "summary": "A simple note", 3136 "type": "Note", 3137 "contentMap": { 3138 "en": "A <em>simple</em> note", 3139 "es": "Una nota <em>sencilla</em>", 3140 "zh-Hans": "一段<em>简单的</em>笔记" 3141 } 3142}` 3143 3144var example115Type = &Note{} 3145 3146func init() { 3147 example115Type.AppendType("Note") 3148 example115Type.AppendSummaryString("A simple note") 3149 example115Type.SetContentMap("en", "A <em>simple</em> note") 3150 example115Type.SetContentMap("es", "Una nota <em>sencilla</em>") 3151 example115Type.SetContentMap("zh-Hans", "一段<em>简单的</em>笔记") 3152} 3153 3154const example116 = `{ 3155 "@context": "https://www.w3.org/ns/activitystreams", 3156 "summary": "A simple note", 3157 "type": "Note", 3158 "mediaType": "text/markdown", 3159 "content": "## A simple note\nA simple markdown ` + "`note`" + `" 3160}` 3161 3162var example116Type = &Note{} 3163 3164func init() { 3165 example116Type.AppendType("Note") 3166 example116Type.AppendSummaryString("A simple note") 3167 example116Type.SetMediaType("text/markdown") 3168 example116Type.AppendContentString("## A simple note\nA simple markdown `note`") 3169} 3170 3171const example117 = `{ 3172 "@context": "https://www.w3.org/ns/activitystreams", 3173 "type": "Note", 3174 "name": "A simple note" 3175}` 3176 3177var example117Type = &Note{} 3178 3179func init() { 3180 example117Type.AppendType("Note") 3181 example117Type.AppendNameString("A simple note") 3182} 3183 3184const example118 = `{ 3185 "@context": "https://www.w3.org/ns/activitystreams", 3186 "type": "Note", 3187 "nameMap": { 3188 "en": "A simple note", 3189 "es": "Una nota sencilla", 3190 "zh-Hans": "一段简单的笔记" 3191 } 3192}` 3193 3194var example118Type = &Note{} 3195 3196func init() { 3197 example118Type.AppendType("Note") 3198 example118Type.SetNameMap("en", "A simple note") 3199 example118Type.SetNameMap("es", "Una nota sencilla") 3200 example118Type.SetNameMap("zh-Hans", "一段简单的笔记") 3201} 3202 3203const example119 = `{ 3204 "@context": "https://www.w3.org/ns/activitystreams", 3205 "type": "Video", 3206 "name": "Birds Flying", 3207 "url": "http://example.org/video.mkv", 3208 "duration": "PT2H" 3209}` 3210 3211var example119Type = &Video{} 3212 3213func init() { 3214 u := MustParseURL("http://example.org/video.mkv") 3215 example119Type.AppendType("Video") 3216 example119Type.AppendNameString("Birds Flying") 3217 example119Type.AppendUrlAnyURI(u) 3218 example119Type.SetDuration(time.Hour * 2) 3219} 3220 3221const example120 = `{ 3222 "@context": "https://www.w3.org/ns/activitystreams", 3223 "type": "Link", 3224 "href": "http://example.org/image.png", 3225 "height": 100, 3226 "width": 100 3227}` 3228 3229var example120Type = &Link{} 3230 3231func init() { 3232 u := MustParseURL("http://example.org/image.png") 3233 example120Type.AppendType("Link") 3234 example120Type.SetHref(u) 3235 example120Type.SetHeight(100) 3236 example120Type.SetWidth(100) 3237} 3238 3239const example121 = `{ 3240 "@context": "https://www.w3.org/ns/activitystreams", 3241 "type": "Link", 3242 "href": "http://example.org/abc", 3243 "mediaType": "text/html", 3244 "name": "Previous" 3245}` 3246 3247var example121Type = &Link{} 3248 3249func init() { 3250 u := MustParseURL("http://example.org/abc") 3251 example121Type.AppendType("Link") 3252 example121Type.SetHref(u) 3253 example121Type.SetMediaType("text/html") 3254 example121Type.AppendNameString("Previous") 3255} 3256 3257const example122 = `{ 3258 "@context": "https://www.w3.org/ns/activitystreams", 3259 "type": "Link", 3260 "href": "http://example.org/abc", 3261 "hreflang": "en", 3262 "mediaType": "text/html", 3263 "name": "Previous" 3264}` 3265 3266var example122Type = &Link{} 3267 3268func init() { 3269 u := MustParseURL("http://example.org/abc") 3270 example122Type.AppendType("Link") 3271 example122Type.SetHref(u) 3272 example122Type.SetMediaType("text/html") 3273 example122Type.AppendNameString("Previous") 3274 example122Type.SetHreflang("en") 3275} 3276 3277const example123 = `{ 3278 "@context": "https://www.w3.org/ns/activitystreams", 3279 "summary": "Page 1 of Sally's notes", 3280 "type": "CollectionPage", 3281 "id": "http://example.org/collection?page=1", 3282 "partOf": "http://example.org/collection", 3283 "items": [ 3284 { 3285 "type": "Note", 3286 "name": "Pizza Toppings to Try" 3287 }, 3288 { 3289 "type": "Note", 3290 "name": "Thought about California" 3291 } 3292 ] 3293}` 3294 3295var example123Type = &CollectionPage{} 3296 3297func init() { 3298 u := MustParseURL("http://example.org/collection") 3299 note1 := &Note{} 3300 note1.AppendType("Note") 3301 note1.AppendNameString("Pizza Toppings to Try") 3302 note2 := &Note{} 3303 note2.AppendType("Note") 3304 note2.AppendNameString("Thought about California") 3305 example123Type.AppendType("CollectionPage") 3306 example123Type.AppendSummaryString("Page 1 of Sally's notes") 3307 example123Type.SetId(MustParseURL("http://example.org/collection?page=1")) 3308 example123Type.SetPartOfIRI(u) 3309 example123Type.AppendItemsObject(note1) 3310 example123Type.AppendItemsObject(note2) 3311} 3312 3313const example124 = `{ 3314 "@context": "https://www.w3.org/ns/activitystreams", 3315 "type": "Place", 3316 "name": "Fresno Area", 3317 "latitude": 36.75, 3318 "longitude": 119.7667, 3319 "radius": 15, 3320 "units": "miles" 3321}` 3322 3323var example124Type = &Place{} 3324 3325func init() { 3326 example124Type.AppendType("Place") 3327 example124Type.AppendNameString("Fresno Area") 3328 example124Type.SetLatitude(36.75) 3329 example124Type.SetLongitude(119.7667) 3330 example124Type.SetRadius(15) 3331 example124Type.SetUnitsUnitsValue("miles") 3332} 3333 3334const example125 = `{ 3335 "@context": "https://www.w3.org/ns/activitystreams", 3336 "type": "Place", 3337 "name": "Fresno Area", 3338 "latitude": 36.75, 3339 "longitude": 119.7667, 3340 "radius": 15, 3341 "units": "miles" 3342}` 3343 3344var example125Type = &Place{} 3345 3346func init() { 3347 example125Type.AppendType("Place") 3348 example125Type.AppendNameString("Fresno Area") 3349 example125Type.SetLatitude(36.75) 3350 example125Type.SetLongitude(119.7667) 3351 example125Type.SetRadius(15) 3352 example125Type.SetUnitsUnitsValue("miles") 3353} 3354 3355const example126 = `{ 3356 "@context": "https://www.w3.org/ns/activitystreams", 3357 "type": "Link", 3358 "href": "http://example.org/abc", 3359 "hreflang": "en", 3360 "mediaType": "text/html", 3361 "name": "Next" 3362}` 3363 3364var example126Type = &Link{} 3365 3366func init() { 3367 u := MustParseURL("http://example.org/abc") 3368 example126Type.AppendType("Link") 3369 example126Type.SetHref(u) 3370 example126Type.SetHreflang("en") 3371 example126Type.SetMediaType("text/html") 3372 example126Type.AppendNameString("Next") 3373} 3374 3375const example127 = `{ 3376 "@context": "https://www.w3.org/ns/activitystreams", 3377 "type": "Event", 3378 "name": "Going-Away Party for Jim", 3379 "startTime": "2014-12-31T23:00:00-08:00", 3380 "endTime": "2015-01-01T06:00:00-08:00" 3381}` 3382 3383var example127Type = &Event{} 3384 3385func init() { 3386 t1, err := time.Parse(time.RFC3339, "2014-12-31T23:00:00-08:00") 3387 if err != nil { 3388 panic(err) 3389 } 3390 t2, err := time.Parse(time.RFC3339, "2015-01-01T06:00:00-08:00") 3391 if err != nil { 3392 panic(err) 3393 } 3394 example127Type.AppendType("Event") 3395 example127Type.AppendNameString("Going-Away Party for Jim") 3396 example127Type.SetStartTime(t1) 3397 example127Type.SetEndTime(t2) 3398} 3399 3400const example128 = `{ 3401 "@context": "https://www.w3.org/ns/activitystreams", 3402 "summary": "A simple note", 3403 "type": "Note", 3404 "content": "Fish swim.", 3405 "published": "2014-12-12T12:12:12Z" 3406}` 3407 3408var example128Type = &Note{} 3409 3410func init() { 3411 t, err := time.Parse(time.RFC3339, "2014-12-12T12:12:12Z") 3412 if err != nil { 3413 panic(err) 3414 } 3415 example128Type.AppendType("Note") 3416 example128Type.AppendSummaryString("A simple note") 3417 example128Type.AppendContentString("Fish swim.") 3418 example128Type.SetPublished(t) 3419} 3420 3421const example129 = `{ 3422 "@context": "https://www.w3.org/ns/activitystreams", 3423 "type": "Event", 3424 "name": "Going-Away Party for Jim", 3425 "startTime": "2014-12-31T23:00:00-08:00", 3426 "endTime": "2015-01-01T06:00:00-08:00" 3427}` 3428 3429var example129Type = &Event{} 3430 3431func init() { 3432 t1, err := time.Parse(time.RFC3339, "2014-12-31T23:00:00-08:00") 3433 if err != nil { 3434 panic(err) 3435 } 3436 t2, err := time.Parse(time.RFC3339, "2015-01-01T06:00:00-08:00") 3437 if err != nil { 3438 panic(err) 3439 } 3440 example129Type.AppendType("Event") 3441 example129Type.AppendNameString("Going-Away Party for Jim") 3442 example129Type.SetStartTime(t1) 3443 example129Type.SetEndTime(t2) 3444} 3445 3446const example130 = `{ 3447 "@context": "https://www.w3.org/ns/activitystreams", 3448 "type": "Place", 3449 "name": "Fresno Area", 3450 "latitude": 36.75, 3451 "longitude": 119.7667, 3452 "radius": 15, 3453 "units": "miles" 3454}` 3455 3456var example130Type = &Place{} 3457 3458func init() { 3459 example130Type.AppendType("Place") 3460 example130Type.AppendNameString("Fresno Area") 3461 example130Type.SetLatitude(36.75) 3462 example130Type.SetLongitude(119.7667) 3463 example130Type.SetRadius(15) 3464 example130Type.SetUnitsUnitsValue("miles") 3465} 3466 3467const example131 = `{ 3468 "@context": "https://www.w3.org/ns/activitystreams", 3469 "type": "Link", 3470 "href": "http://example.org/abc", 3471 "hreflang": "en", 3472 "mediaType": "text/html", 3473 "name": "Preview", 3474 "rel": ["canonical", "preview"] 3475}` 3476 3477var example131Type = &Link{} 3478 3479func init() { 3480 u := MustParseURL("http://example.org/abc") 3481 example131Type.AppendType("Link") 3482 example131Type.SetHref(u) 3483 example131Type.SetHreflang("en") 3484 example131Type.SetMediaType("text/html") 3485 example131Type.AppendNameString("Preview") 3486 example131Type.AppendRel("canonical") 3487 example131Type.AppendRel("preview") 3488} 3489 3490const example132 = `{ 3491 "@context": "https://www.w3.org/ns/activitystreams", 3492 "summary": "Page 1 of Sally's notes", 3493 "type": "OrderedCollectionPage", 3494 "startIndex": 0, 3495 "orderedItems": [ 3496 { 3497 "type": "Note", 3498 "name": "Density of Water" 3499 }, 3500 { 3501 "type": "Note", 3502 "name": "Air Mattress Idea" 3503 } 3504 ] 3505}` 3506 3507var example132Type = &OrderedCollectionPage{} 3508 3509func init() { 3510 note1 := &Note{} 3511 note1.AppendType("Note") 3512 note1.AppendNameString("Density of Water") 3513 note2 := &Note{} 3514 note2.AppendType("Note") 3515 note2.AppendNameString("Air Mattress Idea") 3516 example132Type.AppendType("OrderedCollectionPage") 3517 example132Type.AppendSummaryString("Page 1 of Sally's notes") 3518 example132Type.SetStartIndex(0) 3519 example132Type.AppendOrderedItemsObject(note1) 3520 example132Type.AppendOrderedItemsObject(note2) 3521} 3522 3523const example133 = `{ 3524 "@context": "https://www.w3.org/ns/activitystreams", 3525 "name": "Cane Sugar Processing", 3526 "type": "Note", 3527 "summary": "A simple <em>note</em>" 3528}` 3529 3530var example133Type = &Note{} 3531 3532func init() { 3533 example133Type.AppendType("Note") 3534 example133Type.AppendNameString("Cane Sugar Processing") 3535 example133Type.AppendSummaryString("A simple <em>note</em>") 3536} 3537 3538const example134 = `{ 3539 "@context": "https://www.w3.org/ns/activitystreams", 3540 "name": "Cane Sugar Processing", 3541 "type": "Note", 3542 "summaryMap": { 3543 "en": "A simple <em>note</em>", 3544 "es": "Una <em>nota</em> sencilla", 3545 "zh-Hans": "一段<em>简单的</em>笔记" 3546 } 3547}` 3548 3549var example134Type = &Note{} 3550 3551func init() { 3552 example134Type.AppendType("Note") 3553 example134Type.AppendNameString("Cane Sugar Processing") 3554 example134Type.SetSummaryMap("en", "A simple <em>note</em>") 3555 example134Type.SetSummaryMap("es", "Una <em>nota</em> sencilla") 3556 example134Type.SetSummaryMap("zh-Hans", "一段<em>简单的</em>笔记") 3557} 3558 3559const example135 = `{ 3560 "@context": "https://www.w3.org/ns/activitystreams", 3561 "summary": "Sally's notes", 3562 "type": "Collection", 3563 "totalItems": 2, 3564 "items": [ 3565 { 3566 "type": "Note", 3567 "name": "Which Staircase Should I Use" 3568 }, 3569 { 3570 "type": "Note", 3571 "name": "Something to Remember" 3572 } 3573 ] 3574}` 3575 3576var example135Type = &Collection{} 3577 3578func init() { 3579 note1 := &Note{} 3580 note1.AppendType("Note") 3581 note1.AppendNameString("Which Staircase Should I Use") 3582 note2 := &Note{} 3583 note2.AppendType("Note") 3584 note2.AppendNameString("Something to Remember") 3585 example135Type.AppendType("Collection") 3586 example135Type.AppendSummaryString("Sally's notes") 3587 example135Type.SetTotalItems(2) 3588 example135Type.AppendItemsObject(note1) 3589 example135Type.AppendItemsObject(note2) 3590} 3591 3592const example136 = `{ 3593 "@context": "https://www.w3.org/ns/activitystreams", 3594 "type": "Place", 3595 "name": "Fresno Area", 3596 "latitude": 36.75, 3597 "longitude": 119.7667, 3598 "radius": 15, 3599 "units": "miles" 3600}` 3601 3602var example136Type = &Place{} 3603 3604func init() { 3605 example136Type.AppendType("Place") 3606 example136Type.AppendNameString("Fresno Area") 3607 example136Type.SetLatitude(36.75) 3608 example136Type.SetLongitude(119.7667) 3609 example136Type.SetRadius(15) 3610 example136Type.SetUnitsUnitsValue("miles") 3611} 3612 3613const example137 = `{ 3614 "@context": "https://www.w3.org/ns/activitystreams", 3615 "name": "Cranberry Sauce Idea", 3616 "type": "Note", 3617 "content": "Mush it up so it does not have the same shape as the can.", 3618 "updated": "2014-12-12T12:12:12Z" 3619}` 3620 3621var example137Type = &Note{} 3622 3623func init() { 3624 t, err := time.Parse(time.RFC3339, "2014-12-12T12:12:12Z") 3625 if err != nil { 3626 panic(err) 3627 } 3628 example137Type.AppendType("Note") 3629 example137Type.AppendNameString("Cranberry Sauce Idea") 3630 example137Type.AppendContentString("Mush it up so it does not have the same shape as the can.") 3631 example137Type.SetUpdated(t) 3632} 3633 3634const example138 = `{ 3635 "@context": "https://www.w3.org/ns/activitystreams", 3636 "type": "Link", 3637 "href": "http://example.org/image.png", 3638 "height": 100, 3639 "width": 100 3640}` 3641 3642var example138Type = &Link{} 3643 3644func init() { 3645 u := MustParseURL("http://example.org/image.png") 3646 example138Type.AppendType("Link") 3647 example138Type.SetHref(u) 3648 example138Type.SetHeight(100) 3649 example138Type.SetWidth(100) 3650} 3651 3652const example139 = `{ 3653 "@context": "https://www.w3.org/ns/activitystreams", 3654 "summary": "Sally is an acquaintance of John's", 3655 "type": "Relationship", 3656 "subject": { 3657 "type": "Person", 3658 "name": "Sally" 3659 }, 3660 "relationship": "http://purl.org/vocab/relationship/acquaintanceOf", 3661 "object": { 3662 "type": "Person", 3663 "name": "John" 3664 } 3665}` 3666 3667var example139Type = &Relationship{} 3668 3669func init() { 3670 u := MustParseURL("http://purl.org/vocab/relationship/acquaintanceOf") 3671 subject := &Person{} 3672 subject.AppendType("Person") 3673 subject.AppendNameString("Sally") 3674 object := &Person{} 3675 object.AppendType("Person") 3676 object.AppendNameString("John") 3677 example139Type.AppendType("Relationship") 3678 example139Type.AppendSummaryString("Sally is an acquaintance of John's") 3679 example139Type.SetSubjectObject(subject) 3680 example139Type.AppendObject(object) 3681 example139Type.SetRelationshipIRI(u) 3682} 3683 3684const example140 = `{ 3685 "@context": "https://www.w3.org/ns/activitystreams", 3686 "summary": "Sally is an acquaintance of John's", 3687 "type": "Relationship", 3688 "subject": { 3689 "type": "Person", 3690 "name": "Sally" 3691 }, 3692 "relationship": "http://purl.org/vocab/relationship/acquaintanceOf", 3693 "object": { 3694 "type": "Person", 3695 "name": "John" 3696 } 3697}` 3698 3699var example140Type = &Relationship{} 3700 3701func init() { 3702 u := MustParseURL("http://purl.org/vocab/relationship/acquaintanceOf") 3703 subject := &Person{} 3704 subject.AppendType("Person") 3705 subject.AppendNameString("Sally") 3706 object := &Person{} 3707 object.AppendType("Person") 3708 object.AppendNameString("John") 3709 example140Type.AppendType("Relationship") 3710 example140Type.AppendSummaryString("Sally is an acquaintance of John's") 3711 example140Type.SetSubjectObject(subject) 3712 example140Type.AppendObject(object) 3713 example140Type.SetRelationshipIRI(u) 3714} 3715 3716const example141 = `{ 3717 "@context": "https://www.w3.org/ns/activitystreams", 3718 "summary": "Sally's profile", 3719 "type": "Profile", 3720 "describes": { 3721 "type": "Person", 3722 "name": "Sally" 3723 }, 3724 "url": "http://sally.example.org" 3725}` 3726 3727var example141Type = &Profile{} 3728 3729func init() { 3730 u := MustParseURL("http://sally.example.org") 3731 person := &Person{} 3732 person.AppendType("Person") 3733 person.AppendNameString("Sally") 3734 example141Type.AppendType("Profile") 3735 example141Type.AppendSummaryString("Sally's profile") 3736 example141Type.AppendUrlAnyURI(u) 3737 example141Type.SetDescribes(person) 3738} 3739 3740const example142 = `{ 3741"@context": "https://www.w3.org/ns/activitystreams", 3742"summary": "This image has been deleted", 3743"type": "Tombstone", 3744"formerType": "Image", 3745"url": "http://example.org/image/2" 3746}` 3747 3748var example142Type = &Tombstone{} 3749 3750func init() { 3751 u := MustParseURL("http://example.org/image/2") 3752 example142Type.AppendType("Tombstone") 3753 example142Type.AppendSummaryString("This image has been deleted") 3754 example142Type.AppendFormerTypeString("Image") 3755 example142Type.AppendUrlAnyURI(u) 3756} 3757 3758const example143 = `{ 3759"@context": "https://www.w3.org/ns/activitystreams", 3760"summary": "This image has been deleted", 3761"type": "Tombstone", 3762"deleted": "2016-05-03T00:00:00Z" 3763}` 3764 3765var example143Type = &Tombstone{} 3766 3767func init() { 3768 t, err := time.Parse(time.RFC3339, "2016-05-03T00:00:00Z") 3769 if err != nil { 3770 panic(err) 3771 } 3772 example143Type.AppendType("Tombstone") 3773 example143Type.AppendSummaryString("This image has been deleted") 3774 example143Type.SetDeleted(t) 3775} 3776 3777const example144 = `{ 3778 "@context": "https://www.w3.org/ns/activitystreams", 3779 "summary": "Activities in Project XYZ", 3780 "type": "Collection", 3781 "items": [ 3782 { 3783 "summary": "Sally created a note", 3784 "type": "Create", 3785 "id": "http://activities.example.com/1", 3786 "actor": "http://sally.example.org", 3787 "object": { 3788 "summary": "A note", 3789 "type": "Note", 3790 "id": "http://notes.example.com/1", 3791 "content": "A note" 3792 }, 3793 "context": { 3794 "type": "http://example.org/Project", 3795 "name": "Project XYZ" 3796 }, 3797 "audience": { 3798 "type": "Group", 3799 "name": "Project XYZ Working Group" 3800 }, 3801 "to": "http://john.example.org" 3802 }, 3803 { 3804 "summary": "John liked Sally's note", 3805 "type": "Like", 3806 "id": "http://activities.example.com/1", 3807 "actor": "http://john.example.org", 3808 "object": "http://notes.example.com/1", 3809 "context": { 3810 "type": "http://example.org/Project", 3811 "name": "Project XYZ" 3812 }, 3813 "audience": { 3814 "type": "Group", 3815 "name": "Project XYZ Working Group" 3816 }, 3817 "to": "http://sally.example.org" 3818 } 3819 ] 3820}` 3821 3822var example144Type = &Collection{} 3823 3824func init() { 3825 sally := MustParseURL("http://sally.example.org") 3826 john := MustParseURL("http://john.example.org") 3827 o := MustParseURL("http://notes.example.com/1") 3828 context := make(map[string]interface{}) 3829 context["type"] = "http://example.org/Project" 3830 context["name"] = "Project XYZ" 3831 audience := &Group{} 3832 audience.AppendType("Group") 3833 audience.AppendNameString("Project XYZ Working Group") 3834 note := &Note{} 3835 note.AppendType("Note") 3836 note.AppendSummaryString("A note") 3837 note.SetId(MustParseURL("http://notes.example.com/1")) 3838 note.AppendContentString("A note") 3839 create := &Create{} 3840 create.AppendType("Create") 3841 create.AppendSummaryString("Sally created a note") 3842 create.SetId(MustParseURL("http://activities.example.com/1")) 3843 create.AppendActorIRI(sally) 3844 create.AppendObject(note) 3845 create.SetUnknownContext(context) 3846 create.AppendAudienceObject(audience) 3847 create.AppendToIRI(john) 3848 like := &Like{} 3849 like.AppendType("Like") 3850 like.AppendSummaryString("John liked Sally's note") 3851 like.SetId(MustParseURL("http://activities.example.com/1")) 3852 like.AppendActorIRI(john) 3853 like.AppendObjectIRI(o) 3854 like.SetUnknownContext(context) 3855 like.AppendAudienceObject(audience) 3856 like.AppendToIRI(sally) 3857 example144Type.AppendType("Collection") 3858 example144Type.AppendSummaryString("Activities in Project XYZ") 3859 example144Type.AppendItemsObject(create) 3860 example144Type.AppendItemsObject(like) 3861} 3862 3863const example145 = `{ 3864 "@context": "https://www.w3.org/ns/activitystreams", 3865 "summary": "Sally's friends list", 3866 "type": "Collection", 3867 "items": [ 3868 { 3869 "summary": "Sally is influenced by Joe", 3870 "type": "Relationship", 3871 "subject": { 3872 "type": "Person", 3873 "name": "Sally" 3874 }, 3875 "relationship": "http://purl.org/vocab/relationship/influencedBy", 3876 "object": { 3877 "type": "Person", 3878 "name": "Joe" 3879 } 3880 }, 3881 { 3882 "summary": "Sally is a friend of Jane", 3883 "type": "Relationship", 3884 "subject": { 3885 "type": "Person", 3886 "name": "Sally" 3887 }, 3888 "relationship": "http://purl.org/vocab/relationship/friendOf", 3889 "object": { 3890 "type": "Person", 3891 "name": "Jane" 3892 } 3893 } 3894 ] 3895}` 3896 3897var example145Type = &Collection{} 3898 3899func init() { 3900 friend := MustParseURL("http://purl.org/vocab/relationship/friendOf") 3901 influenced := MustParseURL("http://purl.org/vocab/relationship/influencedBy") 3902 sally := &Person{} 3903 sally.AppendType("Person") 3904 sally.AppendNameString("Sally") 3905 jane := &Person{} 3906 jane.AppendType("Person") 3907 jane.AppendNameString("Jane") 3908 joe := &Person{} 3909 joe.AppendType("Person") 3910 joe.AppendNameString("Joe") 3911 joeRel := &Relationship{} 3912 joeRel.AppendType("Relationship") 3913 joeRel.AppendSummaryString("Sally is influenced by Joe") 3914 joeRel.SetSubjectObject(sally) 3915 joeRel.AppendObject(joe) 3916 joeRel.SetRelationshipIRI(influenced) 3917 janeRel := &Relationship{} 3918 janeRel.AppendType("Relationship") 3919 janeRel.AppendSummaryString("Sally is a friend of Jane") 3920 janeRel.SetSubjectObject(sally) 3921 janeRel.AppendObject(jane) 3922 janeRel.SetRelationshipIRI(friend) 3923 example145Type.AppendType("Collection") 3924 example145Type.AppendSummaryString("Sally's friends list") 3925 example145Type.AppendItemsObject(joeRel) 3926 example145Type.AppendItemsObject(janeRel) 3927} 3928 3929// NOTE: Added `Z` to `startTime` to make align to spec! 3930const example146 = `{ 3931 "@context": "https://www.w3.org/ns/activitystreams", 3932 "summary": "Sally became a friend of Matt", 3933 "type": "Create", 3934 "actor": "http://sally.example.org", 3935 "object": { 3936 "type": "Relationship", 3937 "subject": "http://sally.example.org", 3938 "relationship": "http://purl.org/vocab/relationship/friendOf", 3939 "object": "http://matt.example.org", 3940 "startTime": "2015-04-21T12:34:56Z" 3941 } 3942}` 3943 3944var example146Type = &Create{} 3945 3946func init() { 3947 friend := MustParseURL("http://purl.org/vocab/relationship/friendOf") 3948 m := MustParseURL("http://matt.example.org") 3949 s := MustParseURL("http://sally.example.org") 3950 t, err := time.Parse(time.RFC3339, "2015-04-21T12:34:56Z") 3951 if err != nil { 3952 panic(err) 3953 } 3954 relationship := &Relationship{} 3955 relationship.AppendType("Relationship") 3956 relationship.SetSubjectIRI(s) 3957 relationship.SetRelationshipIRI(friend) 3958 relationship.AppendObjectIRI(m) 3959 relationship.SetStartTime(t) 3960 example146Type.AppendType("Create") 3961 example146Type.AppendSummaryString("Sally became a friend of Matt") 3962 example146Type.AppendActorIRI(s) 3963 example146Type.AppendObject(relationship) 3964} 3965 3966const example147 = `{ 3967 "@context": "https://www.w3.org/ns/activitystreams", 3968 "id": "http://example.org/connection-requests/123", 3969 "summary": "Sally requested to be a friend of John", 3970 "type": "Offer", 3971 "actor": "acct:sally@example.org", 3972 "object": { 3973 "summary": "Sally and John's friendship", 3974 "id": "http://example.org/connections/123", 3975 "type": "Relationship", 3976 "subject": "acct:sally@example.org", 3977 "relationship": "http://purl.org/vocab/relationship/friendOf", 3978 "object": "acct:john@example.org" 3979 }, 3980 "target": "acct:john@example.org" 3981}` 3982 3983var example147Type = &Offer{} 3984 3985func init() { 3986 friend := MustParseURL("http://purl.org/vocab/relationship/friendOf") 3987 s := MustParseURL("acct:sally@example.org") 3988 t := MustParseURL("acct:john@example.org") 3989 rel := &Relationship{} 3990 rel.AppendType("Relationship") 3991 rel.AppendSummaryString("Sally and John's friendship") 3992 rel.SetId(MustParseURL("http://example.org/connections/123")) 3993 rel.SetSubjectIRI(s) 3994 rel.AppendObjectIRI(t) 3995 rel.SetRelationshipIRI(friend) 3996 example147Type.AppendType("Offer") 3997 example147Type.AppendSummaryString("Sally requested to be a friend of John") 3998 example147Type.SetId(MustParseURL("http://example.org/connection-requests/123")) 3999 example147Type.AppendActorIRI(s) 4000 example147Type.AppendObject(rel) 4001 example147Type.AppendTargetIRI(t) 4002} 4003 4004const example148 = `{ 4005 "@context": "https://www.w3.org/ns/activitystreams", 4006 "summary": "Sally and John's relationship history", 4007 "type": "Collection", 4008 "items": [ 4009 { 4010 "summary": "John accepted Sally's friend request", 4011 "id": "http://example.org/activities/122", 4012 "type": "Accept", 4013 "actor": "acct:john@example.org", 4014 "object": "http://example.org/connection-requests/123", 4015 "inReplyTo": "http://example.org/connection-requests/123", 4016 "context": "http://example.org/connections/123", 4017 "result": [ 4018 "http://example.org/activities/123", 4019 "http://example.org/activities/124", 4020 "http://example.org/activities/125", 4021 "http://example.org/activities/126" 4022 ] 4023 }, 4024 { 4025 "summary": "John followed Sally", 4026 "id": "http://example.org/activities/123", 4027 "type": "Follow", 4028 "actor": "acct:john@example.org", 4029 "object": "acct:sally@example.org", 4030 "context": "http://example.org/connections/123" 4031 }, 4032 { 4033 "summary": "Sally followed John", 4034 "id": "http://example.org/activities/124", 4035 "type": "Follow", 4036 "actor": "acct:sally@example.org", 4037 "object": "acct:john@example.org", 4038 "context": "http://example.org/connections/123" 4039 }, 4040 { 4041 "summary": "John added Sally to his friends list", 4042 "id": "http://example.org/activities/125", 4043 "type": "Add", 4044 "actor": "acct:john@example.org", 4045 "object": "http://example.org/connections/123", 4046 "target": { 4047 "type": "Collection", 4048 "summary": "John's Connections" 4049 }, 4050 "context": "http://example.org/connections/123" 4051 }, 4052 { 4053 "summary": "Sally added John to her friends list", 4054 "id": "http://example.org/activities/126", 4055 "type": "Add", 4056 "actor": "acct:sally@example.org", 4057 "object": "http://example.org/connections/123", 4058 "target": { 4059 "type": "Collection", 4060 "summary": "Sally's Connections" 4061 }, 4062 "context": "http://example.org/connections/123" 4063 } 4064 ] 4065}` 4066 4067var example148Type = &Collection{} 4068 4069func init() { 4070 john := MustParseURL("acct:john@example.org") 4071 sally := MustParseURL("acct:sally@example.org") 4072 req123 := MustParseURL("http://example.org/connection-requests/123") 4073 conn123 := MustParseURL("http://example.org/connections/123") 4074 a123 := MustParseURL("http://example.org/activities/123") 4075 a124 := MustParseURL("http://example.org/activities/124") 4076 a125 := MustParseURL("http://example.org/activities/125") 4077 a126 := MustParseURL("http://example.org/activities/126") 4078 jc := &Collection{} 4079 jc.AppendType("Collection") 4080 jc.AppendSummaryString("John's Connections") 4081 sc := &Collection{} 4082 sc.AppendType("Collection") 4083 sc.AppendSummaryString("Sally's Connections") 4084 o1 := &Accept{} 4085 o1.AppendType("Accept") 4086 o1.SetId(MustParseURL("http://example.org/activities/122")) 4087 o1.AppendSummaryString("John accepted Sally's friend request") 4088 o1.AppendObjectIRI(req123) 4089 o1.AppendInReplyToIRI(req123) 4090 o1.AppendContextIRI(conn123) 4091 o1.AppendResultIRI(a123) 4092 o1.AppendResultIRI(a124) 4093 o1.AppendResultIRI(a125) 4094 o1.AppendResultIRI(a126) 4095 o1.AppendActorIRI(john) 4096 o2 := &Follow{} 4097 o2.AppendType("Follow") 4098 o2.SetId(MustParseURL("http://example.org/activities/123")) 4099 o2.AppendActorIRI(john) 4100 o2.AppendObjectIRI(sally) 4101 o2.AppendContextIRI(conn123) 4102 o2.AppendSummaryString("John followed Sally") 4103 o3 := &Follow{} 4104 o3.AppendType("Follow") 4105 o3.SetId(MustParseURL("http://example.org/activities/124")) 4106 o3.AppendActorIRI(sally) 4107 o3.AppendObjectIRI(john) 4108 o3.AppendContextIRI(conn123) 4109 o3.AppendSummaryString("Sally followed John") 4110 o4 := &Add{} 4111 o4.AppendType("Add") 4112 o4.SetId(MustParseURL("http://example.org/activities/125")) 4113 o4.AppendSummaryString("John added Sally to his friends list") 4114 o4.AppendActorIRI(john) 4115 o4.AppendObjectIRI(conn123) 4116 o4.AppendContextIRI(conn123) 4117 o4.AppendTargetObject(jc) 4118 o5 := &Add{} 4119 o5.AppendType("Add") 4120 o5.SetId(MustParseURL("http://example.org/activities/126")) 4121 o5.AppendSummaryString("Sally added John to her friends list") 4122 o5.AppendActorIRI(sally) 4123 o5.AppendObjectIRI(conn123) 4124 o5.AppendContextIRI(conn123) 4125 o5.AppendTargetObject(sc) 4126 example148Type.AppendType("Collection") 4127 example148Type.AppendSummaryString("Sally and John's relationship history") 4128 example148Type.AppendItemsObject(o1) 4129 example148Type.AppendItemsObject(o2) 4130 example148Type.AppendItemsObject(o3) 4131 example148Type.AppendItemsObject(o4) 4132 example148Type.AppendItemsObject(o5) 4133} 4134 4135const example149 = `{ 4136 "@context": "https://www.w3.org/ns/activitystreams", 4137 "type": "Place", 4138 "name": "San Francisco, CA" 4139}` 4140 4141var example149Type = &Place{} 4142 4143func init() { 4144 example149Type.AppendType("Place") 4145 example149Type.AppendNameString("San Francisco, CA") 4146} 4147 4148// NOTE: Un-stringified the longitude and latitude values. 4149const example150 = `{ 4150 "@context": "https://www.w3.org/ns/activitystreams", 4151 "type": "Place", 4152 "name": "San Francisco, CA", 4153 "longitude": 122.4167, 4154 "latitude": 37.7833 4155}` 4156 4157var example150Type = &Place{} 4158 4159func init() { 4160 example150Type.AppendType("Place") 4161 example150Type.AppendNameString("San Francisco, CA") 4162 example150Type.SetLongitude(122.4167) 4163 example150Type.SetLatitude(37.7833) 4164} 4165 4166const example151 = `{ 4167 "@context": "https://www.w3.org/ns/activitystreams", 4168 "name": "A question about robots", 4169 "id": "http://help.example.org/question/1", 4170 "type": "Question", 4171 "content": "I'd like to build a robot to feed my cat. Should I use Arduino or Raspberry Pi?" 4172}` 4173 4174var example151Type = &Question{} 4175 4176func init() { 4177 example151Type.AppendType("Question") 4178 example151Type.AppendNameString("A question about robots") 4179 example151Type.SetId(MustParseURL("http://help.example.org/question/1")) 4180 example151Type.AppendContentString("I'd like to build a robot to feed my cat. Should I use Arduino or Raspberry Pi?") 4181} 4182 4183const example152 = `{ 4184 "@context": "https://www.w3.org/ns/activitystreams", 4185 "id": "http://polls.example.org/question/1", 4186 "name": "A question about robots", 4187 "type": "Question", 4188 "content": "I'd like to build a robot to feed my cat. Which platform is best?", 4189 "oneOf": [ 4190 {"name": "arduino"}, 4191 {"name": "raspberry pi"} 4192 ] 4193}` 4194 4195var example152Type = &Question{} 4196 4197func init() { 4198 ard := make(map[string]interface{}) 4199 ard["name"] = "arduino" 4200 ras := make(map[string]interface{}) 4201 ras["name"] = "raspberry pi" 4202 oneOf := []interface{}{ard, ras} 4203 example152Type.AppendType("Question") 4204 example152Type.AppendNameString("A question about robots") 4205 example152Type.SetId(MustParseURL("http://polls.example.org/question/1")) 4206 example152Type.AppendContentString("I'd like to build a robot to feed my cat. Which platform is best?") 4207 example152Type.SetUnknownOneOf(oneOf) 4208} 4209 4210const example153 = `{ 4211 "@context": "https://www.w3.org/ns/activitystreams", 4212 "attributedTo": "http://sally.example.org", 4213 "inReplyTo": "http://polls.example.org/question/1", 4214 "name": "arduino" 4215}` 4216 4217var example153Type = &Unknown{} 4218 4219func init() { 4220 example153Type.SetField("attributedTo", "http://sally.example.org") 4221 example153Type.SetField("inReplyTo", "http://polls.example.org/question/1") 4222 example153Type.SetField("name", "arduino") 4223} 4224 4225const example154 = `{ 4226 "@context": "https://www.w3.org/ns/activitystreams", 4227 "name": "A question about robots", 4228 "id": "http://polls.example.org/question/1", 4229 "type": "Question", 4230 "content": "I'd like to build a robot to feed my cat. Which platform is best?", 4231 "oneOf": [ 4232 {"name": "arduino"}, 4233 {"name": "raspberry pi"} 4234 ], 4235 "replies": { 4236 "type": "Collection", 4237 "totalItems": 3, 4238 "items": [ 4239 { 4240 "attributedTo": "http://sally.example.org", 4241 "inReplyTo": "http://polls.example.org/question/1", 4242 "name": "arduino" 4243 }, 4244 { 4245 "attributedTo": "http://joe.example.org", 4246 "inReplyTo": "http://polls.example.org/question/1", 4247 "name": "arduino" 4248 }, 4249 { 4250 "attributedTo": "http://john.example.org", 4251 "inReplyTo": "http://polls.example.org/question/1", 4252 "name": "raspberry pi" 4253 } 4254 ] 4255 }, 4256 "result": { 4257 "type": "Note", 4258 "content": "Users are favoriting "arduino" by a 33% margin." 4259 } 4260}` 4261 4262var example154Type = &Question{} 4263 4264func init() { 4265 ard := make(map[string]interface{}) 4266 ard["name"] = "arduino" 4267 ras := make(map[string]interface{}) 4268 ras["name"] = "raspberry pi" 4269 oneOf := []interface{}{ard, ras} 4270 one := make(map[string]interface{}) 4271 one["attributedTo"] = "http://sally.example.org" 4272 one["inReplyTo"] = "http://polls.example.org/question/1" 4273 one["name"] = "arduino" 4274 two := make(map[string]interface{}) 4275 two["attributedTo"] = "http://joe.example.org" 4276 two["inReplyTo"] = "http://polls.example.org/question/1" 4277 two["name"] = "arduino" 4278 three := make(map[string]interface{}) 4279 three["attributedTo"] = "http://john.example.org" 4280 three["inReplyTo"] = "http://polls.example.org/question/1" 4281 three["name"] = "raspberry pi" 4282 items := []interface{}{one, two, three} 4283 replies := &Collection{} 4284 replies.AppendType("Collection") 4285 replies.SetTotalItems(3) 4286 replies.SetUnknownItems(items) 4287 note := &Note{} 4288 note.AppendType("Note") 4289 note.AppendContentString("Users are favoriting "arduino" by a 33% margin.") 4290 example154Type.AppendType("Question") 4291 example154Type.AppendNameString("A question about robots") 4292 example154Type.SetId(MustParseURL("http://polls.example.org/question/1")) 4293 example154Type.AppendContentString("I'd like to build a robot to feed my cat. Which platform is best?") 4294 example154Type.SetUnknownOneOf(oneOf) 4295 example154Type.SetReplies(replies) 4296 example154Type.AppendResultObject(note) 4297} 4298 4299const example155 = `{ 4300 "@context": "https://www.w3.org/ns/activitystreams", 4301 "summary": "History of John's note", 4302 "type": "Collection", 4303 "items": [ 4304 { 4305 "summary": "Sally liked John's note", 4306 "type": "Like", 4307 "actor": "http://sally.example.org", 4308 "id": "http://activities.example.com/1", 4309 "published": "2015-11-12T12:34:56Z", 4310 "object": { 4311 "summary": "John's note", 4312 "type": "Note", 4313 "id": "http://notes.example.com/1", 4314 "attributedTo": "http://john.example.org", 4315 "content": "My note" 4316 } 4317 }, 4318 { 4319 "summary": "Sally disliked John's note", 4320 "type": "Dislike", 4321 "actor": "http://sally.example.org", 4322 "id": "http://activities.example.com/2", 4323 "published": "2015-12-11T21:43:56Z", 4324 "object": { 4325 "summary": "John's note", 4326 "type": "Note", 4327 "id": "http://notes.example.com/1", 4328 "attributedTo": "http://john.example.org", 4329 "content": "My note" 4330 } 4331 } 4332 ] 4333}` 4334 4335var example155Type = &Collection{} 4336 4337func init() { 4338 john := MustParseURL("http://john.example.org") 4339 sally := MustParseURL("http://sally.example.org") 4340 t1, err := time.Parse(time.RFC3339, "2015-11-12T12:34:56Z") 4341 if err != nil { 4342 panic(err) 4343 } 4344 t2, err := time.Parse(time.RFC3339, "2015-12-11T21:43:56Z") 4345 if err != nil { 4346 panic(err) 4347 } 4348 note := &Note{} 4349 note.AppendType("Note") 4350 note.AppendSummaryString("John's note") 4351 note.SetId(MustParseURL("http://notes.example.com/1")) 4352 note.AppendContentString("My note") 4353 note.AppendAttributedToIRI(john) 4354 like := &Like{} 4355 like.AppendType("Like") 4356 like.AppendSummaryString("Sally liked John's note") 4357 like.SetId(MustParseURL("http://activities.example.com/1")) 4358 like.AppendActorIRI(sally) 4359 like.SetPublished(t1) 4360 like.AppendObject(note) 4361 dislike := &Dislike{} 4362 dislike.AppendType("Dislike") 4363 dislike.AppendSummaryString("Sally disliked John's note") 4364 dislike.SetId(MustParseURL("http://activities.example.com/2")) 4365 dislike.AppendActorIRI(sally) 4366 dislike.SetPublished(t2) 4367 dislike.AppendObject(note) 4368 example155Type.AppendType("Collection") 4369 example155Type.AppendSummaryString("History of John's note") 4370 example155Type.AppendItemsObject(like) 4371 example155Type.AppendItemsObject(dislike) 4372} 4373 4374const example156 = `{ 4375 "@context": "https://www.w3.org/ns/activitystreams", 4376 "summary": "History of John's note", 4377 "type": "Collection", 4378 "items": [ 4379 { 4380 "summary": "Sally liked John's note", 4381 "type": "Like", 4382 "id": "http://activities.example.com/1", 4383 "actor": "http://sally.example.org", 4384 "published": "2015-11-12T12:34:56Z", 4385 "object": { 4386 "summary": "John's note", 4387 "type": "Note", 4388 "id": "http://notes.example.com/1", 4389 "attributedTo": "http://john.example.org", 4390 "content": "My note" 4391 } 4392 }, 4393 { 4394 "summary": "Sally no longer likes John's note", 4395 "type": "Undo", 4396 "id": "http://activities.example.com/2", 4397 "actor": "http://sally.example.org", 4398 "published": "2015-12-11T21:43:56Z", 4399 "object": "http://activities.example.com/1" 4400 } 4401 ] 4402}` 4403 4404var example156Type = &Collection{} 4405 4406func init() { 4407 john := MustParseURL("http://john.example.org") 4408 sally := MustParseURL("http://sally.example.org") 4409 a := MustParseURL("http://activities.example.com/1") 4410 t1, err := time.Parse(time.RFC3339, "2015-11-12T12:34:56Z") 4411 if err != nil { 4412 panic(err) 4413 } 4414 t2, err := time.Parse(time.RFC3339, "2015-12-11T21:43:56Z") 4415 if err != nil { 4416 panic(err) 4417 } 4418 note := &Note{} 4419 note.AppendType("Note") 4420 note.SetId(MustParseURL("http://notes.example.com/1")) 4421 note.AppendSummaryString("John's note") 4422 note.AppendAttributedToIRI(john) 4423 note.AppendContentString("My note") 4424 like := &Like{} 4425 like.AppendType("Like") 4426 like.SetId(MustParseURL("http://activities.example.com/1")) 4427 like.AppendSummaryString("Sally liked John's note") 4428 like.AppendActorIRI(sally) 4429 like.SetPublished(t1) 4430 like.AppendObject(note) 4431 undo := &Undo{} 4432 undo.AppendType("Undo") 4433 undo.SetId(MustParseURL("http://activities.example.com/2")) 4434 undo.AppendSummaryString("Sally no longer likes John's note") 4435 undo.AppendActorIRI(sally) 4436 undo.SetPublished(t2) 4437 undo.AppendObjectIRI(a) 4438 example156Type.AppendType("Collection") 4439 example156Type.AppendSummaryString("History of John's note") 4440 example156Type.AppendItemsObject(like) 4441 example156Type.AppendItemsObject(undo) 4442} 4443 4444// NOTE: The `content` field has been inlined to keep within JSON spec. 4445const example157 = `{ 4446 "@context": "https://www.w3.org/ns/activitystreams", 4447 "name": "A thank-you note", 4448 "type": "Note", 4449 "content": "Thank you <a href='http://sally.example.org'>@sally</a> for all your hard work! <a href='http://example.org/tags/givingthanks'>#givingthanks</a>", 4450 "to": { 4451 "name": "Sally", 4452 "type": "Person", 4453 "id": "http://sally.example.org" 4454 }, 4455 "tag": { 4456 "id": "http://example.org/tags/givingthanks", 4457 "name": "#givingthanks" 4458 } 4459}` 4460 4461var example157Type = &Note{} 4462 4463func init() { 4464 tag := make(map[string]interface{}) 4465 tag["id"] = "http://example.org/tags/givingthanks" 4466 tag["name"] = "#givingthanks" 4467 person := &Person{} 4468 person.AppendType("Person") 4469 person.AppendNameString("Sally") 4470 person.SetId(MustParseURL("http://sally.example.org")) 4471 example157Type.AppendType("Note") 4472 example157Type.AppendNameString("A thank-you note") 4473 example157Type.AppendContentString("Thank you <a href='http://sally.example.org'>@sally</a> for all your hard work! <a href='http://example.org/tags/givingthanks'>#givingthanks</a>") 4474 example157Type.AppendToObject(person) 4475 example157Type.SetUnknownTag(tag) 4476} 4477 4478const example158 = `{ 4479 "@context": "https://www.w3.org/ns/activitystreams", 4480 "name": "A thank-you note", 4481 "type": "Note", 4482 "content": "Thank you @sally for all your hard work! #givingthanks", 4483 "tag": [ 4484 { 4485 "type": "Mention", 4486 "href": "http://example.org/people/sally", 4487 "name": "@sally" 4488 }, 4489 { 4490 "id": "http://example.org/tags/givingthanks", 4491 "name": "#givingthanks" 4492 } 4493 ] 4494}` 4495 4496var example158Type = &Note{} 4497 4498func init() { 4499 u := MustParseURL("http://example.org/people/sally") 4500 tag := make(map[string]interface{}) 4501 tag["id"] = "http://example.org/tags/givingthanks" 4502 tag["name"] = "#givingthanks" 4503 mention := &Mention{} 4504 mention.AppendType("Mention") 4505 mention.SetHref(u) 4506 mention.AppendNameString("@sally") 4507 example158Type.AppendType("Note") 4508 example158Type.AppendNameString("A thank-you note") 4509 example158Type.AppendContentString("Thank you @sally for all your hard work! #givingthanks") 4510 example158Type.AppendTagLink(mention) 4511 example158Type.SetUnknownTag(tag) 4512} 4513 4514const example159 = `{ 4515 "@context": "https://www.w3.org/ns/activitystreams", 4516 "summary": "Sally moved the sales figures from Folder A to Folder B", 4517 "type": "Move", 4518 "actor": "http://sally.example.org", 4519 "object": { 4520 "type": "Document", 4521 "name": "sales figures" 4522 }, 4523 "origin": { 4524 "type": "Collection", 4525 "name": "Folder A" 4526 }, 4527 "target": { 4528 "type": "Collection", 4529 "name": "Folder B" 4530 } 4531}` 4532 4533var example159Type = &Move{} 4534 4535func init() { 4536 sally := MustParseURL("http://sally.example.org") 4537 obj := &Document{} 4538 obj.AppendType("Document") 4539 obj.AppendNameString("sales figures") 4540 origin := &Collection{} 4541 origin.AppendType("Collection") 4542 origin.AppendNameString("Folder A") 4543 target := &Collection{} 4544 target.AppendType("Collection") 4545 target.AppendNameString("Folder B") 4546 example159Type.AppendType("Move") 4547 example159Type.AppendSummaryString("Sally moved the sales figures from Folder A to Folder B") 4548 example159Type.AppendActorIRI(sally) 4549 example159Type.AppendObject(obj) 4550 example159Type.AppendOriginObject(origin) 4551 example159Type.AppendTargetObject(target) 4552} 4553