client/home: format absolute time
This commit is contained in:
parent
ad6750a055
commit
85ed552fce
5 changed files with 30 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
<div class='content-wrapper transparent' id='home'>
|
||||
<div class='messages'></div>
|
||||
<h1>{{name}}</h1>
|
||||
<footer>Version: <span class='version'>{{version}}</span> (built {{buildDate}})</footer>
|
||||
<footer>Version: <span class='version'>{{version}}</span> (built {{#reltime}}{{buildDate}}{{/reltime}})</footer>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
require('./util/handlebars-helpers.js');
|
||||
|
||||
// ----------------------
|
||||
// - import controllers -
|
||||
// ----------------------
|
||||
|
|
15
client/js/util/handlebars-helpers.js
Normal file
15
client/js/util/handlebars-helpers.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
const handlebars = require('handlebars');
|
||||
const misc = require('./misc.js');
|
||||
|
||||
handlebars.registerHelper('reltime', function(options) {
|
||||
return new handlebars.SafeString(
|
||||
'<time datetime="' +
|
||||
options.fn(this) +
|
||||
'" title="' +
|
||||
options.fn(this) +
|
||||
'">' +
|
||||
misc.formatRelativeTime(options.fn(this)) +
|
||||
'</time>');
|
||||
});
|
|
@ -1,6 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const util = require('../util.js');
|
||||
const config = require('../config.js');
|
||||
const BaseView = require('./base_view.js');
|
||||
|
||||
|
@ -14,7 +13,7 @@ class HomeView extends BaseView {
|
|||
this.showView(this.template({
|
||||
name: config.basic.name,
|
||||
version: config.meta.version,
|
||||
buildDate: util.formatRelativeTime(config.meta.buildDate),
|
||||
buildDate: config.meta.buildDate,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue