Skip to content

Commit 693e7a1

Browse files
bourgeoajeff-zuckerTallTedtimea-solidcsarven
authored
add space:Storage (#1632)
* Update index.html * Update default-templates/server/index.html Co-authored-by: Ted Thibodeau Jr <[email protected]> * lint * redirect for Login to serverRoot * Update default-templates/server/index.html Co-authored-by: Timea <[email protected]> * Update default-templates/server/index.html Co-authored-by: Timea <[email protected]> * Update default-templates/server/index.html Co-authored-by: Timea <[email protected]> * Update default-templates/server/index.html Co-authored-by: Timea <[email protected]> * Update default-views/account/register-form.hbs Co-authored-by: Timea <[email protected]> * Update default-templates/server/index.html Co-authored-by: Timea <[email protected]> * add space:Storage * use storage * update to class Storage Co-authored-by: Sarven Capadisli <[email protected]> * update to class Storage lib/header.js Co-authored-by: Sarven Capadisli <[email protected]> * Update update to class Storage lib/header.js Co-authored-by: Sarven Capadisli <[email protected]> * update linksHandler() and add tests Co-authored-by: Jeff Zucker <[email protected]> Co-authored-by: Ted Thibodeau Jr <[email protected]> Co-authored-by: Timea <[email protected]> Co-authored-by: Sarven Capadisli <[email protected]>
1 parent ac59676 commit 693e7a1

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

lib/header.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ function addLinks (res, fileMetadata) {
3939
if (fileMetadata.isDirectContainer) {
4040
addLink(res, 'http://www.w3.org/ns/ldp#DirectContainer', 'type')
4141
}
42+
if (fileMetadata.isStorage) {
43+
addLink(res, 'http://www.w3.org/ns/pim/space#Storage', 'type')
44+
}
4245
}
4346

4447
async function linksHandler (req, res, next) {
@@ -64,6 +67,7 @@ async function linksHandler (req, res, next) {
6467
}
6568
const fileMetadata = new metadata.Metadata()
6669
if (filename.endsWith('/')) {
70+
if (req.path === '/') fileMetadata.isStorage = true
6771
fileMetadata.isContainer = true
6872
fileMetadata.isBasicContainer = true
6973
} else {
@@ -102,6 +106,8 @@ function parseMetadataFromHeader (linkHeader) {
102106
fileMetadata.isBasicContainer = true
103107
} else if (parsedLinks[rel] === 'http://www.w3.org/ns/ldp#DirectContainer') {
104108
fileMetadata.isDirectContainer = true
109+
} else if (parsedLinks[rel] === 'http://www.w3.org/ns/pim/space#Storage') {
110+
fileMetadata.isStorage = true
105111
}
106112
}
107113
}

lib/ldp-container.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ const path = require('path')
1414
async function addContainerStats (ldp, reqUri, filename, resourceGraph) {
1515
const containerStats = await ldp.stat(filename)
1616
addStats(resourceGraph, reqUri, containerStats, filename)
17+
const storage = new URL(reqUri)
18+
if (reqUri === storage.origin + '/') {
19+
resourceGraph.add(
20+
resourceGraph.sym(reqUri),
21+
ns.rdf('type'),
22+
ns.space('Storage')
23+
)
24+
}
1725
resourceGraph.add(
1826
resourceGraph.sym(reqUri),
1927
ns.rdf('type'),

lib/ldp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class LDP {
108108
$rdf.parse(containerData, resourceGraph, reqUri, 'text/turtle')
109109
} catch (err) {
110110
debug.handlers('GET -- Error parsing data: ' + err)
111-
throw error(500, "Can't parse container")
111+
throw error(500, "Can't parse container .meta")
112112
}
113113

114114
try {

lib/metadata.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ function Metadata () {
77
this.isContainer = false
88
this.isBasicContainer = false
99
this.isDirectContainer = false
10+
this.isStorage = false
1011
}

test/integration/http-test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ describe('HTTP APIs', function () {
7676
.expect('content-type', /text\/turtle/)
7777
.expect(200, done)
7878
})
79+
it('should contain space:Storage triple', function (done) {
80+
server.get('/')
81+
.expect('content-type', /text\/turtle/)
82+
.expect(200, done)
83+
.expect((res) => {
84+
const turtle = res.text
85+
assert.match(turtle, /space:Storage/)
86+
const kb = rdf.graph()
87+
rdf.parse(turtle, kb, 'https://localhost/', 'text/turtle')
88+
89+
assert(kb.match(undefined,
90+
rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
91+
rdf.namedNode('http://www.w3.org/ns/pim/space#Storage')
92+
).length, 'Must contain a triple space:Storage')
93+
})
94+
})
95+
it('should have set Link as Container/BasicContainer/Storage', function (done) {
96+
server.get('/')
97+
.expect('content-type', /text\/turtle/)
98+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#BasicContainer>; rel="type"/)
99+
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Container>; rel="type"/)
100+
.expect('Link', /<http:\/\/www.w3.org\/ns\/pim\/space#Storage>; rel="type"/)
101+
.expect(200, done)
102+
})
79103
})
80104

81105
describe('OPTIONS API', function () {

0 commit comments

Comments
 (0)