From d3d937afccfa9a380e695e13aa0ece70177ffbc8 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 15 Jun 2013 15:18:41 -0700 Subject: [PATCH] Added build date to footer --- NzbDrone.Api/Client/ClientSettings.cs | 4 ++++ UI/Shared/Footer/Model.js | 11 ++++++++++- UI/Shared/Footer/Template.html | 2 +- UI/Shared/Footer/View.js | 1 + UI/Shared/Footer/footer.less | 3 --- UI/app.js | 3 ++- 6 files changed, 18 insertions(+), 6 deletions(-) delete mode 100644 UI/Shared/Footer/footer.less diff --git a/NzbDrone.Api/Client/ClientSettings.cs b/NzbDrone.Api/Client/ClientSettings.cs index 40cc49550..b62bddf30 100644 --- a/NzbDrone.Api/Client/ClientSettings.cs +++ b/NzbDrone.Api/Client/ClientSettings.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using NzbDrone.Common; using NzbDrone.Common.Messaging; +using NzbDrone.Common.Serializer; using NzbDrone.Core.Lifecycle; namespace NzbDrone.Api.Client @@ -15,6 +16,7 @@ public class ClientSettings : IHandle private readonly EnvironmentProvider _environmentProvider; private static readonly Regex VersionRegex = new Regex(@"(?<=Version:\s')(.*)(?=')", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex BuildDateRegex = new Regex(@"(?<=BuildDate:\s)('.*')", RegexOptions.IgnoreCase | RegexOptions.Compiled); public ClientSettings(EnvironmentProvider environmentProvider) { @@ -28,8 +30,10 @@ public void Handle(ApplicationStartedEvent message) var appFile = Path.Combine(_environmentProvider.StartUpPath, "UI", "app.js"); var contents = File.ReadAllText(appFile); var version = _environmentProvider.Version; + var date = _environmentProvider.BuildDateTime; contents = VersionRegex.Replace(contents, version.ToString()); + contents = BuildDateRegex.Replace(contents, date.ToUniversalTime().ToJson()); File.WriteAllText(appFile, contents); } diff --git a/UI/Shared/Footer/Model.js b/UI/Shared/Footer/Model.js index 3e6261bd1..8f2b2a056 100644 --- a/UI/Shared/Footer/Model.js +++ b/UI/Shared/Footer/Model.js @@ -3,7 +3,16 @@ define(['app'], function () { NzbDrone.Shared.Footer.Model = Backbone.Model.extend({ defaults: { - 'version' : '0.0.0.0' + 'version' : '0.0.0.0', + 'buildDate' : Date.create() + }, + + mutators: { + humanizedBuildDate: function () { + var date = Date.create(this.get('buildDate')); + + return date.short(); + } } }); diff --git a/UI/Shared/Footer/Template.html b/UI/Shared/Footer/Template.html index 21d3de7ed..45ecea1b1 100644 --- a/UI/Shared/Footer/Template.html +++ b/UI/Shared/Footer/Template.html @@ -1,2 +1,2 @@ 

© Copyright 2013 NzbDrone

-

v{{version}}

\ No newline at end of file +

v{{version}} ({{humanizedBuildDate}})

\ No newline at end of file diff --git a/UI/Shared/Footer/View.js b/UI/Shared/Footer/View.js index 7933baaf3..3db52203b 100644 --- a/UI/Shared/Footer/View.js +++ b/UI/Shared/Footer/View.js @@ -8,6 +8,7 @@ define(['app', initialize: function () { this.model = new NzbDrone.Shared.Footer.Model(); this.model.set('version', NzbDrone.Constants.Version); + this.model.set('buildDate', NzbDrone.Constants.BuildDate); } }); diff --git a/UI/Shared/Footer/footer.less b/UI/Shared/Footer/footer.less deleted file mode 100644 index 5f989373d..000000000 --- a/UI/Shared/Footer/footer.less +++ /dev/null @@ -1,3 +0,0 @@ -footer { - font-size: 12.6px; -} \ No newline at end of file diff --git a/UI/app.js b/UI/app.js index 8bfac1f33..a7074cfab 100644 --- a/UI/app.js +++ b/UI/app.js @@ -172,7 +172,8 @@ define([ window.NzbDrone.Constants = { ApiRoot: '/api', - Version: '0.0.0.0' + Version: '0.0.0.0', + BuildDate: '2013-01-01T00:00:00Z' }; window.NzbDrone.addInitializer(function () {