Skip to content

Commit 38246cc

Browse files
author
Nicola Greco
committed
Merge pull request #56 from nicola/suffix
Adding suffix to commandLine and setting '.' as default
2 parents 31be762 + 732ef4a commit 38246cc

6 files changed

Lines changed: 47 additions & 29 deletions

File tree

‎README.md‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,25 @@ $ ldnode -v
7070

7171
The command line tool has the following options
7272

73-
Usage: ldnode [options]
74-
75-
Options:
76-
-v, --verbose Print the logs to console
77-
--version Print current ldnode version
78-
-u, --uri Default address of the server (e.g. http[s]://host:port/path)
79-
-b, --base Base location to serve resources
80-
-p, --port Port to use
81-
-c, --cache Set cache time (in seconds), 0 for no cache
82-
-K, --key Path to the ssl key
83-
-C, --cert Path to the ssl cert
84-
--webid Enable WebID+TLS authentication
85-
-s, --secret HTTP Session secret key (e.g. "your secret phrase")
86-
--no-live Disable live support through WebSockets
73+
```
74+
Usage: ldnode [options]
75+
76+
Options:
77+
-v, --verbose Print the logs to console
78+
--version Print current ldnode version
79+
-u, --uri Default address of the server (e.g. http[s]://host:port/path)
80+
-b, --base Base location to serve resources
81+
-p, --port Port to use
82+
-c, --cache Set cache time (in seconds), 0 for no cache
83+
-K, --key Path to the ssl key
84+
-C, --cert Path to the ssl cert
85+
--webid Enable WebID+TLS authentication
86+
-s, --secret HTTP Session secret key (e.g. "your secret phrase")
87+
--no-live Disable live support through WebSockets
88+
-sA, --suffix-acl Suffix for acl files (default: '.acl')
89+
-sC, --suffix-changes Suffix for acl files (default: '.changes')
90+
-sE, --suffix-sse Suffix for SSE files (default: '.events')
91+
```
8792

8893
## Tests
8994

‎acl.js‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ var file = require('./fileStore.js');
1313
var ns = require('./vocab/ns.js').ns;
1414
var rdfVocab = require('./vocab/rdf.js');
1515

16-
var aclExtension = ".acl";
17-
1816
function allow(mode, req, res) {
1917
var options = req.app.locals.ldp;
2018
var origin = req.get('origin');
@@ -35,8 +33,8 @@ function allow(mode, req, res) {
3533
}
3634

3735
for (var i = 0; i < depth.length; i++) {
38-
var pathAcl = S(filepath).endsWith(aclExtension) ?
39-
filepath : filepath + aclExtension;
36+
var pathAcl = S(filepath).endsWith(options.suffixAcl) ?
37+
filepath : filepath + options.suffixAcl;
4038
var pathUri = file.filenameToBaseUri(filepath, options.uri, options.base);
4139
relativePath = path.relative(options.base, filepath);
4240

‎bin/ldnode.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ var argv = require('nomnom')
6060
help: 'Disable live support through WebSockets',
6161
flag: true
6262
})
63+
.option('suffixAcl', {
64+
full: 'suffix-acl',
65+
help: 'Suffix for acl files (default: \'.acl\')',
66+
abbr: 'sA'
67+
})
68+
.option('suffixChanges', {
69+
full: 'suffix-changes',
70+
help: 'Suffix for acl files (default: \'.changes\')',
71+
abbr: 'sC'
72+
})
73+
.option('suffixSSE', {
74+
full: 'suffix-sse',
75+
help: 'Suffix for SSE files (default: \'.events\')',
76+
abbr: 'sE'
77+
})
6378
.parse();
6479

6580
// Print version and leave

‎handlers/get.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ function get(req, res, includeBody) {
2424
var options = req.app.locals.ldp;
2525

2626
// Add request to subscription service
27-
if (('' + req.path).slice(-options.changesSuffix.length) ===
28-
options.changesSuffix) {
27+
if (('' + req.path).slice(-options.suffixChanges.length) ===
28+
options.suffixChanges) {
2929
debug("GET -- Subscribed to ", req.path);
3030
return subscription.subscribeToChanges(req, res);
3131
}
@@ -34,10 +34,10 @@ function get(req, res, includeBody) {
3434
if (options.live) {
3535
// Note not yet in
3636
// http://www.iana.org/assignments/link-relations/link-relations.xhtml
37-
header.addLink(res, req.path + options.changesSuffix, 'changes');
38-
// res.header('Link' , '' + req.path + options.SSESuffix + ' ; rel=events' );
37+
header.addLink(res, req.path + options.suffixChanges, 'changes');
38+
// res.header('Link' , '' + req.path + options.suffixSSE + ' ; rel=events' );
3939
// overwrites the pevious
40-
res.header('Updates-Via', '' + req.path + options.changesSuffix);
40+
res.header('Updates-Via', '' + req.path + options.suffixChanges);
4141
}
4242

4343
if (includeBody) {

‎options.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ function params(argv) {
2727

2828
// Processed
2929
opts.leavePatchConnectionOpen = false;
30-
opts.aclSuffix = argv.aclSuffix || ",acl";
30+
opts.suffixAcl = argv.suffixAcl || ".acl";
31+
opts.suffixChanges = argv.suffixChanges || '.changes';
32+
opts.suffixSSE = argv.suffixSSE || '.events';
3133

3234
if (!(S(opts.base).endsWith('/'))) {
3335
opts.base += '/';
3436
}
35-
opts.changesSuffix = argv.changesSuffix || ',changes';
36-
opts.SSESuffix = argv.SSESuffix || ',events';
3737

3838
opts.pathStart = '/' +
3939
opts.uri

‎subscription.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports.subscribeToChanges_SSE = function(req, res) {
1717

1818
var messageCount;
1919
debug("Server Side Events subscription");
20-
var targetPath = req.path.slice(0, - options.changesSuffix.length); // lop off ',events'
20+
var targetPath = req.path.slice(0, - options.suffixChanges.length); // lop off ',events'
2121
if (SSEsubscriptions[targetPath] === undefined) {
2222
SSEsubscriptions[targetPath] = redis.createClient();
2323
}
@@ -61,7 +61,7 @@ exports.subscribeToChanges_SSE = function(req, res) {
6161
exports.publishDelta_SSE = function (req, res, patchKB, targetURI){
6262
// @@ TODO
6363
var options = req.app.locals.ldp;
64-
var targetPath = req.path.slice(0, - options.changesSuffix.length); // lop off ',changes'
64+
var targetPath = req.path.slice(0, - options.suffixChanges.length); // lop off ',changes'
6565
var publisherClient = SSEsubscriptions[targetPath];
6666
publisherClient.publish( 'updates', ('"' + targetPath + '" data changed visited') );
6767
};
@@ -74,7 +74,7 @@ var DelayedResponse = require('http-delayed-response');
7474

7575
exports.subscribeToChangesLongPoll = function(req, res) {
7676
var options = req.app.locals.ldp;
77-
var targetPath = req.path.slice(0, - options.changesSuffix.length); // lop off ',changes'
77+
var targetPath = req.path.slice(0, - options.suffixChanges.length); // lop off ',changes'
7878
if (subscriptions[targetPath] === undefined) {
7979
subscriptions[targetPath] = [];
8080
}

0 commit comments

Comments
 (0)