-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from solid/attribution-image
Attribution image
- Loading branch information
Showing
18 changed files
with
298 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@prefix : <#> . | ||
@prefix XML: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix as: <https://www.w3.org/ns/activitystreams#> . | ||
@prefix pro: </profile/actor#> . | ||
|
||
:it | ||
a as:Note ; | ||
as:attributedTo pro:me ; | ||
as:content "This is an ActivityStreams Note attributed to an Actor" ; | ||
as:published "2020-08-23T14:26:44+0200"^^XML:dateTime . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@prefix : <#> . | ||
@prefix XML: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix as: <https://www.w3.org/ns/activitystreams#> . | ||
@prefix pro: </profile/foaf#> . | ||
|
||
:it | ||
a as:Note ; | ||
as:attributedTo pro:me ; | ||
as:content "This is an ActivityStreams Note attributed to a FOAF Person" ; | ||
as:published "2020-08-23T14:26:44+0200"^^XML:dateTime . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@prefix : <#> . | ||
@prefix XML: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix as: <https://www.w3.org/ns/activitystreams#> . | ||
@prefix pro: </profile/vcard#> . | ||
|
||
:it | ||
a as:Note ; | ||
as:attributedTo pro:me ; | ||
as:content "This is an ActivityStreams Note attributed to a vcard Individual" ; | ||
as:published "2020-08-23T14:26:44+0200"^^XML:dateTime . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@prefix : <#> . | ||
@prefix as: <https://www.w3.org/ns/activitystreams#> . | ||
|
||
:me | ||
a as:Person ; | ||
as:name "Activity Streams Actor" ; | ||
as:image :image . | ||
|
||
:image | ||
a as:Image; | ||
as:url <https://i.pravatar.cc/300> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@prefix : <#> . | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . | ||
|
||
:me | ||
a foaf:Person ; | ||
foaf:name "A. N. Other" ; | ||
foaf:img <https://i.pravatar.cc/300> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@prefix : <#> . | ||
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . | ||
|
||
:me | ||
a vcard:Individual ; | ||
vcard:fn "A. N. Other" ; | ||
vcard:hasPhoto <https://i.pravatar.cc/300> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { AttributionTag } from "./AttributionTag"; | ||
|
||
describe("AttributionTag", () => { | ||
describe("attribution to person without image", () => { | ||
beforeEach(() => { | ||
render( | ||
<AttributionTag | ||
to={{ | ||
discriminator: "PersonAttribution", | ||
webId: "https://pod.example/person#me", | ||
name: "Jane Doe", | ||
}} | ||
/> | ||
); | ||
}); | ||
|
||
it("renders name", () => { | ||
expect(screen.getByText("Jane Doe")).toBeInTheDocument(); | ||
}); | ||
|
||
it("links name to WebID", () => { | ||
const name = screen.getByText("Jane Doe"); | ||
expect(name).toContainHTML( | ||
'<a href="https://pod.example/person#me">Jane Doe</a>' | ||
); | ||
}); | ||
|
||
it("does not show an image", () => { | ||
expect(screen.queryByAltText("Jane Doe")).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe("attribution to person with image", () => { | ||
beforeEach(() => { | ||
render( | ||
<AttributionTag | ||
to={{ | ||
discriminator: "PersonAttribution", | ||
webId: "https://pod.example/person#me", | ||
name: "Jane Doe", | ||
imageSrc: "https://pod.example/person.png", | ||
}} | ||
/> | ||
); | ||
}); | ||
|
||
it("does show an image", () => { | ||
const element = screen.getByAltText("Jane Doe"); | ||
expect(element.tagName).toEqual("IMG"); | ||
expect(element).toHaveAttribute("src", "https://pod.example/person.png"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { graph, sym } from "rdflib"; | ||
import { readAttribution } from "./attribution"; | ||
import { ns } from "solid-ui"; | ||
|
||
describe("read note attribution", () => { | ||
describe("GIVEN a note attributed to as:Person with image", () => { | ||
let store; | ||
beforeEach(() => { | ||
store = graph(); | ||
store.add( | ||
sym("https://pod.example/note#it"), | ||
ns.as("attributedTo"), | ||
sym("https://pod.example/person#me"), | ||
sym("https://pod.example/note") | ||
); | ||
store.add( | ||
sym("https://pod.example/person#me"), | ||
ns.rdf("type"), | ||
ns.as("Person"), | ||
sym("https://pod.example/person") | ||
); | ||
store.add( | ||
sym("https://pod.example/person#me"), | ||
ns.as("image"), | ||
sym("https://pod.example/person#image"), | ||
sym("https://pod.example/person") | ||
); | ||
store.add( | ||
sym("https://pod.example/person#image"), | ||
ns.as("url"), | ||
sym("https://pod.example/person.png"), | ||
sym("https://pod.example/person") | ||
); | ||
}); | ||
describe("WHEN trying to read the attribution", () => { | ||
let attribution; | ||
beforeEach(() => { | ||
attribution = readAttribution( | ||
sym("https://pod.example/note#it"), | ||
store | ||
); | ||
}); | ||
it("THEN the note attributes to the person with image", () => { | ||
expect(attribution.imageSrc).toEqual("https://pod.example/person.png"); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("GIVEN a note attributed to foaf:Person with img", () => { | ||
let store; | ||
beforeEach(() => { | ||
store = graph(); | ||
store.add( | ||
sym("https://pod.example/note#it"), | ||
ns.as("attributedTo"), | ||
sym("https://pod.example/person#me"), | ||
sym("https://pod.example/note") | ||
); | ||
store.add( | ||
sym("https://pod.example/person#me"), | ||
ns.rdf("type"), | ||
ns.foaf("Person"), | ||
sym("https://pod.example/person") | ||
); | ||
store.add( | ||
sym("https://pod.example/person#me"), | ||
ns.foaf("img"), | ||
sym("https://pod.example/person.png"), | ||
sym("https://pod.example/person") | ||
); | ||
}); | ||
describe("WHEN trying to read the attribution", () => { | ||
let attribution; | ||
beforeEach(() => { | ||
attribution = readAttribution( | ||
sym("https://pod.example/note#it"), | ||
store | ||
); | ||
}); | ||
it("THEN the note attributes to the person with image", () => { | ||
expect(attribution.imageSrc).toEqual("https://pod.example/person.png"); | ||
}); | ||
}); | ||
}); | ||
describe("GIVEN a note attributed to vcard:Individual that hasPhoto", () => { | ||
let store; | ||
beforeEach(() => { | ||
store = graph(); | ||
store.add( | ||
sym("https://pod.example/note#it"), | ||
ns.as("attributedTo"), | ||
sym("https://pod.example/person#me"), | ||
sym("https://pod.example/note") | ||
); | ||
store.add( | ||
sym("https://pod.example/person#me"), | ||
ns.rdf("type"), | ||
ns.vcard("Individual"), | ||
sym("https://pod.example/person") | ||
); | ||
store.add( | ||
sym("https://pod.example/person#me"), | ||
ns.vcard("hasPhoto"), | ||
sym("https://pod.example/person.png"), | ||
sym("https://pod.example/person") | ||
); | ||
}); | ||
describe("WHEN trying to read the attribution", () => { | ||
let attribution; | ||
beforeEach(() => { | ||
attribution = readAttribution( | ||
sym("https://pod.example/note#it"), | ||
store | ||
); | ||
}); | ||
it("THEN the note attributes to the person with image", () => { | ||
expect(attribution.imageSrc).toEqual("https://pod.example/person.png"); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.