From c2a1b9b430c180edeefc3110d4d196e9d96f7f27 Mon Sep 17 00:00:00 2001 From: Shane Burgess Date: Fri, 2 Oct 2015 01:07:58 -0700 Subject: [PATCH 1/6] datapoint.js allow punct chars in data values Relaxed sanitization for data values to permit period, space, and colon characters. --- src/datapoint.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/datapoint.js b/src/datapoint.js index a03b712..360f59f 100644 --- a/src/datapoint.js +++ b/src/datapoint.js @@ -3,7 +3,7 @@ var _ = require('underscore'); var spaceRegex = /[^A-Za-z0-9_\-]*/ var nameRegex = /[^A-Za-z0-9_\-]*/ -var valueRegex = /[^A-Za-z0-9_\-]*/ +var valueRegex = /[^A-Za-z0-9_\-\.: ]*/ var Datapoint = { @@ -197,7 +197,7 @@ var Datapoint = { }); }, - // get the last 100 data points + // get a set of data points, starting at 'offset' and returning 'limit' number of points history: function(redis, space, name, offset, limit, cb) { var flow = []; var context = {}; @@ -228,4 +228,4 @@ var Datapoint = { } } -module.exports = Datapoint; \ No newline at end of file +module.exports = Datapoint; From 2fdd27f3f44521c964cb64a561048fb987189bba Mon Sep 17 00:00:00 2001 From: Shane Burgess Date: Fri, 2 Oct 2015 01:15:44 -0700 Subject: [PATCH 2/6] Updated routes.js for new isVhsOpen.com features Added URI matching for dual-dataname query for fullpage, which uses template 'data-dual-full'. path: '/s/{spacename}/data/{dataname1}/{dataname2}/fullpage' --- src/routes.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/routes.js b/src/routes.js index e71148d..129b008 100644 --- a/src/routes.js +++ b/src/routes.js @@ -191,6 +191,38 @@ server.route({ } }); +// a basic page showing two datapoints in a style designed for isvhsopen.com +server.route({ + method: 'GET', + path: '/s/{spacename}/data/{dataname1}/{dataname2}/fullpage', + handler: function(request, reply) { + var redisClient = request.server.plugins['hapi-redis'].client; + Datapoint.get(redisClient, request.params.spacename, request.params.dataname1, function(err, data1) { + if (err) { + request.log.error(err); + reply(404); + } else { + Datapoint.get(redisClient, request.params.spacename, request.params.dataname2, function(err, data2) { + if (err) { + request.log.error(err); + reply(404); + } else { + var renderContext = { + datapoint1: data1, + datapoint2: data2, + space: {name: "vhs"} + }; + server.render("data-full", renderContext, {}, function(err, rendered) { + if (err) return reply(err); + reply(rendered); + }); + } + }); + } + }); + } +}); + // a verbose page about the datavalue server.route({ method: 'GET', From ea6a030b86d7311b3ba4486aa223581a4d520642 Mon Sep 17 00:00:00 2001 From: Shane Burgess Date: Fri, 2 Oct 2015 01:30:23 -0700 Subject: [PATCH 3/6] Create data-dual-full.html template for isvhsopen This template is for displaying two datapoints at once. Visually, datapoint1 is the primary datapoint, and datapoint2 is the secondary. The primary use for this is for the new isvhsopen.com. datapoint1.value will be either 'closed' or 'open' and datapoint2.value might be 'until 12:45'. CSS formatting is specifically designed for this to look good, but other datapoint values will still work fine. Note that the "as of" tooltip only shows the last updated time of datapoint1. --- views/data-dual-full.html | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 views/data-dual-full.html diff --git a/views/data-dual-full.html b/views/data-dual-full.html new file mode 100644 index 0000000..f5a0e31 --- /dev/null +++ b/views/data-dual-full.html @@ -0,0 +1,47 @@ +{{#extend "main"}} + {{#content "head" mode="append"}} + + {{/content}} + {{#content "body"}} +
+
+

{{datapoint1.value}}

+

{{datapoint2.value}}

+
As of {{datapoint1.last_updated}}
+
+
+ {{/content}} + {{#content "footer"}} +
+

+ VHS API +

+
+ {{/content}} +{{/extend}} From 76da8321c7dc19f765959a43b6f49d4ebbc7a614 Mon Sep 17 00:00:00 2001 From: Shane Burgess Date: Fri, 2 Oct 2015 01:38:43 -0700 Subject: [PATCH 4/6] Update main.html remove perldancer references --- views/layouts/main.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/layouts/main.html b/views/layouts/main.html index 00f9091..938e45a 100644 --- a/views/layouts/main.html +++ b/views/layouts/main.html @@ -32,7 +32,7 @@

Hackspace API

From c9ff9522ccd521b29491e799b89bb93844d01562 Mon Sep 17 00:00:00 2001 From: Shane Burgess Date: Fri, 2 Oct 2015 01:42:18 -0700 Subject: [PATCH 5/6] update 404.html remove perldancer references --- public/404.html | 1 - 1 file changed, 1 deletion(-) diff --git a/public/404.html b/public/404.html index fc3e1c4..8883254 100644 --- a/public/404.html +++ b/public/404.html @@ -12,7 +12,6 @@

Error 404

Page Not Found

Sorry, this is the void.

From 1ada86e4d7560b7e736732d9ecde1e27dd001d40 Mon Sep 17 00:00:00 2001 From: Shane Burgess Date: Fri, 2 Oct 2015 01:42:40 -0700 Subject: [PATCH 6/6] update 500.html remove perldancer references --- public/500.html | 1 - 1 file changed, 1 deletion(-) diff --git a/public/500.html b/public/500.html index 232dde9..c8d5eb4 100644 --- a/public/500.html +++ b/public/500.html @@ -12,7 +12,6 @@

Error 500

Internal Server Error

Wooops, something went wrong