Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.
Merged
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
3 changes: 2 additions & 1 deletion generators/app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
"@hocs": "./src/hocs",
"@utils": "./src/utils",
"@hooks": "./src/hooks",
"@constants": "./src/constants"
"@constants": "./src/constants",
"@vocabs": "./src/vocabs"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
notification as helperNotification
} from '@utils';
import { GameStatusList, GameStatus, KnownInboxes } from '@constants';
import { LDP } from '@vocabs';
import { Wrapper, ListWrapper, GameListContainers, GameListHeader } from './list.style';
import GameItem from './children';

Expand Down Expand Up @@ -187,10 +188,28 @@ const List = ({ webId, gamePath, sendNotification }: Props) => {
const getGames = useCallback(
async url => {
try {
let gameItemPredicate;
const document = await ldflexHelper.fetchLdflexDocument(url);
let gameList = [];
if (!document) return gameList;
for await (const item of document['schema:hasPart']) {

const type = await document['rdf:type'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these strings (schema:hasPart too) to a const value.

const typeValue = type ? type.value : undefined;

/**
* If the document is a container, then we want to loop over the ldp:contains property of the container
* If it is not a container, we are using schema:hasPart so we don't confuse it with a container
* schema:hasPart is used for externally linked games in other people's pods
*/
if (typeValue === LDP.BASICCONTAINER) {
gameItemPredicate = 'ldp:contains';
} else {
gameItemPredicate = 'schema:hasPart';
}

for await (const item of document[gameItemPredicate]) {
// TODO: Add SHEX Validation here instead of checking manually for filenames and types

const { value } = item;
if (
value.includes('.ttl') &&
Expand Down
3 changes: 3 additions & 0 deletions generators/app/templates/src/vocabs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { LDP } from './predicates';

export { LDP };
7 changes: 7 additions & 0 deletions generators/app/templates/src/vocabs/predicates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Object containing a reference to the UI ontology's IRIs
*/
const ldpBase = 'http://www.w3.org/ns/ldp#';
export const LDP = {
BASICCONTAINER: `${ldpBase}BasicContainer`
};