mirror of
https://github.com/pa11y/pa11y-dashboard.git
synced 2025-09-24 22:31:15 +00:00
Add a view helper for date formatting
This commit is contained in:
3
app.js
3
app.js
@@ -36,6 +36,9 @@ function initApp (config, callback) {
|
|||||||
}));
|
}));
|
||||||
app.express.set('view engine', 'html');
|
app.express.set('view engine', 'html');
|
||||||
|
|
||||||
|
// View helpers
|
||||||
|
require('./view/helper/date')(hbs.registerHelper);
|
||||||
|
|
||||||
// Populate view locals
|
// Populate view locals
|
||||||
app.express.locals({
|
app.express.locals({
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
"chalk": "~0.2",
|
"chalk": "~0.2",
|
||||||
"express": "~3.4",
|
"express": "~3.4",
|
||||||
"express-hbs": "~0.2",
|
"express-hbs": "~0.2",
|
||||||
|
"moment": "~2.2",
|
||||||
"pa11y-webservice-client-node": "git+ssh://git@github.com:nature/pa11y-webservice-client-node.git#1.0.0-beta.2"
|
"pa11y-webservice-client-node": "git+ssh://git@github.com:nature/pa11y-webservice-client-node.git#1.0.0-beta.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
20
view/helper/date.js
Normal file
20
view/helper/date.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var moment = require('moment');
|
||||||
|
|
||||||
|
module.exports = helper;
|
||||||
|
|
||||||
|
function helper (register) {
|
||||||
|
|
||||||
|
// Format a date with Moment
|
||||||
|
register('date-format', function (context, block) {
|
||||||
|
var format = block.hash.format || 'YYYY-MM-DD HH:mm:ss';
|
||||||
|
return moment(context).format(format);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get a relative date
|
||||||
|
register('date-relative', function (context) {
|
||||||
|
return moment(context).fromNow();
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
@@ -2,10 +2,10 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{{#results}}
|
{{#results}}
|
||||||
<li>
|
<li>
|
||||||
<b>Date:</b> {{date}}<br/>
|
<b>Date:</b> {{date-format date format="DD MMM YYYY"}}<br/>
|
||||||
<b>Errors:</b> {{count.error}}<br/>
|
<b>Errors:</b> {{count.error}}<br/>
|
||||||
<b>Warnings:</b> {{count.warning}}<br/>
|
<b>Warnings:</b> {{count.warning}}<br/>
|
||||||
<b>Notices:</b> {{count.notice}}
|
<b>Notices:</b> {{count.notice}}
|
||||||
</li>
|
</li>
|
||||||
{{/results}}
|
{{/results}}
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -7,8 +7,9 @@
|
|||||||
{{url}} ({{standard}})
|
{{url}} ({{standard}})
|
||||||
|
|
||||||
{{#last_result}}
|
{{#last_result}}
|
||||||
<br/>Last run: {{date}}
|
<br/>
|
||||||
<br/>Errors: {{count.error}}
|
Last run: {{date-format date format="DD MMM YYYY"}}<br/>
|
||||||
|
Errors: {{count.error}}
|
||||||
{{/last_result}}
|
{{/last_result}}
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
|
Reference in New Issue
Block a user