From 4c052a19617b079b917ba2eedd9838441d36ec5a Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Thu, 29 Jan 2015 20:09:23 +0100 Subject: [PATCH 1/9] fixed turtle examples 1 & 3 --- activitystreams2.html | 38 ++++++++++++++++++-------------------- tests/examples.js | 12 ++++++++++++ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/activitystreams2.html b/activitystreams2.html index 5417247..03a2e98 100644 --- a/activitystreams2.html +++ b/activitystreams2.html @@ -309,9 +309,9 @@

Minimal Activity

@prefix as: <http://www.w3.org/ns/activitystreams#> .
 
-_:c14n0 a as:Post ;
+_:b0 a as:Post ;
   as:actor <urn:example:person:martin> ;
-  as:object <http://example.org/foo> .
+ as:object <http://example.org/foo.jpg> . @@ -750,27 +750,25 @@

An extended activity

as:href <http://example.org/martin/image> ; as:mediaType "image/jpeg" ; as:width "250"^^xsd:nonNegativeInteger ; - as:height "250"^^xsd:nonNegativeInteger . + as:height "250"^^xsd:nonNegativeInteger ] . <http://example.org/album/my_fluffy_cat> a as:Image ; as:preview [ a as:Link ; as:href <http://example.org/album/my_fluffy_cat_thumb.jpg> ; - as:mediaType "image/jpeg" . + as:mediaType "image/jpeg" ] ; - as:url ( - [ - a as:Link ; - as:href <http://example.org/album/my_fluffy_cat.jpg> ; - as:mediaType "image/jpeg" . - ] - [ - a as:Link ; - as:href <http://example.org/album/my_fluffy_cat.png> ; - as:mediaType "image/png" . - ] - ) . + as:url [ + a as:Link ; + as:href <http://example.org/album/my_fluffy_cat.jpg> ; + as:mediaType "image/jpeg" + ], + [ + a as:Link ; + as:href <http://example.org/album/my_fluffy_cat.png> ; + as:mediaType "image/png" + ] . <http://example.org/album/> a as:Album ; as:displayName "Martin's Photo Album"@en ; @@ -778,17 +776,17 @@

An extended activity

as:image [ a as:Link ; as:href <http://example.org/album/thumbnail.jpg> ; - as:mediaType "image/jpeg" . + as:mediaType "image/jpeg" ] . -_:c14n0 a as:Collection ; +_:b0 a as:Collection ; as:totalItems "1"^^xsd:nonNegativeInteger ; as:items [ a as:Post ; as:published "2011-02-10T15:04:55Z"^^xsd:dateTime ; as:generator <http://example.org/activities-app> ; as:provider <http://example.org/activity-stream> ; - as:displayName "Martin posted a new video to his album"@en ; + as:displayName "Martin posted a new video to his album."@en ; as:displayName "Martin phost le fisean nua a albam."@ga ; as:actor <urn:example:person:martin> ; as:object <http://example.org/album/my_fluffy_cat> ; @@ -3407,4 +3405,4 @@

2014-09-30

- \ No newline at end of file + diff --git a/tests/examples.js b/tests/examples.js index 0a65a95..f89835e 100644 --- a/tests/examples.js +++ b/tests/examples.js @@ -22,3 +22,15 @@ describe('Minimal Activity', function(){ basicCompare('ex1', done); }); }); + +//describe('Basic activity with some additional detail', function(){ + //it('JSON-LD and Turtle should match', function(done){ + //basicCompare('ex2', done); + //}); +//}); + +describe('An extended activity', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex3', done); + }); +}); From fcfe771d072131b328ed18817d1bbb65ed65b9b2 Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Thu, 29 Jan 2015 20:26:46 +0100 Subject: [PATCH 2/9] fixed turtle example 2 and removed debug output --- activitystreams2.html | 6 +++--- tests/examples.js | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/activitystreams2.html b/activitystreams2.html index 03a2e98..6ea9166 100644 --- a/activitystreams2.html +++ b/activitystreams2.html @@ -472,17 +472,17 @@

Basic activity with some additional detail

as:image [ a as:Link ; as:href <http://example.org/martin/image.jpg> ; - as:mediaType "image/jpeg" . + as:mediaType "image/jpeg" ] . -<http://example.org/blog/> a <"urn:example:types:blog"> ; +<http://example.org/blog/> a <urn:example:types:blog> ; as:displayName "Martin's Blog" . <urn:example:blog:abc123/xyz> a as:Article ; as:displayName "Why I love Activity Streams" ; as:url <http://example.org/blog/2011/02/entry> . -_:c14n0 as as:Post ; +_:b0 a as:Post ; as:published "2015-02-10T15:04:55Z"^^xsd:dateTime ; as:actor <urn:example:person:martin> ; as:object <urn:example:blog:abc123/xyz> ; diff --git a/tests/examples.js b/tests/examples.js index f89835e..3d1c7d9 100644 --- a/tests/examples.js +++ b/tests/examples.js @@ -8,8 +8,6 @@ function basicCompare(name, done){ new rdf.TurtleParser().parse(helper.getTurtle(name), function(turtle){ new rdf.JsonLdParser().parse(helper.getJsonld(name), function(jsonld){ utils.compareGraph(turtle, jsonld, function(comparison, a, b){ - console.log('turtle /n', a); - console.log('jsonld /n', b); expect(comparison).to.be.true; done(); }); @@ -23,11 +21,11 @@ describe('Minimal Activity', function(){ }); }); -//describe('Basic activity with some additional detail', function(){ - //it('JSON-LD and Turtle should match', function(done){ - //basicCompare('ex2', done); - //}); -//}); +describe('Basic activity with some additional detail', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex2', done); + }); +}); describe('An extended activity', function(){ it('JSON-LD and Turtle should match', function(done){ From d478587dff56786e2911a6b279304ec57798d270 Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Sat, 7 Feb 2015 20:59:05 +0100 Subject: [PATCH 3/9] fixed injecting context for array of contexts --- package.json | 3 +++ tests/helper.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3a08cdf..12f6bac 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,8 @@ "rdf-interfaces": "~0.1.0", "rdf-ext": "~0.1.8", "rdf-test-utils": "~0.1.0" + }, + "dependencies": { + "lodash": "~3.1.0" } } diff --git a/tests/helper.js b/tests/helper.js index 961b9dc..bf90329 100644 --- a/tests/helper.js +++ b/tests/helper.js @@ -1,5 +1,6 @@ var fs = require('fs'); var $ = require('cheerio'); +var _ = require('lodash'); // cache in memory var examples = {}; @@ -20,7 +21,12 @@ var getJsonld = function(name) { if (!examples[name]) { examples[name] = JSON.parse(doc('#' + name + '-jsonld pre.example').text()); // set context - examples[name]['@context'] = getContext()['@context']; + if(examples[name]['@context'] == "http://www.w3.org/ns/activitystreams") { + examples[name]['@context'] = getContext()['@context']; + } else { + var as =_.find(examples[name]['@context'], "http://www.w3.org/ns/activitystreams"); + as = getContext()['@context']; + } } return examples[name]; }; From 564bcfb654f99ebaa0c8142c2c52fe86e2471107 Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Sat, 7 Feb 2015 21:21:11 +0100 Subject: [PATCH 4/9] few more examples pass --- activitystreams2.html | 14 +++++++++----- tests/examples.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/activitystreams2.html b/activitystreams2.html index 6ea9166..19334fa 100644 --- a/activitystreams2.html +++ b/activitystreams2.html @@ -1046,7 +1046,7 @@

Object

as:actor <http://example.org/~sally> ; as:object [ a as:Link ; - as:href <http://example.org/posts/1> . + as:href <http://example.org/posts/1> ] . @@ -1134,7 +1134,7 @@

Object

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix gr: <http://purl.org/goodrelations/v1#> . -_:c14n0 a as:Place, gr:Location ; +_:b0 a as:Place, gr:Location ; as:displayName "Sally's Restaurant" ; as:longitude "12.34"^^xsd:float ; as:latitude "56.78"^^xsd:float ; @@ -1170,6 +1170,8 @@

Natural Language Values

{
+  "@context": "http://www.w3.org/ns/activitystreams",
+  "@type": "Object",
   "displayName": "This is the title"
 }
@@ -1192,7 +1194,7 @@

Natural Language Values

@prefix as: <http://www.w3.org/ns/activitystreams#> .
 
-_:c14n0 a as:Object ;
+_:b0 a as:Object ;
   as:displayName "This is the title" .
@@ -1209,6 +1211,8 @@

Natural Language Values

{
+  "@context": "http://www.w3.org/ns/activitystreams",
+  "@type": "Object",
   "displayNameMap": {
     "en": "This is the title",
     "fr": "C'est le titre",
@@ -1241,10 +1245,10 @@ 

Natural Language Values

@prefix as: <http://www.w3.org/ns/activitystreams#> .
 
-_:c14n0 a as:Object ;
+_:b0 a as:Object ;
   as:displayName "This is the title"@en ;
   as:displayName "C'est le titre"@fr ;
-  as:displayName "Este el el titulo"@sp .
+ as:displayName "Este es el titulo"@sp . diff --git a/tests/examples.js b/tests/examples.js index 3d1c7d9..1c48e35 100644 --- a/tests/examples.js +++ b/tests/examples.js @@ -32,3 +32,33 @@ describe('An extended activity', function(){ basicCompare('ex3', done); }); }); + +describe('Object', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex4', done); + }); +}); + +describe('Object subclass', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex5', done); + }); +}); + +describe('Object with multiple types', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex6', done); + }); +}); + +describe('displayName', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex7', done); + }); +}); + +describe('displayNameMap', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex8', done); + }); +}); From 5bb7a300ea3821b9a6aca56850c5218267fa58fb Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Sat, 7 Feb 2015 23:32:33 +0100 Subject: [PATCH 5/9] turtle fixed till Actor --- activitystreams2.html | 36 +++++++++++++++-------------- tests/examples.js | 53 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/activitystreams2.html b/activitystreams2.html index 19334fa..b27ba43 100644 --- a/activitystreams2.html +++ b/activitystreams2.html @@ -1292,9 +1292,10 @@

Natural Language Values

{
   "@context": [
     "http://www.w3.org/ns/activitystreams",
-    {"@language": "en"}
+    {"@language": "en"}
   ],
-  "displayName": "This is the title"
+  "@type": "Object",
+  "displayName": "This is the title"
 }
@@ -1340,10 +1341,11 @@

Natural Language Values

{
   "@context": "http://www.w3.org/ns/activitystreams",
-  "displayName": {
+  "@type": "Object",
+  "displayName": {
     "@value": "This is the title",
     "@language": "en"
-  }
+  }
 }
@@ -1597,7 +1599,7 @@

Link

as:image [ a as:Link ; as:href <http://example.org/application/123.png> ; - as:mediaType "image/png" . + as:mediaType "image/png" ] . @@ -1681,14 +1683,14 @@

Link

<http://example.org/application/123> a as:Application ; as:displayName "My Application" ; - as:image ( - <http://example.org/application/abc.gif> + as:image + <http://example.org/application/abc.gif> , [ a as:Link ; as:href <http://example.org/application/123.png> ; - as:mediaType "image/png" . - ] - ) . + as:mediaType "image/png" + ] . + @@ -1779,15 +1781,15 @@

Link

<http://example.org/application/123> a as:Application ; as:displayName "My Application" ; - as:image ( - <http://example.org/application/abc.gif> + as:image + <http://example.org/application/abc.gif> , [ a as:Link ; as:href <http://example.org/application/123.png> ; as:mediaType "image/png" ; - as:rel "canonical" . - ] - ) . + as:rel "canonical" + ] . + diff --git a/tests/examples.js b/tests/examples.js index 1c48e35..e43f7cb 100644 --- a/tests/examples.js +++ b/tests/examples.js @@ -4,10 +4,14 @@ var rdf = require('rdf-interfaces'); require('rdf-ext')(rdf); var utils = require('rdf-test-utils')(rdf); +var fs = require('fs'); + function basicCompare(name, done){ new rdf.TurtleParser().parse(helper.getTurtle(name), function(turtle){ new rdf.JsonLdParser().parse(helper.getJsonld(name), function(jsonld){ utils.compareGraph(turtle, jsonld, function(comparison, a, b){ + fs.writeFileSync('turtle.n3', a); + fs.writeFileSync('jsonld.n3', b); expect(comparison).to.be.true; done(); }); @@ -62,3 +66,52 @@ describe('displayNameMap', function(){ basicCompare('ex8', done); }); }); + +describe('default @language', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex9', done); + }); +}); + +describe('specify @language in value object', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex10', done); + }); +}); + +// https://github.com/jasnell/w3c-socialwg-activitystreams/issues/71 +//describe('Excluding a natural language property from the language context', function(){ + //it('JSON-LD and Turtle should match', function(done){ + //basicCompare('ex11', done); + //}); +//}); + +describe('single image', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex12', done); + }); +}); + +describe('Link with mediaType', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex13', done); + }); +}); + +describe('string and Link in array', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex14', done); + }); +}); + +describe('Link rel=canonical', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex15', done); + }); +}); + +describe('Link rel=canonical', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex15', done); + }); +}); From b6806c0a591512c9c0ace251906304993dc7c927 Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Sat, 7 Feb 2015 23:51:35 +0100 Subject: [PATCH 6/9] fixed until Collection --- activitystreams2.html | 17 +++++++++-------- tests/examples.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/activitystreams2.html b/activitystreams2.html index b27ba43..6f857e3 100644 --- a/activitystreams2.html +++ b/activitystreams2.html @@ -1906,14 +1906,15 @@

Actor

</div> @@ -2002,7 +2003,7 @@

Actor

as:actor <acct:sally@example.org> ; as:object [ a as:Note ; - as:content "This is a simple note" . + as:content "This is a simple note" ] . @@ -2103,11 +2104,11 @@

Actor

vcard:given-name "Sally" ; vcard:family-name "Smith" . -_:c14n0 a as:Share ; +_:b0 a as:Share ; as:actor <acct:sally@example.org> ; as:object [ a as:Note ; - as:content "This is a simple note" . + as:content "This is a simple note" ] . @@ -2202,7 +2203,7 @@

Activity

>@prefix as: <http://www.w3.org/ns/activitystreams#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . -_:c14n0 a as:Like ; +<urn:example:activity:1> a as:Like ; as:published "2014-09-30T12:34:56Z"^^xsd:dateTime ; as:actor <http://example.org/profiles/joe> ; as:object <http://example.com/notes/1> . @@ -2288,7 +2289,7 @@

Activity

>@prefix as: <http://www.w3.org/ns/activitystreams#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . -_:c14n0 a as:Like, <http://schema.org/LikeAction>; +<urn:example:activity:1> a as:Like, <http://schema.org/LikeAction>; as:published "2014-09-30T12:34:56Z"^^xsd:dateTime ; as:actor <http://example.org/profiles/joe> ; as:object <http://example.com/notes/1> . diff --git a/tests/examples.js b/tests/examples.js index e43f7cb..b34f445 100644 --- a/tests/examples.js +++ b/tests/examples.js @@ -115,3 +115,33 @@ describe('Link rel=canonical', function(){ basicCompare('ex15', done); }); }); + +describe('An Activity with a Person actor', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex16', done); + }); +}); + +describe('An Activity with a Person actor extended with VCard properties', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex17', done); + }); +}); + +describe('An Actor that is both a Person and a vcard:Individual', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex18', done); + }); +}); + +describe('simple Activity', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex19', done); + }); +}); + +describe('An Activity that is both a Like and a http://schema.org/LikeAction', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex20', done); + }); +}); From f1d58658f5165d07bd2b1277401453da21c869a1 Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Sun, 8 Feb 2015 00:34:26 +0100 Subject: [PATCH 7/9] most turtle examples fixed --- activitystreams2.html | 9 +++++---- tests/examples.js | 44 +++++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/activitystreams2.html b/activitystreams2.html index 6f857e3..30cd22f 100644 --- a/activitystreams2.html +++ b/activitystreams2.html @@ -2520,15 +2520,15 @@

Collection

>@prefix as: <http://www.w3.org/ns/activitystreams#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . -_:c14n0 a as:Collection ; +_:b0 a as:Collection ; as:totalItems "10"^^xsd:nonNegativeInteger ; as:itemsPerPage "1"^^xsd:nonNegativeInteger ; as:next <http://example.org/foo?page=2> ; as:self <http://example.org/foo?page=1> ; as:items [ - a a:Post; + a as:Post; as:actor <urn:example:person:sally> ; - as:object <http://example.org/foo> . + as:object <http://example.org/foo> ] . @@ -2613,6 +2613,7 @@

Collection

diff --git a/tests/examples.js b/tests/examples.js index a5da2e2..048b34c 100644 --- a/tests/examples.js +++ b/tests/examples.js @@ -75,12 +75,11 @@ describe('specify @language in value object', function(){ }); }); -// https://github.com/jasnell/w3c-socialwg-activitystreams/issues/71 -//describe('Excluding a natural language property from the language context', function(){ - //it('JSON-LD and Turtle should match', function(done){ - //basicCompare('ex11', done); - //}); -//}); +describe('Excluding a natural language property from the language context', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex11', done); + }); +}); describe('single image', function(){ it('JSON-LD and Turtle should match', function(done){ From 834516a0596000f43530feb7a2af7d49a5e74d2d Mon Sep 17 00:00:00 2001 From: elf Pavlik Date: Mon, 9 Feb 2015 02:15:05 +0100 Subject: [PATCH 9/9] fixed last example with ordered collection --- activitystreams2.html | 8 ++++---- package.json | 2 +- tests/examples.js | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/activitystreams2.html b/activitystreams2.html index 959a864..e0fd895 100644 --- a/activitystreams2.html +++ b/activitystreams2.html @@ -2614,7 +2614,7 @@

Collection

diff --git a/package.json b/package.json index 12f6bac..4149278 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "mocha": "~2.1.0", "chai": "~1.10.0", "rdf-interfaces": "~0.1.0", - "rdf-ext": "~0.1.8", + "rdf-ext": "~0.1.9", "rdf-test-utils": "~0.1.0" }, "dependencies": { diff --git a/tests/examples.js b/tests/examples.js index 048b34c..9ad8a27 100644 --- a/tests/examples.js +++ b/tests/examples.js @@ -141,11 +141,11 @@ describe('unordered collection with paging', function(){ }); }); -//describe('simple ordered collection with paging', function(){ - //it('JSON-LD and Turtle should match', function(done){ - //basicCompare('ex22', done); - //}); -//}); +describe('simple ordered collection with paging', function(){ + it('JSON-LD and Turtle should match', function(done){ + basicCompare('ex22', done); + }); +}); describe('GeoJSON Point Coordinates', function(){ });