1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

cache busting for js file based on server version.

This commit is contained in:
Keivan Beigi 2013-06-20 17:06:56 -07:00
parent 5c3f0203e5
commit 0916c8b8d1
12 changed files with 205 additions and 126 deletions

View File

@ -24,13 +24,13 @@ private Response GetStatus()
{
return new
{
Version = _environmentProvider.Version,
Version = _environmentProvider.Version.ToString(),
AppData = _environmentProvider.GetAppDataPath(),
IsAdmin = _environmentProvider.IsAdmin,
IsUserInteractive = _environmentProvider.IsUserInteractive,
BuildTime = _environmentProvider.BuildDateTime,
StartupPath = _environmentProvider.StartUpPath,
OsVersion = _environmentProvider.GetOsVersion(),
OsVersion = _environmentProvider.GetOsVersion().ToString(),
IsMono = EnvironmentProvider.IsMono,
IsProduction = EnvironmentProvider.IsProduction,
IsDebug = EnvironmentProvider.IsDebug,

View File

@ -134,7 +134,7 @@ public virtual DateTime BuildDateTime
get
{
var fileLocation = Assembly.GetCallingAssembly().Location;
return new FileInfo(fileLocation).CreationTime;
return new FileInfo(fileLocation).LastWriteTimeUtc;
}
}

4
UI/Constants.js Normal file
View File

@ -0,0 +1,4 @@
"use strict";
define({
ApiRoot : '/api'
});

View File

@ -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);
});
}
});

View File

@ -77,8 +77,7 @@
</body>
<script src="/JsLibraries/jquery.js"></script>
<script src="/JsLibraries/messenger.js"></script>
<script src="/JsLibraries/lunr.js"></script>
<script src="/JsLibraries/sugar.js"></script>
<script src="/ServerStatus.js"></script>
<script data-main="/app" src="/JsLibraries/require.js"></script>
<script src="/Routing.js"></script>
</html>

View File

@ -1,5 +1,5 @@
"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({

7
UI/ServerStatus.js Normal file
View File

@ -0,0 +1,7 @@
var statusText = $.ajax({
type : "GET",
url : 'api/system/status',
async: false,
}).responseText;
window.ServerStatus = JSON.parse(statusText);

View File

@ -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();
}
}
});
});

View File

@ -1,2 +1,2 @@
<p>&copy; Copyright 2013 NzbDrone</p>
<p>v{{version}} ({{humanizedBuildDate}})</p>
&copy; Copyright 2013 NzbDrone
<p>v{{version}} ({{ShortDate buildTime}})</p>

View File

@ -1,14 +1,12 @@
"use strict";
define(['app',
'Shared/Footer/Model'], function (App, FooterModel) {
return Backbone.Marionette.ItemView.extend({
define(
[
'marionette',
'System/StatusModel'
], function (Marionette, StatusModel) {
return Marionette.ItemView.extend({
template: 'Shared/Footer/Template',
initialize: function () {
this.model = new FooterModel();
this.model.set('version', NzbDrone.Constants.Version);
this.model.set('buildDate', NzbDrone.Constants.BuildDate);
}
template: 'Shared/Footer/Template',
model : StatusModel
});
});
});

16
UI/System/StatusModel.js Normal file
View File

@ -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;
});

231
UI/app.js
View File

@ -1,8 +1,11 @@
"use strict";
require.config({
urlArgs: 'bust=' + window.ServerStatus.version,
paths: {
'backbone' : 'JsLibraries/backbone',
'sugar' : 'JsLibraries/sugar',
'handlebars' : 'JsLibraries/handlebars.runtime',
'bootstrap' : 'JsLibraries/bootstrap',
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
@ -24,58 +27,100 @@ require.config({
shim: {
$: {
exports: '$'
exports: '$',
init : function () {
window.Constants = {
ApiRoot: '/api'
};
}
},
bootstrap: {
deps: ['$']
deps:
[
'$'
]
},
'bootstrap.slider': {
deps: ['$']
deps:
[
'$'
]
},
backstrech: {
deps: ['$']
deps:
[
'$'
]
},
'underscore': {
deps : ['$'],
deps :
[
'$'
],
exports: '_'
},
backbone: {
deps : ['underscore', '$'],
deps :
[
'underscore',
'$'
],
exports: 'Backbone'
},
'backbone.deepmodel': {
deps: ['mixins/underscore.mixin.deepExtend']
deps:
[
'mixins/underscore.mixin.deepExtend'
]
},
marionette: {
deps : [
'backbone',
'mixins/backbone.marionette.templates',
'mixins/AsNamedView'
],
deps:
[
'backbone',
'handlebars',
'mixins/backbone.marionette.templates',
'mixins/AsNamedView',
'Handlebars/Helpers/DateTime'
],
exports: 'Marionette',
init : function (Backbone, TemplateMixin, AsNamedView) {
init : function (Backbone, Handlebars, TemplateMixin, AsNamedView, DateTimeHelpers) {
TemplateMixin.call(Marionette.TemplateCache);
AsNamedView.call(Marionette.ItemView.prototype);
DateTimeHelpers.register(Handlebars);
}
},
signalR: {
deps: ['$']
deps:
[
'$'
]
},
'backbone.pageable': {
deps: ['backbone']
deps:
[
'backbone'
]
},
backgrid : {
deps: ['backbone'],
deps:
[
'backbone'
],
init: function () {
Backgrid.Column.prototype.defaults = {
name : undefined,
@ -90,103 +135,113 @@ require.config({
}
},
'backgrid.paginator': {
deps: ['backgrid']
deps:
[
'backgrid'
]
}
}
});
define([
'marionette',
'shared/modal/region',
'Instrumentation/StringFormat',
'Instrumentation/ErrorHandler'
], function (Marionette, ModalRegion) {
define(
[
'marionette',
'shared/modal/region',
'Instrumentation/StringFormat',
'Instrumentation/ErrorHandler'
], function (Marionette, ModalRegion) {
require(['libs/backbone.mutators']);
require(
[
'libs/backbone.mutators'
]);
window.NzbDrone = new Marionette.Application();
window.NzbDrone.Config = {};
window.NzbDrone.Form = {};
window.NzbDrone = new Marionette.Application();
window.NzbDrone.Config = {};
window.NzbDrone.Form = {};
window.NzbDrone.Series = {
Index : {
Table : {},
List : {},
Posters: {}
window.NzbDrone.Series = {
Index : {
Table : {},
List : {},
Posters: {}
},
Edit : {},
Delete : {},
Details: {}
};
},
Edit : {},
Delete : {},
Details: {}
};
window.NzbDrone.AddSeries = {
New : {},
Existing : {},
RootFolders: {}
};
window.NzbDrone.AddSeries = {
New : {},
Existing : {},
RootFolders: {}
};
window.NzbDrone.Episode = {
Search : {},
Summary : {},
Activity: {}
};
window.NzbDrone.Episode = {
Search : {},
Summary : {},
Activity: {}
};
window.NzbDrone.Quality = {};
window.NzbDrone.Quality = {};
window.NzbDrone.Commands = {};
window.NzbDrone.Commands = {};
window.NzbDrone.Shared = {
Toolbar : {},
Messenger : {},
FormatHelpers: {},
Grid : {},
Footer : {}
};
window.NzbDrone.Shared = {
Toolbar : {},
Messenger : {},
FormatHelpers: {},
Grid : {}
};
window.NzbDrone.Cells = {};
window.NzbDrone.Cells = {};
window.NzbDrone.Calendar = {};
window.NzbDrone.Calendar = {};
window.NzbDrone.Missing = {};
window.NzbDrone.History = {};
window.NzbDrone.Logs = {};
window.NzbDrone.Release = {};
window.NzbDrone.Mixins = {};
window.NzbDrone.Missing = {};
window.NzbDrone.History = {};
window.NzbDrone.Logs = {};
window.NzbDrone.Release = {};
window.NzbDrone.Mixins = {};
window.NzbDrone.Events = {
SeriesAdded: 'seriesAdded'
};
window.NzbDrone.Events = {
SeriesAdded: 'seriesAdded'
};
window.NzbDrone.Commands = {
SaveSettings: 'saveSettings'
};
window.NzbDrone.Commands = {
SaveSettings: 'saveSettings'
};
window.NzbDrone.Constants = {
ApiRoot : '/api',
Version : '0.0.0.0',
BuildDate: '2013-01-01T00:00:00Z'
};
window.NzbDrone.Constants = {
ApiRoot: '/api'
};
window.NzbDrone.addInitializer(function () {
window.NzbDrone.addInitializer(function () {
console.log('starting application');
console.log('starting application');
});
NzbDrone.addRegions({
mainRegion : '#main-region',
notificationRegion: '#notification-region',
modalRegion : ModalRegion,
footerRegion : '#footer-region'
});
window.NzbDrone.start();
window.require(
[
'Routing'
]);
return NzbDrone;
});
NzbDrone.addRegions({
mainRegion : '#main-region',
notificationRegion: '#notification-region',
modalRegion : ModalRegion,
footerRegion : '#footer-region'
});
window.NzbDrone.start();
return NzbDrone;
});