Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ <h1>Error 404</h1>
<h2>Page Not Found</h2><p>Sorry, this is the void.</p>
</div>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer</a>.
</div>
</body>
</html>
1 change: 0 additions & 1 deletion public/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ <h1>Error 500</h1>
<h2>Internal Server Error</h2><p>Wooops, something went wrong</p>
</div>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer</a>.
</div>
</body>
</html>
6 changes: 3 additions & 3 deletions src/datapoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {

Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -228,4 +228,4 @@ var Datapoint = {
}
}

module.exports = Datapoint;
module.exports = Datapoint;
32 changes: 32 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
47 changes: 47 additions & 0 deletions views/data-dual-full.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{#extend "main"}}
{{#content "head" mode="append"}}
<style type="text/css">
h1 {
font-size: 144pt;
-webkit-margin-after: 100px;
}
h2 {
font-size: 49pt;
text-align: right;
margin-right: 9px;
}
#fact {
position: fixed;
left: 50%;
margin-left: -250px;
top: 40%;
margin-top: -50px;
}
#facttime {
margin-top: 16px;
margin-right: 11px;
}
.footer {
position: fixed;
bottom: 0px;
}

</style>
{{/content}}
{{#content "body"}}
<div class="container">
<div id="fact">
<h1>{{datapoint1.value}}</h1>
<h2>{{datapoint2.value}}</h2>
<div id="facttime" class="label pull-right">As of <abbr class="timeago" title="{{datapoint1.datetime}}">{{datapoint1.last_updated}}</abbr></div>
</div>
</div>
{{/content}}
{{#content "footer"}}
<div class="container">
<p class="pull-right">
<a href="http://api.hackspace.ca">VHS API</a>
</p>
</div>
{{/content}}
{{/extend}}
2 changes: 1 addition & 1 deletion views/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1><a href="/">Hackspace API</a></h1>
<footer class="footer">
{{#block "footer"}}
<div class="container">
Created by <a href="http://twitter.com/lukec">@lukec</a> for <a href="http://vancouver.hackspace.ca">Vancouver Hack Space</a> using <a href="http://perldancer.org/">Dancer</a>. The code is <a href="http://github.com/vhs/api">up on Github</a>!
Created by the <a href="http://vancouver.hackspace.ca">Vancouver Hack Space</a>. The code is <a href="http://github.com/vhs/api">up on Github</a>!
</div>
{{/block}}
</footer>
Expand Down