cache busting for js file based on server version.

pull/6/head
Keivan Beigi 11 years ago
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>&copy; Copyright 2013 NzbDrone</p> &copy; 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;
});

@ -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', [
'mixins/backbone.marionette.templates', 'backbone',
'mixins/AsNamedView' 'handlebars',
], 'mixins/backbone.marionette.templates',
'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,102 +135,112 @@ require.config({
} }
}, },
'backgrid.paginator': { 'backgrid.paginator': {
deps: ['backgrid'] deps:
[
'backgrid'
]
} }
} }
}); });
define([ define(
'marionette', [
'shared/modal/region', 'marionette',
'Instrumentation/StringFormat', 'shared/modal/region',
'Instrumentation/ErrorHandler' 'Instrumentation/StringFormat',
], function (Marionette, ModalRegion) { 'Instrumentation/ErrorHandler'
], function (Marionette, ModalRegion) {
require(['libs/backbone.mutators']); require(
[
'libs/backbone.mutators'
]);
window.NzbDrone = new Marionette.Application(); window.NzbDrone = new Marionette.Application();
window.NzbDrone.Config = {}; window.NzbDrone.Config = {};
window.NzbDrone.Form = {}; window.NzbDrone.Form = {};
window.NzbDrone.Series = { window.NzbDrone.Series = {
Index : { Index : {
Table : {}, Table : {},
List : {}, List : {},
Posters: {} Posters: {}
}, },
Edit : {}, Edit : {},
Delete : {}, Delete : {},
Details: {} Details: {}
}; };
window.NzbDrone.AddSeries = { window.NzbDrone.AddSeries = {
New : {}, New : {},
Existing : {}, Existing : {},
RootFolders: {} RootFolders: {}
}; };
window.NzbDrone.Episode = { window.NzbDrone.Episode = {
Search : {}, Search : {},
Summary : {}, Summary : {},
Activity: {} Activity: {}
}; };
window.NzbDrone.Quality = {}; window.NzbDrone.Quality = {};
window.NzbDrone.Commands = {}; window.NzbDrone.Commands = {};
window.NzbDrone.Shared = { window.NzbDrone.Shared = {
Toolbar : {}, Toolbar : {},
Messenger : {}, Messenger : {},
FormatHelpers: {}, FormatHelpers: {},
Grid : {}, Grid : {}
Footer : {} };
};
window.NzbDrone.Cells = {}; window.NzbDrone.Cells = {};
window.NzbDrone.Calendar = {}; window.NzbDrone.Calendar = {};
window.NzbDrone.Missing = {}; window.NzbDrone.Missing = {};
window.NzbDrone.History = {}; window.NzbDrone.History = {};
window.NzbDrone.Logs = {}; window.NzbDrone.Logs = {};
window.NzbDrone.Release = {}; window.NzbDrone.Release = {};
window.NzbDrone.Mixins = {}; window.NzbDrone.Mixins = {};
window.NzbDrone.Events = { window.NzbDrone.Events = {
SeriesAdded: 'seriesAdded' SeriesAdded: 'seriesAdded'
}; };
window.NzbDrone.Commands = { window.NzbDrone.Commands = {
SaveSettings: 'saveSettings' SaveSettings: 'saveSettings'
}; };
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 () {
console.log('starting application'); console.log('starting application');
}); });
NzbDrone.addRegions({ NzbDrone.addRegions({
mainRegion : '#main-region', mainRegion : '#main-region',
notificationRegion: '#notification-region', notificationRegion: '#notification-region',
modalRegion : ModalRegion, modalRegion : ModalRegion,
footerRegion : '#footer-region' footerRegion : '#footer-region'
}); });
window.NzbDrone.start(); window.NzbDrone.start();
return NzbDrone;
}); window.require(
[
'Routing'
]);
return NzbDrone;
});

Loading…
Cancel
Save