Skip to content

Commit 182e90d

Browse files
committed
solving and cleaning little TODOs
1 parent 530f749 commit 182e90d

3 files changed

Lines changed: 17 additions & 21 deletions

File tree

acl.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*jslint node: true*/
22
/*jshint loopfunc:true */
33
"use strict";
4-
5-
var fs = require('fs');
64
var glob = require('glob');
75
var path = require('path');
86
var $rdf = require('rdflib');
@@ -154,12 +152,15 @@ ACL.prototype.findACL = function(mode, address, userId, callback) {
154152
return done(true);
155153
}
156154

157-
// Set the new path for the next loop iteration
158-
accessType = "defaultForNew";
155+
// if we have iterated through all the relativePaths
156+
// and it is not the first iteration
159157
if (relativePath.length === 0 && i !== 0) {
160-
// TODO handle this error
161158
return done(true);
162-
} else if (path.dirname(path.dirname(relativePath)) === '.') {
159+
}
160+
161+
// Set the new path for the next loop iteration
162+
accessType = "defaultForNew";
163+
if (path.dirname(path.dirname(relativePath)) === '.') {
163164
filepath = ldp.root;
164165
} else {
165166
filepath = ldp.root + path.dirname(relativePath);
@@ -382,13 +383,12 @@ ACL.prototype.fetchDocument = function(uri, callback) {
382383
return cb(null, '');
383384
}
384385

385-
return fs.readFile(documentPath, {encoding: 'utf8'}, cb);
386+
return ldp.readFile(documentPath, cb);
386387
});
387388
},
388389
function (body, cb) {
389390
try {
390391
$rdf.parse(body, graph, uri, 'text/turtle');
391-
// TODO, check what to return
392392
return cb(null, graph);
393393
} catch(err) {
394394
return cb(err, graph);

handlers/get.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ function get(req, res, includeBody) {
5252
}
5353

5454
var filename = file.uriToFilename(req.path, ldp.root);
55-
var baseUri = file.uriBase(req);
5655

5756
var aclLink = file.getResourceLink(
58-
filename, baseUri,
57+
filename, uri,
5958
ldp.root, ldp.suffixAcl,
6059
metaExtension);
6160

6261
var metaLink = file.getResourceLink(
63-
filename, baseUri,
62+
filename, uri,
6463
ldp.root, metaExtension,
6564
ldp.suffixAcl);
6665

6766
header.addLink(res, aclLink, 'acl');
6867
header.addLink(res, metaLink, 'describedBy');
6968

69+
// Get resource or container
7070
ldp.get(filename, uri, includeBody, function(err, data, container) {
7171

7272
// This should be implemented in LDP.prototype.get
@@ -75,6 +75,7 @@ function get(req, res, includeBody) {
7575
return globHandler(req, res);
7676
}
7777

78+
7879
if (err) {
7980
debug('GET/HEAD -- Read error: ' + err);
8081
return res
@@ -112,9 +113,7 @@ function get(req, res, includeBody) {
112113
// TODO this should be added as a middleware in the routes
113114
res.locals.turtleData = data;
114115
return parseLinkedData(req, res);
115-
116116
});
117-
118117
}
119118

120119
function globHandler(req, res) {
@@ -180,8 +179,6 @@ function aclAllow(match, req, res, callback) {
180179
}
181180

182181
var relativePath = '/' + path.relative(ldp.root, match);
183-
184-
// TODO find a better hack, maybe pass as a param?
185182
res.locals.path = relativePath;
186183
acl.allow("Read", req, res, function(err) {
187184
callback(!err);
@@ -218,6 +215,7 @@ function parseLinkedData(req, res) {
218215
.send(err);
219216
}
220217

218+
// Graph to `accept` type
221219
$rdf.serialize(undefined, resourceGraph, null, accept, function(err, result) {
222220
if (result === undefined || err) {
223221
debug("GET/HEAD -- Serialization error: " + err);

ldp.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function LDP(argv) {
5656
ldp.xssProxy = argv.xssProxy;
5757
ldp.proxyFilter = regexp().start(ldp.xssProxy).toRegExp();
5858

59-
// TODO this should be an attribute of an object
59+
// Cache of usedURIs
6060
ldp.usedURIs = {};
6161

6262
debug.settings("mount: " + ldp.mount);
@@ -225,19 +225,18 @@ LDP.prototype.listContainer = function (filename, uri, containerData, callback)
225225
}
226226
],
227227
function (err, data) {
228+
var turtleData;
228229
try {
229-
var turtleData = $rdf.serialize(
230+
turtleData = $rdf.serialize(
230231
undefined,
231232
resourceGraph,
232233
null,
233234
'text/turtle');
234-
235-
// TODO dont forget to parseLinkedData
236-
return callback(null, turtleData);
237235
} catch (parseErr) {
238236
debug.handlers("GET/HEAD -- Error serializing container: " + parseErr);
239237
return callback({status: 500, message: parseErr});
240238
}
239+
return callback(null, turtleData);
241240
});
242241
};
243242

@@ -383,7 +382,6 @@ LDP.prototype.releaseResourceUri = function (uri) {
383382
LDP.prototype.createNewResource = function(uri, resourcePath, resourceGraph, callback) {
384383
var ldp = this;
385384
var resourceURI = path.relative(ldp.root, resourcePath);
386-
//TODO write files with relative URIS.
387385
var rawResource = $rdf.serialize(
388386
undefined,
389387
resourceGraph,

0 commit comments

Comments
 (0)