Adding versioning to front page.

- Fixes #51
This commit is contained in:
Dessalines 2019-04-08 20:28:07 -07:00
parent e120c69a52
commit dae66517aa
5 changed files with 18 additions and 5 deletions

1
ui/.gitignore vendored
View file

@ -1,3 +1,4 @@
src/version.ts
dist
.fusebox
_site

View file

@ -11,6 +11,7 @@ const transformInferno = require('ts-transform-inferno').default;
const transformClasscat = require('ts-transform-classcat').default;
let fuse, app;
let isProduction = false;
var setVersion = require('./set_version.js').setVersion;
Sparky.task('config', _ => {
fuse = new FuseBox({
@ -41,15 +42,16 @@ Sparky.task('config', _ => {
});
app = fuse.bundle('app').instructions('>index.tsx');
});
Sparky.task('version', _ => setVersion());
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
Sparky.task('env', _ => (isProduction = true));
Sparky.task('copy-assets', () => Sparky.src('assets/*.svg').dest('dist/'));
Sparky.task('dev', ['clean', 'config', 'copy-assets'], _ => {
Sparky.task('dev', ['clean', 'config', 'copy-assets', 'version'], _ => {
fuse.dev();
app.hmr().watch();
return fuse.run();
});
Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => {
Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets', 'version'], _ => {
// fuse.dev({ reload: true }); // remove after demo
return fuse.run();
});

9
ui/set_version.js Normal file
View file

@ -0,0 +1,9 @@
const fs = require('fs');
exports.setVersion = function() {
let revision = require('child_process')
.execSync('git describe --tags --long')
.toString().trim();
let line = `export let version: string = "${revision}";`;
fs.writeFileSync("./src/version.ts", line);
}

View file

@ -17,11 +17,11 @@ export class MomentTime extends Component<MomentTimeProps, any> {
render() {
if (this.props.data.updated) {
return (
<span className="font-italics">modified {moment.utc(this.props.data.updated).fromNow()}</span>
<span title={this.props.data.updated} className="font-italics">modified {moment.utc(this.props.data.updated).fromNow()}</span>
)
} else {
return (
<span>{moment.utc(this.props.data.published).fromNow()}</span>
<span title={this.props.data.published}>{moment.utc(this.props.data.published).fromNow()}</span>
)
}
}

View file

@ -2,6 +2,7 @@ import { Component, linkEvent } from 'inferno';
import { Link } from 'inferno-router';
import { repoUrl } from '../utils';
import { UserService } from '../services';
import { version } from '../version';
interface NavbarState {
isLoggedIn: boolean;
@ -40,7 +41,7 @@ export class Navbar extends Component<any, NavbarState> {
navbar() {
return (
<nav class="navbar navbar-expand-sm navbar-light bg-light p-0 px-3 shadow">
<a class="navbar-brand" href="#">
<a title={version} class="navbar-brand" href="#">
<svg class="icon mr-2"><use xlinkHref="#icon-mouse"></use></svg>
Lemmy
</a>