summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/.gitignore1
-rw-r--r--ui/fuse.js6
-rw-r--r--ui/set_version.js9
-rw-r--r--ui/src/components/moment-time.tsx4
-rw-r--r--ui/src/components/navbar.tsx3
5 files changed, 18 insertions, 5 deletions
diff --git a/ui/.gitignore b/ui/.gitignore
index cc0ab540..1e420dc4 100644
--- a/ui/.gitignore
+++ b/ui/.gitignore
@@ -1,3 +1,4 @@
+src/version.ts
dist
.fusebox
_site
diff --git a/ui/fuse.js b/ui/fuse.js
index a9283fad..c70edfb8 100644
--- a/ui/fuse.js
+++ b/ui/fuse.js
@@ -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();
});
diff --git a/ui/set_version.js b/ui/set_version.js
new file mode 100644
index 00000000..bfd640c2
--- /dev/null
+++ b/ui/set_version.js
@@ -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);
+}
diff --git a/ui/src/components/moment-time.tsx b/ui/src/components/moment-time.tsx
index f07f04a3..b7402e7e 100644
--- a/ui/src/components/moment-time.tsx
+++ b/ui/src/components/moment-time.tsx
@@ -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>
)
}
}
diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx
index c4b51e37..ca0c5a2a 100644
--- a/ui/src/components/navbar.tsx
+++ b/ui/src/components/navbar.tsx
@@ -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>