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 dist
.fusebox .fusebox
_site _site

View File

@ -11,6 +11,7 @@ const transformInferno = require('ts-transform-inferno').default;
const transformClasscat = require('ts-transform-classcat').default; const transformClasscat = require('ts-transform-classcat').default;
let fuse, app; let fuse, app;
let isProduction = false; let isProduction = false;
var setVersion = require('./set_version.js').setVersion;
Sparky.task('config', _ => { Sparky.task('config', _ => {
fuse = new FuseBox({ fuse = new FuseBox({
@ -41,15 +42,16 @@ Sparky.task('config', _ => {
}); });
app = fuse.bundle('app').instructions('>index.tsx'); app = fuse.bundle('app').instructions('>index.tsx');
}); });
Sparky.task('version', _ => setVersion());
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/')); Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
Sparky.task('env', _ => (isProduction = true)); Sparky.task('env', _ => (isProduction = true));
Sparky.task('copy-assets', () => Sparky.src('assets/*.svg').dest('dist/')); 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(); fuse.dev();
app.hmr().watch(); app.hmr().watch();
return fuse.run(); 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 // fuse.dev({ reload: true }); // remove after demo
return fuse.run(); 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() { render() {
if (this.props.data.updated) { if (this.props.data.updated) {
return ( 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 { } else {
return ( 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 { Link } from 'inferno-router';
import { repoUrl } from '../utils'; import { repoUrl } from '../utils';
import { UserService } from '../services'; import { UserService } from '../services';
import { version } from '../version';
interface NavbarState { interface NavbarState {
isLoggedIn: boolean; isLoggedIn: boolean;
@ -40,7 +41,7 @@ export class Navbar extends Component<any, NavbarState> {
navbar() { navbar() {
return ( return (
<nav class="navbar navbar-expand-sm navbar-light bg-light p-0 px-3 shadow"> <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> <svg class="icon mr-2"><use xlinkHref="#icon-mouse"></use></svg>
Lemmy Lemmy
</a> </a>