Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
feat(ui): current version is now displayed. additionally, new version…
Browse files Browse the repository at this point in the history
…s will be looked for every 10 minutes if possible

closes #45
  • Loading branch information
seiyria committed Dec 3, 2015
1 parent 4619dca commit 4f25b9b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
11 changes: 11 additions & 0 deletions gulp/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const currentTag = require('./_common').currentTag;

const versionSources = ['./bower.json', './package.json'];

const execSync = require('child_process').execSync;

const versionStream = (type) => {
return gulp.src(versionSources)
.pipe(bump({ type: type }))
Expand All @@ -35,6 +37,15 @@ const pushStream = () => {
git.push('origin', 'master', { args: '--tags' });
};

gulp.task('generate:versionjson', ['compile:all'], function() {
fs.writeFileSync('dist/version.json', JSON.stringify({
tag: execSync('git describe --abbrev=0').toString().trim(),
hash: execSync('git log --pretty=format:\'%H\' -1').toString().trim(),
date: execSync('git log --pretty=format:\'%ad\' --date=short -1').toString().trim(),
longDate: execSync('git log --pretty=format:\'%ad\' -1').toString().trim()
}));
});

gulp.task('generate:changelog', () => {
return changelog({
releaseCount: 0,
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gulp.task('release:patch', ['bump:patch', 'deploy']);
gulp.task('release:minor', ['bump:minor', 'deploy']);
gulp.task('release:major', ['bump:major', 'deploy']);

gulp.task('build:all', ['copy:dist', 'build:lib', 'compile:all']);
gulp.task('build:all', ['copy:dist', 'build:lib', 'compile:all', 'generate:versionjson']);
gulp.task('compile:all', ['compile:js', 'compile:sass', 'compile:jade']);
gulp.task('check', ['test', 'build:all']);

Expand Down
13 changes: 12 additions & 1 deletion src/jade/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ html(ng-app="Roguathia", ng-controller="Root")
header.navbar.navbar-default
.container-fluid
.navbar-header
a.navbar-brand Roguathia
a.navbar-brand
span(ng-bind="title()") Roguathia

.navbar-collapse.collapse(ng-if="updateAvailable && latestTag", ng-cloak)
ul.nav.navbar-nav
li
a(href) Update Available: v{{latestTag}}
li
a.btn.btn-link(target="_blank", href="https://github.com/seiyria/Roguathia/blob/master/CHANGELOG.md") Changelog
li
a.btn.btn-link(href=".") Refresh


.container-fluid(ng-cloak)
.row.margin-left--30
Expand Down
27 changes: 22 additions & 5 deletions src/js/angular/controllers/Root.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@

import module from '../module';

class Root {
module.controller('Root', ($scope, $http, $interval) => {

/* ngInject */
constructor() {}
}
// get the current version
$http.get('version.json').then(res => {
$scope.tag = res.data.tag;
});

module.controller('Root', Root);
// title is either the game name or with the version tag if available
$scope.title = () => {
if($scope.tag) {
return `Roguathia v${$scope.tag}`;
}

return 'Roguathia';
};

// check for an update every 10 minutes
$interval(() => {
$http.get('https://api.github.com/repos/seiyria/Roguathia/tags').then(res => {
$scope.latestTag = res.data ? res.data[0].name : null;
$scope.updateAvailable = $scope.tag != $scope.latestTag;
});
}, 600000);
});
4 changes: 4 additions & 0 deletions src/scss/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
overflow-x: hidden;
}

[ng-cloak] {
display: none!important;
}

.msg {

display: table;
Expand Down

0 comments on commit 4f25b9b

Please sign in to comment.