cache busting for js file based on server version.
This commit is contained in:
parent
5c3f0203e5
commit
0916c8b8d1
|
@ -24,13 +24,13 @@ namespace NzbDrone.Api.System
|
||||||
{
|
{
|
||||||
return new
|
return new
|
||||||
{
|
{
|
||||||
Version = _environmentProvider.Version,
|
Version = _environmentProvider.Version.ToString(),
|
||||||
AppData = _environmentProvider.GetAppDataPath(),
|
AppData = _environmentProvider.GetAppDataPath(),
|
||||||
IsAdmin = _environmentProvider.IsAdmin,
|
IsAdmin = _environmentProvider.IsAdmin,
|
||||||
IsUserInteractive = _environmentProvider.IsUserInteractive,
|
IsUserInteractive = _environmentProvider.IsUserInteractive,
|
||||||
BuildTime = _environmentProvider.BuildDateTime,
|
BuildTime = _environmentProvider.BuildDateTime,
|
||||||
StartupPath = _environmentProvider.StartUpPath,
|
StartupPath = _environmentProvider.StartUpPath,
|
||||||
OsVersion = _environmentProvider.GetOsVersion(),
|
OsVersion = _environmentProvider.GetOsVersion().ToString(),
|
||||||
IsMono = EnvironmentProvider.IsMono,
|
IsMono = EnvironmentProvider.IsMono,
|
||||||
IsProduction = EnvironmentProvider.IsProduction,
|
IsProduction = EnvironmentProvider.IsProduction,
|
||||||
IsDebug = EnvironmentProvider.IsDebug,
|
IsDebug = EnvironmentProvider.IsDebug,
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace NzbDrone.Common
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var fileLocation = Assembly.GetCallingAssembly().Location;
|
var fileLocation = Assembly.GetCallingAssembly().Location;
|
||||||
return new FileInfo(fileLocation).CreationTime;
|
return new FileInfo(fileLocation).LastWriteTimeUtc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
"use strict";
|
||||||
|
define({
|
||||||
|
ApiRoot : '/api'
|
||||||
|
});
|
|
@ -0,0 +1,18 @@
|
||||||
|
"use strict";
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
'sugar'
|
||||||
|
], {
|
||||||
|
register: function (handlebars) {
|
||||||
|
handlebars.registerHelper("ShortDate", function (input) {
|
||||||
|
if (!input) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
var date = Date.create(input);
|
||||||
|
var result = '<span title="' + date.full() + '">' + date.short() + '</span>';
|
||||||
|
|
||||||
|
return new handlebars.SafeString(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -77,8 +77,7 @@
|
||||||
</body>
|
</body>
|
||||||
<script src="/JsLibraries/jquery.js"></script>
|
<script src="/JsLibraries/jquery.js"></script>
|
||||||
<script src="/JsLibraries/messenger.js"></script>
|
<script src="/JsLibraries/messenger.js"></script>
|
||||||
<script src="/JsLibraries/lunr.js"></script>
|
<script src="/ServerStatus.js"></script>
|
||||||
<script src="/JsLibraries/sugar.js"></script>
|
|
||||||
<script data-main="/app" src="/JsLibraries/require.js"></script>
|
<script data-main="/app" src="/JsLibraries/require.js"></script>
|
||||||
<script src="/Routing.js"></script>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
require(['app', 'Controller', 'RouteBinder', 'Shared/Footer/View'], function (App, Controller, RouteBinder, FooterView) {
|
require(['Controller', 'RouteBinder', 'Shared/Footer/View'], function (Controller, RouteBinder, FooterView) {
|
||||||
|
|
||||||
NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
|
NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
var statusText = $.ajax({
|
||||||
|
type : "GET",
|
||||||
|
url : 'api/system/status',
|
||||||
|
async: false,
|
||||||
|
}).responseText;
|
||||||
|
|
||||||
|
window.ServerStatus = JSON.parse(statusText);
|
|
@ -1,18 +0,0 @@
|
||||||
"use strict";
|
|
||||||
define(['app'], function () {
|
|
||||||
|
|
||||||
return Backbone.Model.extend({
|
|
||||||
defaults: {
|
|
||||||
'version' : '0.0.0.0',
|
|
||||||
'buildDate' : Date.create()
|
|
||||||
},
|
|
||||||
|
|
||||||
mutators: {
|
|
||||||
humanizedBuildDate: function () {
|
|
||||||
var date = Date.create(this.get('buildDate'));
|
|
||||||
|
|
||||||
return date.short();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,2 +1,2 @@
|
||||||
<p>© Copyright 2013 NzbDrone</p>
|
© Copyright 2013 NzbDrone
|
||||||
<p>v{{version}} ({{humanizedBuildDate}})</p>
|
<p>v{{version}} ({{ShortDate buildTime}})</p>
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
define(['app',
|
define(
|
||||||
'Shared/Footer/Model'], function (App, FooterModel) {
|
[
|
||||||
return Backbone.Marionette.ItemView.extend({
|
'marionette',
|
||||||
|
'System/StatusModel'
|
||||||
|
], function (Marionette, StatusModel) {
|
||||||
|
return Marionette.ItemView.extend({
|
||||||
|
|
||||||
template: 'Shared/Footer/Template',
|
template: 'Shared/Footer/Template',
|
||||||
|
model : StatusModel
|
||||||
initialize: function () {
|
});
|
||||||
this.model = new FooterModel();
|
|
||||||
this.model.set('version', NzbDrone.Constants.Version);
|
|
||||||
this.model.set('buildDate', NzbDrone.Constants.BuildDate);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
"use strict";
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
'backbone',
|
||||||
|
'constants'
|
||||||
|
], function (Backbone) {
|
||||||
|
|
||||||
|
var model = Backbone.Model.extend({
|
||||||
|
url: Constants.ApiRoot + '/system/status'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var instance = new model();
|
||||||
|
instance.fetch();
|
||||||
|
return instance;
|
||||||
|
});
|
101
UI/app.js
101
UI/app.js
|
@ -1,8 +1,11 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
require.config({
|
require.config({
|
||||||
|
|
||||||
|
urlArgs: 'bust=' + window.ServerStatus.version,
|
||||||
|
|
||||||
paths: {
|
paths: {
|
||||||
'backbone' : 'JsLibraries/backbone',
|
'backbone' : 'JsLibraries/backbone',
|
||||||
|
'sugar' : 'JsLibraries/sugar',
|
||||||
'handlebars' : 'JsLibraries/handlebars.runtime',
|
'handlebars' : 'JsLibraries/handlebars.runtime',
|
||||||
'bootstrap' : 'JsLibraries/bootstrap',
|
'bootstrap' : 'JsLibraries/bootstrap',
|
||||||
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
|
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
|
||||||
|
@ -24,58 +27,100 @@ require.config({
|
||||||
shim: {
|
shim: {
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
exports: '$'
|
exports: '$',
|
||||||
|
init : function () {
|
||||||
|
window.Constants = {
|
||||||
|
ApiRoot: '/api'
|
||||||
|
};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
bootstrap: {
|
bootstrap: {
|
||||||
deps: ['$']
|
deps:
|
||||||
|
[
|
||||||
|
'$'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
'bootstrap.slider': {
|
'bootstrap.slider': {
|
||||||
deps: ['$']
|
deps:
|
||||||
|
[
|
||||||
|
'$'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
backstrech: {
|
backstrech: {
|
||||||
deps: ['$']
|
deps:
|
||||||
|
[
|
||||||
|
'$'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
'underscore': {
|
'underscore': {
|
||||||
deps : ['$'],
|
deps :
|
||||||
|
[
|
||||||
|
'$'
|
||||||
|
],
|
||||||
exports: '_'
|
exports: '_'
|
||||||
},
|
},
|
||||||
|
|
||||||
backbone: {
|
backbone: {
|
||||||
deps : ['underscore', '$'],
|
deps :
|
||||||
|
[
|
||||||
|
'underscore',
|
||||||
|
'$'
|
||||||
|
],
|
||||||
exports: 'Backbone'
|
exports: 'Backbone'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
'backbone.deepmodel': {
|
'backbone.deepmodel': {
|
||||||
deps: ['mixins/underscore.mixin.deepExtend']
|
deps:
|
||||||
|
[
|
||||||
|
'mixins/underscore.mixin.deepExtend'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
marionette: {
|
marionette: {
|
||||||
deps : [
|
deps:
|
||||||
|
[
|
||||||
'backbone',
|
'backbone',
|
||||||
|
'handlebars',
|
||||||
'mixins/backbone.marionette.templates',
|
'mixins/backbone.marionette.templates',
|
||||||
'mixins/AsNamedView'
|
'mixins/AsNamedView',
|
||||||
|
|
||||||
|
'Handlebars/Helpers/DateTime'
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: 'Marionette',
|
exports: 'Marionette',
|
||||||
init : function (Backbone, TemplateMixin, AsNamedView) {
|
init : function (Backbone, Handlebars, TemplateMixin, AsNamedView, DateTimeHelpers) {
|
||||||
TemplateMixin.call(Marionette.TemplateCache);
|
TemplateMixin.call(Marionette.TemplateCache);
|
||||||
AsNamedView.call(Marionette.ItemView.prototype);
|
AsNamedView.call(Marionette.ItemView.prototype);
|
||||||
|
DateTimeHelpers.register(Handlebars);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
signalR: {
|
signalR: {
|
||||||
deps: ['$']
|
deps:
|
||||||
|
[
|
||||||
|
'$'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
'backbone.pageable': {
|
'backbone.pageable': {
|
||||||
deps: ['backbone']
|
deps:
|
||||||
|
[
|
||||||
|
'backbone'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
backgrid : {
|
backgrid : {
|
||||||
deps: ['backbone'],
|
deps:
|
||||||
|
[
|
||||||
|
'backbone'
|
||||||
|
],
|
||||||
init: function () {
|
init: function () {
|
||||||
Backgrid.Column.prototype.defaults = {
|
Backgrid.Column.prototype.defaults = {
|
||||||
name : undefined,
|
name : undefined,
|
||||||
|
@ -90,19 +135,26 @@ require.config({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'backgrid.paginator': {
|
'backgrid.paginator': {
|
||||||
deps: ['backgrid']
|
deps:
|
||||||
|
[
|
||||||
|
'backgrid'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
define([
|
define(
|
||||||
|
[
|
||||||
'marionette',
|
'marionette',
|
||||||
'shared/modal/region',
|
'shared/modal/region',
|
||||||
'Instrumentation/StringFormat',
|
'Instrumentation/StringFormat',
|
||||||
'Instrumentation/ErrorHandler'
|
'Instrumentation/ErrorHandler'
|
||||||
], function (Marionette, ModalRegion) {
|
], function (Marionette, ModalRegion) {
|
||||||
|
|
||||||
require(['libs/backbone.mutators']);
|
require(
|
||||||
|
[
|
||||||
|
'libs/backbone.mutators'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
window.NzbDrone = new Marionette.Application();
|
window.NzbDrone = new Marionette.Application();
|
||||||
|
@ -141,8 +193,7 @@ define([
|
||||||
Toolbar : {},
|
Toolbar : {},
|
||||||
Messenger : {},
|
Messenger : {},
|
||||||
FormatHelpers: {},
|
FormatHelpers: {},
|
||||||
Grid : {},
|
Grid : {}
|
||||||
Footer : {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.NzbDrone.Cells = {};
|
window.NzbDrone.Cells = {};
|
||||||
|
@ -164,9 +215,7 @@ define([
|
||||||
};
|
};
|
||||||
|
|
||||||
window.NzbDrone.Constants = {
|
window.NzbDrone.Constants = {
|
||||||
ApiRoot : '/api',
|
ApiRoot: '/api'
|
||||||
Version : '0.0.0.0',
|
|
||||||
BuildDate: '2013-01-01T00:00:00Z'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.NzbDrone.addInitializer(function () {
|
window.NzbDrone.addInitializer(function () {
|
||||||
|
@ -184,8 +233,14 @@ define([
|
||||||
|
|
||||||
window.NzbDrone.start();
|
window.NzbDrone.start();
|
||||||
|
|
||||||
|
|
||||||
|
window.require(
|
||||||
|
[
|
||||||
|
'Routing'
|
||||||
|
]);
|
||||||
|
|
||||||
return NzbDrone;
|
return NzbDrone;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue