Skip to content

Commit cfbc744

Browse files
author
nicola
committed
Adding suffix to commandLine and setting '.' as default
1 parent 21fb6cf commit cfbc744

5 files changed

Lines changed: 27 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ The command line tool has the following options
8585
-s, --secret HTTP Session secret key (e.g. "your secret phrase")
8686
-s, --no-live Disable live support through WebSockets
8787

88+
8889
## Tests
8990

9091
The tests assume that there is a running ldnode.

‎bin/ldnode.js‎

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

6681
// 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)