Skip to content

Commit

Permalink
Add pim:Storage and solid:owner
Browse files Browse the repository at this point in the history
  • Loading branch information
csarven committed Jun 4, 2021
1 parent 69920d9 commit 067750e
Show file tree
Hide file tree
Showing 2 changed files with 1,669 additions and 486 deletions.
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function config(configFile){
config['maxResourceCount'] = config.maxResourceCount || 100;
config['maxMemberCount'] = config.maxMemberCount || 10;
config['proxyPath'] = config.proxyPath || '/proxy';
config['owners'] = config.owners || '';

var createDirectories = [config['inboxPath'], config['queuePath'], config['annotationPath'], config['reportsPath']];
createDirectories.forEach(function(path){ if(!fs.existsSync(path)){ fs.mkdirSync(path); } });
Expand Down Expand Up @@ -315,6 +316,14 @@ console.log(config);
var qPosition = req.originalUrl.indexOf('?');
req.requestedPath = (qPosition > -1) ? config.rootPath + req.originalUrl.substr(0, qPosition) : config.rootPath + req.originalUrl;

if(config.owners.length > 0) {
var lHfV = [];
config.owners.forEach(function(i){
lHfV.push('<' + i + '>; rel="http://www.w3.org/ns/solid/terms#owner"');
});
req.linkHeaderFieldValueOwners = lHfV.join(', ');
}

// console.log(req);
// console.log(res);

Expand All @@ -329,6 +338,7 @@ console.log(config);
// console.log('req.url: ' + req.url);
// console.log('req.getUrl: ' + req.getUrl());
// console.log('requestedPath: ' + req.requestedPath);
// console.log('linkHeaderFieldValueOwners: ' + req.linkHeaderFieldValueOwners)
return next();
});

Expand Down Expand Up @@ -1356,6 +1366,17 @@ function handleResource(req, res, next, options){
parameterProfile = ';profile="'+profile+'"';
}

var rootURL = req.getRootUrl() + '/'
var requestedURL = req.getUrl()

if(rootURL === requestedURL) {
res.set('Link', '<http://www.w3.org/ns/pim/space#Storage>; rel="type"')

if(config.owners.length > 0) {
res.set('Link', req.linkHeaderFieldValueOwners)
}
}

// console.log(res)
res.set('Link', '<http://www.w3.org/ns/ldp#Resource>; rel="type", <http://www.w3.org/ns/ldp#RDFSource>; rel="type", <http://www.w3.org/ns/ldp#Container>; rel="type", <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"');
res.set('Content-Type', req.requestedType + parameterProfile + ';charset=utf-8');
Expand Down
Loading

0 comments on commit 067750e

Please sign in to comment.