Skip to content

Specify uri from data in pos-rich-link #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed

- `Thing.reverseRelations()`: Now takes optional predicate to filter by

## 0.17.0

### Changed
Expand Down
25 changes: 25 additions & 0 deletions core/src/thing/Thing.reverseRelations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,30 @@ describe("Thing", function () {
},
]);
});

it("only follows the given predicate if provided", () => {
const store = graph();
const uri = "https://jane.doe.example/container/file.ttl#fragment";
store.add(
sym("https://pod.example/first"),
sym("http://vocab.test/first"),

sym(uri),
);
store.add(
sym("https://pod.example/second"),
sym("http://vocab.test/second"),
sym(uri),
);
const it = new Thing(uri, store);
const result = it.reverseRelations("http://vocab.test/first");
expect(result).toEqual([
{
predicate: "http://vocab.test/first",
label: "first",
uris: ["https://pod.example/first"],
},
]);
});
});
});
4 changes: 2 additions & 2 deletions core/src/thing/Thing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export class Thing {
}));
}

reverseRelations(): Relation[] {
reverseRelations(predicate?: string): Relation[] {
const statements = this.store.statementsMatching(
undefined,
undefined,
predicate ? sym(predicate) : null,
sym(this.uri),
);

Expand Down
10 changes: 5 additions & 5 deletions docs/elements/apps/pos-app-browser/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ------------------------ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | -------------- |
| `mode` | `mode` | The mode the app is running in: - standalone: use this when you deploy it as a standalone web application - pod: use this when you host this app as a default interface for you pod | `"pod" \| "standalone"` | `'standalone'` |
| `restorePreviousSession` | `restore-previous-session` | | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ------------------------ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- | -------------- |
| `mode` | `mode` | The mode the app is running in: - standalone: use this when you deploy it as a standalone web application - pod: use this when you host this app as a default interface for you pod | `"pod" \| "standalone"` | `'standalone'` |
| `restorePreviousSession` | `restore-previous-session` | | `boolean` | `false` |


## Dependencies
Expand Down Expand Up @@ -55,9 +55,9 @@ graph TD;
pos-make-findable --> pos-label
pos-resource --> ion-progress-bar
ion-searchbar --> ion-icon
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-login --> pos-resource
pos-login --> pos-picture
pos-login --> pos-label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
```mermaid
graph TD;
pos-example-resources --> pos-rich-link
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-app-dashboard --> pos-example-resources
style pos-example-resources fill:#f9f,stroke:#333,stroke-width:4px
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/apps/pos-app-dashboard/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ graph TD;
pos-app-dashboard --> pos-getting-started
pos-app-dashboard --> pos-example-resources
pos-example-resources --> pos-rich-link
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-internal-router --> pos-app-dashboard
style pos-app-dashboard fill:#f9f,stroke:#333,stroke-width:4px
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/apps/pos-app-generic/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ graph TD;
pos-add-literal-value --> pos-select-term
pos-relations --> pos-predicate
pos-relations --> pos-rich-link
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-reverse-relations --> pos-predicate
pos-reverse-relations --> pos-rich-link
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/apps/pos-app-ldp-container/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ graph TD;
pos-resource --> ion-progress-bar
pos-container-item --> ion-icon
pos-subjects --> pos-rich-link
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-type-badges --> ion-badge
pos-type-badges --> ion-icon
pos-literals --> pos-predicate
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/apps/pos-app-rdf-document/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ graph TD;
pos-app-rdf-document --> pos-type-badges
pos-app-rdf-document --> pos-literals
pos-subjects --> pos-rich-link
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-type-badges --> ion-badge
pos-type-badges --> ion-icon
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/components/pos-internal-router/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ graph TD;
pos-app-dashboard --> pos-getting-started
pos-app-dashboard --> pos-example-resources
pos-example-resources --> pos-rich-link
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-app-browser --> pos-internal-router
style pos-internal-router fill:#f9f,stroke:#333,stroke-width:4px
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/components/pos-navigation-bar/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ graph TD;
pos-make-findable --> pos-label
pos-resource --> ion-progress-bar
ion-searchbar --> ion-icon
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-app-browser --> pos-navigation-bar
style pos-navigation-bar fill:#f9f,stroke:#333,stroke-width:4px
```
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/components/pos-relations/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ graph TD;
pos-relations --> pos-predicate
pos-relations --> pos-rich-link
pos-predicate --> ion-icon
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-app-generic --> pos-relations
style pos-relations fill:#f9f,stroke:#333,stroke-width:4px
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/components/pos-reverse-relations/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ graph TD;
pos-reverse-relations --> pos-predicate
pos-reverse-relations --> pos-rich-link
pos-predicate --> ion-icon
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-app-generic --> pos-reverse-relations
style pos-reverse-relations fill:#f9f,stroke:#333,stroke-width:4px
Expand Down
20 changes: 12 additions & 8 deletions docs/elements/components/pos-rich-link/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@

## Properties

| Property | Attribute | Description | Type | Default |
| -------- | --------- | ----------- | -------- | ----------- |
| `uri` | `uri` | | `string` | `undefined` |
| Property | Attribute | Description | Type | Default |
| -------- | --------- | ----------------------------------------------------------------------------------------- | -------- | ----------- |
| `rel` | `rel` | Link will be obtained by following the predicate with this URI forward from a resource | `string` | `undefined` |
| `rev` | `rev` | Link will be obtained by following the predicate with this URI in reverse from a resource | `string` | `undefined` |
| `uri` | `uri` | Link will use this URI | `string` | `undefined` |


## Events

| Event | Description | Type |
| ------------- | ----------- | ------------------ |
| `pod-os:link` | | `CustomEvent<any>` |
| Event | Description | Type |
| ----------------- | ----------- | ------------------ |
| `pod-os:error` | | `CustomEvent<any>` |
| `pod-os:link` | | `CustomEvent<any>` |
| `pod-os:resource` | | `CustomEvent<any>` |


## Dependencies
Expand All @@ -31,16 +35,16 @@

### Depends on

- [pos-resource](../pos-resource)
- [pos-label](../pos-label)
- [pos-description](../pos-description)
- [pos-resource](../pos-resource)

### Graph
```mermaid
graph TD;
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-example-resources --> pos-rich-link
pos-navigation-bar --> pos-rich-link
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/components/pos-subjects/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
```mermaid
graph TD;
pos-subjects --> pos-rich-link
pos-rich-link --> pos-resource
pos-rich-link --> pos-label
pos-rich-link --> pos-description
pos-rich-link --> pos-resource
pos-resource --> ion-progress-bar
pos-app-ldp-container --> pos-subjects
pos-app-rdf-document --> pos-subjects
Expand Down
6 changes: 6 additions & 0 deletions elements/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

### Changed

- [pos-rich-link](../docs/elements/components/pos-rich-link):
- can now receive a resource to use for the link
- can now follow `rel` and `rev` to discover a resource to use for the link

### Fixed

- [pos-app-browser](../docs/elements/apps/pos-app-browser): prevent error message flashing up while uri is unset on hard refresh
Expand Down
28 changes: 27 additions & 1 deletion elements/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,18 @@ export namespace Components {
interface PosReverseRelations {
}
interface PosRichLink {
"uri": string;
/**
* Link will be obtained by following the predicate with this URI forward from a resource
*/
"rel"?: string;
/**
* Link will be obtained by following the predicate with this URI in reverse from a resource
*/
"rev"?: string;
/**
* Link will use this URI
*/
"uri"?: string;
}
/**
* The responsibility of pos-router is to handle the `uri` query param, that specifies the URI of the resource that is currently opened.
Expand Down Expand Up @@ -724,6 +735,8 @@ declare global {
};
interface HTMLPosRichLinkElementEventMap {
"pod-os:link": any;
"pod-os:resource": any;
"pod-os:error": any;
}
interface HTMLPosRichLinkElement extends Components.PosRichLink, HTMLStencilElement {
addEventListener<K extends keyof HTMLPosRichLinkElementEventMap>(type: K, listener: (this: HTMLPosRichLinkElement, ev: PosRichLinkCustomEvent<HTMLPosRichLinkElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
Expand Down Expand Up @@ -1066,7 +1079,20 @@ declare namespace LocalJSX {
"onPod-os:resource"?: (event: PosReverseRelationsCustomEvent<any>) => void;
}
interface PosRichLink {
"onPod-os:error"?: (event: PosRichLinkCustomEvent<any>) => void;
"onPod-os:link"?: (event: PosRichLinkCustomEvent<any>) => void;
"onPod-os:resource"?: (event: PosRichLinkCustomEvent<any>) => void;
/**
* Link will be obtained by following the predicate with this URI forward from a resource
*/
"rel"?: string;
/**
* Link will be obtained by following the predicate with this URI in reverse from a resource
*/
"rev"?: string;
/**
* Link will use this URI
*/
"uri"?: string;
}
/**
Expand Down
Loading